Java Code Examples for java.awt.geom.Path2D#contains()
The following examples show how to use
java.awt.geom.Path2D#contains() .
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: RenderingInfo.java From orson-charts with GNU General Public License v3.0 | 6 votes |
/** * Fetches the object, if any, that is rendered at {@code (x, y)}. * * @param x the x-coordinate. * @param y the y-coordinate. * * @return The object (or {@code null}). */ public Object3D fetchObjectAt(double x, double y) { for (int i = this.faces.size() - 1; i >= 0; i--) { Face f = this.faces.get(i); if (f instanceof LabelFace) { Rectangle2D bounds = (Rectangle2D) f.getOwner().getProperty("labelBounds"); if (bounds != null && bounds.contains(x - dx, y - dy)) { return f.getOwner(); } } else { Path2D p = f.createPath(this.projPts); if (p.contains(x - dx, y - dy)) { return f.getOwner(); } } } return null; }
Example 2
Source File: VisualControlRegister.java From workcraft with MIT License | 6 votes |
@Override public boolean hitTestInLocalSpace(Point2D pointInLocalSpace) { double w2 = size / 2; double h2 = size / 2; double dx = size / 5 - strokeWidth / 2; Path2D shape = new Path2D.Double(); shape.moveTo(-w2, 0); shape.lineTo(-w2 + dx, -h2); shape.lineTo(+w2 - dx, -h2); shape.lineTo(+w2, 0); shape.lineTo(+w2 - dx, +h2); shape.lineTo(-w2 + dx, +h2); shape.closePath(); return shape.contains(pointInLocalSpace); }
Example 3
Source File: UnrootedTree.java From MesquiteCore with GNU Lesser General Public License v3.0 | 5 votes |
public boolean inNode(int node, int x, int y){ Path2D nodeP = nodePoly(node); if (nodeP!=null && nodeP.contains(x,y)) return true; else return false; }
Example 4
Source File: Path2DCopyConstructor.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 5
Source File: DiagonalDrawTree.java From MesquiteCore with GNU Lesser General Public License v3.0 | 5 votes |
public boolean inNode(int node, int x, int y){ Path2D nodeP = nodePoly(node); if (nodeP!=null && nodeP.contains(x,y)) return true; else return false; }
Example 6
Source File: ContainedAssociates.java From MesquiteCore with GNU Lesser General Public License v3.0 | 5 votes |
public boolean inNode(int node, int x, int y){ Path2D nodeP = nodePoly(node); if (nodeP!=null && nodeP.contains(x,y)) return true; else return false; }
Example 7
Source File: Path2DCopyConstructor.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 8
Source File: GridEditMetagon.java From Forsythia with GNU General Public License v3.0 | 5 votes |
private ProjectJigSection getSection(double[] p){ Path2D path; for(ProjectJigSection m:GE.ge.editor_jig.editedjig.sections){ path=GE.ge.editor_jig.editedjig.getJigEditorGeometryCache().getPath(m.getPolygon()); if(path.contains(p[0],p[1])) return m;} return null;}
Example 9
Source File: GridEditJig.java From Forsythia with GNU General Public License v3.0 | 5 votes |
private ProjectJigSection getSection(double[] p){ Path2D path; for(ProjectJigSection m:GE.ge.editor_jig.editedjig.sections){ path=GE.ge.editor_jig.editedjig.getJigEditorGeometryCache().getPath(m.getPolygon()); if(path.contains(p[0],p[1])) return m;} return null;}
Example 10
Source File: Path2DCopyConstructor.java From hottub with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 11
Source File: Path2DCopyConstructor.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 12
Source File: Path2DCopyConstructor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 13
Source File: Path2DCopyConstructor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 14
Source File: Path2DCopyConstructor.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 15
Source File: CircularTree.java From MesquiteCore with GNU Lesser General Public License v3.0 | 5 votes |
public boolean inNode(int node, int x, int y){ Path2D nodeP = nodePoly(node); if (nodeP!=null && nodeP.contains(x,y)) return true; else return false; }
Example 16
Source File: Path2DCopyConstructor.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static void testContains(Path2D pathA, Path2D pathB) { boolean resA = pathA.contains(pt2d); boolean resB = pathB.contains(pt2d); if (resA != resB) { throw new IllegalStateException("Contains(pt) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(pt2d.getX(), pt2d.getY()); resB = pathB.contains(pt2d.getX(), pt2d.getY()); if (resA != resB) { throw new IllegalStateException("Contains(x,y) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(rect2d); resB = pathB.contains(rect2d); if (resA != resB) { throw new IllegalStateException("Contains(rect2d) are not equals [" + resA + "|" + resB + "] !"); } resA = pathA.contains(1.0, 2.0, 13.0, 17.0); resB = pathB.contains(1.0, 2.0, 13.0, 17.0); if (resA != resB) { throw new IllegalStateException("Contains(doubles) are not equals [" + resA + "|" + resB + "] !"); } log("testContains: passed."); }
Example 17
Source File: ShapeInterpolator.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean contains(double x, double y) { return Path2D.contains(getPathIterator(null), x, y); }
Example 18
Source File: ShapeInterpolator.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean contains(Point2D p) { return Path2D.contains(getPathIterator(null), p); }
Example 19
Source File: ShapeInterpolator.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean contains(double x, double y, double width, double height) { return Path2D.contains(getPathIterator(null), x, y, width, height); }
Example 20
Source File: ShapeInterpolator.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean contains(Rectangle2D r) { return Path2D.contains(getPathIterator(null), r); }