org.gicentre.treemappa
Class LocatedObject

java.lang.Object
  extended by org.gicentre.treemappa.LocatedObject
All Implemented Interfaces:
java.lang.Comparable<LocatedObject>

public class LocatedObject
extends java.lang.Object
implements java.lang.Comparable<LocatedObject>

Stores a 2D location which can be attached to any object.

Version:
3.0, 25th March, 2011.
Author:
Jo Wood. giCentre.

Constructor Summary
LocatedObject(double x, double y, java.lang.Comparable obj)
          Creates a new location with the given coordinates attached to the given object.
 
Method Summary
 int compareTo(LocatedObject otherLocation)
          Compares this location with the given location.
 java.awt.geom.Point2D getLocation()
          Reports the coordinates of this object.
 java.lang.Comparable getObject()
          Reports the object that has been given a location.
 void setSortByObject(boolean isObject)
          Sets any sorting operation to sort either by object (true) or location (false).
 java.lang.String toString()
          Reports a textual representation of the located object.
 void translate(double tx, double ty)
          Translates the object by the given coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocatedObject

public LocatedObject(double x,
                     double y,
                     java.lang.Comparable obj)
Creates a new location with the given coordinates attached to the given object.

Parameters:
x - X-coordinate of location.
y - Y-coordinate of location.
obj - Object with which to attach location.
Method Detail

setSortByObject

public void setSortByObject(boolean isObject)
Sets any sorting operation to sort either by object (true) or location (false).

Parameters:
isObject - Object ordered by object type if true, otherwise by distance from origin.

translate

public void translate(double tx,
                      double ty)
Translates the object by the given coordinates.

Parameters:
tx - X-coordinate of the translation.
ty - Y-coordinate of the translation.

getLocation

public java.awt.geom.Point2D getLocation()
Reports the coordinates of this object.

Returns:
Location of this object.

getObject

public java.lang.Comparable getObject()
Reports the object that has been given a location. This can be null if no object assigned.

Returns:
Object that has been given a location.

compareTo

public int compareTo(LocatedObject otherLocation)
Compares this location with the given location. If this location is closer to the origin, it will return +1, if matching the other location's distance, 0, otherwise -1.

Specified by:
compareTo in interface java.lang.Comparable<LocatedObject>
Parameters:
otherLocation - Location with which to make comparison.
Returns:
Positive if this object closer to origin, negative if the other is closer, or 0 if equal distance.

toString

public java.lang.String toString()
Reports a textual representation of the located object.

Overrides:
toString in class java.lang.Object
Returns:
Textual representation of the located object.


treeMappa V.3.0.1, API documentation generated 4th April, 2011