Java Code Examples for java.awt.geom.Path2D#intersects()

The following examples show how to use java.awt.geom.Path2D#intersects() . 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: Path2DCopyConstructor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 2
Source File: Path2DCopyConstructor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 3
Source File: Path2DCopyConstructor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 4
Source File: Path2DCopyConstructor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 5
Source File: Path2DCopyConstructor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 6
Source File: Path2DCopyConstructor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 7
Source File: Path2DCopyConstructor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 8
Source File: Path2DCopyConstructor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 9
Source File: Path2DCopyConstructor.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testIntersect(Path2D pathA, Path2D pathB) {
    boolean resA = pathA.intersects(rect2d);
    boolean resB = pathB.intersects(rect2d);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(rect2d) are not equals ["
            + resA + "|" + resB + "] !");
    }
    resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
    resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
    if (resA != resB) {
        throw new IllegalStateException("Intersects(doubles) are not equals ["
            + resA + "|" + resB + "] !");
    }
    log("testIntersect: passed.");
}
 
Example 10
Source File: ShapeInterpolator.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean intersects(double x, double y, double w, double h) {
    return Path2D.intersects(getPathIterator(null), x, y, w, h);
}
 
Example 11
Source File: ShapeInterpolator.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean intersects(Rectangle2D r) {
    return Path2D.intersects(getPathIterator(null), r);
}
 
Example 12
Source File: SinglePointRenderer.java    From mil-sym-java with Apache License 2.0 4 votes vote down vote up
private ShapeInfo CreateFeintDummyIndicator(String symbolID, Rectangle2D symbolBounds, Rectangle2D echelonBounds )
{
    Path2D sFeint = new Path2D.Double();
    ShapeInfo siFeint = null;
    //float dash[] = {5.0f};
    float dash[] = {6.0f, 4.0f};
    //Shape sFeint = null;
    //dashed stroke
    float width = 2.0f;

    try
    {
        if(symbolBounds != null && symbolBounds.getWidth()<20)
        {
            width = 1.0f;
            dash[0] = 5.0f;
            dash[1] = 3.0f;
        }
        
        Stroke stroke = new BasicStroke(width,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);

        Point2D left = new Point2D.Double(symbolBounds.getX(), symbolBounds.getY());

        Point2D top = null;//new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .75));

        Point2D right = new Point2D.Double(symbolBounds.getX() + symbolBounds.getWidth(), symbolBounds.getY());

        String affiliation = symbolID.substring(1, 2);
                    if(affiliation.equals("F") ||
                            affiliation.equals("A") ||
                            affiliation.equals("D") ||
                            affiliation.equals("M") ||
                            affiliation.equals("J") ||
                            affiliation.equals("K"))
                    {
                        top = new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .75));
                    }
                    else
                    {
                        top = new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .54));

                    }

        Line2D leftLine = new Line2D.Double(left, top);
        Line2D rightLine = new Line2D.Double(top, right);
        sFeint.append(leftLine, false);
        sFeint.append(rightLine, false);

        if(echelonBounds != null && sFeint.intersects(echelonBounds))
        {
            //move it above echelon and add some breathing room
            sFeint.transform(AffineTransform.getTranslateInstance(0, -echelonBounds.getHeight()-2));
        }

        siFeint = new ShapeInfo(sFeint);
        siFeint.setLineColor(Color.BLACK);
        siFeint.setStroke(stroke);
        siFeint.setShapeType(ShapeInfo.SHAPE_TYPE_UNIT_DISPLAY_MODIFIER);
    }
    catch(Exception exc)
    {
        ErrorLogger.LogException(_className, "CreateFeintDummyIndicator()", exc);
    }
    return siFeint;
}