]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Hover to follow Loop image. Flip image with the clockwise option. (refs #3012)
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 22 Nov 2013 09:48:49 +0000 (09:48 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 22 Nov 2013 09:48:49 +0000 (09:48 +0000)
Simantics flips to not mirror text elements.

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28356 ac1ea38d-2e2b-0410-8846-a27921b304fc

15 files changed:
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/CommentSymbols.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/AuxiliaryFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextElementNoBounds.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/InputFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopClockwise.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/StockFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynElementHints.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynElementUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ValveFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Loop.java

index ec145e4c8a035d98ef83b94ddd820e4955b57586..7bdd693ebac6a9c3113c72ecdd14d8d3ae0ac1ce 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index 82666f4568b6c74c794fa71fc825246d21efadee..adfd0b9af7ec0e896d7b65a9b88354e67d4bcca9 100644 (file)
@@ -16,10 +16,8 @@ SYSDYN.AdditionalSymbols.MultilineText <T DIA.TextElement
     G2D.HasSVGDocument """<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" overflow="visible" version="1.1"><g style="fill:#000000;fill-opacity:1;stroke:none"><path d="m 4.2699962,-2.1489344 -0.4716797,0 C 3.7572928,-2.3129896 3.6832369,-2.5078137 3.5761485,-2.733407 3.4690444,-2.9589851 3.3494156,-3.1720383 3.2172618,-3.3725672 3.0805357,-3.5821941 2.9312845,-3.7656249 2.7695079,-3.9228601 2.6077171,-4.0800777 2.4516301,-4.1700841 2.3012462,-4.1928797 2.1599637,-4.2110997 1.9822295,-4.2247716 1.768043,-4.2338953 1.5538445,-4.2430007 1.3556025,-4.247558 1.1733165,-4.2475672 l -0.3964844,0 0,7.7587891 c -5.05e-6,0.1503919 0.031896,0.2882498 0.0957031,0.4135742 0.0637969,0.1253264 0.17545037,0.2221687 0.33496097,0.2905273 0.082026,0.031902 0.2540632,0.075196 0.5161132,0.1298829 0.2620381,0.054688 0.4659766,0.08431 0.6118165,0.088867 l 0,0.4853516 -4.5800782,0 0,-0.4853516 c 0.127602,-0.00911 0.3224261,-0.027343 0.5844727,-0.054687 0.2620414,-0.027343 0.4431935,-0.061523 0.543457,-0.102539 0.15038733,-0.059244 0.26090154,-0.1446932 0.33154298,-0.2563477 0.0706345,-0.1116526 0.10595343,-0.2609038 0.10595704,-0.4477539 l 0,-7.8203125 -0.39648442,0 c -0.1412791,9.2e-6 -0.3167346,0.00343 -0.5263671,0.010254 -0.2096379,0.00685 -0.4101586,0.021656 -0.6015625,0.044434 -0.1503926,0.018238 -0.3064797,0.1082447 -0.4682618,0.2700196 -0.1617853,0.1617925 -0.3110364,0.3452233 -0.4477539,0.5502929 -0.1367197,0.2050862 -0.2574879,0.4226967 -0.3623047,0.6528321 -0.1048184,0.2301506 -0.177735,0.4204173 -0.21875,0.5708007 l -0.4785156,0 0,-2.6318359 8.4492188,0 z" /></g></svg>""" : L0.String\r
 \r
 SYSDYN.Loop <T SYSDYN.Component <T DIA.FontProvider <T DIA.ColorProvider //<T DIA.TextElement\r
-    >-- SYSDYN.Loop.Clockwise --> L0.Boolean <R L0.ConsistsOf : L0.FunctionalRelation\r
     >-- SYSDYN.Loop.Comment --> L0.String <R L0.ConsistsOf : L0.FunctionalRelation\r
     >-- SYSDYN.Loop.Items --> L0.List <R L0.DependsOn : L0.FunctionalRelation\r
-    @L0.assert SYSDYN.Loop.Clockwise L0.True\r
     @L0.assert SYSDYN.Loop.Comment "$$AUTO$$"\r
     @L0.assert G2D.HasFont SYSDYN.DefaultFont     \r
     @L0.assert G2D.HasColor \r
@@ -27,6 +25,8 @@ SYSDYN.Loop <T SYSDYN.Component <T DIA.FontProvider <T DIA.ColorProvider //<T DI
         \r
 SYSDYN.LoopSymbol <T SYSDYN.SysdynSymbol\r
     @MOD.defSymbol "Loop" SYSDYN.Loop\r
+    >-- SYSDYN.LoopSymbol.Clockwise --> L0.Boolean <R L0.ConsistsOf : L0.FunctionalRelation\r
+    @L0.assert SYSDYN.LoopSymbol.Clockwise L0.True\r
     L0.HasDescription "(Shift+L)"\r
     L0.IsDependencyOf GENERAL\r
     G2D.HasSVGDocument \r
index b51c3e17da69661fd30cf3b58e41813b6cbf3013..14500185076fe37b7af50af1a654844ee589f693 100644 (file)
@@ -459,8 +459,8 @@ public class SysdynResource {
     public final Resource LookupExpression_lookup_Inverse;\r
     public final Resource Loop;\r
     public final Resource LoopSymbol;\r
-    public final Resource Loop_Clockwise;\r
-    public final Resource Loop_Clockwise_Inverse;\r
+    public final Resource LoopSymbol_Clockwise;\r
+    public final Resource LoopSymbol_Clockwise_Inverse;\r
     public final Resource Loop_Comment;\r
     public final Resource Loop_Comment_Inverse;\r
     public final Resource Loop_Items;\r
@@ -1213,8 +1213,8 @@ public class SysdynResource {
         public static final String LookupExpression_lookup_Inverse = "http://www.simantics.org/Sysdyn-1.1/LookupExpression/lookup/Inverse";\r
         public static final String Loop = "http://www.simantics.org/Sysdyn-1.1/Loop";\r
         public static final String LoopSymbol = "http://www.simantics.org/Sysdyn-1.1/LoopSymbol";\r
-        public static final String Loop_Clockwise = "http://www.simantics.org/Sysdyn-1.1/Loop/Clockwise";\r
-        public static final String Loop_Clockwise_Inverse = "http://www.simantics.org/Sysdyn-1.1/Loop/Clockwise/Inverse";\r
+        public static final String LoopSymbol_Clockwise = "http://www.simantics.org/Sysdyn-1.1/LoopSymbol/Clockwise";\r
+        public static final String LoopSymbol_Clockwise_Inverse = "http://www.simantics.org/Sysdyn-1.1/LoopSymbol/Clockwise/Inverse";\r
         public static final String Loop_Comment = "http://www.simantics.org/Sysdyn-1.1/Loop/Comment";\r
         public static final String Loop_Comment_Inverse = "http://www.simantics.org/Sysdyn-1.1/Loop/Comment/Inverse";\r
         public static final String Loop_Items = "http://www.simantics.org/Sysdyn-1.1/Loop/Items";\r
@@ -1977,8 +1977,8 @@ public class SysdynResource {
         LookupExpression_lookup_Inverse = getResourceOrNull(graph, URIs.LookupExpression_lookup_Inverse);\r
         Loop = getResourceOrNull(graph, URIs.Loop);\r
         LoopSymbol = getResourceOrNull(graph, URIs.LoopSymbol);\r
-        Loop_Clockwise = getResourceOrNull(graph, URIs.Loop_Clockwise);\r
-        Loop_Clockwise_Inverse = getResourceOrNull(graph, URIs.Loop_Clockwise_Inverse);\r
+        LoopSymbol_Clockwise = getResourceOrNull(graph, URIs.LoopSymbol_Clockwise);\r
+        LoopSymbol_Clockwise_Inverse = getResourceOrNull(graph, URIs.LoopSymbol_Clockwise_Inverse);\r
         Loop_Comment = getResourceOrNull(graph, URIs.Loop_Comment);\r
         Loop_Comment_Inverse = getResourceOrNull(graph, URIs.Loop_Comment_Inverse);\r
         Loop_Items = getResourceOrNull(graph, URIs.Loop_Items);\r
index 391a582939d21051b4061ae6e7bbd8bd3e620453..c25ac8ec198915d4fe076cc48b7efa69aa401104 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Collection;
 \r
 import org.simantics.db.Resource;\r
 import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.IElement;\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
@@ -31,6 +32,7 @@ import org.simantics.g2d.element.handler.impl.TextImpl;
 import org.simantics.g2d.image.Image;\r
 import org.simantics.g2d.image.impl.ShapeImage;\r
 import org.simantics.g2d.utils.Alignment;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
 \r
 /**\r
  * @author Tuukka Lehtonen\r
@@ -51,10 +53,27 @@ public class AuxiliaryFactory extends SysdynElementFactory {
                 new StaticObjectAdapter(elementType),\r
                 new StaticSymbolImpl(AUX_STATIC_IMAGE),\r
                 StaticSymbolImageInitializer.INSTANCE,\r
-                new HoverTextElementHandler(0, 0, Alignment.LEADING, 0, 1.5, 1.5, true),\r
+                new AuxiliarySceneGraph(0, 0, Alignment.LEADING, 0, 1.5, 1.5, true),\r
                 BoundsOutline.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(AuxiliaryFactory.class.getSimpleName());\r
     }\r
+    \r
+    public static class AuxiliarySceneGraph extends HoverTextElementHandler {\r
 \r
+               private static final long serialVersionUID = -7077873654863790864L;\r
+               \r
+               public AuxiliarySceneGraph(double i, double j, Alignment leading, double k, double d,\r
+                               double e, boolean b) {\r
+                       super(i, j, leading, k, d, e, b);\r
+               }\r
+\r
+               @Override\r
+               public void init(IElement e, G2DParentNode parent) {\r
+                       super.init(e, parent);\r
+                       unflipText(e);\r
+               }\r
+\r
+    }\r
+       \r
 }\r
index 41c548d91f85449d3a65acf9e1cf0c9b648c9610..d0076512ceb11e3b98043f8007979ca8858130de 100644 (file)
@@ -207,6 +207,19 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif
                        node.setTransform(at);\r
        }\r
        \r
+       public static void unflipText(IElement e) {\r
+               Object o = e.getHint(SG_NODE);\r
+               if (o instanceof TextNode) {\r
+                       TextNode text = (TextNode)o;\r
+                   AffineTransform at = text.getTransform();\r
+                   double x = at.getTranslateX();\r
+                   double y = at.getTranslateY();\r
+                   at.setToRotation(0);\r
+                   at.setToTranslation(x, y);\r
+                   at.setTransform(at);\r
+               }\r
+       }\r
+       \r
        protected void activateEdit(final HoverTextNode node, final IElement e) {\r
                final ICanvasContext ctx = DiagramNodeUtil.getCanvasContext(node);\r
         // FIXME: needed only because eventdelegator registrations are done before adding node to scene graph.\r
index 42c2c0a62923aea85fe4682c73a59130946d8c30..859dd10952687a03ecb8d6e55e79c21bc8be2841 100644 (file)
@@ -211,6 +211,8 @@ public class InputFactory extends SysdynElementFactory {
                 at2.translate(0, font.getSize2D() * scale);\r
                 node.setTransform(at2);\r
             }\r
+            \r
+            unflipText(e);\r
         }\r
 \r
         @Override\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopClockwise.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopClockwise.java
new file mode 100644 (file)
index 0000000..19cf448
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.ElementHandler;\r
+\r
+public class LoopClockwise implements ElementHandler {\r
+\r
+       private static final long serialVersionUID = -5104770127548577905L;\r
+       \r
+       public static final LoopClockwise INSTANCE = new LoopClockwise();\r
+    \r
+    public String getTextLocation(IElement e) {\r
+        return e.getHint(SysdynElementHints.KEY_LOOP_CLOCKWISE);\r
+    }\r
+\r
+    \r
+    public void setTextLocation(IElement e, Boolean clockwise) {\r
+        if (clockwise != null)\r
+            e.setHint(SysdynElementHints.KEY_LOOP_CLOCKWISE, clockwise);\r
+        else\r
+            e.removeHint(SysdynElementHints.KEY_LOOP_CLOCKWISE);\r
+    }\r
+\r
+}\r
index 68952772ff7fb9db67a33c3acf00e086b2971cc8..8ea6915ff5e167604fb1d639b94b60359fb7189c 100644 (file)
@@ -18,10 +18,11 @@ import java.awt.Shape;
 import java.awt.geom.AffineTransform;\r
 import java.awt.geom.Arc2D;\r
 import java.awt.geom.Path2D;\r
-import java.awt.geom.Rectangle2D;\r
+import java.awt.geom.Point2D;\r
 import java.awt.geom.RectangularShape;\r
 import java.util.Collection;\r
 \r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
@@ -104,11 +105,12 @@ public class LoopFactory extends SysdynElementFactory {
                                new StaticObjectAdapter(elementType),\r
                                new StaticSymbolImpl(image),\r
                                StaticSymbolImageInitializer.INSTANCE,\r
+                               LoopSceneGraph.INSTANCE,\r
                                new LoopImageSceneGraph(image),\r
                                HoverImpl.INSTANCE,\r
-                               LoopSceneGraph.INSTANCE,\r
-                               BoundsOutline.INSTANCE\r
-                               ).setId(LoopFactory.class.getSimpleName());\r
+                               BoundsOutline.INSTANCE,\r
+                               LoopClockwise.INSTANCE\r
+        ).setId(LoopFactory.class.getSimpleName());\r
        }\r
 \r
        static Shape getLoopShape() {\r
@@ -143,6 +145,19 @@ public class LoopFactory extends SysdynElementFactory {
                        Collection<ObjectTerminal> terminals) {\r
                return null;\r
        }\r
+       \r
+    @Override\r
+    public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource element, final IElement e) throws DatabaseException {\r
+        super.load(graph, canvas, diagram, element, e);\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        Boolean clockwise = graph.getPossibleRelatedValue(element, sr.LoopSymbol_Clockwise, Bindings.BOOLEAN);\r
+        if(clockwise == null) {\r
+            clockwise = Boolean.TRUE;\r
+        }\r
+        SysdynElementUtils.setLoopClockwise(e, clockwise);\r
+    }\r
+    \r
+    \r
 \r
        /**\r
         * Handling for the loop image on diagram.\r
@@ -168,11 +183,19 @@ public class LoopFactory extends SysdynElementFactory {
                        // Create new hover shape node for the loop image\r
                        final HoverShapeNode node = ElementUtils.getOrCreateNode(e, parent, NODE, "loopHover", HoverShapeNode.class);\r
                        \r
-                       // Set the shape of the shape node to match the shape of the image\r
+                       // Mirror the image if clockwise is selected.\r
+                       Boolean clockwise = e.getHint(SysdynElementHints.KEY_LOOP_CLOCKWISE);\r
                        SVGNode image = e.getHint(getNodeKey());\r
+                       if (clockwise != null && clockwise) {\r
+               Point2D imageParent = (Point2D) image.localToParent(new Point2D.Double(0.0,0.0)).clone();\r
+               AffineTransform at = new AffineTransform(-1.0, 0.0, 0.0, 1.0, imageParent.getX(), imageParent.getY());\r
+               image.setTransform(at);\r
+                       }\r
+                       \r
+                       // Set the shape of the shape node to match the shape of the image\r
                        RectangularShape bounds = (RectangularShape)image.getBounds().clone();\r
                        node.setShape(bounds);\r
-\r
+                                               \r
                        // Set the shape node transparent\r
                        Paint paint = new Color(0,0,0,0);\r
                        node.setColor(paint);\r
@@ -232,6 +255,9 @@ public class LoopFactory extends SysdynElementFactory {
                        AffineTransform at = ElementUtils.getTransform(e);\r
                        final HoverShapeNode node = ElementUtils.getOrCreateNode(e, parent, NODE, "loopComment", HoverShapeNode.class);\r
 \r
+                       // Unflip the text and image\r
+                       unflipText(e);\r
+\r
                        if(at != null) {\r
                                node.setTransform(at);\r
 \r
@@ -247,12 +273,11 @@ public class LoopFactory extends SysdynElementFactory {
                                                name.setHorizontalAlignment((byte) alignment.ordinal());\r
                                }\r
                        }\r
-\r
                }\r
 \r
                private static double getXCoordShift(IElement e) {\r
                        //String location = e.getHint(SysdynElementHints.KEY_LOCATION);\r
-                       return 0.4;\r
+                       return 0;\r
                }\r
 \r
                private static double getYCoordShift(IElement e) {\r
index e67b7967813a08d78db593e27f5ef6f3bdd75145..a7f9b15f2e7532ebc1d2b50b4c0d142c8d4bcb63 100644 (file)
@@ -73,6 +73,12 @@ public class ModuleFactory extends SysdynElementFactory {
                super(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable);\r
         }\r
                \r
+               @Override\r
+               public void init(IElement e, G2DParentNode parent) {\r
+                       super.init(e, parent);\r
+                       unflipText(e);\r
+               }\r
+               \r
                protected HoverTextNode getTextNode(IElement e, G2DParentNode parent) {\r
                        return ElementUtils.getOrCreateNode(e, parent, SG_NODE, "text", ModuleNode.class, getCallback(e, parent, ModuleNode.class));\r
                }\r
index 1777033c4624f46dc803c9d39171f518b435ae18..13a6ee48be5bc63d71345ce3fccac47946daf778 100644 (file)
@@ -39,6 +39,7 @@ import org.simantics.g2d.element.handler.impl.TextImpl;
 import org.simantics.g2d.image.Image;\r
 import org.simantics.g2d.image.impl.ShapeImage;\r
 import org.simantics.g2d.utils.Alignment;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
 \r
 public class StockFactory extends SysdynElementFactory {\r
 \r
@@ -57,7 +58,7 @@ public class StockFactory extends SysdynElementFactory {
                 new StaticObjectAdapter(elementType),\r
                 new StaticSymbolImpl(STOCK_IMAGE),\r
                 StaticSymbolImageInitializer.INSTANCE,\r
-                new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f, 1.0, 1.0, true),\r
+                new StockSceneGraph(0, 0, Alignment.LEADING, 1f, 1.0, 1.0, true),\r
                 BoundsOutline.INSTANCE,\r
                 new BorderColorImpl(Color.BLACK),\r
                 new WholeElementTerminals(terminals)\r
@@ -69,5 +70,23 @@ public class StockFactory extends SysdynElementFactory {
         super.load(graph, canvas, diagram, element, e);\r
         e.setHint(ElementHints.KEY_BORDER_COLOR, e.getHint(ElementHints.KEY_TEXT_COLOR));\r
     }\r
-            \r
+           \r
+    public static class StockSceneGraph extends HoverTextElementHandler {\r
+\r
+               private static final long serialVersionUID = 6635538659448488606L;\r
+\r
+               public StockSceneGraph(double i, double j, Alignment leading, double k, double d,\r
+                               double e, boolean b) {\r
+                       super(i, j, leading, k, d, e, b);\r
+               }\r
+\r
+               @Override\r
+               public void init(IElement e, G2DParentNode parent) {\r
+                       super.init(e, parent);\r
+                       unflipText(e);\r
+               }\r
+\r
+    }\r
+       \r
+    \r
 }\r
index 14a59e8361b68aa553bc702e2ebe3241b1e5c1c8..fdd74d41423922c2430b3c1272722e0c425947f5 100644 (file)
@@ -21,6 +21,7 @@ public class SysdynElementHints {
     public static final Key KEY_INPUT_REFERENCE = new KeyOf(String.class, "INPUT_REFERENCE");\r
     public static final Key KEY_ORIENTATION = new KeyOf(String.class, "ORIENTATION");   \r
     public static final Key KEY_LOCATION = new KeyOf(String.class, "LOCATION");     \r
+    public static final Key KEY_LOOP_CLOCKWISE = new KeyOf(Boolean.class, "LOOP_CLOCKWISE");     \r
     \r
     public static final Key       SYSDYN_KEY_TOOL = new KeyOf(ToolMode.class, "SysdynKeyTool");\r
     public static final IToolMode DEPENDENCY_TOOL = new ToolMode("DependencyTool");\r
index 6802a9d95070a7c541dea2614c412774e17cd2f4..f912495f581ac095bc4889466b668271543c0e3f 100644 (file)
@@ -64,4 +64,20 @@ public class SysdynElementUtils {
             return null;\r
     }\r
 \r
+       public static void setLoopClockwise(IElement e, Boolean clockwise) {\r
+        LoopClockwise l = e.getElementClass().getSingleItem(LoopClockwise.class);\r
+        if(l != null)\r
+            l.setTextLocation(e, clockwise);\r
+       }\r
+\r
+    public static String getLoopClockwise(IElement e)\r
+    {\r
+       LoopClockwise l = e.getElementClass().getSingleItem(LoopClockwise.class);\r
+        if(l != null)\r
+            return l.getTextLocation(e);\r
+        else\r
+            return null;\r
+    }\r
+\r
+\r
 }\r
index 4f861591d902f57a5c239050ce02e3a33cca63f7..94d16aead56f6124896a5cd374f8ff5b159a3c9e 100644 (file)
@@ -220,6 +220,8 @@ public class ValveFactory extends SysdynElementFactory {
                 }\r
             };\r
             e.addHintListener(hoverHintListener);\r
+            \r
+                       unflipText(e);\r
         }\r
 \r
         @Override\r
index 27cc9a56903e5fd8cd64da3dd390aaae224b34bb..60720d62aee508f108dc1660c0f614e0b3a73c4d 100644 (file)
@@ -30,6 +30,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.modeling.ModelingResources;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.datastructures.Pair;\r
 import org.simantics.utils.datastructures.Triple;\r
@@ -127,10 +128,14 @@ public class LoopTab extends LabelPropertyTabContributor {
         }\r
         \r
         @Override\r
-        public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException {\r
+        public void apply(WriteGraph graph, Resource component) throws DatabaseException {\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
-            graph.deny(connectionElement, sr.Loop_Clockwise);\r
-            graph.claimLiteral(connectionElement, sr.Loop_Clockwise, clockwise);\r
+            ModelingResources mr = ModelingResources.getInstance(graph);\r
+               Resource symbol = graph.getPossibleObject(component, mr.ComponentToElement);\r
+            if(symbol != null) {\r
+               graph.deny(symbol, sr.LoopSymbol_Clockwise);\r
+               graph.claimLiteral(symbol, sr.LoopSymbol_Clockwise, clockwise);\r
+            }\r
         }\r
         \r
     }\r
@@ -148,10 +153,15 @@ public class LoopTab extends LabelPropertyTabContributor {
         }\r
 \r
         @Override\r
-        public Boolean perform(ReadGraph graph, Resource dependencyConnection) throws DatabaseException {\r
-            SysdynResource sr = SysdynResource.getInstance(graph);\r
-            Boolean clockwise = graph.getPossibleRelatedValue(dependencyConnection, sr.Loop_Clockwise, Bindings.BOOLEAN);  \r
-            return ObjectUtils.objectEquals(this.clockwise, clockwise);\r
+        public Boolean perform(ReadGraph graph, Resource component) throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(graph); \r
+               ModelingResources mr = ModelingResources.getInstance(graph);\r
+               Resource symbol = graph.getPossibleObject(component, mr.ComponentToElement);\r
+            if(symbol != null) {\r
+               Boolean clockwise = graph.getPossibleRelatedValue(symbol, sr.LoopSymbol_Clockwise, Bindings.BOOLEAN);  \r
+               return ObjectUtils.objectEquals(this.clockwise, clockwise);\r
+            }\r
+            return Boolean.TRUE;\r
         }\r
     }\r
     \r
index 1345faa0a037af5769bd2ed826180d31ed7fa544..f81e5355b63b4c7d2dd4693bf911730f7214ff27 100644 (file)
@@ -31,7 +31,7 @@ public class Loop implements IElement {
     @RelatedElement(Layer0.URIs.PartOf)\r
     protected Object parent;\r
     \r
-    @RelatedValue(SysdynResource.URIs.Loop_Clockwise)\r
+    @RelatedValue(SysdynResource.URIs.LoopSymbol_Clockwise)\r
     protected Boolean clockwise;\r
     \r
     @RelatedValue(SysdynResource.URIs.Loop_Comment)\r