Java Code Examples for sun.awt.geom.Curve#pointCrossingsForCubic()

The following examples show how to use sun.awt.geom.Curve#pointCrossingsForCubic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubicCurve2D.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 2
Source File: CubicCurve2D.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 3
Source File: CubicCurve2D.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 4
Source File: CubicCurve2D.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 5
Source File: CubicCurve2D.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 6
Source File: CubicCurve2D.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 7
Source File: CubicCurve2D.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 8
Source File: CubicCurve2D.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public boolean contains(double x, double y) {
    if (!(x * 0.0 + y * 0.0 == 0.0)) {
        /* Either x or y was infinite or NaN.
         * A NaN always produces a negative response to any test
         * and Infinity values cannot be "inside" any path so
         * they should return false as well.
         */
        return false;
    }
    // We count the "Y" crossings to determine if the point is
    // inside the curve bounded by its closing line.
    double x1 = getX1();
    double y1 = getY1();
    double x2 = getX2();
    double y2 = getY2();
    int crossings =
        (Curve.pointCrossingsForLine(x, y, x1, y1, x2, y2) +
         Curve.pointCrossingsForCubic(x, y,
                                      x1, y1,
                                      getCtrlX1(), getCtrlY1(),
                                      getCtrlX2(), getCtrlY2(),
                                      x2, y2, 0));
    return ((crossings & 1) == 1);
}
 
Example 9
Source File: Path2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 10
Source File: Path2D.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 11
Source File: Path2D.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 12
Source File: Path2D.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 13
Source File: Path2D.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 14
Source File: Path2D.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 15
Source File: Path2D.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 16
Source File: Path2D.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    double coords[] = doubleCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 17
Source File: Path2D.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    double coords[] = doubleCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 18
Source File: Path2D.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    double movx, movy, curx, cury, endx, endy;
    double coords[] = doubleCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 19
Source File: Path2D.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    float coords[] = floatCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}
 
Example 20
Source File: Path2D.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
int pointCrossings(double px, double py) {
    if (numTypes == 0) {
        return 0;
    }
    double movx, movy, curx, cury, endx, endy;
    double coords[] = doubleCoords;
    curx = movx = coords[0];
    cury = movy = coords[1];
    int crossings = 0;
    int ci = 2;
    for (int i = 1; i < numTypes; i++) {
        switch (pointTypes[i]) {
        case PathIterator.SEG_MOVETO:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            movx = curx = coords[ci++];
            movy = cury = coords[ci++];
            break;
        case PathIterator.SEG_LINETO:
            crossings +=
                Curve.pointCrossingsForLine(px, py,
                                            curx, cury,
                                            endx = coords[ci++],
                                            endy = coords[ci++]);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_QUADTO:
            crossings +=
                Curve.pointCrossingsForQuad(px, py,
                                            curx, cury,
                                            coords[ci++],
                                            coords[ci++],
                                            endx = coords[ci++],
                                            endy = coords[ci++],
                                            0);
            curx = endx;
            cury = endy;
            break;
    case PathIterator.SEG_CUBICTO:
            crossings +=
                Curve.pointCrossingsForCubic(px, py,
                                             curx, cury,
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             coords[ci++],
                                             endx = coords[ci++],
                                             endy = coords[ci++],
                                             0);
            curx = endx;
            cury = endy;
            break;
        case PathIterator.SEG_CLOSE:
            if (cury != movy) {
                crossings +=
                    Curve.pointCrossingsForLine(px, py,
                                                curx, cury,
                                                movx, movy);
            }
            curx = movx;
            cury = movy;
            break;
        }
    }
    if (cury != movy) {
        crossings +=
            Curve.pointCrossingsForLine(px, py,
                                        curx, cury,
                                        movx, movy);
    }
    return crossings;
}