objects whose geometry is defined by a rectangular frame.
This class does not directly specify any specific geometry by
itself, but merely provides manipulation methods inherited by
a whole category of
objects.
The manipulation methods provided by this class can be used to
query and modify the rectangular frame, which provides a reference
for the subclasses to define their geometry.
Method from java.awt.geom.RectangularShape Detail: |
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
Creates a new object of the same class and with the same
contents as this object. |
public boolean contains(Point2D p) {
return contains(p.getX(), p.getY());
}
|
public boolean contains(Rectangle2D r) {
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
}
|
public Rectangle getBounds() {
double width = getWidth();
double height = getHeight();
if (width < 0 || height < 0) {
return new Rectangle();
}
double x = getX();
double y = getY();
double x1 = Math.floor(x);
double y1 = Math.floor(y);
double x2 = Math.ceil(x + width);
double y2 = Math.ceil(y + height);
return new Rectangle((int) x1, (int) y1,
(int) (x2 - x1), (int) (y2 - y1));
}
|
public double getCenterX() {
return getX() + getWidth() / 2.0;
}
Returns the X coordinate of the center of the framing
rectangle of the Shape in double
precision. |
public double getCenterY() {
return getY() + getHeight() / 2.0;
}
Returns the Y coordinate of the center of the framing
rectangle of the Shape in double
precision. |
public Rectangle2D getFrame() {
return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight());
}
Returns the framing Rectangle2D
that defines the overall shape of this object. |
abstract public double getHeight()
Returns the height of the framing rectangle
in double precision. |
public double getMaxX() {
return getX() + getWidth();
}
Returns the largest X coordinate of the framing
rectangle of the Shape in double
precision. |
public double getMaxY() {
return getY() + getHeight();
}
Returns the largest Y coordinate of the framing
rectangle of the Shape in double
precision. |
public double getMinX() {
return getX();
}
Returns the smallest X coordinate of the framing
rectangle of the Shape in double
precision. |
public double getMinY() {
return getY();
}
Returns the smallest Y coordinate of the framing
rectangle of the Shape in double
precision. |
public PathIterator getPathIterator(AffineTransform at,
double flatness) {
return new FlatteningPathIterator(getPathIterator(at), flatness);
}
Returns an iterator object that iterates along the
Shape object's boundary and provides access to a
flattened view of the outline of the Shape
object's geometry.
Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types will
be returned by the iterator.
The amount of subdivision of the curved segments is controlled
by the flatness parameter, which specifies the
maximum distance that any point on the unflattened transformed
curve can deviate from the returned flattened path segments.
An optional AffineTransform can
be specified so that the coordinates returned in the iteration are
transformed accordingly. |
abstract public double getWidth()
Returns the width of the framing rectangle in
double precision. |
abstract public double getX()
Returns the X coordinate of the upper-left corner of
the framing rectangle in double precision. |
abstract public double getY()
Returns the Y coordinate of the upper-left corner of
the framing rectangle in double precision. |
public boolean intersects(Rectangle2D r) {
return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
}
|
abstract public boolean isEmpty()
Determines whether the RectangularShape is empty.
When the RectangularShape is empty, it encloses no
area. |
public void setFrame(Rectangle2D r) {
setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight());
}
Sets the framing rectangle of this Shape to
be the specified Rectangle2D . The framing rectangle is
used by the subclasses of RectangularShape to define
their geometry. |
public void setFrame(Point2D loc,
Dimension2D size) {
setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
}
Sets the location and size of the framing rectangle of this
Shape to the specified Point2D and
Dimension2D , respectively. The framing rectangle is used
by the subclasses of RectangularShape to define
their geometry. |
abstract public void setFrame(double x,
double y,
double w,
double h)
Sets the location and size of the framing rectangle of this
Shape to the specified rectangular values. |
public void setFrameFromCenter(Point2D center,
Point2D corner) {
setFrameFromCenter(center.getX(), center.getY(),
corner.getX(), corner.getY());
}
Sets the framing rectangle of this Shape based on a
specified center Point2D and corner
Point2D . The framing rectangle is used by the subclasses
of RectangularShape to define their geometry. |
public void setFrameFromCenter(double centerX,
double centerY,
double cornerX,
double cornerY) {
double halfW = Math.abs(cornerX - centerX);
double halfH = Math.abs(cornerY - centerY);
setFrame(centerX - halfW, centerY - halfH, halfW * 2.0, halfH * 2.0);
}
Sets the framing rectangle of this Shape
based on the specified center point coordinates and corner point
coordinates. The framing rectangle is used by the subclasses of
RectangularShape to define their geometry. |
public void setFrameFromDiagonal(Point2D p1,
Point2D p2) {
setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY());
}
Sets the diagonal of the framing rectangle of this Shape
based on two specified Point2D objects. The framing
rectangle is used by the subclasses of RectangularShape
to define their geometry. |
public void setFrameFromDiagonal(double x1,
double y1,
double x2,
double y2) {
if (x2 < x1) {
double t = x1;
x1 = x2;
x2 = t;
}
if (y2 < y1) {
double t = y1;
y1 = y2;
y2 = t;
}
setFrame(x1, y1, x2 - x1, y2 - y1);
}
Sets the diagonal of the framing rectangle of this Shape
based on the two specified coordinates. The framing rectangle is
used by the subclasses of RectangularShape to define
their geometry. |