public final class RoundedRectangle extends java.lang.Object 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) |
T |
expand(double h,
double v)
Expands the horizontal and vertical sides of this
AbstractRectangleBasedGeometry with the values provided as input,
and returns this for convenience. |
T |
expand(double left,
double top,
double right,
double bottom)
Expands this
AbstractRectangleBasedGeometry by the given amounts,
and returns this for convenience. |
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 . |
Rectangle |
getBounds()
|
Point |
getCenter()
Returns the center
Point of this
AbstractRectangleBasedGeometry . |
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] . |
T |
getExpanded(double h,
double v)
Returns a new expanded
AbstractRectangleBasedGeometry , where the
sides are incremented by the horizontal and vertical values provided. |
T |
getExpanded(double left,
double top,
double right,
double bottom)
Creates and returns a new
AbstractRectangleBasedGeometry with the
bounds of this AbstractRectangleBasedGeometry expanded by the
given insets. |
double |
getHeight()
Returns the height of this
AbstractRectangleBasedGeometry . |
Line |
getLeft()
Returns the left edge of this
RoundedRectangle . |
Point |
getLocation()
Returns a
Point specifying the x and y coordinates of this
AbstractRectangleBasedGeometry . |
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)
|
T |
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its
center
Point . |
T |
getScaled(double factorX,
double factorY)
Scales a copy of the calling object by the given factors relative to its
center
Point . |
T |
getScaled(double factor,
double centerX,
double centerY)
Scales a copy of the calling object by the given factor relative to the
given center
Point (cx, cy). |
T |
getScaled(double factorX,
double factorY,
double centerX,
double centerY)
Scales a copy of the calling object by the given factors relative to the
given center
Point (cx, cy). |
T |
getScaled(double factorX,
double factorY,
Point center)
Scales a copy of the calling object by the given factors relative to the
given center
Point . |
T |
getScaled(double factor,
Point center)
Scales a copy of the calling object by the given factor relative to the
given center
Point . |
T |
getShrinked(double h,
double v)
Returns a new
AbstractRectangleBasedGeometry , where the sides are
shrinked by the horizontal and vertical values supplied. |
T |
getShrinked(double left,
double top,
double right,
double bottom)
Returns a new
AbstractRectangleBasedGeometry shrinked by the
specified insets. |
Dimension |
getSize()
Returns a
Dimension that records the width and height of this
AbstractRectangleBasedGeometry . |
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)
|
T |
getTranslated(double dx,
double dy)
Translates a copy of this object by the given values in x and y
direction.
|
T |
getTranslated(Point pt)
Translates a copy of this object by the given
Point . |
double |
getWidth()
Returns the width of this
AbstractRectangleBasedGeometry . |
double |
getX()
Returns the x coordinate this
AbstractRectangleBasedGeometry . |
double |
getY()
Returns the y coordinate of this
AbstractRectangleBasedGeometry . |
int |
hashCode() |
T |
scale(double factor)
Scales the calling object by the given factor relative to its center
Point . |
T |
scale(double fx,
double fy)
Scales the calling object by the given factors relative to the given
center
Point . |
T |
scale(double factor,
double cx,
double cy)
Scales the calling object by the given factor relative to the given
center
Point (cx, cy). |
T |
scale(double fx,
double fy,
double cx,
double cy)
Scales the calling object by the given factors relative to the given
center
Point (cx, cy). |
T |
scale(double fx,
double fy,
Point center)
Scales the calling object by the given factors relative to the given
center
Point . |
T |
scale(double factor,
Point center)
Scales the calling object by the given factor relative to the given
center
Point . |
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. |
T |
setBounds(double x,
double y,
double w,
double h)
Sets the x, y, width, and height values of this
AbstractRectangleBasedGeometry to the given values. |
T |
setBounds(Point loc,
Dimension size)
|
T |
setBounds(Rectangle r)
Sets the x and y coordinates and the width and height of this
AbstractRectangleBasedGeometry to the respective values of the
given Rectangle . |
T |
setHeight(double height)
Sets the height of this
AbstractRectangleBasedGeometry to the
given value. |
T |
setLocation(double x,
double y)
Sets the x and y coordinates of this
AbstractRectangleBasedGeometry to the specified values. |
T |
setLocation(Point p)
Sets the x and y coordinates of this
AbstractRectangleBasedGeometry to the respective values of the
given Point . |
T |
setSize(Dimension d)
Sets the width and height of this
AbstractRectangleBasedGeometry
to the width and height of the given Dimension . |
T |
setSize(double w,
double h)
Sets the width and height of this
AbstractRectangleBasedGeometry
to the given values. |
T |
setWidth(double width)
Sets the width of this
AbstractRectangleBasedGeometry to the
passed-in value. |
T |
setX(double x)
Sets the x-coordinate of this
AbstractRectangleBasedGeometry to
the given value. |
T |
setY(double y)
Sets the y-coordinate of this
AbstractRectangleBasedGeometry to
the given value. |
T |
shrink(double h,
double v)
Shrinks the sides of this
AbstractRectangleBasedGeometry by the
horizontal and vertical values provided as input, and returns this
AbstractRectangleBasedGeometry for convenience. |
T |
shrink(double left,
double top,
double right,
double bottom)
Shrinks this
AbstractRectangleBasedGeometry by the specified
amounts. |
Path |
toPath()
|
java.lang.String |
toString() |
boolean |
touches(IGeometry g)
|
T |
translate(double dx,
double dy)
Translates the object by the given values in x and y direction.
|
T |
translate(Point p)
Translates the object by the given
Point . |
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 T expand(double h, double v)
AbstractRectangleBasedGeometry
with the values provided as input,
and returns this
for convenience. The location of its center
is kept constant.h
- the horizontal incrementv
- the vertical incrementthis
for conveniencepublic T expand(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry
by the given amounts,
and returns this for convenience.left
- the amount to expand the left sidetop
- the amount to expand the top sideright
- the amount to expand the right sidebottom
- the amount to expand the bottom sidethis
for conveniencepublic Point getCenter()
Point
of this
AbstractRectangleBasedGeometry
.Point
of this
AbstractRectangleBasedGeometry
public T getExpanded(double h, double v)
AbstractRectangleBasedGeometry
, where the
sides are incremented by the horizontal and vertical values provided. The
center of the AbstractRectangleBasedGeometry
is maintained
constant.h
- The horizontal incrementv
- The vertical incrementAbstractRectangleBasedGeometry
public T getExpanded(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry
with the
bounds of this AbstractRectangleBasedGeometry
expanded by the
given insets.left
- the amount to expand the left sidetop
- the amount to expand the top sideright
- the amount to expand the right sidebottom
- the amount to expand the bottom sideAbstractRectangleBasedGeometry
public final double getHeight()
AbstractRectangleBasedGeometry
.AbstractRectangleBasedGeometry
public Point getLocation()
Point
specifying the x and y coordinates of this
AbstractRectangleBasedGeometry
.Point
representing the x and y coordinates of this
AbstractRectangleBasedGeometry
public T getScaled(double factor)
IScalable
Point
.public T getScaled(double factorX, double factorY)
IScalable
Point
.public T getScaled(double factor, double centerX, double centerY)
IScalable
Point
(cx, cy).getScaled
in interface IScalable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
factor
- scale-factorcenterX
- x-coordinate of the relative Point
for the scalingcenterY
- y-coordinate of the relative Point
for the scalingpublic T getScaled(double factorX, double factorY, double centerX, double centerY)
IScalable
Point
(cx, cy).getScaled
in interface IScalable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
factorX
- x-scale-factorfactorY
- y-scale-factorcenterX
- x-coordinate of the relative Point
for the scalingcenterY
- y-coordinate of the relative Point
for the scalingpublic T getScaled(double factorX, double factorY, Point center)
IScalable
Point
.public T getScaled(double factor, Point center)
IScalable
Point
.public T getShrinked(double h, double v)
AbstractRectangleBasedGeometry
, where the sides are
shrinked by the horizontal and vertical values supplied. The center of
this AbstractRectangleBasedGeometry
is kept constant.h
- horizontal reduction amountv
- vertical reduction amountAbstractRectangleBasedGeometry
public T getShrinked(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry
shrinked by the
specified insets.left
- the amount to shrink the left sidetop
- the amount to shrink the top sideright
- the amount to shrink the right sidebottom
- the amount to shrink the bottom sideAbstractRectangleBasedGeometry
public final Dimension getSize()
Dimension
that records the width and height of this
AbstractRectangleBasedGeometry
.Dimension
that records the width and height of this
AbstractRectangleBasedGeometry
public T getTranslated(double dx, double dy)
ITranslatable
getTranslated
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
dx
- x-translationdy
- y-translationpublic T getTranslated(Point pt)
ITranslatable
Point
.getTranslated
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
pt
- translation Point
public final double getWidth()
AbstractRectangleBasedGeometry
.AbstractRectangleBasedGeometry
public final double getX()
AbstractRectangleBasedGeometry
.AbstractRectangleBasedGeometry
public final double getY()
AbstractRectangleBasedGeometry
.AbstractRectangleBasedGeometry
public T scale(double factor)
IScalable
Point
.public T scale(double fx, double fy)
IScalable
Point
.public T scale(double factor, double cx, double cy)
IScalable
Point
(cx, cy).public T scale(double fx, double fy, double cx, double cy)
IScalable
Point
(cx, cy).scale
in interface IScalable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
fx
- x-scale-factorfy
- y-scale-factorcx
- x-coordinate of the relative Point
for the scalingcy
- y-coordinate of the relative Point
for the scalingthis
for conveniencepublic T scale(double fx, double fy, Point center)
IScalable
Point
.public T scale(double factor, Point center)
IScalable
Point
.public final T setBounds(double x, double y, double w, double h)
AbstractRectangleBasedGeometry
to the given values.x
- the new x-coordinatey
- the new y-coordinatew
- the new widthh
- the new heightthis
for conveniencepublic final T setBounds(Rectangle r)
AbstractRectangleBasedGeometry
to the respective values of the
given Rectangle
.r
- the Rectangle
specifying the new x, y, width, and
height values of this AbstractRectangleBasedGeometry
this
for conveniencepublic final T setHeight(double height)
AbstractRectangleBasedGeometry
to the
given value.height
- the new heightthis
for conveniencepublic final T setLocation(double x, double y)
AbstractRectangleBasedGeometry
to the specified values.x
- the new x coordinate of this
AbstractRectangleBasedGeometry
y
- the new y coordinate of this
AbstractRectangleBasedGeometry
this
for conveniencepublic final T setLocation(Point p)
AbstractRectangleBasedGeometry
to the respective values of the
given Point
.p
- the Point
specifying the new x and y coordinates of
this AbstractRectangleBasedGeometry
this
for conveniencepublic final T setSize(Dimension d)
AbstractRectangleBasedGeometry
to the width and height of the given Dimension
.d
- the Dimension
specifying the new width and height of
this AbstractRectangleBasedGeometry
this
for conveniencepublic final T setSize(double w, double h)
AbstractRectangleBasedGeometry
to the given values.w
- the new width of this AbstractRectangleBasedGeometry
h
- the new height of this AbstractRectangleBasedGeometry
this
for conveniencepublic final T setWidth(double width)
AbstractRectangleBasedGeometry
to the
passed-in value.width
- the new width of this AbstractRectangleBasedGeometry
this
for conveniencepublic final T setX(double x)
AbstractRectangleBasedGeometry
to
the given value.x
- The new x-coordinate.this
for convenience.public final T setY(double y)
AbstractRectangleBasedGeometry
to
the given value.y
- The new y-coordinate.this
for convenience.public T shrink(double h, double v)
AbstractRectangleBasedGeometry
by the
horizontal and vertical values provided as input, and returns this
AbstractRectangleBasedGeometry
for convenience. The center of
this AbstractRectangleBasedGeometry
is kept constant.h
- horizontal reduction amountv
- vertical reduction amountthis
for conveniencepublic T shrink(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry
by the specified
amounts.left
- the amount to shrink the left sidetop
- the amount to shrink the top sideright
- the amount to shrink the right sidebottom
- the amount to shrink the bottom sidethis
for conveniencepublic T translate(double dx, double dy)
ITranslatable
translate
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
dx
- x-translationdy
- y-translationthis
for conveniencepublic T translate(Point p)
ITranslatable
Point
.translate
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
p
- translation Point
this
for conveniencepublic 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.