From 40b592c95889b55cecc1c4280de64e56c5d434a2 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Wed, 24 Apr 2019 10:46:51 +0300 Subject: [PATCH] Store initial links between route notes for JS connection rendering Change-Id: Ic56c50e66a132e914a1bc816da57ae886a617259 --- .../simantics/diagram/connection/Link.java | 19 ++++++++++++++++++ .../diagram/connection/RouteGraph.java | 20 ++++++++++++++----- .../diagram/adapter/RouteGraphUtils.java | 6 ++++++ 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/Link.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 index 000000000..30737e7bd --- /dev/null +++ b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/Link.java @@ -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; + } +} diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java index 62d3de68f..6515774cc 100644 --- a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java +++ b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/RouteGraph.java @@ -11,11 +11,6 @@ *******************************************************************************/ 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 lines = new ArrayList(4); ArrayList terminals = new ArrayList(4); + ArrayList transientLines = new ArrayList(4); int caseId; boolean isSimpleConnection; @@ -189,6 +190,15 @@ public class RouteGraph implements Serializable { PlainLineEndStyle.INSTANCE, null); } + private Collection initialLinks; + public void setInitialLinks(Collection initialLinks) { + this.initialLinks = initialLinks; + } + + public Collection getInitialLinks() { + return initialLinks; + } + /** * Links nodes. */ diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java index 17ccbe351..192b4947f 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java @@ -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 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; -- 2.47.1