FileDocCategorySizeDatePackage
Point.javaAPI DocAndroid 1.5 API5732Wed May 06 22:41:54 BST 2009java.awt

Point

public class Point extends Point2D implements Serializable
The Point class represents a point location with coordinates X, Y in current coordinate system.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
The Constant serialVersionUID.
public int
x
The X coordinate of Point.
public int
y
The 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.

param
x the X coordinate of Point.
param
y the Y coordinate of Point.

        setLocation(x, y);
    
public Point(Point p)
Instantiates a new point, giving it the same location as the parameter p.

param
p the Point object giving the coordinates of the new point.

        setLocation(p.x, p.y);
    
Methods Summary
public booleanequals(java.lang.Object obj)
Compares current Point with the specified object.

param
obj the Object to be compared.
return
true, if the Object being compared is a Point whose coordinates are equal to the coordinates of this Point, false otherwise.
see
java.awt.geom.Point2D#equals(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.PointgetLocation()
Gets the location of the Point as a new Point object.

return
a copy of the Point.

        return new Point(x, y);
    
public doublegetX()
Gets X coordinate of Point as a double.

return
X coordinate of the point as a double.
see
java.awt.geom.Point2D#getX()

        return x;
    
public doublegetY()
Gets Y coordinate of Point as a double.

return
Y coordinate of the point as a double.
see
java.awt.geom.Point2D#getY()

        return y;
    
public voidmove(int x, int y)
Moves the Point to the specified (x, y) location.

param
x the X coordinate of the new location.
param
y the Y coordinate of the new location.

        setLocation(x, y);
    
public voidsetLocation(int x, int y)
Sets the location of the Point to the coordinates X, Y.

param
x the X coordinate of the Point's new location.
param
y the Y coordinate of the Point's new location.

        this.x = x;
        this.y = y;
    
public voidsetLocation(double x, double y)
Sets the location of Point to the specified double coordinates.

param
x the X the Point's new location.
param
y the Y the Point's new location.
see
java.awt.geom.Point2D#setLocation(double, double)

        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 voidsetLocation(java.awt.Point p)
Sets the location of the Point to the same coordinates as p.

param
p the Point that gives the new location.

        setLocation(p.x, p.y);
    
public java.lang.StringtoString()
Returns string representation of the current Point object.

return
a string representation of the current Point object.

        return getClass().getName() + "[x=" + x + ",y=" + y + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    
public voidtranslate(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.

param
dx the horizontal delta - the Point is moved to this distance along X axis.
param
dy the vertical delta - the Point is moved to this distance along Y axis.

        x += dx;
        y += dy;