]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7519) Configurable branch point radius 59/1059/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 29 Sep 2017 13:27:01 +0000 (16:27 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 29 Sep 2017 13:27:01 +0000 (16:27 +0300)
Change-Id: I0fc188f24ef6d9308bef6836595792348a38f603

bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java
bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ConnectionVisuals.java
bundles/org.simantics.diagram/src/org/simantics/diagram/query/ConnectionVisualsRequest.java
bundles/org.simantics.g2d.ontology/graph/G2D.pgraph

index 9338e917221be3fcd06222e80ebf39f3288a7751..62c4046151e875fdda0e13715a5aa619c9afae36 100644 (file)
@@ -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;
index 45e4079065f76f1932f26c04b5035f61229a13ec..5f62ac31469798b15ac2d95ec2712a75b108bcc2 100644 (file)
@@ -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;
     }
-
 }
index 4af440a52c931fa81013388d41d57ab01d85a466..73e3615cee0589fd7f3fa42f98cb3a7d4cca2c69 100644 (file)
@@ -52,9 +52,10 @@ public class ConnectionVisualsRequest extends ResourceRead<ConnectionVisuals> {
 
         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) {
index 15506f545bdeef7cddd13824033b870e085a8937..ce06a4109e47fe1c9b94b25e6cfd0f267554264a 100644 (file)
@@ -94,6 +94,8 @@ G2D.StrokeType.Scaling : G2D.StrokeType
 G2D.StrokeType.Nonscaling : G2D.StrokeType
 G2D.HasRounding <R L0.HasProperty : L0.FunctionalRelation
     --> L0.Double
+G2D.HasBranchPointRadius <R L0.HasProperty : L0.FunctionalRelation
+    --> L0.Double
 G2D.LineEnd <T L0.Property
     @L0.optionalProperty G2D.HasLineEndStyle
     @L0.singleProperty G2D.HasSize