]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Changed sysdyn to use new routing mode
authorniemisto <niemisto@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 18 Jun 2012 11:22:58 +0000 (11:22 +0000)
committerniemisto <niemisto@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 18 Jun 2012 11:22:58 +0000 (11:22 +0000)
refs #3279

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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java

index 885b75b59628c6b84866fe978609636b0d798c6a..47120e9449071f751ca1ee5425ebc8eedd72548f 100644 (file)
@@ -15,7 +15,6 @@ import java.awt.Color;
 import java.awt.Graphics2D;\r
 import java.awt.geom.AffineTransform;\r
 import java.awt.geom.Path2D;\r
-import java.awt.geom.Rectangle2D;\r
 import java.io.Serializable;\r
 import java.util.StringTokenizer;\r
 \r
@@ -39,16 +38,13 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable {
     protected Path2D path;\r
     protected double lineEndLength;\r
     \r
-    protected Rectangle2D bounds = new Rectangle2D.Double();\r
-    \r
-    public FlowArrowLineStyle(String desc, Rectangle2D bounds) {\r
+    public FlowArrowLineStyle(String desc) {\r
         this.type = ArrowType.None;\r
         this.lineEndLength = 0.0;\r
 \r
         double l = length;\r
         double w = width;\r
         double s = space;\r
-        this.bounds = bounds;\r
 \r
         StringTokenizer tokenizer = new StringTokenizer(desc);\r
         if (tokenizer.hasMoreTokens()) {\r
@@ -80,23 +76,6 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable {
     public void render(Graphics2D g, double x, double y, int dir) {\r
         if (type == ArrowType.None || path == null)\r
             return;\r
-        // Calculate coordinates to the border of the terminal\r
-        switch(dir) {\r
-            case 0:\r
-                x = bounds.getMinX();\r
-                break;\r
-            case 1:\r
-                y = bounds.getMinY();\r
-                break;\r
-            case 2:\r
-                x = bounds.getMaxX();\r
-                break;\r
-            case 3:\r
-                y = bounds.getMaxY();\r
-                break;\r
-            default:\r
-                return;\r
-        }\r
         AffineTransform old = g.getTransform();\r
         g.translate(x, y);\r
         g.rotate(dir*Math.PI*0.5);\r
@@ -116,20 +95,6 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable {
 \r
     @Override\r
     public double getLineEndLength(int direction) {\r
-        switch(direction) {\r
-            case 0:\r
-                lineEndLength = bounds.getWidth() / 2.0;\r
-                break;\r
-            case 1:\r
-                lineEndLength = bounds.getHeight() / 2.0;\r
-                break;\r
-            case 2:\r
-                lineEndLength =  bounds.getWidth() / 2.0;\r
-                break;\r
-            case 3:\r
-                lineEndLength = bounds.getHeight() / 2.0;\r
-                break;\r
-        }\r
         return lineEndLength;\r
     }\r
 \r
index df190df77077b9f9a5d21142060bd85c42003dd6..e30d2578d2d46875332680a2c6dc001281526dbf 100644 (file)
@@ -234,7 +234,7 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
             // Expand bounds by 4mm to make the connections enter the terminals\r
             // at a straight angle and from a distance instead of coming in\r
             // "horizontally".\r
-            GeometryUtils.expandRectangle(bounds, 4);\r
+            //GeometryUtils.expandRectangle(bounds, 4);\r
 \r
             minx = bounds.getMinX();\r
             miny = bounds.getMinY();\r
@@ -271,14 +271,9 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
                 direction = 0xf;\r
 \r
             //System.out.println("load line style: " + NameUtils.getSafeLabel(graph, attachmentRelation));\r
-            ILineEndStyle endStyle = loadLineEndStyle(graph, te, attachmentRelation, new Rectangle2D.Double(\r
-                    bounds.getX(), \r
-                    bounds.getY(), \r
-                    bounds.getWidth(), \r
-                    bounds.getHeight())\r
-            );\r
-\r
-            RouteTerminal routeTerminal = rg.addTerminal(x, y, minx, miny, maxx, maxy, direction, endStyle);\r
+            ILineEndStyle endStyle = loadLineEndStyle(graph, te, attachmentRelation);\r
+\r
+            RouteTerminal routeTerminal = rg.addBigTerminal(/*x, y,*/ minx, miny, maxx, maxy, /*direction,*/ endStyle);\r
             routeTerminal.setData( RouteGraphConnection.serialize(graph, connector) );\r
 \r
             nodes.add( connector );\r
@@ -377,20 +372,17 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
         return null;\r
     }\r
 \r
-    public ILineEndStyle loadLineEndStyle(ReadGraph graph, IElement te, Resource attachmentRelation, Rectangle2D bounds)\r
+    public ILineEndStyle loadLineEndStyle(ReadGraph graph, IElement te, Resource attachmentRelation)\r
             throws DatabaseException {\r
         ILineEndStyle style;\r
         // TODO: change bounds according to terminal type: Very small rectangle for Valves, Text box size for Stocks and Clouds\r
         if(te.getElementClass().containsClass(ValveSceneGraph.class)) {\r
-            GeometryUtils.expandRectangle(bounds, -4);\r
-            style =  new FlowArrowLineStyle("none 0 0 0", bounds);\r
+            style =  new FlowArrowLineStyle("none 0 0 0");\r
         } else {\r
             if (graph.isSubrelationOf(attachmentRelation, DIA.HasHeadConnector)) {\r
-                GeometryUtils.expandRectangle(bounds, -2.5);\r
-                style = new FlowArrowLineStyle("fill 2 2 -1.5", bounds);\r
+                style = new FlowArrowLineStyle("fill 2 2 0");\r
             } else {\r
-                GeometryUtils.expandRectangle(bounds, -4);\r
-                style =  new FlowArrowLineStyle("none 0 0 0", bounds);\r
+                style =  new FlowArrowLineStyle("none 0 0 0");\r
             }\r
         }\r
         return style;\r