Class java.awt.Point
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.Point
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.
- Version:
- 1.14, 07/01/98
- Author:
- Sami Shaio
- Since:
- JDK1.0
-
x
- The x coordinate.
-
y
- The y coordinate.
-
java.awt.Point()
- Constructs and initializes a point at the origin
(0, 0) of the coordinate space.
-
java.awt.Point(Point)
- Constructs and initializes a point with the same location as
the specified
Point
object.
-
java.awt.Point(int, int)
- Constructs and initializes a point at the specified
(x, y) location in the coordinate space.
-
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(Point)
- Sets the location of the point to the specificed location.
-
setLocation(int, int)
- Changes the point to have 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.
- Since:
JDK1.0
y
public int y
- The y coordinate.
- Since:
JDK1.0
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.
- Since:
- JDK1.1
Point
public Point(Point p)
- Constructs and initializes a point with the same location as
the specified
Point
object.
- Parameters:
- p - a point.
- Since:
- JDK1.1
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.
- Since:
- JDK1.0
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
- Since:
- JDK1.0
getLocation
public java.awt.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.
- Since:
- JDK1.1
- See Also:
- getLocation, setLocation(java.awt.Point), setLocation(int, int)
hashCode
public int hashCode()
- Returns the hashcode for this point.
- Returns:
- a hash code for this point.
- Overrides:
- hashCode in class Object
- Since:
- JDK1.0
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.
- Since:
- JDK1.0
- See Also:
- setLocation(int, int)
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.
- Since:
- JDK1.1
- See Also:
- setLocation(java.awt.Point), 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.
- Since:
- JDK1.1
- See Also:
- setLocation(int, int), getLocation, move(int, int)
toString
public java.lang.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
- Since:
- JDK1.0
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.
- Since:
- JDK1.0
All Packages Class Hierarchy This Package Previous Next Index