java.awt
Class Point

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by java.awt.Point
All Implemented Interfaces:
Cloneable

public class Point
extends Point2D

Represents a point in two dimensional space using integer co-ordinates

Author:
Lawrie Griffiths

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
 
Field Summary
 int x
          The x coordinate of the point
 int y
          The y coordinate of the point
 
Constructor Summary
Point()
          Create a point at (0,0)
Point(int x, int y)
          Create a point at (x,y)
Point(Point p)
          Create a point from a given point
 
Method Summary
 boolean equals(Object obj)
          Test if this point is equal to a given object
 Point getLocation()
          Get the location of the point
 double getX()
          Get the x coordinate as a double
 double getY()
          Get the y coordinate as a double
 void move(int x, int y)
          Move the location of the point to (x,y)
 void setLocation(double x, double y)
          Set the location of this Point2D using double coordinates
 void setLocation(int x, int y)
          Set the location of the point using integer coordinates
 void setLocation(Point p)
          Set the location of the point to a given point
 String toString()
          Represent the point as a String
 void translate(int dx, int dy)
          Move the point by the vector (dx, dy)
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x
The x coordinate of the point


y

public int y
The y coordinate of the point

Constructor Detail

Point

public Point()
Create a point at (0,0)


Point

public Point(int x,
             int y)
Create a point at (x,y)

Parameters:
x - the x coordinate
y - the y coordinate

Point

public Point(Point p)
Create a point from a given point

Parameters:
p - the given point
Method Detail

getX

public double getX()
Description copied from class: Point2D
Get the x coordinate as a double

Specified by:
getX in class Point2D
Returns:
the x co-ordinate (as a double)

getY

public double getY()
Description copied from class: Point2D
Get the y coordinate as a double

Specified by:
getY in class Point2D
Returns:
the y coordinate (as a double)

setLocation

public void setLocation(double x,
                        double y)
Description copied from class: Point2D
Set the location of this Point2D using double coordinates

Specified by:
setLocation in class Point2D
Parameters:
x - the new x coordinate
y - the new y coordinate

setLocation

public void setLocation(int x,
                        int y)
Set the location of the point using integer coordinates

Parameters:
x - the x coordinate
y - the y coordinate

setLocation

public void setLocation(Point p)
Set the location of the point to a given point

Parameters:
p - the given point

move

public void move(int x,
                 int y)
Move the location of the point to (x,y)

Parameters:
x - the new x coordinate
y - the new y coordinate

translate

public void translate(int dx,
                      int dy)
Move the point by the vector (dx, dy)

Parameters:
dx - the increment of the x coordinate
dy - the increment of the y coordinate

getLocation

public Point getLocation()
Get the location of the point

Returns:
the location (i.e. the point itself)

toString

public String toString()
Represent the point as a String

Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Description copied from class: Point2D
Test if this point is equal to a given object

Overrides:
equals in class Point2D