1 package org.simantics.district.network.profile;
3 import java.util.Optional;
5 import org.simantics.db.Resource;
6 import org.simantics.scl.runtime.function.Function1;
9 * @author Tuukka Lehtonen
11 public class DiagramSettings {
13 public final Optional<Function1<Resource, Double>> vertexScaleProperty;
14 public final double vertexScaleGain;
15 public final double vertexScaleBias;
16 public final Optional<Function1<Resource, Double>> edgeThicknessProperty;
17 public final double edgeThicknessGain;
18 public final double edgeThicknessBias;
19 public final Optional<Function1<Resource, Double>> elementColoringFunction;
20 public final float elementColoringGradientHue;
21 public final float elementColoringGradientSaturation;
22 public final transient ColorGradient coloringGradient;
24 public DiagramSettings(
25 Function1<Resource, Double> vertexScaleProperty, double vertexScaleGain, double vertexScaleBias,
26 Function1<Resource, Double> edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias,
27 Function1<Resource, Double> elementColoringFunction,
28 float elementColoringGradientHue,
29 float elementColoringGradientSaturation
31 this.vertexScaleProperty = Optional.ofNullable(vertexScaleProperty);
32 this.vertexScaleGain = vertexScaleGain;
33 this.vertexScaleBias = vertexScaleBias;
34 this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty);
35 this.edgeThicknessGain = edgeThicknessGain;
36 this.edgeThicknessBias = edgeThicknessBias;
37 this.elementColoringFunction = Optional.ofNullable(elementColoringFunction);
38 this.elementColoringGradientHue = elementColoringGradientHue;
39 this.elementColoringGradientSaturation = elementColoringGradientSaturation;
40 this.coloringGradient = Colors.cached(
42 elementColoringGradientHue,
43 elementColoringGradientSaturation)
48 public int hashCode() {
51 result = prime * result + edgeThicknessProperty.hashCode();
53 temp = Double.doubleToLongBits(edgeThicknessGain);
54 result = prime * result + (int) (temp ^ (temp >>> 32));
55 temp = Double.doubleToLongBits(edgeThicknessBias);
56 result = prime * result + (int) (temp ^ (temp >>> 32));
57 result = prime * result + vertexScaleProperty.hashCode();
58 temp = Double.doubleToLongBits(vertexScaleGain);
59 result = prime * result + (int) (temp ^ (temp >>> 32));
60 temp = Double.doubleToLongBits(vertexScaleBias);
61 result = prime * result + (int) (temp ^ (temp >>> 32));
62 result = prime * result + elementColoringFunction.hashCode();
63 result = prime * result + Float.floatToIntBits(elementColoringGradientHue);
64 result = prime * result + Float.floatToIntBits(elementColoringGradientSaturation);
69 public boolean equals(Object obj) {
74 if (getClass() != obj.getClass())
76 DiagramSettings other = (DiagramSettings) obj;
77 if (!edgeThicknessProperty.equals(other.edgeThicknessProperty))
79 if (Double.doubleToLongBits(edgeThicknessGain) != Double.doubleToLongBits(other.edgeThicknessGain))
81 if (Double.doubleToLongBits(edgeThicknessBias) != Double.doubleToLongBits(other.edgeThicknessBias))
83 if (!vertexScaleProperty.equals(other.vertexScaleProperty))
85 if (Double.doubleToLongBits(vertexScaleGain) != Double.doubleToLongBits(other.vertexScaleGain))
87 if (Double.doubleToLongBits(vertexScaleBias) != Double.doubleToLongBits(other.vertexScaleBias))
89 if (!elementColoringFunction.equals(other.elementColoringFunction))
91 if (Float.floatToIntBits(elementColoringGradientHue) != Float.floatToIntBits(other.elementColoringGradientHue))
93 if (Float.floatToIntBits(elementColoringGradientSaturation) != Float.floatToIntBits(other.elementColoringGradientSaturation))
99 public String toString() {
100 return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f - coloringFunction: %s, hue: %f, saturation: %f]",
101 vertexScaleProperty.toString(), vertexScaleGain, vertexScaleBias,
102 edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias,
103 elementColoringFunction.toString(),
104 elementColoringGradientHue, elementColoringGradientSaturation