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<Resource> vertexScalingProperty;
- public final double vertexScalingScale;
- public final Optional<Resource> edgeThicknessProperty;
- public final double edgeThicknessScale;
+ public final Optional<Function1<Resource, Double>> arrowLengthProperty;
+ public final double arrowLengthGain;
+ public final double arrowLengthBias;
- 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;
+ public DiagramSettings(
+ Function1<Resource, Double> arrowLengthProperty, double arrowLengthGain, double arrowLengthBias
+ ) {
+ this.arrowLengthProperty = Optional.ofNullable(arrowLengthProperty);
+ this.arrowLengthGain = arrowLengthGain;
+ this.arrowLengthBias = arrowLengthBias;
}
@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 + edgeThicknessProperty.hashCode();
+ result = prime * result + arrowLengthProperty.hashCode();
+ long temp = result;
+ //temp = Double.doubleToLongBits(edgeThicknessGain);
result = prime * result + (int) (temp ^ (temp >>> 32));
-// result = prime * result + vertexScalingProperty.hashCode();
- temp = Double.doubleToLongBits(vertexScalingScale);
+ //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));
+
return result;
}
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))
+
+ if (!arrowLengthProperty.equals(other.arrowLengthProperty))
return false;
- if (!vertexScalingProperty.equals(other.vertexScalingProperty))
+ if (Double.doubleToLongBits(arrowLengthGain) != Double.doubleToLongBits(other.arrowLengthGain))
return false;
- if (Double.doubleToLongBits(vertexScalingScale) != Double.doubleToLongBits(other.vertexScalingScale))
+ if (Double.doubleToLongBits(arrowLengthBias) != Double.doubleToLongBits(other.arrowLengthBias))
return false;
+
return true;
}
-
+ @Override
+ public String toString() {
+ return String.format("DiagramSettings[%s * %f + %f]",
+ arrowLengthProperty, arrowLengthGain, arrowLengthBias
+ );
+ }
+
}