Package org.eclipse.gef.geometry.planar
Class PolyBezier
- java.lang.Object
-
- org.eclipse.gef.geometry.planar.PolyBezier
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,ICurve
,IGeometry
,IRotatable<PolyBezier>
,IScalable<PolyBezier>
,ITranslatable<PolyBezier>
public class PolyBezier extends java.lang.Object implements ICurve, ITranslatable<PolyBezier>, IScalable<PolyBezier>, IRotatable<PolyBezier>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static double
INTERPOLATION_CURVE_WIDTH_COEFFICIENT
The default curve width coefficient used in interpolateCubic(...)
-
Constructor Summary
Constructors Constructor Description PolyBezier(BezierCurve... beziers)
Constructs a newPolyBezier
of the givenBezierCurve
s.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Overridden with public visibility as recommended withinCloneable
.boolean
contains(Point p)
boolean
equals(java.lang.Object o)
Rectangle
getBounds()
PolyBezier
getCopy()
Returns a new identical copy of thisIGeometry
.Point[]
getIntersections(ICurve c)
ICurve[]
getOverlaps(ICurve c)
Point
getP1()
Point
getP2()
Point
getProjection(Point reference)
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)
PolyBezier
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its centerPoint
.PolyBezier
getScaled(double fx, double fy)
Scales a copy of the calling object by the given factors relative to its centerPoint
.PolyBezier
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).PolyBezier
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).PolyBezier
getScaled(double fx, double fy, Point center)
Scales a copy of the calling object by the given factors relative to the given centerPoint
.PolyBezier
getScaled(double factor, Point center)
Scales a copy of the calling object by the given factor relative to the given centerPoint
.PolyBezier
getTransformed(AffineTransform t)
PolyBezier
getTranslated(double dx, double dy)
Translates a copy of this object by the given values in x and y direction.PolyBezier
getTranslated(Point d)
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.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
overlaps(ICurve c)
PolyBezier
rotateCCW(Angle angle)
PolyBezier
rotateCCW(Angle angle, double cx, double cy)
Directly rotates thisPolyBezier
counter-clock-wise around the given point (specified by cx and cy) by the givenAngle
.PolyBezier
rotateCCW(Angle angle, Point center)
PolyBezier
rotateCW(Angle angle)
PolyBezier
rotateCW(Angle angle, double cx, double cy)
Directly rotates thisPolyBezier
clock-wise around the given point (specified by cx and cy) by the givenAngle
.PolyBezier
rotateCW(Angle angle, Point center)
PolyBezier
scale(double factor)
Scales the calling object by the given factor relative to its centerPoint
.PolyBezier
scale(double fx, double fy)
Scales the calling object by the given factors relative to the given centerPoint
.PolyBezier
scale(double factor, double cx, double cy)
Scales the calling object by the given factor relative to the given centerPoint
(cx, cy).PolyBezier
scale(double fx, double fy, double cx, double cy)
Scales the calling object by the given factors relative to the given centerPoint
(cx, cy).PolyBezier
scale(double fx, double fy, Point center)
Scales the calling object by the given factors relative to the given centerPoint
.PolyBezier
scale(double factor, Point center)
Scales the calling object by the given factor relative to the given centerPoint
.BezierCurve[]
toBezier()
Computes a list ofBezierCurve
s that approximate theICurve
.Path
toPath()
java.lang.String
toString()
boolean
touches(IGeometry g)
PolyBezier
translate(double dx, double dy)
Translates the object by the given values in x and y direction.PolyBezier
translate(Point d)
Translates the object by the givenPoint
.
-
-
-
Field Detail
-
INTERPOLATION_CURVE_WIDTH_COEFFICIENT
public static final double INTERPOLATION_CURVE_WIDTH_COEFFICIENT
The default curve width coefficient used in interpolateCubic(...) methods.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PolyBezier
public PolyBezier(BezierCurve... beziers)
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 Detail
-
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
public static PolyBezier interpolateCubic(double... coordinates)
- 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(Point...)
-
interpolateCubic
public static PolyBezier interpolateCubic(double curveWidthCoefficient, Point... points)
- 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
public static PolyBezier interpolateCubic(Point... points)
- Parameters:
points
- The array ofPoint
s which lie on the resultingPolyBezier
.- Returns:
PolyBezier
with continuousCubicCurve
segments through the givenPoint
s.- See Also:
interpolateCubic(double, Point...)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
getCopy
public PolyBezier getCopy()
Description copied from interface:IGeometry
Returns a new identical copy of thisIGeometry
.
-
getIntersections
public Point[] getIntersections(ICurve c)
Description copied from interface:ICurve
- Specified by:
getIntersections
in interfaceICurve
- Parameters:
c
- TheICurve
to compute intersection points with.- Returns:
- The points of intersection.
-
getOverlaps
public ICurve[] getOverlaps(ICurve c)
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.
-
getProjection
public Point getProjection(Point reference)
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
public PolyBezier getRotatedCCW(Angle angle)
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
public PolyBezier getRotatedCCW(Angle angle, double cx, double cy)
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
public PolyBezier getRotatedCCW(Angle angle, Point center)
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
public PolyBezier getRotatedCW(Angle angle)
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
public PolyBezier getRotatedCW(Angle angle, double cx, double cy)
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
public PolyBezier getRotatedCW(Angle angle, Point center)
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
public PolyBezier getScaled(double factor)
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
public PolyBezier getScaled(double fx, double fy)
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
public PolyBezier getScaled(double factor, double cx, double cy)
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
public PolyBezier getScaled(double fx, double fy, double cx, double cy)
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
public PolyBezier getScaled(double fx, double fy, Point center)
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
public PolyBezier getScaled(double factor, Point center)
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
public PolyBezier getTransformed(AffineTransform t)
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
public PolyBezier getTranslated(double dx, double dy)
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
public PolyBezier getTranslated(Point d)
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
public boolean intersects(ICurve c)
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
public boolean overlaps(ICurve c)
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
public PolyBezier rotateCCW(Angle angle)
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
public PolyBezier rotateCCW(Angle angle, double cx, double cy)
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
public PolyBezier rotateCCW(Angle angle, Point center)
Directly rotates thisPolyBezier
counter-clock-wise around the givenPoint
by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place.
-
rotateCW
public PolyBezier rotateCW(Angle angle)
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
public PolyBezier rotateCW(Angle angle, double cx, double cy)
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
public PolyBezier rotateCW(Angle angle, Point center)
Directly rotates thisPolyBezier
clock-wise around the givenPoint
by the givenAngle
. Direct adaptation means, thatthis
PolyBezier
is modified in-place.
-
scale
public PolyBezier scale(double factor)
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
public PolyBezier scale(double fx, double fy)
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
public PolyBezier scale(double factor, double cx, double cy)
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
public PolyBezier scale(double fx, double fy, double cx, double cy)
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
public PolyBezier scale(double fx, double fy, Point center)
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
public PolyBezier scale(double factor, Point center)
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
public BezierCurve[] 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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
translate
public PolyBezier translate(double dx, double dy)
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
public PolyBezier translate(Point d)
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
public java.lang.Object clone()
Overridden with public visibility as recommended withinCloneable
.- Overrides:
clone
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
-