java.awt
Class Point

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.geom.Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D 
      extended by java.awt.Point
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

public class Point
extends Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

A point representing a location in (x, y) coordinate space, specified in integer precision.

Since:
JDK1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
Point2D.Double sample code for java.awt.geom.Point2D.Double definition code for java.awt.geom.Point2D.Double , Point2D.Float sample code for java.awt.geom.Point2D.Float definition code for java.awt.geom.Point2D.Float
 
Field Summary
 int x sample code for java.awt.Point.x definition code for java.awt.Point.x
          The x coordinate.
 int y sample code for java.awt.Point.y definition code for java.awt.Point.y
          The y coordinate.
 
Constructor Summary
Point sample code for java.awt.Point.Point() definition code for java.awt.Point.Point() ()
          Constructs and initializes a point at the origin (0, 0) of the coordinate space.
Point sample code for java.awt.Point.Point(int, int) definition code for java.awt.Point.Point(int, int) (int x, int y)
          Constructs and initializes a point at the specified (xy) location in the coordinate space.
Point sample code for java.awt.Point.Point(java.awt.Point) definition code for java.awt.Point.Point(java.awt.Point) (Point sample code for java.awt.Point definition code for java.awt.Point  p)
          Constructs and initializes a point with the same location as the specified Point object.
 
Method Summary
 boolean equals sample code for java.awt.Point.equals(java.lang.Object) definition code for java.awt.Point.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Determines whether or not two points are equal.
 Point sample code for java.awt.Point definition code for java.awt.Point getLocation sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation() ()
          Returns the location of this point.
 double getX sample code for java.awt.Point.getX() definition code for java.awt.Point.getX() ()
          Returns the X coordinate of the point in double precision.
 double getY sample code for java.awt.Point.getY() definition code for java.awt.Point.getY() ()
          Returns the Y coordinate of the point in double precision.
 void move sample code for java.awt.Point.move(int, int) definition code for java.awt.Point.move(int, int) (int x, int y)
          Moves this point to the specified location in the (xy) coordinate plane.
 void setLocation sample code for java.awt.Point.setLocation(double, double) definition code for java.awt.Point.setLocation(double, double) (double x, double y)
          Sets the location of this point to the specified double coordinates.
 void setLocation sample code for java.awt.Point.setLocation(int, int) definition code for java.awt.Point.setLocation(int, int) (int x, int y)
          Changes the point to have the specified location.
 void setLocation sample code for java.awt.Point.setLocation(java.awt.Point) definition code for java.awt.Point.setLocation(java.awt.Point) (Point sample code for java.awt.Point definition code for java.awt.Point  p)
          Sets the location of the point to the specified location.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.awt.Point.toString() definition code for java.awt.Point.toString() ()
          Returns a string representation of this point and its location in the (xy) coordinate space.
 void translate sample code for java.awt.Point.translate(int, int) definition code for java.awt.Point.translate(int, int) (int dx, int dy)
          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).
 
Methods inherited from class java.awt.geom.Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
clone sample code for java.awt.geom.Point2D.clone() definition code for java.awt.geom.Point2D.clone() , distance sample code for java.awt.geom.Point2D.distance(double, double) definition code for java.awt.geom.Point2D.distance(double, double) , distance sample code for java.awt.geom.Point2D.distance(double, double, double, double) definition code for java.awt.geom.Point2D.distance(double, double, double, double) , distance sample code for java.awt.geom.Point2D.distance(java.awt.geom.Point2D) definition code for java.awt.geom.Point2D.distance(java.awt.geom.Point2D) , distanceSq sample code for java.awt.geom.Point2D.distanceSq(double, double) definition code for java.awt.geom.Point2D.distanceSq(double, double) , distanceSq sample code for java.awt.geom.Point2D.distanceSq(double, double, double, double) definition code for java.awt.geom.Point2D.distanceSq(double, double, double, double) , distanceSq sample code for java.awt.geom.Point2D.distanceSq(java.awt.geom.Point2D) definition code for java.awt.geom.Point2D.distanceSq(java.awt.geom.Point2D) , hashCode sample code for java.awt.geom.Point2D.hashCode() definition code for java.awt.geom.Point2D.hashCode() , setLocation sample code for java.awt.geom.Point2D.setLocation(java.awt.geom.Point2D) definition code for java.awt.geom.Point2D.setLocation(java.awt.geom.Point2D)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

x sample code for java.awt.Point.x

public int x
The x coordinate. If no x coordinate is set it will default to 0.

See Also:
getLocation() sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation() , move(int, int) sample code for java.awt.Point.move(int, int) definition code for java.awt.Point.move(int, int)

y sample code for java.awt.Point.y

