From e11d9e84600cd5c0f4d9370d54b8eff56e5f0c41 Mon Sep 17 00:00:00 2001 From: lempinen Date: Tue, 27 Jul 2010 07:32:34 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16840 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/elements2/InputFactory.java | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) 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 0c205c38..7bb49b3d 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 @@ -59,7 +59,7 @@ public class InputFactory extends SysdynElementFactory { path.closePath(); return path; } - + @Override protected ElementClass compileElementClass(Resource elementType, Collection terminals) { return ElementClass.compile( @@ -85,7 +85,6 @@ public class InputFactory extends SysdynElementFactory { Builtins b = graph.getBuiltins(); ModelingResources mr = ModelingResources.getInstance(graph); SysdynResource sr = SysdynResource.getInstance(graph); - Resource component = null; Resource dependency = null; Resource refersTo = null; @@ -97,6 +96,7 @@ public class InputFactory extends SysdynElementFactory { refersTo = graph.getPossibleObject(dependency, sr.RefersTo); module = graph.getPossibleObject(dependency, sr.HasTail); } + String inputReference = null; if (module != null && refersTo != null) { inputReference = (String) graph.getPossibleRelatedValue(module, b.HasName); @@ -104,32 +104,36 @@ public class InputFactory extends SysdynElementFactory { inputReference += (String) graph.getPossibleRelatedValue(refersTo, b.HasName); } if (inputReference == null) { - inputReference = "\"\""; + inputReference = ""; } - SysdynElementUtils.setInputReference(e, inputReference); + SysdynElementUtils.setInputReference(e, inputReference); + } - - + + 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"); + public static final Key INPUT_SG_NODE = new SceneGraphNodeKey(TextNode.class, "INPUT_SG_NODE"); private final double originX; private final Alignment horizontalAlignment; - + public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment) { - super(originX, originY, horizontalAlignment, 0, true); + super(originX, originY, horizontalAlignment, (double) 0.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 = ElementUtils.getTextFont(e); + TextNode name = (TextNode) e.getHint(SG_NODE); + Font font = name.getFont().deriveFont(Font.ITALIC); + name.setFont(font); + TextNode node = ElementUtils.getOrCreateNode(e, parent, INPUT_SG_NODE, "input", TextNode.class); + font = ElementUtils.getTextFont(e); font = font.deriveFont((float) 10.0); font = font.deriveFont(Font.ITALIC); Color color = new Color(150, 150, 150); @@ -148,11 +152,16 @@ public class InputFactory extends SysdynElementFactory { @Override public Rectangle2D getBounds(IElement e, Rectangle2D size) { - TextNode node = (TextNode) e.getHint(SG_NODE); + TextNode name = (TextNode) e.getHint(SG_NODE); + TextNode reference = (TextNode) e.getHint(INPUT_SG_NODE); if (size == null) size = new Rectangle2D.Double(); - if (node != null) - size.setRect(node.getBoundsInLocal()); + if (name != null) + size.setRect(name.getBoundsInLocal()); + if(reference != null) { + if (reference.getBoundsInLocal().getWidth() > size.getWidth()) + size.setRect(size.getX(), size.getY(), reference.getBoundsInLocal().getWidth(), size.getHeight()); + } else size.setFrame(0, 0, 0, 0); return size; -- 2.47.1