]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java
Some tweaks to the element selection query view
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / profile / DiagramSettings.java
1 package org.simantics.district.network.profile;
2
3 import java.util.Optional;
4
5 import org.simantics.db.Resource;
6 import org.simantics.scl.runtime.function.Function1;
7
8 /**
9  * @author Tuukka Lehtonen
10  */
11 public class DiagramSettings {
12
13         public final Optional<Function1<Resource, Double>> arrowLengthProperty;
14         public final double arrowLengthGain;
15         public final double arrowLengthBias;
16
17         public DiagramSettings(
18                         Function1<Resource, Double> arrowLengthProperty, double arrowLengthGain, double arrowLengthBias
19                         ) {
20                 this.arrowLengthProperty = Optional.ofNullable(arrowLengthProperty);
21                 this.arrowLengthGain = arrowLengthGain;
22                 this.arrowLengthBias = arrowLengthBias;
23         }
24
25         @Override
26         public int hashCode() {
27                 final int prime = 31;
28                 int result = 1;
29                 //result = prime * result + edgeThicknessProperty.hashCode();
30                 result = prime * result + arrowLengthProperty.hashCode();
31                 long temp = result;
32                 //temp = Double.doubleToLongBits(edgeThicknessGain);
33                 result = prime * result + (int) (temp ^ (temp >>> 32));
34                 //temp = Double.doubleToLongBits(edgeThicknessBias);
35                 result = prime * result + (int) (temp ^ (temp >>> 32));
36                 temp = Double.doubleToLongBits(arrowLengthGain);
37                 result = prime * result + (int) (temp ^ (temp >>> 32));
38                 temp = Double.doubleToLongBits(arrowLengthBias);
39                 result = prime * result + (int) (temp ^ (temp >>> 32));
40
41                 return result;
42         }
43
44         @Override
45         public boolean equals(Object obj) {
46                 if (this == obj)
47                         return true;
48                 if (obj == null)
49                         return false;
50                 if (getClass() != obj.getClass())
51                         return false;
52                 DiagramSettings other = (DiagramSettings) obj;
53
54                 if (!arrowLengthProperty.equals(other.arrowLengthProperty))
55                         return false;
56                 if (Double.doubleToLongBits(arrowLengthGain) != Double.doubleToLongBits(other.arrowLengthGain))
57                         return false;
58                 if (Double.doubleToLongBits(arrowLengthBias) != Double.doubleToLongBits(other.arrowLengthBias))
59                         return false;
60
61                 return true;
62         }
63
64         @Override
65         public String toString() {
66                 return String.format("DiagramSettings[%s * %f + %f]",
67                                 arrowLengthProperty, arrowLengthGain, arrowLengthBias
68                                 );
69         }
70
71 }