X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fadapter%2FRouteGraphUtils.java;h=62c4046151e875fdda0e13715a5aa619c9afae36;hb=9f0fd59be54719b1fe9322d8fd37e4950857308c;hp=1b7376f96e4301814ba70ac861635ff058806cce;hpb=e571f79968d4f002505f3ea11e50ac7075d492c0;p=simantics%2Fplatform.git 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 1b7376f96..62c404615 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 @@ -110,12 +110,21 @@ public class RouteGraphUtils { RouteGraph rg = new RouteGraph(); // Default capacity should be enough for common cases. - Set links = new THashSet(); - Map nodeByData = new THashMap(); + Set links = new THashSet<>(); + Map nodeByData = new THashMap<>(); // Load all route graph interior RouteNodes: route lines and points for (Resource interiorNode : graph.getObjects(connection, DIA.HasInteriorRouteNode)) { if (graph.isInstanceOf(interiorNode, DIA.RouteLine)) { + Collection areConnected = graph.getObjects(interiorNode, DIA.AreConnected); + if (areConnected.size() < 2) { + // Degenerated route line encountered, most likely due to a bug somewhere else. + // Ignoring them because adding them to the RouteGraph structure would cause + // problems during rendering. + LOGGER.warn("Stray RouteLine found: " + NameUtils.getSafeName(graph, interiorNode)); + continue; + } + Boolean isHorizontal = graph.getRelatedValue(interiorNode, DIA.IsHorizontal, Bindings.BOOLEAN); Double position = graph.getRelatedValue(interiorNode, DIA.HasPosition, Bindings.DOUBLE); RouteLine line = rg.addLine(isHorizontal, position); @@ -123,7 +132,7 @@ public class RouteGraphUtils { nodeByData.put( interiorNode, line ); - for (Resource connectedTo : graph.getObjects(interiorNode, DIA.AreConnected)) { + for (Resource connectedTo : areConnected) { links.add( new EdgeResource(interiorNode, connectedTo) ); } } else if (graph.isInstanceOf(interiorNode, DIA.RoutePoint)) { @@ -524,7 +533,7 @@ public class RouteGraphUtils { } } - private static final ConnectionStyle DEFAULT_CONNECTION_STYLE = new ExampleConnectionStyle(); + private static final ConnectionStyle DEFAULT_CONNECTION_STYLE = new BasicConnectionStyle(Color.BLACK, Color.BLACK, 3, ExampleConnectionStyle.SOLID, ExampleConnectionStyle.SOLID, 8); /** * @param graph @@ -569,7 +578,7 @@ public class RouteGraphUtils { // Fixed style settings Color branchPointColor = Color.BLACK; - double branchPointRadius = 0.5; + double branchPointRadius = cv != null && cv.branchPointRadius != null ? cv.branchPointRadius : 0.5; double degenerateLineLength = 0.8; Color lineColor = cv != null ? cv.toColor() : null;