Methods Summary |
---|
public java.lang.Object | clone()Creates a new object of the same class and with the same
contents as this object.
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
|
public boolean | contains(java.awt.geom.Point2D p)Tests if a specified Point2D is inside the boundary
of the Shape .
return contains(p.getX(), p.getY());
|
public boolean | contains(java.awt.geom.Rectangle2D r)Tests if the interior of the Shape entirely contains the
specified Rectangle2D .
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
public java.awt.Rectangle | getBounds()Returns the bounding box of the Shape .
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()Returns the X coordinate of the center of the framing
rectangle of the Shape in double
precision.
return getX() + getWidth() / 2.0;
|
public double | getCenterY()Returns the Y coordinate of the center of the framing
rectangle of the Shape in double
precision.
return getY() + getHeight() / 2.0;
|
public java.awt.geom.Rectangle2D | getFrame()Returns the framing {@link Rectangle2D}
that defines the overall shape of this object.
return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight());
|
public abstract double | getHeight()Returns the height of the framing rectangle
in double precision.
|
public double | getMaxX()Returns the largest X coordinate of the framing
rectangle of the Shape in double
precision.
return getX() + getWidth();
|
public double | getMaxY()Returns the largest Y coordinate of the framing
rectangle of the Shape in double
precision.
return getY() + getHeight();
|
public double | getMinX()Returns the smallest X coordinate of the framing
rectangle of the Shape in double
precision.
return getX();
|
public double | getMinY()Returns the smallest Y coordinate of the framing
rectangle of the Shape in double
precision.
return getY();
|
public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform at, double 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 {@link AffineTransform} can
be specified so that the coordinates returned in the iteration are
transformed accordingly.
return new FlatteningPathIterator(getPathIterator(at), flatness);
|
public abstract double | getWidth()Returns the width of the framing rectangle in
double precision.
|
public abstract double | getX()Returns the X coordinate of the upper left corner of
the framing rectangle in double precision.
|
public abstract double | getY()Returns the Y coordinate of the upper left corner of
the framing rectangle in double precision.
|
public boolean | intersects(java.awt.geom.Rectangle2D r)Tests if the interior of theShape intersects the
interior of a specified Rectangle2D .
return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
public abstract boolean | isEmpty()Determines whether the RectangularShape is empty.
When the RectangularShape is empty, it encloses no
area.
|
public abstract 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.
The framing rectangle is used by the subclasses of
RectangularShape to define their geometry.
|
public void | setFrame(java.awt.geom.Point2D loc, java.awt.geom.Dimension2D size)Sets the location and size of the framing rectangle of this
Shape to the specified {@link Point2D} and
{@link Dimension2D}, respectively. The framing rectangle is used
by the subclasses of RectangularShape to define
their geometry.
setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
|
public void | setFrame(java.awt.geom.Rectangle2D r)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.
setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
public void | setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)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.
double halfW = Math.abs(cornerX - centerX);
double halfH = Math.abs(cornerY - centerY);
setFrame(centerX - halfW, centerY - halfH, halfW * 2.0, halfH * 2.0);
|
public void | setFrameFromCenter(java.awt.geom.Point2D center, java.awt.geom.Point2D corner)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.
setFrameFromCenter(center.getX(), center.getY(),
corner.getX(), corner.getY());
|
public void | setFrameFromDiagonal(double x1, double y1, double x2, double y2)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.
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);
|
public void | setFrameFromDiagonal(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)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.
setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|