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 (xy) coordinate space.

Version:
1.14, 07/01/98
Author:
Sami Shaio
Since:
JDK1.0

Variable Index

 o x
The x coordinate.
 o y
The y coordinate.

Constructor Index

 o java.awt.Point()
Constructs and initializes a point at the origin (0, 0) of the coordinate space.
 o java.awt.Point(Point)
Constructs and initializes a point with the same location as the specified Point object.
 o java.awt.Point(int, int)
Constructs and initializes a point at the specified (xy) location in the coordinate space.

Method Index

 o equals(Object)
Determines whether two points are equal.
 o getLocation()
Returns the location of this point.
 o hashCode()
Returns the hashcode for this point.
 o move(int, int)
Moves this point to the specificed location in the (xy) coordinate plane.
 o setLocation(Point)
Sets the location of the point to the specificed location.
 o setLocation(int, int)
Changes the point to have the specificed location.
 o toString()
Returns a representation of this point and its location in the (xy) coordinate space as a string.
 o translate(int, int)
Translates this point, at location (xy), by dx along the x axis and dy along the y axis so that it now represents the point (x + dx, y + dy).

Variables

 o x
public int x
The x coordinate.

Since: JDK1.0
 o y
public int y
The y coordinate.

Since: JDK1.0

Constructors

 o 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
 o 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
 o Point
public Point(int x,
             int y)
Constructs and initializes a point at the specified (xy) location in the coordinate space.

Parameters:
x - the x coordinate.
y - the y coordinate.
Since:
JDK1.0

Methods

 o 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
 o 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)
 o 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
 o move
public void move(int x,
                 int y)
Moves this point to the specificed location in the (xy) 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)
 o 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
 o 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)
 o toString
public java.lang.String toString()
Returns a representation of this point and its location in the (xy) 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
 o translate
public void translate(int x,
                      int y)
Translates this point, at location (xy), 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