/** * Indicates whether the rectangular shape contains the specified point. * This point should be expressed in logical coordinates. */ public boolean contains(final Point2D point) { return logicalShape.contains(point); }
/** * Indicates whether the rectangular shape contains the specified * rectangle. This rectangle must be expressed in logical * coordinates. This method can conservatively return * {@code false} as permitted by the {@link Shape} specification. */ public boolean contains(double x, double y, double width, double height) { return logicalShape.contains(x, y, width, height); }
/** * Indicates whether the rectangular shape contains the specified point. * This point should be expressed in logical coordinates. */ public boolean contains(final double x, final double y) { return logicalShape.contains(x, y); }
/** * Indicates whether the rectangular shape contains the specified * rectangle. This rectangle should be expressed in logical * coordinates. This method can conservatively return * {@code false} as permitted by the {@link Shape} specification. */ public boolean contains(final Rectangle2D rect) { return logicalShape.contains(rect); }
/** * * @param x coordinate * @param y coordinate * @return true if (x,y) intersects with the annotation */ @Override public boolean contains(int x, int y) { return noteRect.contains(x, y); }
/** * Method called automatically when the user releases the mouse button. * The default implementation calls {@link #stateChanged} with the * argument {@code false}, in order to inform the derived classes * that the changes are finished. */ public void mouseReleased(final MouseEvent event) { if (isDragging && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { isDragging = false; final Component source = event.getComponent(); try { tmp.x = event.getX(); tmp.y = event.getY(); mouseOverRect = drawnShape.contains(transform.inverseTransform(tmp, tmp)); if (!mouseOverRect && source != null) source.setCursor(null); event.consume(); } catch (NoninvertibleTransformException exception) { // Ignore this exception. } try { // It is essential that 'isDragging=false'. fireStateChanged(); } catch (RuntimeException exception) { ExceptionMonitor.show(source, exception); } } }
/** * Method called automatically when the user presses a mouse button * anywhere within the component. The default implementation * checks if the button was pressed whilst the mouse cursor was * within the rectangle. If so, this object will track the mouse drags * to move or resize the rectangle. */ public void mousePressed(final MouseEvent e) { if (!e.isConsumed() && (e.getModifiers() & MouseEvent.BUTTON1_MASK)!= 0) { if (adjustingSides != 0 || moveable) { tmp.x = e.getX(); tmp.y = e.getY(); try { if (drawnShape.contains(transform.inverseTransform(tmp, tmp))) { mouseDX = tmp.x - drawnShape.getX(); mouseDY = tmp.y - drawnShape.getY(); isDragging = true; e.consume(); } } catch (NoninvertibleTransformException exception) { // Pas besoin de grer cette exception. // L'ignorer est correct. } } } }
return rect.contains(point);
addMouseMotionListener(new MouseMotionAdapter(){ public void mouseMoved(MouseEvent e) { if (circle.contains(e.getPoint())) { insideCircle = true; } else {
@Override public void mouseMoved(MouseEvent mEvt) { if (ellipse.contains(mEvt.getPoint())) { setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } else {
@Override public void mousePressed(MouseEvent e) { if (ellipse.contains(e.getPoint())) { setRandomGradient(); repaint();
addMouseListener(new MouseAdapter(){ public void mousePressed(MouseEvent e) { if (circle.contains(e.getPoint())) { changeColor();
System.out.println("Clicked on the Panel"); if(menuRect.contains(click))
public void mouseMoved(MouseEvent e) { Point p = e.getPoint(); if (RECTANGLE.contains(p)) { color = HOVER_COLOR; } else {
if (points[i].contains(p)) { pos = i; return;
if (feeltraceShape.contains(p)) { newLocation = p; } else {
/** * 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())); }