Example usage for java.awt.geom Area intersects

List of usage examples for java.awt.geom Area intersects

Introduction

In this page you can find the example usage for java.awt.geom Area intersects.

Prototype

public boolean intersects(double x, double y, double w, double h) 

Source Link

Usage

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0);
    Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0);

    Area a1 = new Area(e1);
    Area a2 = new Area(e2);

    a1.intersects(20, 20, 300, 300);

    g2.setColor(Color.orange);//from   www . j a  v  a  2s .  co m
    g2.fill(a1);

    g2.setColor(Color.black);
    g2.drawString("intersect", 20, 140);
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * @see Graphics2D#hit(Rectangle, Shape, boolean)
 *//*from w  w  w .j a va2 s .  c  om*/
@Override
public boolean hit(final Rectangle rect, Shape s, final boolean onStroke) {
    if (onStroke) {
        s = stroke.createStrokedShape(s);
    }
    s = transform.createTransformedShape(s);
    final Area area = new Area(s);
    if (clip != null) {
        area.intersect(clip);
    }
    return area.intersects(rect.x, rect.y, rect.width, rect.height);
}