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 Point2DasPoint()Method to translate thisCoordinateto aPoint2D.intcompareTo(Coordinate that)booleanequals(Object object)intgetX()intgetY()inthashCode()static SortedSet<Coordinate>range(int y0, int x0, int yN, int xN)Static method to return aSortedSetofCoordinates specified by the parameters.static SortedSet<Coordinate>range(Coordinate min, Coordinate max)Static method to return aSortedSetofCoordinates specified by the parameters.StringtoString()Coordinatetranslate(Coordinate ds)Coordinatetranslate(Number dy, Number dx)booleanwithin(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- TheCoordinatedescribing the change.- Returns:
- The relative
Coordinate.
-
within
public boolean within(Coordinate min, Coordinate max)
- Parameters:
min- The minimumCoordinate.max- The maximumCoordinate.- Returns:
trueif within the area;falseotherwise.
-
asPoint
public Point2D asPoint()
Method to translate thisCoordinateto aPoint2D.- Returns:
- The
Point.
-
compareTo
public int compareTo(Coordinate that)
- Specified by:
compareToin interfaceComparable<Coordinate>
-
range
public static SortedSet<Coordinate> range(Coordinate min, Coordinate max)
Static method to return aSortedSetofCoordinates specified by the parameters.- Parameters:
min-[y0, x0]max-[yN, xN]- Returns:
- The
SortedSetofCoordinates.
-
range
public static SortedSet<Coordinate> range(int y0, int x0, int yN, int xN)
Static method to return aSortedSetofCoordinates specified by the parameters.- Parameters:
y0-MIN(y)x0-MIN(x)yN-MAX(y) + 1xN-MAX(x) + 1- Returns:
- The
SortedSetofCoordinates.
-
-