/** * Indicates whether the rectangular shape intersects the specified * rectangle. This rectangle must be expressed in logical coordinates. * This method can conservatively return {@code true} as permitted by * the {@link Shape} specification. */ public boolean intersects(final Rectangle2D rect) { return drawnShape.intersects(rect); }
/** * Indicates whether the rectangular shape intersects the specified * rectangle. This rectangle must be expressed in logical coordinates. * This method can conservatively return {@code true} as permitted by * the {@link Shape} specification. */ public boolean intersects(double x, double y, double width, double height) { return drawnShape.intersects(x, y, width, height); }
boolean collides = false; for (Rectangle2D check : used) { if (bounds.intersects(check)) { collides = true; break;
if (fireBall.intersects(rct)) { it.remove(); delats.remove(rct);
if (entities.get(0).intersects(entities.get(1))) { System.out.println("Intersecting");
assertFalse("r1.intersects(r2)", r1.intersects(r2)); assertFalse("r1.contains(r2)", r1.contains(r2)); if (r1 instanceof Rectangle2D) {
assertFalse("r1.intersects(r2)", r1.intersects(r2)); assertFalse("r1.contains(r2)", r1.contains(r2)); if (r1 instanceof Rectangle2D) {
/** * Tests if the given {@code outer} shape contains the given {@code inner} rectangle. * This method will also verify class consistency by invoking the {@code intersects} * method, and by interchanging the arguments. * * <p>This method can be used for testing the {@code outer} implementation - * it should not be needed for standard JDK implementations.</p> * * @param outer the shape which is expected to contains the given rectangle. * @param inner the rectangle which should be contained by the shape. */ public static void assertContains(final RectangularShape outer, final Rectangle2D inner) { assertTrue("outer.contains(inner)", outer.contains (inner)); assertTrue("outer.intersects(inner)", outer.intersects(inner)); if (outer instanceof Rectangle2D) { assertTrue ("inner.intersects(outer)", inner.intersects((Rectangle2D) outer)); assertFalse("inner.contains(outer)", inner.contains ((Rectangle2D) outer)); } assertTrue("outer.contains(centerX, centerY)", outer.contains(inner.getCenterX(), inner.getCenterY())); }
/** * Tests if the given {@code outer} shape contains the given {@code inner} rectangle. * This method will also verify class consistency by invoking the {@code intersects} * method, and by interchanging the arguments. This method can be used for testing * the {@code outer} implementation - it should not be needed for standard implementations. * * @param outer The shape which is expected to contains the given rectangle. * @param inner The rectangle which should be contained by the shape. * * @since 3.20 */ public static void assertContains(final RectangularShape outer, final Rectangle2D inner) { assertTrue("outer.contains(inner)", outer.contains (inner)); assertTrue("outer.intersects(inner)", outer.intersects(inner)); if (outer instanceof Rectangle2D) { assertTrue ("inner.intersects(outer)", inner.intersects((Rectangle2D) outer)); assertFalse("inner.contains(outer)", inner.contains ((Rectangle2D) outer)); } assertTrue("outer.contains(centerX, centerY)", outer.contains(inner.getCenterX(), inner.getCenterY())); }