Search in sources :

Example 1 with AreaOp

use of sun.awt.geom.AreaOp in project jdk8u_jdk by JetBrains.

the class AreaIterator method pathToCurves.

private static Vector pathToCurves(PathIterator pi) {
    Vector curves = new Vector();
    int windingRule = pi.getWindingRule();
    // coords array is big enough for holding:
    //     coordinates returned from currentSegment (6)
    //     OR
    //         two subdivided quadratic curves (2+4+4=10)
    //         AND
    //             0-1 horizontal splitting parameters
    //             OR
    //             2 parametric equation derivative coefficients
    //     OR
    //         three subdivided cubic curves (2+6+6+6=20)
    //         AND
    //             0-2 horizontal splitting parameters
    //             OR
    //             3 parametric equation derivative coefficients
    double[] coords = new double[23];
    double movx = 0, movy = 0;
    double curx = 0, cury = 0;
    double newx, newy;
    while (!pi.isDone()) {
        switch(pi.currentSegment(coords)) {
            case PathIterator.SEG_MOVETO:
                Curve.insertLine(curves, curx, cury, movx, movy);
                curx = movx = coords[0];
                cury = movy = coords[1];
                Curve.insertMove(curves, movx, movy);
                break;
            case PathIterator.SEG_LINETO:
                newx = coords[0];
                newy = coords[1];
                Curve.insertLine(curves, curx, cury, newx, newy);
                curx = newx;
                cury = newy;
                break;
            case PathIterator.SEG_QUADTO:
                newx = coords[2];
                newy = coords[3];
                Curve.insertQuad(curves, curx, cury, coords);
                curx = newx;
                cury = newy;
                break;
            case PathIterator.SEG_CUBICTO:
                newx = coords[4];
                newy = coords[5];
                Curve.insertCubic(curves, curx, cury, coords);
                curx = newx;
                cury = newy;
                break;
            case PathIterator.SEG_CLOSE:
                Curve.insertLine(curves, curx, cury, movx, movy);
                curx = movx;
                cury = movy;
                break;
        }
        pi.next();
    }
    Curve.insertLine(curves, curx, cury, movx, movy);
    AreaOp operator;
    if (windingRule == PathIterator.WIND_EVEN_ODD) {
        operator = new AreaOp.EOWindOp();
    } else {
        operator = new AreaOp.NZWindOp();
    }
    return operator.calculate(curves, EmptyCurves);
}
Also used : Vector(java.util.Vector) AreaOp(sun.awt.geom.AreaOp)

Aggregations

Vector (java.util.Vector)1 AreaOp (sun.awt.geom.AreaOp)1