From: lempinen Date: Mon, 26 Jul 2010 12:48:39 +0000 (+0000) Subject: git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16827 ac1ea38d-2e2b... X-Git-Tag: simantics-1.2.0~161 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ac3d4d40fb4508e8eb05a3c7c80cc33deb136cfc;p=simantics%2Fsysdyn.git git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16827 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java index b26509f9..0c205c38 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java @@ -5,13 +5,13 @@ import java.awt.Color; import java.awt.Font; import java.awt.Shape; import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; import java.util.Collection; import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.elements.TextElementHandler; import org.simantics.diagram.elements.TextElementNoBounds; import org.simantics.diagram.elements.TextNode; import org.simantics.g2d.canvas.ICanvasContext; @@ -20,6 +20,7 @@ import org.simantics.g2d.element.ElementClass; import org.simantics.g2d.element.ElementUtils; import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.SceneGraphNodeKey; +import org.simantics.g2d.element.handler.InternalSize; import org.simantics.g2d.element.handler.impl.BoundsOutline; import org.simantics.g2d.element.handler.impl.DefaultTransform; import org.simantics.g2d.element.handler.impl.ObjectTerminal; @@ -71,10 +72,8 @@ public class InputFactory extends SysdynElementFactory { new StaticObjectAdapter(elementType), new StaticSymbolImpl(INPUT_IMAGE), StaticSymbolImageInitializer.INSTANCE, - TextElementHandler.INSTANCE, Input.INSTANCE, - new InputSceneGraph(0, 5, Alignment.CENTER), -// InputSceneGraph.INSTANCE, + new InputSceneGraph(0, 0, Alignment.CENTER), BoundsOutline.INSTANCE, new WholeElementTerminals(terminals) ).setId(InputFactory.class.getSimpleName()); @@ -112,7 +111,7 @@ public class InputFactory extends SysdynElementFactory { } - public static class InputSceneGraph extends TextElementNoBounds { + public static class InputSceneGraph extends TextElementNoBounds implements InternalSize { private static final long serialVersionUID = -3713275157729126409L; public static final Key SG_NODE = new SceneGraphNodeKey(TextNode.class, "INPUT_SG_NODE"); @@ -121,15 +120,15 @@ public class InputFactory extends SysdynElementFactory { private final Alignment horizontalAlignment; public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment) { - super(originX, originY, horizontalAlignment); + super(originX, originY, horizontalAlignment, 0, true); this.originX = originX; this.horizontalAlignment = horizontalAlignment; } @Override public void init(final IElement e, G2DParentNode parent) { + super.init(e, parent); TextNode node = ElementUtils.getOrCreateNode(e, parent, SG_NODE, "input", TextNode.class); - //Font font = new Font("Tahoma", 0, 12); Font font = ElementUtils.getTextFont(e); font = font.deriveFont((float) 10.0); font = font.deriveFont(Font.ITALIC); @@ -144,6 +143,19 @@ public class InputFactory extends SysdynElementFactory { node.setHorizontalAlignment((byte) horizontalAlignment.ordinal()); node.setBorderWidth((float) 0); node.setEditable(false); + node.setShowSelection(false); + } + + @Override + public Rectangle2D getBounds(IElement e, Rectangle2D size) { + TextNode node = (TextNode) e.getHint(SG_NODE); + if (size == null) + size = new Rectangle2D.Double(); + if (node != null) + size.setRect(node.getBoundsInLocal()); + else + size.setFrame(0, 0, 0, 0); + return size; } } }