public class Point extends Point2D implements Serializable
There are some public fields; if you mess with them in an inconsistent manner, it is your own fault when you get invalid results. Also, this class is not threadsafe.
Point2D.Double, Point2D.Float| Modifier and Type | Field and Description |
|---|---|
int |
x
The x coordinate.
|
int |
y
The y coordinate.
|
| Constructor and Description |
|---|
Point()
Initializes a new instance of
Point representing the
coordinates (0, 0). |
Point(int x,
int y)
Initializes a new instance of
Point with the specified
coordinates. |
Point(Point p)
Initializes a new instance of
Point with coordinates
identical to the coordinates of the specified point. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Tests whether or not this object is equal to the specified object.
|
Point |
getLocation()
Returns the location of this point.
|
double |
getX()
Get the x coordinate.
|
double |
getY()
Get the y coordinate.
|
void |
move(int x,
int y)
Sets this object's coordinates to the specified values.
|
void |
setLocation(double x,
double y)
Sets this object's coordinates to the specified values.
|
void |
setLocation(int x,
int y)
Sets this object's coordinates to the specified values.
|
void |
setLocation(Point p)
Sets this object's coordinates to match those of the specified point.
|
String |
toString()
Returns a string representation of this object.
|
void |
translate(int dx,
int dy)
Changes the coordinates of this point such that the specified
dx parameter is added to the existing X coordinate and
dy is added to the existing Y coordinate. |
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocationpublic int x
getLocation(),
move(int, int)public int y
getLocation(),
move(int, int)public Point()
Point representing the
coordinates (0, 0).public Point(Point p)
Point with coordinates
identical to the coordinates of the specified point.p - the point to copy the coordinates fromNullPointerException - if p is nullpublic Point(int x, int y)
Point with the specified
coordinates.x - the X coordinatey - the Y coordinatepublic double getX()
public double getY()
public Point getLocation()
setLocation(Point)public void setLocation(Point p)
p - the point to copy the coordinates fromNullPointerException - if p is nullpublic void setLocation(int x, int y)
move() method.x - the new X coordinatey - the new Y coordinatepublic void setLocation(double x, double y)
Math.floor(double).setLocation in class Point2Dx - the new X coordinatey - the new Y coordinatepublic void move(int x, int y)
setLocation(int, int) method.x - the new X coordinatey - the new Y coordinatepublic void translate(int dx, int dy)
dx parameter is added to the existing X coordinate and
dy is added to the existing Y coordinate.dx - the amount to add to the X coordinatedy - the amount to add to the Y coordinatepublic boolean equals(Object obj)
equals in class Point2Dobj - the object to test against for equalityObject.hashCode()public String toString()
getClass().getName() + "[x=" + x + ",y=" + y + ']'.toString in class ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)