public int y
The y coordinate. If no y coordinate is set it will default to 0.

See Also:
getLocation() sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation() , move(int, int) sample code for java.awt.Point.move(int, int) definition code for java.awt.Point.move(int, int)
Constructor Detail

Point sample code for java.awt.Point() definition code for java.awt.Point()

public Point()
Constructs and initializes a point at the origin (0, 0) of the coordinate space.

Since:
JDK1.1

Point sample code for java.awt.Point(java.awt.Point) definition code for java.awt.Point(java.awt.Point)

public Point(Point sample code for java.awt.Point definition code for java.awt.Point  p)
Constructs and initializes a point with the same location as the specified Point object.

Parameters:
p - a point
Since:
JDK1.1

Point sample code for java.awt.Point(int, int) definition code for java.awt.Point(int, int)

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
Method Detail

getX sample code for java.awt.Point.getX() definition code for java.awt.Point.getX()

public double getX()
Returns the X coordinate of the point in double precision.

Specified by:
getX sample code for java.awt.geom.Point2D.getX() definition code for java.awt.geom.Point2D.getX() in class Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
Returns:
the X coordinate of the point in double precision

getY sample code for java.awt.Point.getY() definition code for java.awt.Point.getY()

public double getY()
Returns the Y coordinate of the point in double precision.

Specified by:
getY sample code for java.awt.geom.Point2D.getY() definition code for java.awt.geom.Point2D.getY() in class Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
Returns:
the Y coordinate of the point in double precision

getLocation sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation()

public Point sample code for java.awt.Point definition code for 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:
Component.getLocation() sample code for java.awt.Component.getLocation() definition code for java.awt.Component.getLocation() , setLocation(java.awt.Point) sample code for java.awt.Point.setLocation(java.awt.Point) definition code for java.awt.Point.setLocation(java.awt.Point) , setLocation(int, int) sample code for java.awt.Point.setLocation(int, int) definition code for java.awt.Point.setLocation(int, int)

setLocation sample code for java.awt.Point.setLocation(java.awt.Point) definition code for java.awt.Point.setLocation(java.awt.Point)

public void setLocation(Point sample code for java.awt.Point definition code for java.awt.Point  p)
Sets the location of the point to the specified 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:
Component.setLocation(java.awt.Point) sample code for java.awt.Component.setLocation(java.awt.Point) definition code for java.awt.Component.setLocation(java.awt.Point) , getLocation() sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation()

setLocation sample code for java.awt.Point.setLocation(int, int) definition code for java.awt.Point.setLocation(int, int)

public void setLocation(int x,
                        int y)
Changes the point to have the specified 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:
Component.setLocation(int, int) sample code for java.awt.Component.setLocation(int, int) definition code for java.awt.Component.setLocation(int, int) , getLocation() sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation() , move(int, int) sample code for java.awt.Point.move(int, int) definition code for java.awt.Point.move(int, int)

setLocation sample code for java.awt.Point.setLocation(double, double) definition code for java.awt.Point.setLocation(double, double)

public void setLocation(double x,
                        double y)
Sets the location of this point to the specified double coordinates. The double values will be rounded to integer values. Any number smaller than Integer.MIN_VALUE will be reset to MIN_VALUE, and any number larger than Integer.MAX_VALUE will be reset to MAX_VALUE.

Specified by:
setLocation sample code for java.awt.geom.Point2D.setLocation(double, double) definition code for java.awt.geom.Point2D.setLocation(double, double) in class Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
Parameters:
x - the x coordinate of the new location
y - the y coordinate of the new location
See Also:
getLocation() sample code for java.awt.Point.getLocation() definition code for java.awt.Point.getLocation()

move sample code for java.awt.Point.move(int, int) definition code for java.awt.Point.move(int, int)

public void move(int x,
                 int y)
Moves this point to the specified 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:
Component.setLocation(int, int) sample code for java.awt.Component.setLocation(int, int) definition code for java.awt.Component.setLocation(int, int)

translate sample code for java.awt.Point.translate(int, int) definition code for java.awt.Point.translate(int, int)

public void translate(int dx,
                      int dy)
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

equals sample code for java.awt.Point.equals(java.lang.Object) definition code for java.awt.Point.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Determines whether or not two points are equal. Two instances of Point2D are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.

Overrides:
equals sample code for java.awt.geom.Point2D.equals(java.lang.Object) definition code for java.awt.geom.Point2D.equals(java.lang.Object) in class Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D
Parameters:
obj - an object to be compared with this Point2D
Returns:
true if the object to be compared is an instance of Point2D and has the same values; false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for java.awt.Point.toString() definition code for java.awt.Point.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string representation of this point and its location in the (xy) coordinate space. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this point