import java.awt.geom.Area; ... public static boolean testIntersection(Shape shapeA, Shape shapeB) { Area areaA = new Area(shapeA); areaA.intersect(new Area(shapeB)); return !areaA.isEmpty(); }
public boolean intersects(Path p) { Area a1 = new Area(getGeneralPath()); Area a2 = new Area(p.getGeneralPath()); a1.intersect(a2); return !a1.isEmpty(); }
/** * Return true if this area node represents an empty area. * * @return true if this area node represents an empty area */ public boolean isEmpty() { return area.isEmpty(); }
/** * Return true if this area node represents an empty area. * * @return true if this area node represents an empty area */ public boolean isEmpty() { return area.isEmpty(); }
public void addToExposedAreaHistory(Area newArea) { if (newArea != null && !newArea.isEmpty()) { exposedAreaHistory.add(newArea); } }
import java.awt.geom.Area; ... boolean playerHitByTentacle(Tentacle t, Player p) { Area player = new Area(p.getPath2D()); Area tentacle = new Area(t.getPath2D()); player.intersect(tentacle); return !player.isEmpty(); }
Area a = new Area(shape1); Area b = new Area(shape2); b.intersect(a); if (!b.isEmpty()) { //Shapes have non-empty intersection, so do you actions. //In case of need, actual intersection is in Area b. (its destructive operation) }
boolean intersectionExists(Shape shape1, Shape shape2) { Area area1 = new Area(shape1); area1.intersect(new Area(shape2)); return !area1.isEmpty(); }
public void removeExposedAreaHistory(Area newArea) { if (newArea != null && !newArea.isEmpty()) { exposedAreaHistory.subtract(newArea); } }
/** * Check whether the two provided areas intersect one another. * * @param a1 some area * @param a2 some other area * @return true if there is a non-empty intersection */ public static boolean intersection (Area a1, Area a2) { Area copy = new Area(a1); copy.intersect(a2); return !copy.isEmpty(); }
Shape shape0 = new Rectangle2D.Double(mxY, myY, 20, 20); Shape shape1 = new Ellipse2D.Double(nX, nY, 20, 20); Area a0 = new Area(shape0); Area a1 = new Area(shape1); a0.intersect(a1); if (!a0.isEmpty()) { /* They intersect! */ }
/** * Checks if two areas collide. * * @param area1 the first area. * @param area2 the second area. * @return true if areas collide. */ private static boolean doAreasCollide(Area area1, Area area2) { Area collide = new Area(area1); collide.intersect(area2); return !collide.isEmpty(); }
Area area = new Area(poly1); area.intersect(new Area(poly2)); return area.isEmpty();
public void paint(final Graphics2D g, final AffineTransform aff, final boolean fill, final Color color) { g.setColor(color); if (!area.isEmpty()) { if (fill) g.fill(area.createTransformedArea(aff)); else g.draw(area.createTransformedArea(aff)); } if (null != this.painter) { try { this.painter.paint(g, aff, fill); } catch (Exception e) {} } }
protected Collection<java.awt.geom.Point2D> getIntersections(java.awt.geom.Line2D line, Area shape) { Area intersectionArea = new Area(getLineShape(line)); intersectionArea.intersect(shape); if (!intersectionArea.isEmpty()) { Rectangle2D bounds2D = intersectionArea.getBounds2D(); HashSet<java.awt.geom.Point2D> intersections = new HashSet<>(1); intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY())); return intersections; } return Collections.EMPTY_SET; }
public static boolean disjoint(SpatialEntity e1, SpatialEntity e2) { Area a1 = e1.getArea(); Area a2 = e2.getArea(); a1.intersect(a2); return a1.isEmpty(); }
/** Determine if a particular scaling ratio works */ private boolean isOK(Area shape, Rectangle2D shapeBounds,Rectangle2D bounds,float ratio) { Area area = new Area(shape); area.transform(AffineTransform.getScaleInstance(ratio, ratio)); Rectangle2D r = ShapeBounds.getBounds(area); area.transform(AffineTransform.getTranslateInstance(-r.getCenterX()+bounds.getCenterX(), -r.getCenterY()+bounds.getCenterY())); Area boundsArea = new Area(bounds); boundsArea.subtract(area); return boundsArea.isEmpty(); }
private boolean intersectsTargetArea(Product product) { Area productArea = Utils.createProductArea(product); productArea.intersect(targetArea); boolean valid = !productArea.isEmpty(); if (!valid) { logSkipped("The product '" + product.getName() + "' does not intersect the target product."); } return valid; }
/** Return Area in local coords. The area includes a little square for the point, always. */ @Override public final Area getArea() { if (null == this.aw) return super.getArea(); // a little square labeling this point final Area a = this.aw.getArea(); if (a.isEmpty()) return super.getArea(); a.add(super.getArea()); // ensure the point is part of the Area always return a; }