Example usage for java.awt.geom Area contains

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

Introduction

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

Prototype

public boolean contains(double x, double y) 

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.subtract(a2);//from  w  w  w. j  a v a  2 s  .  co  m

    g2.setColor(Color.orange);
    g2.fill(a1);

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

    System.out.println(a1.contains(50, 50));
}

From source file:com.t3.macro.api.views.TokenView.java

/**
 * Calculates if a certain point on the map is visible for this Token.
 * @param x the x coordinate of the point you want to test
 * @param y the y coordinate of the point you want to test
 * @return if the point is visible//w w w.  j a v a2  s .co m
 */
public boolean isVisible(int x, int y) {
    Area visArea = TabletopTool.getFrame().getZoneRenderer(token.getZone()).getZoneView().getVisibleArea(token);
    if (visArea == null)
        return false;
    else
        return visArea.contains(x, y);
}