Merge branch 'documentation/JAL-3407_2.11.1_release' into releases/Release_2_11_1_Branch
[jalview.git] / src / jalview / datamodel / Point.java
1 package jalview.datamodel;
2
3 /**
4  * A bean that models an (x, y, z) position in 3-D space
5  */
6 public final class Point
7 {
8   public final float x;
9
10   public final float y;
11
12   public final float z;
13
14   public Point(float xVal, float yVal, float zVal)
15   {
16     x = xVal;
17     y = yVal;
18     z = zVal;
19   }
20
21   /**
22    * toString for convenience of inspection in debugging or logging
23    */
24   @Override
25   public String toString()
26   {
27     return String.format("[%f, %f, %f]", x, y, z);
28   }
29
30   @Override
31   public int hashCode()
32   {
33     final int prime = 31;
34     int result = 1;
35     result = prime * result + Float.floatToIntBits(x);
36     result = prime * result + Float.floatToIntBits(y);
37     result = prime * result + Float.floatToIntBits(z);
38     return result;
39   }
40
41   @Override
42   public boolean equals(Object obj)
43   {
44     if (this == obj)
45     {
46       return true;
47     }
48     if (obj == null)
49     {
50       return false;
51     }
52     if (getClass() != obj.getClass())
53     {
54       return false;
55     }
56     Point other = (Point) obj;
57     if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
58     {
59       return false;
60     }
61     if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
62     {
63       return false;
64     }
65     if (Float.floatToIntBits(z) != Float.floatToIntBits(other.z))
66     {
67       return false;
68     }
69     return true;
70   }
71 }