org.gicentre.treemappa
Class LocationList

java.lang.Object
  extended by org.gicentre.treemappa.LocationList

public class LocationList
extends java.lang.Object

Stores a list of objects each be associated with a location. Allows spatial queries of the list (find closest item to (x,y)).

Version:
3.0, 24th February, 2011.
Author:
Jo Wood, giCentre.

Constructor Summary
LocationList()
          Creates the collection.
 
Method Summary
 void add(LocatedObject locObj)
          Adds the given object to the collection.
 void clear()
          Clears the contents of the list.
 LocatedObject get(int index)
          Gets the object at the given position in the collection.
 LocatedObject getClosest(java.awt.geom.Point2D location)
          Retrieves the object closest to the given location.
 void remove(int index)
          Removes the object at the given position in the collection.
 boolean remove(LocatedObject locObj)
          Removes the given object from the collection.
 int size()
          Reports the number of items stored in the list.
 void sortByDistance(java.awt.geom.Point2D p)
          Sorts the locations by distance from the given point.
 void sortByObject()
          Sorts the locations by the descending natural order of the objects that are attached to them.
 java.lang.String toString()
          Reports a textual representation of the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocationList

public LocationList()
Creates the collection.

Method Detail

add

public void add(LocatedObject locObj)
Adds the given object to the collection.

Parameters:
locObj - New located object to add to the collection.

remove

public boolean remove(LocatedObject locObj)
Removes the given object from the collection.

Parameters:
locObj - Object to remove from the collection.
Returns:
True if object found and removed successfully.

remove

public void remove(int index)
Removes the object at the given position in the collection.

Parameters:
index - Position in list at which to remove the object.

clear

public void clear()
Clears the contents of the list.


get

public LocatedObject get(int index)
Gets the object at the given position in the collection.

Parameters:
index - Position in list at which to find the object.
Returns:
Object at given index.

size

public int size()
Reports the number of items stored in the list.

Returns:
Number of located objects in list.

sortByObject

public void sortByObject()
Sorts the locations by the descending natural order of the objects that are attached to them. If two objects are identical, they are sorted by ascending distance from origin.


sortByDistance

public void sortByDistance(java.awt.geom.Point2D p)
Sorts the locations by distance from the given point.

Parameters:
p - Point from which to measure distance.

getClosest

public LocatedObject getClosest(java.awt.geom.Point2D location)
Retrieves the object closest to the given location. 2D Euclidean distance used.

Parameters:
location - Location to query.
Returns:
Object closest to the given position or null if no located objects in collection.

toString

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

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


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