 Direct Known Subclasses:
Arc2D
,Ellipse2D
,Rectangle2D
,RoundRectangle2D
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. Since:
 1.2

Constructor Summary
ModifierConstructorDescriptionprotected
This is an abstract class that cannot be instantiated directly. 
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a new object of the same class and with the same contents as this object.boolean
Tests if a specifiedPoint2D
is inside the boundary of theShape
, as described by the definition of insideness.boolean
Tests if the interior of theShape
entirely contains the specifiedRectangle2D
.Returns an integerRectangle
that completely encloses theShape
.double
Returns the X coordinate of the center of the framing rectangle of theShape
indouble
precision.double
Returns the Y coordinate of the center of the framing rectangle of theShape
indouble
precision.getFrame()
Returns the framingRectangle2D
that defines the overall shape of this object.abstract double
Returns the height of the framing rectangle indouble
precision.double
getMaxX()
Returns the largest X coordinate of the framing rectangle of theShape
indouble
precision.double
getMaxY()
Returns the largest Y coordinate of the framing rectangle of theShape
indouble
precision.double
getMinX()
Returns the smallest X coordinate of the framing rectangle of theShape
indouble
precision.double
getMinY()
Returns the smallest Y coordinate of the framing rectangle of theShape
indouble
precision.getPathIterator
(AffineTransform at, double flatness) Returns an iterator object that iterates along theShape
object's boundary and provides access to a flattened view of the outline of theShape
object's geometry.abstract double
getWidth()
Returns the width of the framing rectangle indouble
precision.abstract double
getX()
Returns the X coordinate of the upperleft corner of the framing rectangle indouble
precision.abstract double
getY()
Returns the Y coordinate of the upperleft corner of the framing rectangle indouble
precision.boolean
Tests if the interior of theShape
intersects the interior of a specifiedRectangle2D
.abstract boolean
isEmpty()
Determines whether theRectangularShape
is empty.abstract void
setFrame
(double x, double y, double w, double h) Sets the location and size of the framing rectangle of thisShape
to the specified rectangular values.void
setFrame
(Point2D loc, Dimension2D size) Sets the location and size of the framing rectangle of thisShape
to the specifiedPoint2D
andDimension2D
, respectively.void
Sets the framing rectangle of thisShape
to be the specifiedRectangle2D
.void
setFrameFromCenter
(double centerX, double centerY, double cornerX, double cornerY) Sets the framing rectangle of thisShape
based on the specified center point coordinates and corner point coordinates.void
setFrameFromCenter
(Point2D center, Point2D corner) Sets the framing rectangle of thisShape
based on a specified centerPoint2D
and cornerPoint2D
.void
setFrameFromDiagonal
(double x1, double y1, double x2, double y2) Sets the diagonal of the framing rectangle of thisShape
based on the two specified coordinates.void
setFrameFromDiagonal
(Point2D p1, Point2D p2) Sets the diagonal of the framing rectangle of thisShape
based on two specifiedPoint2D
objects.Methods declared in class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface java.awt.Shape
contains, contains, getBounds2D, getPathIterator, intersects

Constructor Details

RectangularShape
protected RectangularShape()This is an abstract class that cannot be instantiated directly. Since:
 1.2
 See Also:


Method Details

getX
public abstract double getX()Returns the X coordinate of the upperleft corner of the framing rectangle indouble
precision. Returns:
 the X coordinate of the upperleft corner of the framing rectangle.
 Since:
 1.2

getY
public abstract double getY()Returns the Y coordinate of the upperleft corner of the framing rectangle indouble
precision. Returns:
 the Y coordinate of the upperleft corner of the framing rectangle.
 Since:
 1.2

getWidth
public abstract double getWidth()Returns the width of the framing rectangle indouble
precision. Returns:
 the width of the framing rectangle.
 Since:
 1.2

getHeight
public abstract double getHeight()Returns the height of the framing rectangle indouble
precision. Returns:
 the height of the framing rectangle.
 Since:
 1.2

getMinX
public double getMinX()Returns the smallest X coordinate of the framing rectangle of theShape
indouble
precision. Returns:
 the smallest X coordinate of the framing
rectangle of the
Shape
.  Since:
 1.2

getMinY
public double getMinY()Returns the smallest Y coordinate of the framing rectangle of theShape
indouble
precision. Returns:
 the smallest Y coordinate of the framing
rectangle of the
Shape
.  Since:
 1.2

getMaxX
public double getMaxX()Returns the largest X coordinate of the framing rectangle of theShape
indouble
precision. Returns:
 the largest X coordinate of the framing
rectangle of the
Shape
.  Since:
 1.2

getMaxY
public double getMaxY()Returns the largest Y coordinate of the framing rectangle of theShape
indouble
precision. Returns:
 the largest Y coordinate of the framing
rectangle of the
Shape
.  Since:
 1.2

getCenterX
public double getCenterX()Returns the X coordinate of the center of the framing rectangle of theShape
indouble
precision. Returns:
 the X coordinate of the center of the framing rectangle
of the
Shape
.  Since:
 1.2

getCenterY
public double getCenterY()Returns the Y coordinate of the center of the framing rectangle of theShape
indouble
precision. Returns:
 the Y coordinate of the center of the framing rectangle
of the
Shape
.  Since:
 1.2

getFrame
Returns the framingRectangle2D
that defines the overall shape of this object. Returns:
 a
Rectangle2D
, specified indouble
coordinates.  Since:
 1.2
 See Also:

isEmpty
public abstract boolean isEmpty()Determines whether theRectangularShape
is empty. When theRectangularShape
is empty, it encloses no area. Returns:
true
if theRectangularShape
is empty;false
otherwise. Since:
 1.2

