org.jdelaunay.delaunay
Class VerticalComparator

java.lang.Object
  extended by org.jdelaunay.delaunay.VerticalComparator
All Implemented Interfaces:
Serializable, Comparator<DEdge>

public class VerticalComparator
extends Object
implements Comparator<DEdge>, Serializable

The VerticalComparator class will be used to perform sorting and searching operations in vertically sorted lists. We can't use directly the Comparable interface in DEdge, as it is already used for the "left-right" method.

Author:
Alexis Guéganno
See Also:
Serialized Form

Constructor Summary
VerticalComparator(double x)
          Vertical comparator constructor.
 
Method Summary
 int compare(DEdge edge1, DEdge edge2)
          This comparison method is a vertical sorting test : Sort two edges (edge1 and edge2, indeed), and sort them according to their intersection point with the line l of equation x=abs.
 double getAbs()
          get the absciss where we are currently working.
 void setAbs(double x)
          Set the absciss where we are going to work.
 
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

VerticalComparator

public VerticalComparator(double x)
Vertical comparator constructor.

Parameters:
x -
Method Detail

setAbs

public final void setAbs(double x)
Set the absciss where we are going to work.

Parameters:
x -

getAbs

public final double getAbs()
get the absciss where we are currently working.

Returns:
The value currently used for comparison

compare

public final int compare(DEdge edge1,
                         DEdge edge2)
This comparison method is a vertical sorting test : Sort two edges (edge1 and edge2, indeed), and sort them according to their intersection point with the line l of equation x=abs. if p1 (p2) is the intersection between l and the line defined by edge1 (edge2), this method returns : * -1 if p1 < p2 or ( p1 == p2 and this is "under" edge) * 0 if p1 == p2 and (this and edge are colinear) * 1 if p1 > p2 or (p1 == p2 and edge is under this) In our case, we will return -2 if one of the edge is vertical, and has absciss other than abs.

Specified by:
compare in interface Comparator<DEdge>
Parameters:
edge1 -
edge2 -
Returns:
-1 if edge1 < edge2
0 if edge1 == edge2
1 otherwise.


Copyright © 2014 IRSTV CNRS-FR-2488. All Rights Reserved.