X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fprofile%2FDiagramSettings.java;h=13c38bed02d494c1fed8e2ee359a10422e6c6a5b;hb=refs%2Fchanges%2F41%2F2341%2F1;hp=071489de1b0a8cf2f9b2cad1d16f86b0b791b412;hpb=15c720d419c1139942790dc12acb6936e75b1568;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java index 071489de..13c38bed 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java @@ -16,14 +16,32 @@ public class DiagramSettings { public final Optional> edgeThicknessProperty; public final double edgeThicknessGain; public final double edgeThicknessBias; + public final Optional> elementColoringFunction; + public final float elementColoringGradientHue; + public final float elementColoringGradientSaturation; + public final transient ColorGradient coloringGradient; - public DiagramSettings(Function1 vertexScaleProperty, double vertexScaleGain, double vertexScaleBias, Function1 edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias) { + public DiagramSettings( + Function1 vertexScaleProperty, double vertexScaleGain, double vertexScaleBias, + Function1 edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias, + Function1 elementColoringFunction, + float elementColoringGradientHue, + float elementColoringGradientSaturation + ) { this.vertexScaleProperty = Optional.ofNullable(vertexScaleProperty); this.vertexScaleGain = vertexScaleGain; this.vertexScaleBias = vertexScaleBias; this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty); this.edgeThicknessGain = edgeThicknessGain; this.edgeThicknessBias = edgeThicknessBias; + this.elementColoringFunction = Optional.ofNullable(elementColoringFunction); + this.elementColoringGradientHue = elementColoringGradientHue; + this.elementColoringGradientSaturation = elementColoringGradientSaturation; + this.coloringGradient = Colors.cached( + Colors.hsvGradient( + elementColoringGradientHue, + elementColoringGradientSaturation) + ); } @Override @@ -41,6 +59,9 @@ public class DiagramSettings { result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(vertexScaleBias); result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + elementColoringFunction.hashCode(); + result = prime * result + Float.floatToIntBits(elementColoringGradientHue); + result = prime * result + Float.floatToIntBits(elementColoringGradientSaturation); return result; } @@ -65,13 +86,23 @@ public class DiagramSettings { return false; if (Double.doubleToLongBits(vertexScaleBias) != Double.doubleToLongBits(other.vertexScaleBias)) return false; + if (!elementColoringFunction.equals(other.elementColoringFunction)) + return false; + if (Float.floatToIntBits(elementColoringGradientHue) != Float.floatToIntBits(other.elementColoringGradientHue)) + return false; + if (Float.floatToIntBits(elementColoringGradientSaturation) != Float.floatToIntBits(other.elementColoringGradientSaturation)) + return false; return true; } @Override public String toString() { - return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f]", vertexScaleProperty.toString(), - vertexScaleGain, vertexScaleBias, edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias); + return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f - coloringFunction: %s, hue: %f, saturation: %f]", + vertexScaleProperty.toString(), vertexScaleGain, vertexScaleBias, + edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias, + elementColoringFunction.toString(), + elementColoringGradientHue, elementColoringGradientSaturation + ); } }