All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.Point
java.lang.Object
|
+----java.awt.Point
- public class Point
- extends Object
- implements Serializable
The Point
class represents a location in a two-dimensional (x, y) coordinate space.
- x
- The x coordinate.
- y
- The y coordinate.
- Point()
- Constructs and initializes a point at the origin (0, 0) of the coordinate space.
- Point(int, int)
- Constructs and initializes a point at the specified (x, y) location in the coordinate space.
- Point(Point)
- Constructs and initializes a point with the same location as the specified
Point
object.
- equals(Object)
- Determines whether two points are equal.
- getLocation()
- Returns the location of this point.
- hashCode()
- Returns the hashcode for this point.
- move(int, int)
- Moves this point to the specificed location in the (x, y) coordinate plane.
- setLocation(int, int)
- Changes the point to have the specificed location.
- setLocation(Point)
- Sets the location of the point to the specificed location.
- toString()
- Returns a representation of this point and its location in the (x, y) coordinate space as a string.
- translate(int, int)
- Translates this point, at location (x, y), by
dx
along the x axis and dy
along the y axis so that it now represents the point (x
+
dx
, y
+
dy
).
x
public int x
- The x coordinate.
y
public int y
- The y coordinate.
Point
public Point()
- Constructs and initializes a point at the origin (0, 0) of the coordinate space.
- Parameters:
- x - the x coordinate.
- y - the y coordinate.
Point
public Point(Point p)
- Constructs and initializes a point with the same location as the specified
Point
object. - Parameters:
- p - a point.
Point
public Point(int x,
int y)
- Constructs and initializes a point at the specified (x, y) location in the coordinate space.
- Parameters:
- x - the x coordinate.
- y - the y coordinate.
getLocation
public Point getLocation()
- Returns the location of this point. This method is included for completeness, to parallel the
getLocation
method of Component
. - Returns:
- a copy of this point, at the same location.
- See Also:
- getLocation, setLocation, setLocation
setLocation
public void setLocation(Point p)
- Sets the location of the point to the specificed location. This method is included for completeness, to parallel the
setLocation
method of Component
. - Parameters:
- p - a point, the new location for this point.
- See Also:
- setLocation, getLocation
setLocation
public void setLocation(int x,
int y)
- Changes the point to have the specificed location.
This method is included for completeness, to parallel the setLocation
method of Component
. Its behavior is identical with move(int, int)
.
- Parameters:
- x - the x coordinate of the new location.
- y - the y coordinate of the new location.
- See Also:
- setLocation, getLocation, move
move
public void move(int x,
int y)
- Moves this point to the specificed location in the (x, y) coordinate plane. This method is identical with
setLocation(int, int)
. - Parameters:
- x - the x coordinate of the new location.
- y - the y coordinate of the new location.
- See Also:
- setLocation
translate
public void translate(int x,
int y)
- Translates this point, at location (x, y), by
dx
along the x axis and dy
along the y axis so that it now represents the point (x
+
dx
, y
+
dy
). - Parameters:
- dx - the distance to move this point along the x axis.
- dy - the distance to move this point along the y axis.
hashCode
public int hashCode()
- Returns the hashcode for this point.
- Returns:
- a hash code for this point.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Determines whether two points are equal. Two instances of
Point
are equal if the values of their x
and y
member fields, representing their position in the coordinate space, are the same. - Parameters:
- obj - an object to be compared with this point.
- Returns:
true
if the object to be compared is an instance of Point
and has the same values; false
otherwise. - Overrides:
- equals in class Object
toString
public String toString()
- Returns a representation of this point and its location in the (x, y) coordinate space as a string.
- Returns:
- a string representation of this point, including the values of its member fields.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.