From 1e745dd6a0be461f335a9328197136c96d4d4b96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Fri, 29 Sep 2017 16:27:01 +0300 Subject: [PATCH] (refs #7519) Configurable branch point radius Change-Id: I0fc188f24ef6d9308bef6836595792348a38f603 --- .../simantics/diagram/adapter/RouteGraphUtils.java | 2 +- .../diagram/connection/ConnectionVisuals.java | 11 +++++++++-- .../diagram/query/ConnectionVisualsRequest.java | 3 ++- bundles/org.simantics.g2d.ontology/graph/G2D.pgraph | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) 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