private static void copyInputPoints (Sequence points) {
// copy into hull the sequence of input points
hull = new NodeSequence();
Enumeration pe = points.elements();
while (pe.hasMoreElements()) {
Point2D p = (Point2D)pe.nextElement();
hull.insertLast(p);
}
}
private static void anchorPointSearchAndRemove () {
// compute the anchor point and remove it from hull together with
// all the coincident points
Enumeration pe = hull.positions();
Position anchor = (Position)pe.nextElement();
anchorPoint = (Point2D)anchor.element();
// hull contains at least three elements
while (pe.hasMoreElements()) {
Position pos = (Position)pe.nextElement();
Point2D p = (Point2D)pos.element();
int aboveBelow = geomTester.aboveBelow(anchorPoint,p);
int leftRight = geomTester.leftRight(anchorPoint,p);
if (aboveBelow == GeomTester2D.BELOW ||
aboveBelow == GeomTester2D.ON &&
leftRight == GeomTester2D.LEFT) {
anchor = pos;
anchorPoint = p;
}
else
if (aboveBelow == GeomTester2D.ON &&
leftRight == GeomTester2D.ON)
hull.remove(pos);
}
hull.remove(anchor);
}
private static void sortPoints() {
// sort the points in hull around the anchor point
SortObject sorter = new ListMergeSort();
ConvexHullComparator comp = new ConvexHullComparator(anchorPoint,
geomTester);
sorter.sort(hull,comp);
}