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


Variable Index

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

Constructor Index

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

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(int, int)
Changes the point to have the specificed location.
 o setLocation(Point)
Sets the location of the point to 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.

 o y
 public int y
The y coordinate.

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.
 o Point
 public Point(Point p)
Constructs and initializes a point with the same location as the specified Point object.

Parameters:
p - a point.
 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.

Methods

 o 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
 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.
See Also:
setLocation, 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.
See Also:
setLocation, getLocation, move
 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.
See Also:
setLocation
 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.
 o hashCode
 public int hashCode()
Returns the hashcode for this point.

Returns:
a hash code for this point.
Overrides:
hashCode in class Object
 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
 o toString
 public 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

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature