]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java
Arrow length indicators for flow magnitude
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / profile / DiagramSettings.java
index 13c38bed02d494c1fed8e2ee359a10422e6c6a5b..a0dcd40f9e7a8b022f038e4e1cbb984c07d34521 100644 (file)
@@ -16,6 +16,9 @@ public class DiagramSettings {
        public final Optional<Function1<Resource, Double>> edgeThicknessProperty;
        public final double edgeThicknessGain;
        public final double edgeThicknessBias;
+       public final Optional<Function1<Resource, Double>> arrowLengthProperty;
+       public final double arrowLengthGain;
+       public final double arrowLengthBias;
        public final Optional<Function1<Resource, Double>> elementColoringFunction;
        public final float elementColoringGradientHue;
        public final float elementColoringGradientSaturation;
@@ -24,6 +27,7 @@ public class DiagramSettings {
        public DiagramSettings(
                        Function1<Resource, Double> vertexScaleProperty, double vertexScaleGain, double vertexScaleBias,
                        Function1<Resource, Double> edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias,
+                       Function1<Resource, Double> arrowLengthProperty, double arrowLengthGain, double arrowLengthBias,
                        Function1<Resource, Double> elementColoringFunction,
                        float elementColoringGradientHue,
                        float elementColoringGradientSaturation
@@ -34,6 +38,9 @@ public class DiagramSettings {
                this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty);
                this.edgeThicknessGain = edgeThicknessGain;
                this.edgeThicknessBias = edgeThicknessBias;
+               this.arrowLengthProperty = Optional.ofNullable(arrowLengthProperty);
+               this.arrowLengthGain = arrowLengthGain;
+               this.arrowLengthBias = arrowLengthBias;
                this.elementColoringFunction = Optional.ofNullable(elementColoringFunction);
                this.elementColoringGradientHue = elementColoringGradientHue;
                this.elementColoringGradientSaturation = elementColoringGradientSaturation;
@@ -49,11 +56,16 @@ public class DiagramSettings {
                final int prime = 31;
                int result = 1;
                result = prime * result + edgeThicknessProperty.hashCode();
+               result = prime * result + arrowLengthProperty.hashCode();
                long temp;
                temp = Double.doubleToLongBits(edgeThicknessGain);
                result = prime * result + (int) (temp ^ (temp >>> 32));
                temp = Double.doubleToLongBits(edgeThicknessBias);
                result = prime * result + (int) (temp ^ (temp >>> 32));
+               temp = Double.doubleToLongBits(arrowLengthGain);
+               result = prime * result + (int) (temp ^ (temp >>> 32));
+               temp = Double.doubleToLongBits(arrowLengthBias);
+               result = prime * result + (int) (temp ^ (temp >>> 32));
                result = prime * result + vertexScaleProperty.hashCode();
                temp = Double.doubleToLongBits(vertexScaleGain);
                result = prime * result + (int) (temp ^ (temp >>> 32));
@@ -80,6 +92,12 @@ public class DiagramSettings {
                        return false;
                if (Double.doubleToLongBits(edgeThicknessBias) != Double.doubleToLongBits(other.edgeThicknessBias))
                        return false;
+               if (!arrowLengthProperty.equals(other.arrowLengthProperty))
+                       return false;
+               if (Double.doubleToLongBits(arrowLengthGain) != Double.doubleToLongBits(other.arrowLengthGain))
+                       return false;
+               if (Double.doubleToLongBits(arrowLengthBias) != Double.doubleToLongBits(other.arrowLengthBias))
+                       return false;
                if (!vertexScaleProperty.equals(other.vertexScaleProperty))
                        return false;
                if (Double.doubleToLongBits(vertexScaleGain) != Double.doubleToLongBits(other.vertexScaleGain))
@@ -97,9 +115,10 @@ public class DiagramSettings {
 
        @Override
        public String toString() {
-               return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f - coloringFunction: %s, hue: %f, saturation: %f]",
+               return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f - %s * %f + %f - coloringFunction: %s, hue: %f, saturation: %f]",
                                vertexScaleProperty.toString(), vertexScaleGain, vertexScaleBias,
                                edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias,
+                               arrowLengthProperty, arrowLengthGain, arrowLengthBias,
                                elementColoringFunction.toString(),
                                elementColoringGradientHue, elementColoringGradientSaturation
                                );