From: Tuukka Lehtonen Date: Thu, 20 Feb 2020 11:35:13 +0000 (+0000) Subject: Merge "Fixed Path2D creation to work with overlapping RoutePoints" X-Git-Tag: v1.43.0~94 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=7bc4de702166fe57dd45b7f161847e6d21d83bb4;hp=c24439ef11722e3a652f0fb670d38e3d911142d9;p=simantics%2Fplatform.git Merge "Fixed Path2D creation to work with overlapping RoutePoints" --- 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 9b707eae7..fe9371766 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 @@ -21,9 +21,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.TreeMap; +import java.util.stream.Collectors; import org.simantics.diagram.connection.rendering.arrows.ILineEndStyle; import org.simantics.diagram.connection.rendering.arrows.PlainLineEndStyle; @@ -1412,9 +1413,7 @@ public class RouteGraph implements Serializable { } // Analyze graph - Map begins = -// new THashMap(); //The ordering of the coordinates in the path should be deterministic between scenegraphs - new TreeMap(RG_COMP); + Map begins = new HashMap(); for(RouteLine line : lines) { add(begins, line); } @@ -1428,7 +1427,9 @@ public class RouteGraph implements Serializable { } // Create paths - for(RoutePoint begin : begins.keySet().toArray(new RoutePoint[begins.size()])) { + // Sort the begins so that the order of segments is deterministic. This is required when comparing e.g. SVG diagrams. + // In case of overlapping begins the order may vary. + for(RoutePoint begin : begins.keySet().stream().sorted(RG_COMP).collect(Collectors.toList())) { RouteLine curLine = begins.remove(begin); drawContinuousPath(path, begins, begin, curLine); }