goldman.collection.tagged.spatial
Class TaggedElementXYComparator<T extends XYPoint>

java.lang.Object
  extended by goldman.collection.tagged.spatial.TaggedElementXYComparator<T>
All Implemented Interfaces:
XYComparator<TaggedElement<T,?>>, Comparator<TaggedElement<T,?>>

public class TaggedElementXYComparator<T extends XYPoint>
extends Object
implements XYComparator<TaggedElement<T,?>>

The TaggedElementXYComparator used by the quad tree is defined over tags that are two-dimensional points.


Constructor Summary
TaggedElementXYComparator(XYComparator<? super T> comp)
           
 
Method Summary
 int compare(TaggedElement<T,?> a, TaggedElement<T,?> b)
           
 double compareX(TaggedElement<T,?> a, TaggedElement<T,?> b)
          Compares a and b according to their x-coordinates.
 double compareY(TaggedElement<T,?> a, TaggedElement<T,?> b)
          Compares a and b according to their y-coordinates.
 double getX(TaggedElement<T,?> item)
          Returns the x-coordinate of the given item.
 double getY(TaggedElement<T,?> item)
          Returns the y-coordinate of the given item.
 int quadrant(TaggedElement<T,?> origin, TaggedElement<T,?> item)
          Returns the quadrant for the given item with respect to the given origin where 0 indicates lower left, 1 indicates lower right, 2 indicates upper right, 3 indicates upper left, and 4 indicates the item is at the origin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

TaggedElementXYComparator

public TaggedElementXYComparator(XYComparator<? super T> comp)
Method Detail

compareX

public double compareX(TaggedElement<T,?> a,
                       TaggedElement<T,?> b)
Description copied from interface: XYComparator
Compares a and b according to their x-coordinates.

Specified by:
compareX in interface XYComparator<TaggedElement<T extends XYPoint,?>>

compareY

public double compareY(TaggedElement<T,?> a,
                       TaggedElement<T,?> b)
Description copied from interface: XYComparator
Compares a and b according to their y-coordinates.

Specified by:
compareY in interface XYComparator<TaggedElement<T extends XYPoint,?>>

getX

public double getX(TaggedElement<T,?> item)
Description copied from interface: XYComparator
Returns the x-coordinate of the given item.

Specified by:
getX in interface XYComparator<TaggedElement<T extends XYPoint,?>>

getY

public double getY(TaggedElement<T,?> item)
Description copied from interface: XYComparator
Returns the y-coordinate of the given item.

Specified by:
getY in interface XYComparator<TaggedElement<T extends XYPoint,?>>

compare

public int compare(TaggedElement<T,?> a,
                   TaggedElement<T,?> b)
Specified by:
compare in interface Comparator<TaggedElement<T extends XYPoint,?>>

quadrant

public int quadrant(TaggedElement<T,?> origin,
                    TaggedElement<T,?> item)
Description copied from interface: XYComparator
Returns the quadrant for the given item with respect to the given origin where 0 indicates lower left, 1 indicates lower right, 2 indicates upper right, 3 indicates upper left, and 4 indicates the item is at the origin.

Specified by:
quadrant in interface XYComparator<TaggedElement<T extends XYPoint,?>>