objectdraw
Class Location

java.lang.Object
  extended by objectdraw.Location
All Implemented Interfaces:
Serializable

public class Location
extends Object
implements Serializable

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

Version:
1.1.1 released February 2005
See Also:
Serialized Form

Constructor Summary
Location(double x, double y)
          Constructs a new Location object.
Location(Location point)
          Constructs a copy of a Location object.
Location(Point point)
          Constructs a new Location object based on a Point object.
 
Method Summary
 double distanceTo(Location point)
          Determines the distance to the given Location.
 boolean equals(Object obj)
          Compares Location to another object
 double getX()
          Retrieves the Location's x coordinate.
 double getY()
          Retrieves the Location's y coordinate.
 int hashCode()
          Generates a hashCode for a Location
 Point toPoint()
          Retrieves the nearest point with integer coordinates as a Point.
 String toString()
          Generates a string representation of the Location.
 void translate(double dx, double dy)
          Translates the Location by the given increments.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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 copy of a Location object.

Parameters:
point - the Location to copy

Location

public Location(Point point)
Constructs a new Location object based on a Point object.

Parameters:
point - the point to copy
Method Detail

distanceTo

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

Returns:
distance to the given Location

equals

public boolean equals(Object obj)
Compares Location to another object

Overrides:
equals in class Object
Returns:
true if obj is a Location with the same coordinates

getX

public double getX()
Retrieves the Location's x coordinate.

Returns:
x value of point

getY

public double getY()
Retrieves the Location's y coordinate.

Returns:
y value of point

hashCode

public int hashCode()
Generates a hashCode for a Location

Overrides:
hashCode in class Object
Returns:
hashCode representation of Location

toPoint

public Point toPoint()
Retrieves the nearest point with integer coordinates as a Point.

Returns:
nearest point on the integer lattice

toString

public String toString()
Generates a string representation of the Location.

Overrides:
toString in class Object
Returns:
string representation of object

translate

public void translate(double dx,
                      double dy)
Translates the Location by the given increments.

Parameters:
dx - amount to translate in x-direction
dy - amount to translate in y-direction