package org.simantics.district.network.profile; import java.util.Optional; import org.simantics.db.Resource; /** * @author Tuukka Lehtonen */ public class DiagramSettings { public final Optional vertexScalingProperty; public final double vertexScalingScale; public final Optional edgeThicknessProperty; public final double edgeThicknessScale; public DiagramSettings(Resource vertexScalingProperty, double vertexScalingScale, Resource edgeThicknessProperty, double edgeThicknessScale) { this.vertexScalingProperty = Optional.ofNullable(vertexScalingProperty); this.vertexScalingScale = vertexScalingScale; this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty); this.edgeThicknessScale = edgeThicknessScale; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + edgeThicknessProperty.hashCode(); long temp; temp = Double.doubleToLongBits(edgeThicknessScale); result = prime * result + (int) (temp ^ (temp >>> 32)); // result = prime * result + vertexScalingProperty.hashCode(); temp = Double.doubleToLongBits(vertexScalingScale); 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(edgeThicknessScale) != Double.doubleToLongBits(other.edgeThicknessScale)) return false; if (!vertexScalingProperty.equals(other.vertexScalingProperty)) return false; if (Double.doubleToLongBits(vertexScalingScale) != Double.doubleToLongBits(other.vertexScalingScale)) return false; return true; } }