Pointpublic class Point extends Point2D implements SerializableThe Point class represents a point location with coordinates X, Y in current
coordinate system. |
Fields Summary |
---|
private static final long | serialVersionUIDThe Constant serialVersionUID. | public int | xThe X coordinate of Point. | public int | yThe Y coordinate of Point. |
Constructors Summary |
---|
public Point()Instantiates a new point with (0, O) coordinates, the origin of
coordinate system.
setLocation(0, 0);
| public Point(int x, int y)Instantiates a new point with (x, y) coordinates.
setLocation(x, y);
| public Point(Point p)Instantiates a new point, giving it the same location as the parameter p.
setLocation(p.x, p.y);
|
Methods Summary |
---|
public boolean | equals(java.lang.Object obj)Compares current Point with the specified object.
if (obj == this) {
return true;
}
if (obj instanceof Point) {
Point p = (Point)obj;
return x == p.x && y == p.y;
}
return false;
| public java.awt.Point | getLocation()Gets the location of the Point as a new Point object.
return new Point(x, y);
| public double | getX()Gets X coordinate of Point as a double.
return x;
| public double | getY()Gets Y coordinate of Point as a double.
return y;
| public void | move(int x, int y)Moves the Point to the specified (x, y) location.
setLocation(x, y);
| public void | setLocation(int x, int y)Sets the location of the Point to the coordinates X, Y.
this.x = x;
this.y = y;
| public void | setLocation(double x, double y)Sets the location of Point to the specified double coordinates.
x = x < Integer.MIN_VALUE ? Integer.MIN_VALUE : x > Integer.MAX_VALUE ? Integer.MAX_VALUE
: x;
y = y < Integer.MIN_VALUE ? Integer.MIN_VALUE : y > Integer.MAX_VALUE ? Integer.MAX_VALUE
: y;
setLocation((int)Math.round(x), (int)Math.round(y));
| public void | setLocation(java.awt.Point p)Sets the location of the Point to the same coordinates as p.
setLocation(p.x, p.y);
| public java.lang.String | toString()Returns string representation of the current Point object.
return getClass().getName() + "[x=" + x + ",y=" + y + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
| public void | translate(int dx, int dy)Translates current Point moving it from the position (x, y) to the new
position given by (x+dx, x+dy) coordinates.
x += dx;
y += dy;
|
|