| 1 |
package dr.app.gui.chart; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
public class XY implements Comparable<XY> { |
| 9 |
final double x, y; |
| 10 |
|
| 11 |
XY(double x, double y) { |
| 12 |
this.x = x; |
| 13 |
this.y = y; |
| 14 |
} |
| 15 |
|
| 16 |
public boolean equals(Object o){ |
| 17 |
if(this==o)return true; |
| 18 |
if(o==null)return false; |
| 19 |
if(o instanceof XY){ |
| 20 |
XY xy = (XY)o; |
| 21 |
return this.x==xy.x && this.y==xy.y; |
| 22 |
} |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
public int hashCode(){ |
| 27 |
return (int) (x * 31 + y); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
@Override |
| 32 |
public int compareTo(final XY o) { |
| 33 |
int cmp = Double.compare(this.x, o.x); |
| 34 |
if (cmp == 0) cmp = Double.compare(this.y, o.y); |
| 35 |
return cmp; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
} |