Hello, I have a java package conatain three files. I compiled this package correctly using Netbeans V.6. When I run each file in the package, it gives me a message "class org.bluer.cg.filename does not have a main method"!!!
Can anyone help me?
I attached just two files to look at them. (1) package org.bluear.cg.hull;
/** * Returns the array of indices of points that are part of the convex * hull. * * @param points A collection of <code>Point2D</code> objects. * @return The list of points that are vertices of a convex hull. */ public abstract List getHullPoints(Collection points);
/** * Classifies the location of the point (x2, y2) relatively to the segment * defined by points (x0, y0) and (x1, y1). The following illustrates * regions considered by this method: * <pre> * * LEFT * BEYOND * . * DESTINATION * / * BETWEEN * / RIGHT * ORIGIN * . * BEHIND * </pre> * @param x0 The x of the starting point of the segment. * @param y0 The y of the starting point of the segment. * @param x1 The x of the final point of the segment. * @param y1 The y of the final point of the segment. * @param x2 The x of the point whose position we are testing. * @param y2 The y of the point whose position we are testing. */ public static int classify(double x0, double y0, double x1, double y1, double x2, double y2) { double dx1 = x1 - x0; double dx2 = x2 - x0; double dy1 = y1 - y0; double dy2 = y2 - y0; double sa = dx1 * dy2 - dx2 * dy1;
/** * Returns a code indicating where point <code>c</code> is located with * respect to the segment formed by points <code>a</code> and <code>b</code>. * * @param a The first point of the segment. * @param b The second point of the segment. * @param c The point classified with respect to the segment. * @return The code indicating the relative location of c. */ public static int classify(Point2D a, Point2D b, Point2D c) { return (classify(a.getX(), a.getY(), b.getX(), b.getY(), c.getX(), c.getY())); }
/** * Returns whether or not the tree given points are co-linear. * * @param p1 The first point. * @param p2 The second points. * @param p3 The third point. * @return Whether or not the three points are co-linear. */ public static boolean colinear(Point2D p1, Point2D p2, Point2D p3) { return (p1.getX()*(p2.getY() - p3.getY()) + p2.getX()*(p3.getY() - p1.getY()) + p3.getX()*(p1.getY() - p2.getY())) == 0.0; } }
// Step 2: sort points by their polar coordinate relative to p0 Arrays.sort(pt, 1, n, new PolarComparator(p0));
// Step 3: Find the second point of the hull ... i = 1;
while (i+1 < n && colinear(p0, pt[i], pt[i+1])) { ++ i; }
hull.add(p0); hull.add(pt[i]);
// Step 4: Grow the current hull until it includes all points for (i = i + 1; i < n; ++ i) { pi = pt[i]; Point2D p1 = (Point2D) hull.get(hull.size() - 1); p0 = (Point2D) hull.get(hull.size() - 2);
/** * Local class used by the sort method to classify points based on their * polar coordinates with respect to the specified pivot point, p0. * * @author Bo Majewski */ private static class PolarComparator implements Comparator {
private Point2D p0;
/** * Creates a new comparator that used the given pivot point. * * @param p0 The pivot point. */ public PolarComparator(Point2D p0) { this.p0 = p0; }
/** * Compares object o1 to object o2. This method returns a negative * value if o1 lies to the left of o2 with respect to the pivot p0. * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { Point2D p1 = (Point2D) o1; Point2D p2 = (Point2D) o2;
// take care of degenerate cases first ... if (p1.equals(this.p0)) { return (p2.equals(this.p0)? 0 : -1); }
if (p2.equals(this.p0)) { return (1); }
// this is when neither p1 nor p2 is identical to pivot ... double d = ((p2.getX() - p0.getX())*(p1.getY() - p0.getY()) - (p1.getX() - p0.getX())*(p2.getY() - p0.getY()));