Vector doGraham(Vector p) {
        int i, j, min, M;
        Point t;
        min = 0;
        // search for minimum:
        for (i = 1; i < p.size(); ++i) {
            if (((Point) p.get(i)).y < ((Point) p.get(min)).y)
                min = i;
        }
        // continue along the values with same y component
        for (i = 0; i < p.size(); ++i) {
            if ((((Point) p.get(i)).y == ((Point) p.get(min)).y)
                    && (((Point) p.get(i)).x > ((Point) p.get(min)).x)) {
                min = i;
            }
        }
        // swap:
        t = (Point) p.get(0);
        p.set(0, p.get(min));
        p.set(min, t);
        thetaComparator comp = new thetaComparator((Point) p.get(0));
        Collections.sort(p, comp);
        p.add(0, new Point((Point) p.get(p.size() - 1))); // the first is the
        // last.
        M = 3;
        for (i = 4; i < p.size(); ++i) {
            while (ccw((Point) p.get(M), (Point) p.get(M - 1), (Point) p.get(i)) >= 0) {
                M--;
            }
            M++;
            // swap:
            t = (Point) p.get(M);
            p.set(M, p.get(i));
            p.set(i, t);
        }
        p.remove(0);
        p.setSize(M);
        return p;
    }