Class java.awt.Point
java.lang.Object
|
+----java.awt.geom.Point2D
|
+----java.awt.Point
- public class Point
- extends Point2D
- implements Serializable
A point representing a location in (x, y) coordinate space, specified
in integer precision.
- Since:
- JDK1.0
Field Summary
|
int
|
x
The x coordinate.
|
int
|
y
The y coordinate.
|
Constructor Summary
|
Point()
Constructs and initializes a point at the origin
(0, 0) of the coordinate space.
|
Point(Point p)
Constructs and initializes a point with the same location as
the specified Point object.
|
Point(int x,
int y)
Constructs and initializes a point at the specified
(x, y) location in the coordinate space.
|
Method Summary
|
boolean
|
equals(Object obj)
Determines whether two points are equal.
|
Point
|
getLocation()
Returns the location of this point.
|
double
|
getX()
Returns the X coordinate of the point in double precision.
|
double
|
getY()
Returns the Y coordinate of the point in double precision.
|
int
|
hashCode()
Returns the hashcode for this point.
|
void
|
move(int x,
int y)
Moves this point to the specificed location in the
(x, y) coordinate plane.
|
void
|
setLocation(Point p)
Sets the location of the point to the specificed location.
|
void
|
setLocation(int x,
int y)
Changes the point to have the specificed location.
|
void
|
setLocation(double x,
double y)
Sets the location of this point to the specified float coordinates.
|
String
|
toString()
Returns a representation of this point and its location
in the (x, y) coordinate space as a string.
|
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 ).
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
getX
public double getX()
- Returns the X coordinate of the point in double precision.
- Overrides:
- getX in class Point2D
getY
public double getY()
- Returns the Y coordinate of the point in double precision.
- Overrides:
- getY in class Point2D
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(java.awt.Point), 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.
- 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.
- See Also:
- setLocation(int, int), getLocation, move(int, int)
setLocation
public void setLocation(double x,
double y)
- Sets the location of this point to the specified float coordinates.
- Overrides:
- setLocation in class Point2D
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(int, int)
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 Point2D
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
Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.