- 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 SummaryConstructorsModifierConstructorDescriptionprotectedThis is an abstract class that cannot be instantiated directly.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Creates a new object of the same class and with the same contents as this object.booleanTests if a specifiedPoint2Dis inside the boundary of theShape, as described by the definition of insideness.booleanTests if the interior of theShapeentirely contains the specifiedRectangle2D.Returns an integerRectanglethat completely encloses theShape.doubleReturns the X coordinate of the center of the framing rectangle of theShapeindoubleprecision.doubleReturns the Y coordinate of the center of the framing rectangle of theShapeindoubleprecision.getFrame()Returns the framingRectangle2Dthat defines the overall shape of this object.abstract doubleReturns the height of the framing rectangle indoubleprecision.doublegetMaxX()Returns the largest X coordinate of the framing rectangle of theShapeindoubleprecision.doublegetMaxY()Returns the largest Y coordinate of the framing rectangle of theShapeindoubleprecision.doublegetMinX()Returns the smallest X coordinate of the framing rectangle of theShapeindoubleprecision.doublegetMinY()Returns the smallest Y coordinate of the framing rectangle of theShapeindoubleprecision.getPathIterator(AffineTransform at, double flatness) Returns an iterator object that iterates along theShapeobject's boundary and provides access to a flattened view of the outline of theShapeobject's geometry.abstract doublegetWidth()Returns the width of the framing rectangle indoubleprecision.abstract doublegetX()Returns the X coordinate of the upper-left corner of the framing rectangle indoubleprecision.abstract doublegetY()Returns the Y coordinate of the upper-left corner of the framing rectangle indoubleprecision.booleanTests if the interior of theShapeintersects the interior of a specifiedRectangle2D.abstract booleanisEmpty()Determines whether theRectangularShapeis empty.abstract voidsetFrame(double x, double y, double w, double h) Sets the location and size of the framing rectangle of thisShapeto the specified rectangular values.voidsetFrame(Point2D loc, Dimension2D size) Sets the location and size of the framing rectangle of thisShapeto the specifiedPoint2DandDimension2D, respectively.voidSets the framing rectangle of thisShapeto be the specifiedRectangle2D.voidsetFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY) Sets the framing rectangle of thisShapebased on the specified center point coordinates and corner point coordinates.voidsetFrameFromCenter(Point2D center, Point2D corner) Sets the framing rectangle of thisShapebased on a specified centerPoint2Dand cornerPoint2D.voidsetFrameFromDiagonal(double x1, double y1, double x2, double y2) Sets the diagonal of the framing rectangle of thisShapebased on the two specified coordinates.voidsetFrameFromDiagonal(Point2D p1, Point2D p2) Sets the diagonal of the framing rectangle of thisShapebased on two specifiedPoint2Dobjects.Methods declared in class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface java.awt.Shapecontains, contains, getBounds2D, getPathIterator, intersects
- 
Constructor Details- 
RectangularShapeprotected RectangularShape()This is an abstract class that cannot be instantiated directly.- Since:
- 1.2
- See Also:
 
 
- 
- 
Method Details- 
getXpublic abstract double getX()Returns the X coordinate of the upper-left corner of the framing rectangle indoubleprecision.- Returns:
- the X coordinate of the upper-left corner of the framing rectangle.
- Since:
- 1.2
 
- 
getYpublic abstract double getY()Returns the Y coordinate of the upper-left corner of the framing rectangle indoubleprecision.- Returns:
- the Y coordinate of the upper-left corner of the framing rectangle.
- Since:
- 1.2
 
- 
getWidthpublic abstract double getWidth()Returns the width of the framing rectangle indoubleprecision.- Returns:
- the width of the framing rectangle.
- Since:
- 1.2
 
- 
getHeightpublic abstract double getHeight()Returns the height of the framing rectangle indoubleprecision.- Returns:
- the height of the framing rectangle.
- Since:
- 1.2
 
- 
getMinXpublic double getMinX()Returns the smallest X coordinate of the framing rectangle of theShapeindoubleprecision.- Returns:
- the smallest X coordinate of the framing
          rectangle of the Shape.
- Since:
- 1.2
 
- 
getMinYpublic double getMinY()Returns the smallest Y coordinate of the framing rectangle of theShapeindoubleprecision.- Returns:
- the smallest Y coordinate of the framing
          rectangle of the Shape.
- Since:
- 1.2
 
- 
getMaxXpublic double getMaxX()Returns the largest X coordinate of the framing rectangle of theShapeindoubleprecision.- Returns:
- the largest X coordinate of the framing
          rectangle of the Shape.
- Since:
- 1.2
 
- 
getMaxYpublic double getMaxY()Returns the largest Y coordinate of the framing rectangle of theShapeindoubleprecision.- Returns:
- the largest Y coordinate of the framing
          rectangle of the Shape.
- Since:
- 1.2
 
- 
getCenterXpublic double getCenterX()Returns the X coordinate of the center of the framing rectangle of theShapeindoubleprecision.- Returns:
- the X coordinate of the center of the framing rectangle
          of the Shape.
- Since:
- 1.2
 
- 
getCenterYpublic double getCenterY()Returns the Y coordinate of the center of the framing rectangle of theShapeindoubleprecision.- Returns:
- the Y coordinate of the center of the framing rectangle
          of the Shape.
- Since:
- 1.2
 
- 
getFrameReturns the framingRectangle2Dthat defines the overall shape of this object.- Returns:
- a Rectangle2D, specified indoublecoordinates.
- Since:
- 1.2
- See Also:
 
- 
isEmptypublic abstract boolean isEmpty()Determines whether theRectangularShapeis empty. When theRectangularShapeis empty, it encloses no area.- Returns:
- trueif the- RectangularShapeis empty;- falseotherwise.
- Since:
- 1.2
 
- 
setFramepublic abstract void setFrame(double x, double y, double w, double h) Sets the location and size of the framing rectangle of thisShapeto the specified rectangular values.- Parameters:
- x- the X coordinate of the upper-left corner of the specified rectangular shape
- y- the Y coordinate of the upper-left corner of the specified rectangular shape
- w- the width of the specified rectangular shape
- h- the height of the specified rectangular shape
- Since:
- 1.2
- See Also:
 
- 
setFrameSets the location and size of the framing rectangle of thisShapeto the specifiedPoint2DandDimension2D, respectively. The framing rectangle is used by the subclasses ofRectangularShapeto define their geometry.- Parameters:
- loc- the specified- Point2D
- size- the specified- Dimension2D
- Since:
- 1.2
- See Also:
 
- 
setFrameSets the framing rectangle of thisShapeto be the specifiedRectangle2D. The framing rectangle is used by the subclasses ofRectangularShapeto define their geometry.- Parameters:
- r- the specified- Rectangle2D
- Since:
- 1.2
- See Also:
 
- 
setFrameFromDiagonalpublic void setFrameFromDiagonal(double x1, double y1, double x2, double y2) Sets the diagonal of the framing rectangle of thisShapebased on the two specified coordinates. The framing rectangle is used by the subclasses ofRectangularShapeto define their geometry.- Parameters:
- x1- the X coordinate of the start point of the specified diagonal
- y1- the Y coordinate of the start point of the specified diagonal
- x2- the X coordinate of the end point of the specified diagonal
- y2- the Y coordinate of the end point of the specified diagonal
- Since:
- 1.2
 
- 
setFrameFromDiagonalSets the diagonal of the framing rectangle of thisShapebased on two specifiedPoint2Dobjects. The framing rectangle is used by the subclasses ofRectangularShapeto define their geometry.- Parameters:
- p1- the start- Point2Dof the specified diagonal
- p2- the end- Point2Dof the specified diagonal
- Since:
- 1.2
 
- 
setFrameFromCenterpublic void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY) Sets the framing rectangle of thisShapebased on the specified center point coordinates and corner point coordinates. The framing rectangle is used by the subclasses ofRectangularShapeto define their geometry.- Parameters:
- centerX- the X coordinate of the specified center point
- centerY- the Y coordinate of the specified center point
- cornerX- the X coordinate of the specified corner point
- cornerY- the Y coordinate of the specified corner point
- Since:
- 1.2
 
- 
setFrameFromCenterSets the framing rectangle of thisShapebased on a specified centerPoint2Dand cornerPoint2D. The framing rectangle is used by the subclasses ofRectangularShapeto define their geometry.- Parameters:
- center- the specified center- Point2D
- corner- the specified corner- Point2D
- Since:
- 1.2
 
- 
containsTests if a specifiedPoint2Dis inside the boundary of theShape, as described by the definition of insideness.
- 
intersectsTests if the interior of theShapeintersects the interior of a specifiedRectangle2D. TheShape.intersects()method allows aShapeimplementation to conservatively returntruewhen:- 
 there is a high probability that the Rectangle2Dand theShapeintersect, but
- the calculations to accurately determine this intersection are prohibitively expensive.
 Shapesthis method might returntrueeven though theRectangle2Ddoes not intersect theShape. TheAreaclass performs more accurate computations of geometric intersection than mostShapeobjects and therefore can be used if a more precise answer is required.- Specified by:
- intersectsin interface- Shape
- Parameters:
- r- the specified- Rectangle2D
- Returns:
- trueif the interior of the- Shapeand the interior of the specified- Rectangle2Dintersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform;- falseotherwise.
- Since:
- 1.2
- See Also:
 
- 
 there is a high probability that the 
- 
containsTests if the interior of theShapeentirely contains the specifiedRectangle2D. TheShape.contains()method allows aShapeimplementation to conservatively returnfalsewhen:- 
 the intersectmethod returnstrueand
- 
 the calculations to determine whether or not the
 Shapeentirely contains theRectangle2Dare prohibitively expensive.
 Shapesthis method might returnfalseeven though theShapecontains theRectangle2D. TheAreaclass performs more accurate geometric computations than mostShapeobjects and therefore can be used if a more precise answer is required.- Specified by:
- containsin interface- Shape
- Parameters:
- r- The specified- Rectangle2D
- Returns:
- trueif the interior of the- Shapeentirely contains the- Rectangle2D;- falseotherwise or, if the- Shapecontains the- Rectangle2Dand the- intersectsmethod returns- trueand the containment calculations would be too expensive to perform.
- Since:
- 1.2
- See Also:
 
- 
 the 
- 
getBoundsReturns an integerRectanglethat completely encloses theShape. Note that there is no guarantee that the returnedRectangleis the smallest bounding box that encloses theShape, only that theShapelies entirely within the indicatedRectangle. The returnedRectanglemight also fail to completely enclose theShapeif theShapeoverflows the limited range of the integer data type. ThegetBounds2Dmethod 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 shapemay not be considered contained in the returnedboundsobject, but only in cases where those points are also not considered contained in the originalshape.If a pointis inside theshapeaccording to thecontains(point)method, then it must be inside the returnedRectanglebounds object according to thecontains(point)method of thebounds. Specifically:shape.contains(x,y)requiresbounds.contains(x,y)If a pointis not inside theshape, then it might still be contained in theboundsobject:bounds.contains(x,y)does not implyshape.contains(x,y)
- 
getPathIteratorReturns an iterator object that iterates along theShapeobject's boundary and provides access to a flattened view of the outline of theShapeobject'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 flatnessparameter, which specifies the maximum distance that any point on the unflattened transformed curve can deviate from the returned flattened path segments. An optionalAffineTransformcan be specified so that the coordinates returned in the iteration are transformed accordingly.- Specified by:
- getPathIteratorin interface- Shape
- Parameters:
- at- an optional- AffineTransformto be applied to the coordinates as they are returned in the iteration, or- nullif 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 PathIteratorobject that provides access to theShapeobject's flattened geometry.
- Since:
- 1.2
 
- 
cloneCreates a new object of the same class and with the same contents as this object.- Overrides:
- clonein class- Object
- Returns:
- a clone of this instance.
- Throws:
- OutOfMemoryError- if there is not enough memory.
- Since:
- 1.2
- See Also:
 
 
-