Package org.eclipse.gef.geometry.planar
Class PolyBezier
java.lang.Object
org.eclipse.gef.geometry.planar.PolyBezier
- All Implemented Interfaces:
Serializable
,Cloneable
,ICurve
,IGeometry
,IRotatable<PolyBezier>
,IScalable<PolyBezier>
,ITranslatable<PolyBezier>
public class PolyBezier
extends Object
implements ICurve, ITranslatable<PolyBezier>, IScalable<PolyBezier>, IRotatable<PolyBezier>
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The default curve width coefficient used in interpolateCubic(...) -
Constructor Summary
ConstructorDescriptionPolyBezier
(BezierCurve... beziers) Constructs a newPolyBezier
of the givenBezierCurve
s. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Overridden with public visibility as recommended withinCloneable
.boolean
boolean
getCopy()
Returns a new identical copy of thisIGeometry
.Point[]
ICurve[]
getP1()
getP2()
getProjection
(Point reference) getRotatedCCW
(Angle angle) getRotatedCCW
(Angle angle, double cx, double cy) getRotatedCCW
(Angle angle, Point center) getRotatedCW
(Angle angle) getRotatedCW
(Angle angle, double cx, double cy) getRotatedCW
(Angle angle, Point center) getScaled
(double factor) Scales a copy of the calling object by the given factor relative to its centerPoint
.getScaled
(double fx, double fy) Scales a copy of the calling object by the given factors relative to its centerPoint
.getScaled
(double factor, double cx, double cy) Scales a copy of the calling object by the given factor relative to the given centerPoint
(cx, cy).getScaled
(double fx, double fy, double cx, double cy) Scales a copy of the calling object by the given factors relative to the given centerPoint
(cx, cy).Scales a copy of the calling object by the given factors relative to the given centerPoint
.Scales a copy of the calling object by the given factor relative to the given centerPoint
.getTranslated
(double dx, double dy) Translates a copy of this object by the given values in x and y direction.Translates a copy of this object by the givenPoint
.double
getX1()
Returns the startPoint
's x coordinate.double
getX2()
Returns the endPoint
's x coordinate.double
getY1()
Returns the startPoint
's y coordinate.double
getY2()
Returns the endPoint
's y coordinate.final int
hashCode()
static PolyBezier
interpolateCubic
(double... coordinates) static PolyBezier
interpolateCubic
(double curveWidthCoefficient, Point... points) static PolyBezier
interpolateCubic
(Angle startAngle, double startLength, Angle endAngle, double endLength, double curveWidthCoefficient, Point... wayPoints) static PolyBezier
interpolateCubic
(Point... points) boolean
intersects
(ICurve c) boolean
Directly rotates thisPolyBezier
counter-clock-wise around the given point (specified by cx and cy) by the givenAngle
.Directly rotates thisPolyBezier
clock-wise around the given point (specified by cx and cy) by the givenAngle
.scale
(double factor) Scales the calling object by the given factor relative to its centerPoint
.scale
(double fx, double fy) Scales the calling object by the given factors relative to the given centerPoint
.scale
(double factor, double cx, double cy) Scales the calling object by the given factor relative to the given centerPoint
(cx, cy).scale
(double fx, double fy, double cx, double cy) Scales the calling object by the given factors relative to the given centerPoint
(cx, cy).Scales the calling object by the given factors relative to the given centerPoint
.Scales the calling object by the given factor relative to the given centerPoint
.toBezier()
Computes a list ofBezierCurve
s that approximate theICurve
.toPath()
toString()
boolean
translate
(double dx, double dy) Translates the object by the given values in x and y direction.Translates the object by the givenPoint
.
-
Field Details
-
INTERPOLATION_CURVE_WIDTH_COEFFICIENT
public static final double INTERPOLATION_CURVE_WIDTH_COEFFICIENTThe default curve width coefficient used in interpolateCubic(...) methods.- See Also:
-
-
Constructor Details
-
PolyBezier
Constructs a newPolyBezier
of the givenBezierCurve
s. TheBezierCurve
s are expected to be connected with each other.- Parameters:
beziers
- theBezierCurve
s which will constitute thisPolyBezier
-
-
Method Details
-
interpolateCubic
public static PolyBezier interpolateCubic(Angle startAngle, double startLength, Angle endAngle, double endLength, double curveWidthCoefficient, Point... wayPoints) Creates a
PolyBezier
consisting of continuousCubicCurve
segments through the givenPoint
s.The start angle and start length constrain the curve. Way points are added to assure the curve starts off with a straight line of said length in the direction specified by said angle.
The end angle and end length constrain the curve. Way points are added to assure the curve ends in a straight line of said length in the direction specified by said angle.
- Parameters:
startAngle
- start direction of the curvestartLength
- length of the straight start segment of the curveendAngle
- end direction of the curveendLength
- length of the straight end segment of the curvecurveWidthCoefficient
- value in the range]0;+Inf[
that adjusts the width of the curve. A value smaller than 1 sharpens the curve and a value greater than 1 thickens the curve.wayPoints
- The array ofPoint
s which lie on the resultingPolyBezier
.- Returns:
PolyBezier
consisting of continuousCubicCurve
segments through the givenPoint
s
-
interpolateCubic
- Parameters:
coordinates
- the coordinates of the points that are to be interpolated.- Returns:
PolyBezier
with continuousCubicCurve
segments through the points, specified via the given coordinates.- See Also:
-
interpolateCubic
- Parameters:
curveWidthCoefficient
- value in the range]0;+Inf[
that adjusts the width of the curve. A value smaller than one sharpens the curve and a value greater than one thickens the curve.points
- The array ofPoint
s which lie on the resultingPolyBezier
.- Returns:
PolyBezier
with continuousCubicCurve
segments through the givenPoint
s.
-
interpolateCubic
- Parameters:
points
- The array ofPoint
s which lie on the resultingPolyBezier
.- Returns:
PolyBezier
with continuousCubicCurve
segments through the givenPoint
s.- See Also:
-
contains
Description copied from interface:IGeometry
-
equals
-
getBounds
Description copied from interface:IGeometry
-
getCopy
Description copied from interface:IGeometry
Returns a new identical copy of thisIGeometry
. -
getIntersections
Description copied from interface:ICurve
- Specified by:
getIntersections
in interfaceICurve
- Parameters:
c
- TheICurve
to compute intersection points with.- Returns:
- The points of intersection.
-
getOverlaps
Description copied from interface:ICurve
- Specified by:
getOverlaps
in interfaceICurve
- Parameters:
c
- The curve to compute overlaps with.- Returns:
- The segments where both curves overlap.
-
getP1
Description copied from interface:ICurve
-
getP2
Description copied from interface:ICurve
-
getProjection
Description copied from interface:ICurve
Returns a projection of the given referencePoint
onto thisICurve
, i.e. aPoint
on thisICurve
that is closest to the given referencePoint
. Note, that- Specified by:
getProjection
in interfaceICurve
- Parameters:
reference
- The referencePoint
for which to return the projection.- Returns:
- The projection of the given reference
Point
onto thisICurve
.
-
getRotatedCCW
Description copied from interface:IRotatable
Rotates the calling object by specifiedAngle
counter-clock-wise (CCW) around its centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCW
in interfaceIRotatable<PolyBezier>
- Parameters:
angle
- rotationAngle
- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCCW
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
counter-clock-wise (CCW) around the specified centerPoint
(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCCW
in interfaceIRotatable<PolyBezier>
- Parameters:
angle
- rotationAngle
cx
- x-coordinate of the relativePoint
for the rotationcy
- y-coordinate of the relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCCW
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
counter-clock-wise (CCW) around the specified centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCW
in interfaceIRotatable<PolyBezier>
- Parameters:
angle
- rotationAngle
center
- relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
Description copied from interface:IRotatable
Rotates the calling object by specifiedAngle
clock-wise (CW) around its centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCW
in interfaceIRotatable<PolyBezier>
- Parameters:
angle
- rotationAngle
- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
clock-wise (CW) around the specified centerPoint
(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCW
in interfaceIRotatable<PolyBezier>
- Parameters:
angle
- rotationAngle
cx
- x-coordinate of the relativePoint
for the rotationcy
- y-coordinate of the relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
clock-wise (CW) around the specified centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCW
in interfaceIRotatable<PolyBezier>
- Parameters:
angle
- rotationAngle
center
- relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getScaled
Description copied from interface:IScalable
Scales a copy of the calling object by the given factor relative to its centerPoint
.- Specified by:
getScaled
in interfaceIScalable<PolyBezier>
- Parameters:
factor
- scale-factor- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalable
Scales a copy of the calling object by the given factors relative to its centerPoint
.- Specified by:
getScaled
in interfaceIScalable<PolyBezier>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factor- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalable
Scales a copy of the calling object by the given factor relative to the given centerPoint
(cx, cy).- Specified by:
getScaled
in interfaceIScalable<PolyBezier>
- Parameters:
factor
- scale-factorcx
- x-coordinate of the relativePoint
for the scalingcy
- y-coordinate of the relativePoint
for the scaling- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalable
Scales a copy of the calling object by the given factors relative to the given centerPoint
(cx, cy).- Specified by:
getScaled
in interfaceIScalable<PolyBezier>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factorcx
- x-coordinate of the relativePoint
for the scalingcy
- y-coordinate of the relativePoint
for the scaling- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalable
Scales a copy of the calling object by the given factors relative to the given centerPoint
.- Specified by:
getScaled
in interfaceIScalable<PolyBezier>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factorcenter
- relativePoint
for the scaling- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalable
Scales a copy of the calling object by the given factor relative to the given centerPoint
.- Specified by:
getScaled
in interfaceIScalable<PolyBezier>
- Parameters:
factor
- scale-factorcenter
- relativePoint
for the scaling- Returns:
- the new, scaled object
-
getTransformed
Default implementation returning a transformedPath
representation of thisIGeometry
. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformed
in interfaceIGeometry
- Parameters:
t
- TheAffineTransform
to be applied- Returns:
- a transformed
Path
representation of thisIGeometry
-
getTranslated
Description copied from interface:ITranslatable
Translates a copy of this object by the given values in x and y direction.- Specified by:
getTranslated
in interfaceITranslatable<PolyBezier>
- Parameters:
dx
- x-translationdy
- y-translation- Returns:
- a new, translated object
-
getTranslated
Description copied from interface:ITranslatable
Translates a copy of this object by the givenPoint
.- Specified by:
getTranslated
in interfaceITranslatable<PolyBezier>
- Parameters:
d
- translationPoint
- Returns:
- a new, translated object
-
getX1
public double getX1()Description copied from interface:ICurve
Returns the startPoint
's x coordinate. -
getX2
public double getX2()Description copied from interface:ICurve
Returns the endPoint
's x coordinate. -
getY1
public double getY1()Description copied from interface:ICurve
Returns the startPoint
's y coordinate. -
getY2
public double getY2()Description copied from interface:ICurve
Returns the endPoint
's y coordinate. -
intersects
Description copied from interface:ICurve
Tests if thisICurve
and the givenICurve
intersect, i.e. whether a final set of intersection points exists. Two curves intersect if they touch (seeIGeometry.touches(IGeometry)
) but do not overlap (seeICurve.overlaps(ICurve)
).- Specified by:
intersects
in interfaceICurve
- Parameters:
c
- TheICurve
to test for intersections.- Returns:
true
if they intersect,false
otherwise
-
overlaps
Description copied from interface:ICurve
Tests if thisICurve
and the givenICurve
overlap, i.e. whether an infinite set of intersection points exists. Two curves overlap if they touch (seeIGeometry.touches(IGeometry)
) but not intersect (seeICurve.intersects(ICurve)
). -
rotateCCW
Directly rotates thisPolyBezier
counter-clock-wise around its centerPoint
by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place.- Parameters:
angle
- rotationAngle
- Returns:
this
for convenience
-
rotateCCW
Directly rotates thisPolyBezier
counter-clock-wise around the given point (specified by cx and cy) by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place. -
rotateCCW
Directly rotates thisPolyBezier
counter-clock-wise around the givenPoint
by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place. -
rotateCW
Directly rotates thisPolyBezier
clock-wise around its centerPoint
by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place.- Parameters:
angle
- rotationAngle
- Returns:
this
for convenience
-
rotateCW
Directly rotates thisPolyBezier
clock-wise around the given point (specified by cx and cy) by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place. -
rotateCW
Directly rotates thisPolyBezier
clock-wise around the givenPoint
by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place. -
scale
Description copied from interface:IScalable
Scales the calling object by the given factor relative to its centerPoint
.- Specified by:
scale
in interfaceIScalable<PolyBezier>
- Parameters:
factor
- scale-factor- Returns:
this
for convenience
-
scale
Description copied from interface:IScalable
Scales the calling object by the given factors relative to the given centerPoint
.- Specified by:
scale
in interfaceIScalable<PolyBezier>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factor- Returns:
this
for convenience
-
scale
Description copied from interface:IScalable
Scales the calling object by the given factor relative to the given centerPoint
(cx, cy).- Specified by:
scale
in interfaceIScalable<PolyBezier>
- Parameters:
factor
- scale-factorcx
- x-coordinate of the relativePoint
for the scalingcy
- y-coordinate of the relativePoint
for the scaling- Returns:
this
for convenience
-
scale
Description copied from interface:IScalable
Scales the calling object by the given factors relative to the given centerPoint
(cx, cy).- Specified by:
scale
in interfaceIScalable<PolyBezier>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factorcx
- x-coordinate of the relativePoint
for the scalingcy
- y-coordinate of the relativePoint
for the scaling- Returns:
this
for convenience
-
scale
Description copied from interface:IScalable
Scales the calling object by the given factors relative to the given centerPoint
.- Specified by:
scale
in interfaceIScalable<PolyBezier>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factorcenter
- relativePoint
for the scaling- Returns:
this
for convenience
-
scale
Description copied from interface:IScalable
Scales the calling object by the given factor relative to the given centerPoint
.- Specified by:
scale
in interfaceIScalable<PolyBezier>
- Parameters:
factor
- scale-factorcenter
- relativePoint
for the scaling- Returns:
this
for convenience
-
toBezier
Description copied from interface:ICurve
Computes a list ofBezierCurve
s that approximate theICurve
. For example, aLine
or aBezierCurve
in general could return a list with the curve itself as its only element. But anEllipse
or anArc
may return a list of consecutiveBezierCurve
s which approximate theICurve
.- Specified by:
toBezier
in interfaceICurve
- Returns:
- a list of
BezierCurve
s that approximate theICurve
-
toPath
Description copied from interface:IGeometry
-
toString
-
translate
Description copied from interface:ITranslatable
Translates the object by the given values in x and y direction.- Specified by:
translate
in interfaceITranslatable<PolyBezier>
- Parameters:
dx
- x-translationdy
- y-translation- Returns:
this
for convenience
-
translate
Description copied from interface:ITranslatable
Translates the object by the givenPoint
.- Specified by:
translate
in interfaceITranslatable<PolyBezier>
- Parameters:
d
- translationPoint
- Returns:
this
for convenience
-
clone
Overridden with public visibility as recommended withinCloneable
. -
hashCode
public final int hashCode() -
touches
Description copied from interface:IGeometry
-