FileDocCategorySizeDatePackage
RoundRectangle2D.javaAPI DocAndroid 1.5 API17974Wed May 06 22:41:54 BST 2009java.awt.geom

RoundRectangle2D

public abstract class RoundRectangle2D extends RectangularShape
The Class RoundRectangle2D describes a rectangle with rounded corners with high-precision data that is appropriate for geometric operations.
since
Android 1.0

Fields Summary
Constructors Summary
protected RoundRectangle2D()
Instantiates a new RoundRectangle2D.

    
Methods Summary
public booleancontains(double px, double py)

        if (isEmpty()) {
            return false;
        }

        double rx1 = getX();
        double ry1 = getY();
        double rx2 = rx1 + getWidth();
        double ry2 = ry1 + getHeight();

        if (px < rx1 || px >= rx2 || py < ry1 || py >= ry2) {
            return false;
        }

        double aw = getArcWidth() / 2.0;
        double ah = getArcHeight() / 2.0;

        double cx, cy;

        if (px < rx1 + aw) {
            cx = rx1 + aw;
        } else if (px > rx2 - aw) {
            cx = rx2 - aw;
        } else {
            return true;
        }

        if (py < ry1 + ah) {
            cy = ry1 + ah;
        } else if (py > ry2 - ah) {
            cy = ry2 - ah;
        } else {
            return true;
        }

        px = (px - cx) / aw;
        py = (py - cy) / ah;
        return px * px + py * py <= 1.0;
    
public booleancontains(double rx, double ry, double rw, double rh)

        if (isEmpty() || rw <= 0.0 || rh <= 0.0) {
            return false;
        }

        double rx1 = rx;
        double ry1 = ry;
        double rx2 = rx + rw;
        double ry2 = ry + rh;

        return contains(rx1, ry1) && contains(rx2, ry1) && contains(rx2, ry2) && contains(rx1, ry2);
    
public abstract doublegetArcHeight()
Gets the arc height.

return
the arc height.

public abstract doublegetArcWidth()
Gets the arc width.

return
the arc width.

public java.awt.geom.PathIteratorgetPathIterator(java.awt.geom.AffineTransform at)

        return new Iterator(this, at);
    
public booleanintersects(double rx, double ry, double rw, double rh)

        if (isEmpty() || rw <= 0.0 || rh <= 0.0) {
            return false;
        }

        double x1 = getX();
        double y1 = getY();
        double x2 = x1 + getWidth();
        double y2 = y1 + getHeight();

        double rx1 = rx;
        double ry1 = ry;
        double rx2 = rx + rw;
        double ry2 = ry + rh;

        if (rx2 < x1 || x2 < rx1 || ry2 < y1 || y2 < ry1) {
            return false;
        }

        double cx = (x1 + x2) / 2.0;
        double cy = (y1 + y2) / 2.0;

        double nx = cx < rx1 ? rx1 : (cx > rx2 ? rx2 : cx);
        double ny = cy < ry1 ? ry1 : (cy > ry2 ? ry2 : cy);

        return contains(nx, ny);
    
public voidsetFrame(double x, double y, double width, double height)

        setRoundRect(x, y, width, height, getArcWidth(), getArcHeight());
    
public abstract voidsetRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
Sets the data of the RoundRectangle2D.

param
x the x coordinate of the rectangle's upper left corner.
param
y the y coordinate of the rectangle's upper left corner.
param
width the width of the rectangle.
param
height the height of the rectangle.
param
arcWidth the arc width of the rounded corners.
param
arcHeight the arc height of the rounded corners.

public voidsetRoundRect(java.awt.geom.RoundRectangle2D rr)
Sets the data of the RoundRectangle2D by copying the values from an existing RoundRectangle2D.

param
rr the round rectangle to copy the data from.
throws
NullPointerException if rr is null.

        setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(), rr.getArcWidth(), rr
                .getArcHeight());