objectdraw
Class Location

java.lang.Object
  |
  +--objectdraw.Location
All Implemented Interfaces:
java.io.Serializable

public class Location
extends java.lang.Object
implements java.io.Serializable

Location is an implementation of a point on the real plane.

See Also:
Serialized Form

Constructor Summary
Location(double x, double y)
          Constructs a new Location object.
Location(Location point)
          Constructs a new Location object at the location of the given Location.
Location(java.awt.Point point)
          Constructs a new Location object based on a Point object.
 
Method Summary
 double distanceTo(Location point)
          Determines the distance to the given point.
 double getX()
          Retrieves the point's x value.
 double getY()
          Retrieves the point's y value.
 java.awt.Point toPoint()
          Retrieves the nearest point on the integer lattice.
 java.lang.String toString()
          Generates a string representation of the object.
 void translate(double dx, double dy)
          Translates the point by the given increments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location(double x,
                double y)
Constructs a new Location object.
Parameters:
x - the point's x value
y - the point's y value

Location

public Location(Location point)
Constructs a new Location object at the location of the given Location.
Parameters:
point - the point to copy

Location

public Location(java.awt.Point point)
Constructs a new Location object based on a Point object.
Parameters:
point - the point to copy
Method Detail

getX

public double getX()
Retrieves the point's x value.
Returns:
x value of point

getY

public double getY()
Retrieves the point's y value.
Returns:
y value of point

distanceTo

public double distanceTo(Location point)
Determines the distance to the given point.
Returns:
distance to the given point

toPoint

public java.awt.Point toPoint()
Retrieves the nearest point on the integer lattice.
Returns:
nearest point on the integer lattice

translate

public void translate(double dx,
                      double dy)
Translates the point by the given increments.
Parameters:
dx - amount to move in x-direction
dy - amount to move in y-direction

toString

public java.lang.String toString()
Generates a string representation of the object.
Overrides:
toString in class java.lang.Object
Returns:
string representation of object