setFrame
public abstract void setFrame(double x, double y, double w, double h) Sets the location and size of the framing rectangle of thisShape
to the specified rectangular values. Parameters:
x
 the X coordinate of the upperleft corner of the specified rectangular shapey
 the Y coordinate of the upperleft corner of the specified rectangular shapew
 the width of the specified rectangular shapeh
 the height of the specified rectangular shape Since:
 1.2
 See Also:

setFrame
Sets the location and size of the framing rectangle of thisShape
to the specifiedPoint2D
andDimension2D
, respectively. The framing rectangle is used by the subclasses ofRectangularShape
to define their geometry. Parameters:
loc
 the specifiedPoint2D
size
 the specifiedDimension2D
 Since:
 1.2
 See Also:

setFrame
Sets the framing rectangle of thisShape
to be the specifiedRectangle2D
. The framing rectangle is used by the subclasses ofRectangularShape
to define their geometry. Parameters:
r
 the specifiedRectangle2D
 Since:
 1.2
 See Also:

setFrameFromDiagonal
public void setFrameFromDiagonal(double x1, double y1, double x2, double y2) Sets the diagonal of the framing rectangle of thisShape
based on the two specified coordinates. The framing rectangle is used by the subclasses ofRectangularShape
to define their geometry. Parameters:
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 diagonal Since:
 1.2

setFrameFromDiagonal
Sets the diagonal of the framing rectangle of thisShape
based on two specifiedPoint2D
objects. The framing rectangle is used by the subclasses ofRectangularShape
to define their geometry. Parameters:
p1
 the startPoint2D
of the specified diagonalp2
 the endPoint2D
of the specified diagonal Since:
 1.2

setFrameFromCenter
public void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY) Sets the framing rectangle of thisShape
based on the specified center point coordinates and corner point coordinates. The framing rectangle is used by the subclasses ofRectangularShape
to define their geometry. Parameters:
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 point Since:
 1.2

setFrameFromCenter
Sets the framing rectangle of thisShape
based on a specified centerPoint2D
and cornerPoint2D
. The framing rectangle is used by the subclasses ofRectangularShape
to define their geometry. Parameters:
center
 the specified centerPoint2D
corner
 the specified cornerPoint2D
 Since:
 1.2

contains
Tests if a specifiedPoint2D
is inside the boundary of theShape
, as described by the definition of insideness. 
intersects
Tests if the interior of theShape
intersects the interior of a specifiedRectangle2D
. TheShape.intersects()
method allows aShape
implementation to conservatively returntrue
when:
there is a high probability that the
Rectangle2D
and theShape
intersect, but  the calculations to accurately determine this intersection are prohibitively expensive.
Shapes
this method might returntrue
even though theRectangle2D
does not intersect theShape
. TheArea
class performs more accurate computations of geometric intersection than mostShape
objects and therefore can be used if a more precise answer is required. Specified by:
intersects
in interfaceShape
 Parameters:
r
 the specifiedRectangle2D
 Returns:
true
if the interior of theShape
and the interior of the specifiedRectangle2D
intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform;false
otherwise. Since:
 1.2
 See Also:

there is a high probability that the

contains
Tests if the interior of theShape
entirely contains the specifiedRectangle2D
. TheShape.contains()
method allows aShape
implementation to conservatively returnfalse
when:
the
intersect
method returnstrue
and 
the calculations to determine whether or not the
Shape
entirely contains theRectangle2D
are prohibitively expensive.
Shapes
this method might returnfalse
even though theShape
contains theRectangle2D
. TheArea
class performs more accurate geometric computations than mostShape
objects and therefore can be used if a more precise answer is required. Specified by:
contains
in interfaceShape
 Parameters:
r
 The specifiedRectangle2D
 Returns:
true
if the interior of theShape
entirely contains theRectangle2D
;false
otherwise or, if theShape
contains theRectangle2D
and theintersects
method returnstrue
and the containment calculations would be too expensive to perform. Since:
 1.2
 See Also:

the

getBounds
Returns an integerRectangle
that completely encloses theShape
. Note that there is no guarantee that the returnedRectangle
is the smallest bounding box that encloses theShape
, only that theShape
lies entirely within the indicatedRectangle
. The returnedRectangle
might also fail to completely enclose theShape
if theShape
overflows the limited range of the integer data type. ThegetBounds2D
method generally returns a tighter bounding box due to its greater flexibility in representation.Note that the definition of insideness can lead to situations where points on the defining outline of the
shape
may not be considered contained in the returnedbounds
object, but only in cases where those points are also not considered contained in the originalshape
.If a
point
is inside theshape
according to thecontains(point)
method, then it must be inside the returnedRectangle
bounds object according to thecontains(point)
method of thebounds
. Specifically:shape.contains(x,y)
requiresbounds.contains(x,y)
If a
point
is not inside theshape
, then it might still be contained in thebounds
object:bounds.contains(x,y)
does not implyshape.contains(x,y)

getPathIterator
Returns an iterator object that iterates along theShape
object's boundary and provides access to a flattened view of the outline of theShape
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 optionalAffineTransform
can be specified so that the coordinates returned in the iteration are transformed accordingly. Specified by:
getPathIterator
in interfaceShape
 Parameters:
at
 an optionalAffineTransform
to be applied to the coordinates as they are returned in the iteration, ornull
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 curve Returns:
 a
PathIterator
object that provides access to theShape
object's flattened geometry.  Since:
 1.2

clone
Creates a new object of the same class and with the same contents as this object. Overrides:
clone
in classObject
 Returns:
 a clone of this instance.
 Throws:
OutOfMemoryError
 if there is not enough memory. Since:
 1.2
 See Also:
