public class RoundRectangle2D extends RectangularShape
RoundRectangle2D class defines a rectangle with
rounded corners defined by a location (x,y), a
dimension (w x h), and the width and height of an arc
with which to round the corners.| Modifier and Type | Field and Description |
|---|---|
float |
arcHeight
The height of the arc that rounds off the corners.
|
float |
arcWidth
The width of the arc that rounds off the corners.
|
float |
height
The height of this
RoundRectangle2D. |
float |
width
The width of this
RoundRectangle2D. |
float |
x
The X coordinate of this
RoundRectangle2D. |
float |
y
The Y coordinate of this
RoundRectangle2D. |
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP, RECT_INTERSECTS| Constructor and Description |
|---|
RoundRectangle2D()
Constructs a new
RoundRectangle2D, initialized to
location (0.0, 0.0), size (0.0, 0.0), and corner arcs
of radius 0.0. |
RoundRectangle2D(float x,
float y,
float w,
float h,
float arcw,
float arch)
Constructs and initializes a
RoundRectangle2D
from the specified float coordinates. |
| Modifier and Type | Method and Description |
|---|---|
private int |
classify(float coord,
float left,
float right,
float arcsize) |
boolean |
contains(float x,
float y)
Tests if the specified coordinates are inside the boundary of the
Shape. |
boolean |
contains(float x,
float y,
float w,
float h)
Tests if the interior of the
Shape entirely contains
the specified rectangular area. |
RoundRectangle2D |
copy()
Returns a new copy of this
Shape instance. |
boolean |
equals(java.lang.Object obj)
Determines whether or not the specified
Object is
equal to this RoundRectangle2D. |
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 |
getHeight()
Returns the height of the framing rectangle
in
double precision. |
PathIterator |
getPathIterator(BaseTransform tx)
Returns an iteration object that defines the boundary of this
RoundRectangle2D. |
float |
getWidth()
Returns the width of the framing rectangle in
double precision. |
float |
getX()
Returns the X coordinate of the upper-left corner of
the framing rectangle in
double precision. |
float |
getY()
Returns the Y coordinate of the upper-left corner of
the framing rectangle in
double precision. |
int |
hashCode()
Returns the hashcode for this
RoundRectangle2D. |
boolean |
intersects(float x,
float y,
float w,
float h)
Tests if the interior of the
Shape intersects the
interior of a specified rectangular area. |
boolean |
isEmpty()
Determines whether the
RectangularShape is empty. |
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 |
setRoundRect(float x,
float y,
float w,
float h,
float arcw,
float arch)
Sets the location, size, and corner radii of this
RoundRectangle2D to the specified
float values. |
void |
setRoundRect(RoundRectangle2D rr)
Sets this
RoundRectangle2D to be the same as the
specified RoundRectangle2D. |
contains, getCenterX, getCenterY, getMaxX, getMaxY, getMinX, getMinY, getPathIterator, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal, toStringaccumulate, accumulateCubic, accumulateCubic, accumulateQuad, contains, intersects, intersectsLine, outcode, pointCrossingsForCubic, pointCrossingsForLine, pointCrossingsForPath, pointCrossingsForQuad, rectCrossingsForCubic, rectCrossingsForLine, rectCrossingsForPath, rectCrossingsForQuadpublic float x
RoundRectangle2D.public float y
RoundRectangle2D.public float width
RoundRectangle2D.public float height
RoundRectangle2D.public float arcWidth
public float arcHeight
public RoundRectangle2D()
RoundRectangle2D, initialized to
location (0.0, 0.0), size (0.0, 0.0), and corner arcs
of radius 0.0.public RoundRectangle2D(float x,
float y,
float w,
float h,
float arcw,
float arch)
RoundRectangle2D
from the specified float coordinates.x - the X coordinate of the newly
constructed RoundRectangle2Dy - the Y coordinate of the newly
constructed RoundRectangle2Dw - the width to which to set the newly
constructed RoundRectangle2Dh - the height to which to set the newly
constructed RoundRectangle2Darcw - the width of the arc to use to round off the
corners of the newly constructed
RoundRectangle2Darch - the height of the arc to use to round off the
corners of the newly constructed
RoundRectangle2Dpublic float getX()
double precision.getX in class RectangularShapepublic float getY()
double precision.getY in class RectangularShapepublic float getWidth()
double precision.getWidth in class RectangularShapepublic float getHeight()
double precision.getHeight in class RectangularShapepublic boolean isEmpty()
RectangularShape is empty.
When the RectangularShape is empty, it encloses no
area.isEmpty in class RectangularShapetrue if the RectangularShape is empty;
false otherwise.public void setRoundRect(float x,
float y,
float w,
float h,
float arcw,
float arch)
RoundRectangle2D to the specified
float values.x - the X coordinate to which to set the
location of this RoundRectangle2Dy - the Y coordinate to which to set the
location of this RoundRectangle2Dw - the width to which to set this
RoundRectangle2Dh - the height to which to set this
RoundRectangle2Darcw - the width to which to set the arc of this
RoundRectangle2Darch - the height to which to set the arc of this
RoundRectangle2Dpublic RectBounds getBounds()
RectBounds is the smallest bounding box that encloses
the Shape, only that the Shape lies
entirely within the indicated RectBounds.getBounds in class RectangularShapeRectBoundspublic void setRoundRect(RoundRectangle2D rr)
RoundRectangle2D to be the same as the
specified RoundRectangle2D.rr - the specified RoundRectangle2Dpublic void setFrame(float x,
float y,
float w,
float h)
Shape to the specified rectangular values.setFrame in class RectangularShapex - 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 boolean contains(float x,
float y)
Shape.private int classify(float coord,
float left,
float right,
float arcsize)
public boolean intersects(float x,
float y,
float w,
float h)
Shape intersects the
interior of a specified rectangular area.
The rectangular area is considered to intersect the Shape
if any point is contained in both the interior of the
Shape and the specified rectangular area.
The Shape.intersects() method allows a Shape
implementation to conservatively return true when:
Shape intersect, but
Shapes this method might
return true even though the rectangular area does not
intersect the Shape.
The Area class performs
more accurate computations of geometric intersection than most
Shape objects and therefore can be used if a more precise
answer is required.intersects in class Shapex - the X coordinate of the upper-left corner
of the specified rectangular areay - the Y coordinate of the upper-left corner
of the specified rectangular areaw - the width of the specified rectangular areah - the height of the specified rectangular areatrue if the interior of the Shape and
the interior of the rectangular area intersect, or are
both highly likely to intersect and intersection calculations
would be too expensive to perform; false otherwise.public boolean contains(float x,
float y,
float w,
float h)
Shape entirely contains
the specified rectangular area. All coordinates that lie inside
the rectangular area must lie within the Shape for the
entire rectanglar area to be considered contained within the
Shape.
The Shape.contains() method allows a Shape
implementation to conservatively return false when:
intersect method returns true and
Shape entirely contains the rectangular area are
prohibitively expensive.
Shapes this method might
return false even though the Shape contains
the rectangular area.
The Area class performs
more accurate geometric computations than most
Shape objects and therefore can be used if a more precise
answer is required.contains in class Shapex - the X coordinate of the upper-left corner
of the specified rectangular areay - the Y coordinate of the upper-left corner
of the specified rectangular areaw - the width of the specified rectangular areah - the height of the specified rectangular areatrue if the interior of the Shape
entirely contains the specified rectangular area;
false otherwise or, if the Shape
contains the rectangular area and the
intersects method returns true
and the containment calculations would be too expensive to
perform.Shape.intersects(float, float, float, float)public PathIterator getPathIterator(BaseTransform tx)
RoundRectangle2D.
The iterator for this class is multi-threaded safe, which means
that this RoundRectangle2D class guarantees that
modifications to the geometry of this RoundRectangle2D
object do not affect any iterations of that geometry that
are already in process.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 desiredPathIterator object that returns the
geometry of the outline of this
RoundRectangle2D, one segment at a time.public RoundRectangle2D copy()
ShapeShape instance.public int hashCode()
RoundRectangle2D.hashCode in class java.lang.ObjectRoundRectangle2D.public boolean equals(java.lang.Object obj)
Object is
equal to this RoundRectangle2D. The specified
Object is equal to this RoundRectangle2D
if it is an instance of RoundRectangle2D and if its
location, size, and corner arc dimensions are the same as this
RoundRectangle2D.equals in class java.lang.Objectobj - an Object to be compared with this
RoundRectangle2D.true if obj is an instance
of RoundRectangle2D and has the same values;
false otherwise.