public final class RoundedRectangle extends AbstractRectangleBasedGeometry<RoundedRectangle,PolyBezier> implements IShape
arc-width width .-------------------. .--------. +----+-----+-----+----+ / / | ^ ^ | arc- | | | | | | height | | + <- arc end point -> + | | | | | \ | | height | + + | | | | | | | + <- arc end point -> + | | | | | \ | v v | +----+-----+-----+----+The maximum value for the arc-width is the width of the rectangle and the maximum value for the arc-height is the height of the rectangle. For the maximal values, the end points of the arcs are at the centers of the sides of the rectangle.
Note that while all manipulations (e.g. within shrink, expand) within this
class are based on double precision, all comparisons (e.g. within contains,
intersects, equals, etc.) are based on a limited precision (with an accuracy
defined within PrecisionUtils
) to compensate for rounding effects.
Constructor and Description |
---|
RoundedRectangle(double x,
double y,
double width,
double height,
double arcWidth,
double arcHeight)
Constructs a new
RoundedRectangle from the given bounds and arc
values. |
RoundedRectangle(Rectangle r,
double arcWidth,
double arcHeight)
Constructs a new
RoundedRectangle from the bounds of the given
Rectangle and the given arc values. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
boolean |
contains(IGeometry g)
|
boolean |
contains(Point p)
|
boolean |
equals(java.lang.Object obj) |
double |
getArcHeight()
Returns the arc height of this
RoundedRectangle , which is the
height of the arc used to define its rounded corners. |
double |
getArcWidth()
Returns the arc width of this
RoundedRectangle , which is the
width of the arc used to define its rounded corners. |
Line |
getBottom()
Returns the bottom edge of this
RoundedRectangle . |
Arc |
getBottomLeftArc()
Returns the bottom left
Arc of this RoundedRectangle . |
Arc |
getBottomRightArc()
Returns the bottom right
Arc of this RoundedRectangle . |
RoundedRectangle |
getCopy()
Returns a new identical copy of this
IGeometry . |
protected double |
getEffectiveArcHeight()
Returns the effective arc height, i.e. clamped to the range
[0;height] . |
protected double |
getEffectiveArcWidth()
Returns the effective arc width, i.e. clamped to the range
[0;width] . |
Line |
getLeft()
Returns the left edge of this
RoundedRectangle . |
PolyBezier |
getOutline()
|
BezierCurve[] |
getOutlineSegments()
|
Line |
getRight()
Returns the right edge of this
RoundedRectangle . |
PolyBezier |
getRotatedCCW(Angle angle)
|
PolyBezier |
getRotatedCCW(Angle angle,
double cx,
double cy)
|
PolyBezier |
getRotatedCCW(Angle angle,
Point center)
|
PolyBezier |
getRotatedCW(Angle angle)
|
PolyBezier |
getRotatedCW(Angle angle,
double cx,
double cy)
|
PolyBezier |
getRotatedCW(Angle angle,
Point center)
|
Line |
getTop()
Returns the top edge of this
RoundedRectangle . |
Arc |
getTopLeftArc()
Returns the top left
Arc of this RoundedRectangle . |
Arc |
getTopRightArc()
Returns the top right
Arc of this RoundedRectangle . |
CurvedPolygon |
getTransformed(AffineTransform t)
|
int |
hashCode() |
RoundedRectangle |
setArcHeight(double arcHeight)
Sets the arc height of this
RoundedRectangle , which is the height
of the arc used to define its rounded corners. |
RoundedRectangle |
setArcWidth(double arcWidth)
Sets the arc width of this
RoundedRectangle , which is the width
of the arc used to define its rounded corners. |
Path |
toPath()
|
java.lang.String |
toString() |
boolean |
touches(IGeometry g)
|
expand, expand, getBounds, getCenter, getExpanded, getExpanded, getHeight, getLocation, getScaled, getScaled, getScaled, getScaled, getScaled, getScaled, getShrinked, getShrinked, getSize, getTranslated, getTranslated, getWidth, getX, getY, scale, scale, scale, scale, scale, scale, setBounds, setBounds, setBounds, setHeight, setLocation, setLocation, setSize, setSize, setWidth, setX, setY, shrink, shrink, translate, translate
public RoundedRectangle(double x, double y, double width, double height, double arcWidth, double arcHeight)
RoundedRectangle
from the given bounds and arc
values.x
- the x-coordinate of the new RoundedRectangle
's boundsy
- the y-coordinate of the new RoundedRectangle
's boundswidth
- the width of the new RoundedRectangle
's boundsheight
- the height of the new RoundedRectangle
's boundsarcWidth
- the arc width of the new RoundedRectangle
rounded
cornersarcHeight
- the arc height of the new RoundedRectangle
rounded
cornerspublic RoundedRectangle(Rectangle r, double arcWidth, double arcHeight)
RoundedRectangle
from the bounds of the given
Rectangle
and the given arc values.r
- the Rectangle
, whose bounds are used to initialize the
x, y, width, and height values of the new
RoundedRectangle
arcWidth
- the arc width of the new RoundedRectangle
rounded
cornersarcHeight
- the arc height of the new RoundedRectangle
rounded
cornerspublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public double getArcHeight()
RoundedRectangle
, which is the
height of the arc used to define its rounded corners.public double getArcWidth()
RoundedRectangle
, which is the
width of the arc used to define its rounded corners.public Line getBottom()
RoundedRectangle
.RoundedRectangle
.public Arc getBottomLeftArc()
Arc
of this RoundedRectangle
.Arc
of this RoundedRectangle
.public Arc getBottomRightArc()
Arc
of this RoundedRectangle
.Arc
of this RoundedRectangle
.public RoundedRectangle getCopy()
IGeometry
IGeometry
.getCopy
in interface IGeometry
IGeometry
IGeometry.getCopy()
protected double getEffectiveArcHeight()
[0;height]
.[0;height]
.protected double getEffectiveArcWidth()
[0;width]
.[0;width]
.public Line getLeft()
RoundedRectangle
.RoundedRectangle
.public PolyBezier getOutline()
IShape
getOutline
in interface IShape
ICurve
representing this IShape
's outline.public BezierCurve[] getOutlineSegments()
IShape
getOutlineSegments
in interface IShape
ICurve
segments of this IShape
's outline.IShape.getOutlineSegments()
public Line getRight()
RoundedRectangle
.RoundedRectangle
.public PolyBezier getRotatedCCW(Angle angle)
IRotatable
Angle
counter-clock-wise
(CCW) around its center Point
. Does not necessarily return an
object of the same type.getRotatedCCW
in interface IRotatable<PolyBezier>
angle
- rotation Angle
IGeometry
representing the result of the rotationpublic PolyBezier getRotatedCCW(Angle angle, double cx, double cy)
IRotatable
Angle
counter-clock-wise (CCW) around the specified center Point
(cx,
cy). Does not necessarily return an object of the same type.getRotatedCCW
in interface IRotatable<PolyBezier>
angle
- rotation Angle
cx
- x-coordinate of the relative Point
for the rotationcy
- y-coordinate of the relative Point
for the rotationIGeometry
representing the result of the rotationpublic PolyBezier getRotatedCCW(Angle angle, Point center)
IRotatable
Angle
counter-clock-wise (CCW) around the specified center Point
. Does
not necessarily return an object of the same type.getRotatedCCW
in interface IRotatable<PolyBezier>
angle
- rotation Angle
center
- relative Point
for the rotationIGeometry
representing the result of the rotationpublic PolyBezier getRotatedCW(Angle angle)
IRotatable
Angle
clock-wise (CW)
around its center Point
. Does not necessarily return an object of
the same type.getRotatedCW
in interface IRotatable<PolyBezier>
angle
- rotation Angle
IGeometry
representing the result of the rotationpublic PolyBezier getRotatedCW(Angle angle, double cx, double cy)
IRotatable
Angle
clock-wise (CW)
around the specified center Point
(cx, cy). Does not necessarily
return an object of the same type.getRotatedCW
in interface IRotatable<PolyBezier>
angle
- rotation Angle
cx
- x-coordinate of the relative Point
for the rotationcy
- y-coordinate of the relative Point
for the rotationIGeometry
representing the result of the rotationpublic PolyBezier getRotatedCW(Angle angle, Point center)
IRotatable
Angle
clock-wise (CW)
around the specified center Point
. Does not necessarily return an
object of the same type.getRotatedCW
in interface IRotatable<PolyBezier>
angle
- rotation Angle
center
- relative Point
for the rotationIGeometry
representing the result of the rotationpublic Line getTop()
RoundedRectangle
.RoundedRectangle
.public Arc getTopLeftArc()
Arc
of this RoundedRectangle
.Arc
of this RoundedRectangle
.public Arc getTopRightArc()
Arc
of this RoundedRectangle
.Arc
of this RoundedRectangle
.public CurvedPolygon getTransformed(AffineTransform t)
Path
representation of this IGeometry
. Subclasses may override this
method to return a more specific representation.getTransformed
in interface IGeometry
getTransformed
in interface IShape
t
- The AffineTransform
to be appliedPath
representation of this
IGeometry
IGeometry.getTransformed(AffineTransform)
public RoundedRectangle setArcHeight(double arcHeight)
RoundedRectangle
, which is the height
of the arc used to define its rounded corners.arcHeight
- the new arc heightthis
for conveniencepublic RoundedRectangle setArcWidth(double arcWidth)
RoundedRectangle
, which is the width
of the arc used to define its rounded corners.arcWidth
- the new arc widththis
for conveniencepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
Cloneable
.clone
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
Copyright (c) 2014 itemis AG, and others. All rights reserved.