package org.simantics.district.network.profile; import java.util.Optional; import org.simantics.db.Resource; import org.simantics.scl.runtime.function.Function1; /** * @author Tuukka Lehtonen */ public class DiagramSettings { public final Optional> vertexScaleProperty; public final double vertexScaleGain; public final double vertexScaleBias; public final Optional> edgeThicknessProperty; public final double edgeThicknessGain; public final double edgeThicknessBias; public DiagramSettings(Function1 vertexScaleProperty, double vertexScaleGain, double vertexScaleBias, Function1 edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias) { this.vertexScaleProperty = Optional.ofNullable(vertexScaleProperty); this.vertexScaleGain = vertexScaleGain; this.vertexScaleBias = vertexScaleBias; this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty); this.edgeThicknessGain = edgeThicknessGain; this.edgeThicknessBias = edgeThicknessBias; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + edgeThicknessProperty.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)); result = prime * result + vertexScaleProperty.hashCode(); temp = Double.doubleToLongBits(vertexScaleGain); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(vertexScaleBias); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DiagramSettings other = (DiagramSettings) obj; if (!edgeThicknessProperty.equals(other.edgeThicknessProperty)) return false; if (Double.doubleToLongBits(edgeThicknessGain) != Double.doubleToLongBits(other.edgeThicknessGain)) return false; if (Double.doubleToLongBits(edgeThicknessBias) != Double.doubleToLongBits(other.edgeThicknessBias)) return false; if (!vertexScaleProperty.equals(other.vertexScaleProperty)) return false; if (Double.doubleToLongBits(vertexScaleGain) != Double.doubleToLongBits(other.vertexScaleGain)) return false; if (Double.doubleToLongBits(vertexScaleBias) != Double.doubleToLongBits(other.vertexScaleBias)) 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); } }