]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java
Arrow length indicators for flow magnitude
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / profile / DiagramSettingsRequest.java
index a17464d8aefe655ea4e83b9eea54832a513cc9f6..2254b305706c6fb0d997fcbe9c65fba6384b4bfe 100644 (file)
@@ -30,9 +30,12 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                float elementColoringGradientHue = 0;
                float elementColoringGradientSaturation = 1;
                Function1<Resource, Double> edgeThicknessProperty = null;
+               Function1<Resource, Double> arrowLengthProperty = null;
                Function1<Resource, Double> nodeScaleProperty = null;
                double edgeThicknessGain = 1;
                double edgeThicknessBias = 0;
+               double arrowLengthGain = 1;
+               double arrowLengthBias = 0;
                double nodeScaleGain = 1;
                double nodeScaleBias = 0;
 
@@ -68,6 +71,22 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                                                safeDoubleProperty(graph, etp, DN.Edge_ThicknessProperty_bias, 0)
                                                + safeDoubleProperty(graph, diagram, DN.Diagram_edgeThicknessBias, 0);
                        }
+                       Resource alp = graph.getPossibleObject(diagram, DN.Diagram_arrowLengthProperty);
+                       //System.out.println("alp: " + NameUtils.getURIOrSafeNameInternal(graph, alp));
+                       if (alp != null) {
+                               Variable alpv = Variables.getPossibleVariable(graph, alp);
+                               if (alpv != null) {
+                                       //System.out.println("alpv: " + alpv.getURI(graph));
+                                       arrowLengthProperty = alpv.getPropertyValue(graph, DN.Edge_ArrowLengthProperty_value);
+                               }
+
+                               arrowLengthGain =
+                                               safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_gain, 1)
+                                               * safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthGain, 1);
+                               arrowLengthBias =
+                                               safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_bias, 0)
+                                               + safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthBias, 0);
+                       }
                        Resource nsp = graph.getPossibleObject(diagram, DN.Diagram_nodeScaleProperty);
                        if (nsp != null) {
                                Variable nspv = Variables.getPossibleVariable(graph, nsp);
@@ -88,6 +107,7 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                DiagramSettings ds = new DiagramSettings(
                                nodeScaleProperty, nodeScaleGain, nodeScaleBias,
                                edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias,
+                               arrowLengthProperty, arrowLengthGain, arrowLengthBias,
                                elementColoringFunction,
                                elementColoringGradientHue,
                                elementColoringGradientSaturation);