From: Hannu Niemistö Date: Fri, 29 Sep 2017 13:27:01 +0000 (+0300) Subject: (refs #7519) Configurable branch point radius X-Git-Tag: v1.31.0~160 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F59%2F1059%2F1;p=simantics%2Fplatform.git (refs #7519) Configurable branch point radius Change-Id: I0fc188f24ef6d9308bef6836595792348a38f603 --- 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 9338e9172..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 @@ -578,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; diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ConnectionVisuals.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ConnectionVisuals.java index 45e407906..5f62ac314 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ConnectionVisuals.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ConnectionVisuals.java @@ -25,14 +25,16 @@ public class ConnectionVisuals { public final float[] color; public final StrokeType strokeType; public final Stroke stroke; + public final Double branchPointRadius; public final Double rounding; - public ConnectionVisuals(float[] color, StrokeType strokeType, Stroke stroke, Double rounding) { + public ConnectionVisuals(float[] color, StrokeType strokeType, Stroke stroke, Double branchPointRadius, Double rounding) { if (color != null && color.length < 3) throw new IllegalArgumentException("colors must have at least 3 components (rgb), got " + color.length); this.color = color; this.strokeType = strokeType; this.stroke = stroke; + this.branchPointRadius = branchPointRadius; this.rounding = rounding; } @@ -48,6 +50,7 @@ public class ConnectionVisuals { public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + ((branchPointRadius == null) ? 0 : branchPointRadius.hashCode()); result = prime * result + Arrays.hashCode(color); result = prime * result + ((rounding == null) ? 0 : rounding.hashCode()); result = prime * result + ((stroke == null) ? 0 : stroke.hashCode()); @@ -64,6 +67,11 @@ public class ConnectionVisuals { if (getClass() != obj.getClass()) return false; ConnectionVisuals other = (ConnectionVisuals) obj; + if (branchPointRadius == null) { + if (other.branchPointRadius != null) + return false; + } else if (!branchPointRadius.equals(other.branchPointRadius)) + return false; if (!Arrays.equals(color, other.color)) return false; if (rounding == null) { @@ -80,5 +88,4 @@ public class ConnectionVisuals { return false; return true; } - } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ConnectionVisualsRequest.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ConnectionVisualsRequest.java index 4af440a52..73e3615ce 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ConnectionVisualsRequest.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ConnectionVisualsRequest.java @@ -52,9 +52,10 @@ public class ConnectionVisualsRequest extends ResourceRead { StrokeType strokeType = toStrokeType(g.getPossibleObject(structuralConnectionType, g2d.HasStrokeType)); Stroke stroke = G2DUtils.getStroke(g, g.getPossibleObject(structuralConnectionType, g2d.HasStroke)); + Double branchPointRadius = g.getPossibleRelatedValue(structuralConnectionType, g2d.HasBranchPointRadius, Bindings.DOUBLE); Double rounding = g.getPossibleRelatedValue(structuralConnectionType, g2d.HasRounding, Bindings.DOUBLE); - return new ConnectionVisuals(color, strokeType, stroke, rounding); + return new ConnectionVisuals(color, strokeType, stroke, branchPointRadius, rounding); } StrokeType toStrokeType(Resource strokeType) { diff --git a/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph b/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph index 15506f545..ce06a4109 100644 --- a/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph +++ b/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph @@ -94,6 +94,8 @@ G2D.StrokeType.Scaling : G2D.StrokeType G2D.StrokeType.Nonscaling : G2D.StrokeType G2D.HasRounding L0.Double +G2D.HasBranchPointRadius L0.Double G2D.LineEnd