Package ball.util
Class Coordinate
- java.lang.Object
-
- ball.util.Coordinate
-
- All Implemented Interfaces:
Serializable
,Comparable<Coordinate>
public class Coordinate extends Object implements Comparable<Coordinate>, Serializable
X-Y coordinate representation.- Author:
- Allen D. Ball
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Coordinate(Number y, Number x)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Point2D
asPoint()
Method to translate thisCoordinate
to aPoint2D
.int
compareTo(Coordinate that)
boolean
equals(Object object)
int
getX()
int
getY()
int
hashCode()
static SortedSet<Coordinate>
range(int y0, int x0, int yN, int xN)
Static method to return aSortedSet
ofCoordinate
s specified by the parameters.static SortedSet<Coordinate>
range(Coordinate min, Coordinate max)
Static method to return aSortedSet
ofCoordinate
s specified by the parameters.String
toString()
Coordinate
translate(Coordinate ds)
Coordinate
translate(Number dy, Number dx)
boolean
within(Coordinate min, Coordinate max)
-
-
-
Constructor Detail
-
Coordinate
@ConstructorProperties({"y","x"}) public Coordinate(Number y, Number x)
- Parameters:
y
- The Y-coordinate.x
- The X-coordinate.
-
-
Method Detail
-
getY
public int getY()
-
getX
public int getX()
-
translate
public Coordinate translate(Number dy, Number dx)
- Parameters:
dy
- The change in Y-coordinate.dx
- The change in X-coordinate.- Returns:
- The relative
Coordinate
.
-
translate
public Coordinate translate(Coordinate ds)
- Parameters:
ds
- TheCoordinate
describing the change.- Returns:
- The relative
Coordinate
.
-
within
public boolean within(Coordinate min, Coordinate max)
- Parameters:
min
- The minimumCoordinate
.max
- The maximumCoordinate
.- Returns:
true
if within the area;false
otherwise.
-
asPoint
public Point2D asPoint()
Method to translate thisCoordinate
to aPoint2D
.- Returns:
- The
Point
.
-
compareTo
public int compareTo(Coordinate that)
- Specified by:
compareTo
in interfaceComparable<Coordinate>
-
range
public static SortedSet<Coordinate> range(Coordinate min, Coordinate max)
Static method to return aSortedSet
ofCoordinate
s specified by the parameters.- Parameters:
min
-[y0, x0]
max
-[yN, xN]
- Returns:
- The
SortedSet
ofCoordinate
s.
-
range
public static SortedSet<Coordinate> range(int y0, int x0, int yN, int xN)
Static method to return aSortedSet
ofCoordinate
s specified by the parameters.- Parameters:
y0
-MIN(y)
x0
-MIN(x)
yN
-MAX(y) + 1
xN
-MAX(x) + 1
- Returns:
- The
SortedSet
ofCoordinate
s.
-
-