Example usage for java.awt.geom Ellipse2D contains

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

Introduction

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

Prototype

public boolean contains(double x, double y) 

Source Link

Usage

From source file:com.gargoylesoftware.htmlunit.html.HtmlArea.java

/**
 * Indicates if this area contains the specified point.
 * @param x the x coordinate of the point
 * @param y the y coordinate of the point
 * @return {@code true} if the point is contained in this area
 *///from   w ww .  j  a v a2  s  .  c  o m
boolean containsPoint(final int x, final int y) {
    final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), "rect").toLowerCase(Locale.ROOT);

    if ("default".equals(shape) && getCoordsAttribute() != null) {
        return true;
    }

    if ("rect".equals(shape) && getCoordsAttribute() != null) {
        final Rectangle2D rectangle = parseRect();
        return rectangle.contains(x, y);
    }

    if ("circle".equals(shape) && getCoordsAttribute() != null) {
        final Ellipse2D ellipse = parseCircle();
        return ellipse.contains(x, y);
    }

    if ("poly".equals(shape) && getCoordsAttribute() != null) {
        final GeneralPath path = parsePoly();
        return path.contains(x, y);
    }

    return false;
}