RoundRectangle2Dpublic abstract class RoundRectangle2D extends RectangularShape The Class RoundRectangle2D describes a rectangle with rounded corners with
high-precision data that is appropriate for geometric operations. |
Constructors Summary |
---|
protected RoundRectangle2D()Instantiates a new RoundRectangle2D.
|
Methods Summary |
---|
public boolean | contains(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 boolean | contains(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 double | getArcHeight()Gets the arc height.
| public abstract double | getArcWidth()Gets the arc width.
| public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform at)
return new Iterator(this, at);
| public boolean | intersects(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 void | setFrame(double x, double y, double width, double height)
setRoundRect(x, y, width, height, getArcWidth(), getArcHeight());
| public abstract void | setRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)Sets the data of the RoundRectangle2D.
| public void | setRoundRect(java.awt.geom.RoundRectangle2D rr)Sets the data of the RoundRectangle2D by copying the values from an
existing RoundRectangle2D.
setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(), rr.getArcWidth(), rr
.getArcHeight());
|
|