public abstract class RectangularShape extends Shape
RectangularShape is the base class for a number of
Shape 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 Shape 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.OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP, RECT_INTERSECTS| Modifier | Constructor and Description |
|---|---|
protected |
RectangularShape()
This is an abstract class that cannot be instantiated directly.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Point2D p)
Tests if a specified
Point2D is inside the boundary
of the Shape. |
RectBounds |
getBounds()
Note that there is no guarantee that the returned
RectBounds is the smallest bounding box that encloses
the Shape, only that the Shape lies
entirely within the indicated RectBounds. |
float |
getCenterX()
Returns the X coordinate of the center of the framing
rectangle of the
Shape in double
precision. |
float |
getCenterY()
Returns the Y coordinate of the center of the framing
rectangle of the
Shape in double
precision. |
abstract float |
getHeight()
Returns the height of the framing rectangle
in
double precision. |
float |
getMaxX()
Returns the largest X coordinate of the framing
rectangle of the
Shape in double
precision. |
float |
getMaxY()
Returns the largest Y coordinate of the framing
rectangle of the
Shape in double
precision. |
float |
getMinX()
Returns the smallest X coordinate of the framing
rectangle of the
Shape in double
precision. |
float |
getMinY()
Returns the smallest Y coordinate of the framing
rectangle of the
Shape in double
precision. |
PathIterator |
getPathIterator(BaseTransform tx,
float 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. |
abstract float |
getWidth()
Returns the width of the framing rectangle in
double precision. |
abstract float |
getX()
Returns the X coordinate of the upper-left corner of
the framing rectangle in
double precision. |
abstract float |
getY()
Returns the Y coordinate of the upper-left corner of
the framing rectangle in
double precision. |
abstract boolean |
isEmpty()
Determines whether the
RectangularShape is empty. |
abstract void |
setFrame(float x,
float y,
float w,
float h)
Sets the location and size of the framing rectangle of this
Shape to the specified rectangular values. |
void |
setFrame(Point2D loc,
Dimension2D size)
Sets the location and size of the framing rectangle of this
Shape to the specified Point2D and
Dimension2D, respectively. |
void |
setFrameFromCenter(float centerX,
float centerY,
float cornerX,
float cornerY)
Sets the framing rectangle of this
Shape
based on the specified center point coordinates and corner point
coordinates. |
void |
setFrameFromCenter(Point2D center,
Point2D corner)
Sets the framing rectangle of this
Shape based on a
specified center Point2D and corner
Point2D. |
void |
setFrameFromDiagonal(float x1,
float y1,
float x2,
float y2)
Sets the diagonal of the framing rectangle of this
Shape
based on the two specified coordinates. |
void |
setFrameFromDiagonal(Point2D p1,
Point2D p2)
Sets the diagonal of the framing rectangle of this
Shape
based on two specified Point2D objects. |
java.lang.String |
toString() |
accumulate, accumulateCubic, accumulateCubic, accumulateQuad, contains, contains, contains, copy, getPathIterator, intersects, intersects, intersectsLine, outcode, pointCrossingsForCubic, pointCrossingsForLine, pointCrossingsForPath, pointCrossingsForQuad, rectCrossingsForCubic, rectCrossingsForLine, rectCrossingsForPath, rectCrossingsForQuadprotected RectangularShape()
Arc2D,
Ellipse2D,
Rectangle2D,
RoundRectangle2Dpublic abstract float getX()
double precision.public abstract float getY()
double precision.public abstract float getWidth()
double precision.public abstract float getHeight()
double precision.public float getMinX()
Shape in double
precision.Shape.public float getMinY()
Shape in double
precision.Shape.public float getMaxX()
Shape in double
precision.Shape.public float getMaxY()
Shape in double
precision.Shape.public float getCenterX()
Shape in double
precision.Shape.public float getCenterY()
Shape in double
precision.Shape.public abstract boolean isEmpty()
RectangularShape is empty.
When the RectangularShape is empty, it encloses no
area.true if the RectangularShape is empty;
false otherwise.public abstract void setFrame(float x,
float y,
float w,
float h)
Shape to the specified rectangular values.x - the X coordinate of the upper-left corner of the
specified rectangular shapey - the Y coordinate of the upper-left corner of the
specified rectangular shapew - the width of the specified rectangular shapeh - the height of the specified rectangular shape#getFramepublic void setFrame(Point2D loc, Dimension2D size)
Shape to the specified Point2D and
Dimension2D, respectively. The framing rectangle is used
by the subclasses of RectangularShape to define
their geometry.loc - the specified Point2Dsize - the specified Dimension2D#getFramepublic void setFrameFromDiagonal(float x1,
float y1,
float x2,
float y2)
Shape
based on the two specified coordinates. The framing rectangle is
used by the subclasses of RectangularShape to define
their geometry.x1 - the X coordinate of the start point of the specified diagonaly1 - the Y coordinate of the start point of the specified diagonalx2 - the X coordinate of the end point of the specified diagonaly2 - the Y coordinate of the end point of the specified diagonalpublic void setFrameFromDiagonal(Point2D p1, Point2D p2)
Shape
based on two specified Point2D objects. The framing
rectangle is used by the subclasses of RectangularShape
to define their geometry.p1 - the start Point2D of the specified diagonalp2 - the end Point2D of the specified diagonalpublic void setFrameFromCenter(float centerX,
float centerY,
float cornerX,
float cornerY)
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.centerX - the X coordinate of the specified center pointcenterY - the Y coordinate of the specified center pointcornerX - the X coordinate of the specified corner pointcornerY - the Y coordinate of the specified corner pointpublic void setFrameFromCenter(Point2D center, Point2D corner)
Shape based on a
specified center Point2D and corner
Point2D. The framing rectangle is used by the subclasses
of RectangularShape to define their geometry.center - the specified center Point2Dcorner - the specified corner Point2Dpublic boolean contains(Point2D p)
Point2D is inside the boundary
of the Shape.public RectBounds getBounds()
RectBounds is the smallest bounding box that encloses
the Shape, only that the Shape lies
entirely within the indicated RectBounds.public PathIterator getPathIterator(BaseTransform tx, float flatness)
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 BaseTransform can
be specified so that the coordinates returned in the iteration are
transformed accordingly.
getPathIterator in class Shapetx - an optional BaseTransform to be applied to the
coordinates as they are returned in the iteration,
or null if untransformed coordinates are desired.flatness - the maximum distance that the line segments used to
approximate the curved segments are allowed to deviate
from any point on the original curvePathIterator object that provides access to
the Shape object's flattened geometry.public java.lang.String toString()
toString in class java.lang.Object