import java.awt.Font;\r
import java.awt.Shape;\r
import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
import java.util.Collection;\r
\r
import org.simantics.db.Builtins;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.elements.TextElementHandler;\r
import org.simantics.diagram.elements.TextElementNoBounds;\r
import org.simantics.diagram.elements.TextNode;\r
import org.simantics.g2d.canvas.ICanvasContext;\r
import org.simantics.g2d.element.ElementUtils;\r
import org.simantics.g2d.element.IElement;\r
import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
new StaticObjectAdapter(elementType),\r
new StaticSymbolImpl(INPUT_IMAGE),\r
StaticSymbolImageInitializer.INSTANCE,\r
- TextElementHandler.INSTANCE,\r
Input.INSTANCE,\r
- new InputSceneGraph(0, 5, Alignment.CENTER),\r
-// InputSceneGraph.INSTANCE,\r
+ new InputSceneGraph(0, 0, Alignment.CENTER),\r
BoundsOutline.INSTANCE,\r
new WholeElementTerminals(terminals)\r
).setId(InputFactory.class.getSimpleName());\r
}\r
\r
\r
- public static class InputSceneGraph extends TextElementNoBounds {\r
+ public static class InputSceneGraph extends TextElementNoBounds implements InternalSize {\r
\r
private static final long serialVersionUID = -3713275157729126409L;\r
public static final Key SG_NODE = new SceneGraphNodeKey(TextNode.class, "INPUT_SG_NODE");\r
private final Alignment horizontalAlignment;\r
\r
public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment) {\r
- super(originX, originY, horizontalAlignment);\r
+ super(originX, originY, horizontalAlignment, 0, true);\r
this.originX = originX;\r
this.horizontalAlignment = horizontalAlignment;\r
}\r
\r
@Override\r
public void init(final IElement e, G2DParentNode parent) {\r
+ super.init(e, parent);\r
TextNode node = ElementUtils.getOrCreateNode(e, parent, SG_NODE, "input", TextNode.class);\r
- //Font font = new Font("Tahoma", 0, 12);\r
Font font = ElementUtils.getTextFont(e);\r
font = font.deriveFont((float) 10.0);\r
font = font.deriveFont(Font.ITALIC);\r
node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
node.setBorderWidth((float) 0);\r
node.setEditable(false);\r
+ node.setShowSelection(false);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ TextNode node = (TextNode) e.getHint(SG_NODE);\r
+ if (size == null)\r
+ size = new Rectangle2D.Double();\r
+ if (node != null)\r
+ size.setRect(node.getBoundsInLocal());\r
+ else\r
+ size.setFrame(0, 0, 0, 0);\r
+ return size;\r
}\r
}\r
}\r