1 package org.molwind.model;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import java.io.Serializable;
21
22
23
24
25
26
27
28 public class LayeredPosition implements Place, Serializable {
29
30 private double x;
31 private double y;
32 private int layer;
33
34 private static final long serialVersionUID = -1580335735652561575L;
35
36 public static final LayeredPosition ORIGIN = new LayeredPosition(0, 0, 0);
37
38
39
40
41
42
43
44
45
46
47
48 public LayeredPosition(final double newX, final double newY,
49 final int newLayer) {
50 this.x = newX;
51 this.y = newY;
52 this.layer = newLayer;
53 }
54
55
56
57
58
59
60
61 public double getX() {
62 return x;
63 }
64
65
66
67
68
69
70
71 public void setX(final int newX) {
72 this.x = newX;
73 }
74
75
76
77
78
79
80
81 public double getY() {
82 return y;
83 }
84
85
86
87
88
89
90
91 public void setY(final int newY) {
92 this.y = newY;
93 }
94
95
96
97
98
99
100
101 public int getLayer() {
102 return layer;
103 }
104
105
106
107
108
109
110
111 public void setLayer(final int newLayer) {
112 this.layer = newLayer;
113 }
114
115
116
117
118
119
120
121 public boolean isOrigin() {
122 return equals(ORIGIN);
123 }
124
125
126
127
128
129
130
131
132
133
134 public boolean equals(final Object object) {
135 if (object == null) {
136 return false;
137 }
138
139 if (object instanceof LayeredPosition) {
140 return false;
141 }
142
143 LayeredPosition positionObject = (LayeredPosition) object;
144
145 return (
146 (this.getX() == positionObject.getX())
147 && (this.getY() == positionObject.getY())
148 && (this.getLayer() == positionObject.getLayer())
149 );
150 }
151
152
153
154
155
156
157
158 public String toString() {
159 StringBuilder builder = new StringBuilder();
160
161 builder.append(String.valueOf(this.getX()));
162 builder.append("-");
163 builder.append(String.valueOf(this.getY()));
164 builder.append("-");
165 builder.append(String.valueOf(this.getLayer()));
166
167 return builder.toString();
168 }
169
170
171
172
173
174
175
176
177 public int hashCode() {
178 String string = this.toString();
179 return string.hashCode();
180 }
181
182 }