]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Store initial links between route notes for JS connection rendering
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 24 Apr 2019 07:46:51 +0000 (10:46 +0300)
committerJussi Koskela <jussi.koskela@semantum.fi>
Wed, 24 Apr 2019 07:46:51 +0000 (10:46 +0300)
Change-Id: Ic56c50e66a132e914a1bc816da57ae886a617259

bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/Link.java [new file with mode: 0644]
bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java

diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/Link.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/Link.java
new file mode 100644 (file)
index 0000000..30737e7
--- /dev/null
@@ -0,0 +1,19 @@
+package org.simantics.diagram.connection;
+
+public class Link {
+    RouteNode node1;
+    RouteNode node2;
+    
+    public Link(RouteNode node1, RouteNode node2) {
+        this.node1 = node1;
+        this.node2 = node2;
+    }
+    
+    public RouteNode getNode1() {
+        return node1;
+    }
+    
+    public RouteNode getNode2() {
+        return node2;
+    }
+}
index 62d3de68fae5f110a6b08eb80dcc7558ca34df80..6515774cc74d3cb00235ae955baab9513ee99b24 100644 (file)
  *******************************************************************************/
 package org.simantics.diagram.connection;
 
-import gnu.trove.list.array.TDoubleArrayList;
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.map.hash.TObjectIntHashMap;
-import gnu.trove.set.hash.THashSet;
-
 import java.awt.geom.Line2D;
 import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;
@@ -34,6 +29,11 @@ import org.simantics.diagram.connection.rendering.arrows.PlainLineEndStyle;
 import org.simantics.diagram.connection.segments.Segment;
 import org.simantics.diagram.connection.splitting.SplittedRouteGraph;
 
+import gnu.trove.list.array.TDoubleArrayList;
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.map.hash.TObjectIntHashMap;
+import gnu.trove.set.hash.THashSet;
+
 public class RouteGraph implements Serializable {
 
     private static final long serialVersionUID = 2004022454972623908L;
@@ -43,6 +43,7 @@ public class RouteGraph implements Serializable {
 
     ArrayList<RouteLine> lines = new ArrayList<RouteLine>(4);
     ArrayList<RouteTerminal> terminals = new ArrayList<RouteTerminal>(4);
+    
     ArrayList<RouteLine> transientLines = new ArrayList<RouteLine>(4);
     int caseId;
     boolean isSimpleConnection;
@@ -189,6 +190,15 @@ public class RouteGraph implements Serializable {
                 PlainLineEndStyle.INSTANCE, null);
     }
     
+    private Collection<Link> initialLinks;
+    public void setInitialLinks(Collection<Link> initialLinks) {
+        this.initialLinks = initialLinks;
+    }
+    
+    public Collection<Link> getInitialLinks() {
+        return initialLinks;
+    }
+    
     /**
      * Links nodes.
      */
index 17ccbe351e0941380bf0b2db94ef9a6a34fc1f96..192b4947fdf90e3ba7dd328fb67d34ab1b056361 100644 (file)
@@ -18,6 +18,7 @@ import java.awt.Shape;
 import java.awt.Stroke;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -34,6 +35,7 @@ import org.simantics.db.common.request.UnaryRead;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.connection.ConnectionVisuals;
+import org.simantics.diagram.connection.Link;
 import org.simantics.diagram.connection.RouteGraph;
 import org.simantics.diagram.connection.RouteGraphConnectionClass;
 import org.simantics.diagram.connection.RouteLine;
@@ -353,6 +355,8 @@ public class RouteGraphUtils {
             }
         }
 
+        Collection<Link> initialLinks = new ArrayList<>();
+        
         // Finish route graph loading by Linking route nodes together
         for (EdgeResource link : links) {
             RouteNode n1 = nodeByData.get(link.first());
@@ -362,7 +366,9 @@ public class RouteGraphUtils {
                 continue;
             }
             rg.link(n1, n2);
+            initialLinks.add(new Link(n1, n2));
         }
+        rg.setInitialLinks(initialLinks);
 
         return rg;