]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16840 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Jul 2010 07:32:34 +0000 (07:32 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Jul 2010 07:32:34 +0000 (07:32 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java

index 0c205c38ceeb845a70f6a93cb81ce3cb2afae576..7bb49b3d20dee3926413d6387264a4a7ad19da02 100644 (file)
@@ -59,7 +59,7 @@ public class InputFactory extends SysdynElementFactory {
         path.closePath();\r
         return path;\r
     }\r
-    \r
+\r
     @Override\r
     protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
         return ElementClass.compile(\r
@@ -85,7 +85,6 @@ public class InputFactory extends SysdynElementFactory {
         Builtins b = graph.getBuiltins();\r
         ModelingResources mr = ModelingResources.getInstance(graph);\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
-\r
         Resource component = null;\r
         Resource dependency = null;\r
         Resource refersTo = null;\r
@@ -97,6 +96,7 @@ public class InputFactory extends SysdynElementFactory {
             refersTo = graph.getPossibleObject(dependency, sr.RefersTo);\r
             module = graph.getPossibleObject(dependency, sr.HasTail);\r
         }\r
+        \r
         String inputReference = null;\r
         if (module != null && refersTo != null) {\r
             inputReference = (String) graph.getPossibleRelatedValue(module, b.HasName);\r
@@ -104,32 +104,36 @@ public class InputFactory extends SysdynElementFactory {
             inputReference += (String) graph.getPossibleRelatedValue(refersTo, b.HasName);\r
         }\r
         if (inputReference == null) {\r
-            inputReference = "\"\"";\r
+            inputReference = "";\r
         }\r
 \r
-       SysdynElementUtils.setInputReference(e, inputReference);\r
+        SysdynElementUtils.setInputReference(e, inputReference);\r
+\r
     }\r
-    \r
-    \r
+\r
+\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
+        public static final Key     INPUT_SG_NODE          = new SceneGraphNodeKey(TextNode.class, "INPUT_SG_NODE");\r
 \r
         private final double originX;\r
         private final Alignment horizontalAlignment;\r
-        \r
+\r
         public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment) {\r
-            super(originX, originY, horizontalAlignment, 0, true);\r
+            super(originX, originY, horizontalAlignment, (double) 0.0, true);\r
             this.originX = originX;\r
             this.horizontalAlignment = horizontalAlignment;\r
         }\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 = ElementUtils.getTextFont(e);\r
+            TextNode name = (TextNode) e.getHint(SG_NODE);\r
+            Font font = name.getFont().deriveFont(Font.ITALIC);\r
+            name.setFont(font);\r
+            TextNode node = ElementUtils.getOrCreateNode(e, parent, INPUT_SG_NODE, "input", TextNode.class);\r
+            font = ElementUtils.getTextFont(e);\r
             font = font.deriveFont((float) 10.0);\r
             font = font.deriveFont(Font.ITALIC);\r
             Color color = new Color(150, 150, 150);\r
@@ -148,11 +152,16 @@ public class InputFactory extends SysdynElementFactory {
 \r
         @Override\r
         public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
-            TextNode node = (TextNode) e.getHint(SG_NODE);\r
+            TextNode name = (TextNode) e.getHint(SG_NODE);\r
+            TextNode reference = (TextNode) e.getHint(INPUT_SG_NODE);\r
             if (size == null)\r
                 size = new Rectangle2D.Double();\r
-            if (node != null)\r
-                size.setRect(node.getBoundsInLocal());\r
+            if (name != null)\r
+                size.setRect(name.getBoundsInLocal());\r
+            if(reference != null) {\r
+                if (reference.getBoundsInLocal().getWidth() > size.getWidth())\r
+                    size.setRect(size.getX(), size.getY(), reference.getBoundsInLocal().getWidth(), size.getHeight());\r
+            }\r
             else\r
                 size.setFrame(0, 0, 0, 0);\r
             return size;\r