Method from java.awt.Point Detail: |
public boolean equals(Object obj) {
if (obj instanceof Point) {
Point pt = (Point)obj;
return (x == pt.x) && (y == pt.y);
}
return super.equals(obj);
}
Determines whether or not two points are equal. Two instances of
Point2D are equal if the values of their
x and y member fields, representing
their position in the coordinate space, are the same. |
public Point getLocation() {
return new Point(x, y);
}
Returns the location of this point.
This method is included for completeness, to parallel the
getLocation method of Component . |
public double getX() {
return x;
}
|
public double getY() {
return y;
}
|
public void move(int x,
int y) {
this.x = x;
this.y = y;
}
Moves this point to the specified location in the
{@code (x,y)} coordinate plane. This method
is identical with setLocation(int, int) . |
public void setLocation(Point p) {
setLocation(p.x, p.y);
}
Sets the location of the point to the specified location.
This method is included for completeness, to parallel the
setLocation method of Component . |
public void setLocation(int x,
int y) {
move(x, y);
}
Changes the point to have the specified location.
This method is included for completeness, to parallel the
setLocation method of Component .
Its behavior is identical with move(int, int) . |
public void setLocation(double x,
double y) {
this.x = (int) Math.floor(x+0.5);
this.y = (int) Math.floor(y+0.5);
}
Sets the location of this point to the specified double coordinates.
The double values will be rounded to integer values.
Any number smaller than Integer.MIN_VALUE
will be reset to MIN_VALUE , and any number
larger than Integer.MAX_VALUE will be
reset to MAX_VALUE . |
public String toString() {
return getClass().getName() + "[x=" + x + ",y=" + y + "]";
}
Returns a string representation of this point and its location
in the {@code (x,y)} coordinate space. This method is
intended to be used only for debugging purposes, and the content
and format of the returned string may vary between implementations.
The returned string may be empty but may not be null . |
public void translate(int dx,
int dy) {
this.x += dx;
this.y += dy;
}
Translates this point, at location {@code (x,y)},
by {@code dx} along the {@code x} axis and {@code dy}
along the {@code y} axis so that it now represents the point
{@code (x+dx,y+dy)}. |