objectdraw
Class Location

java.lang.Object
  extended byobjectdraw.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.

Version:
1.1.2 released July 2006
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(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 Location.
 boolean equals(java.lang.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
 java.awt.Point toPoint()
          Retrieves the nearest point with integer coordinates as a Point.
 java.lang.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
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(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 Location's x coordinate.

Returns:
x value of point

getY

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

Returns:
y value of point

distanceTo

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

Returns:
distance to the given Location

toPoint

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

Returns:
nearest point on the integer lattice

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

toString

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

Returns:
string representation of object

equals

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

Returns:
true if obj is a Location with the same coordinates

hashCode

public int hashCode()
Generates a hashCode for a Location

Returns:
hashCode representation of Location