Class BezierCurve
- java.lang.Object
-
- org.eclipse.gef.geometry.planar.BezierCurve
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,ICurve
,IGeometry
,IRotatable<BezierCurve>
,IScalable<BezierCurve>
,ITranslatable<BezierCurve>
- Direct Known Subclasses:
CubicCurve
,Line
,QuadraticCurve
public class BezierCurve extends java.lang.Object implements ICurve, ITranslatable<BezierCurve>, IScalable<BezierCurve>, IRotatable<BezierCurve>
Instances of the
BezierCurve
class individually represent an arbitrary Bezier curve. This is the base class of the special quadratic and cubic Bezier curve classes (QuadraticCurve
andCubicCurve
).- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BezierCurve(double... controlPoints)
Constructs a newBezierCurve
from the given controlPoint
coordinates.BezierCurve(CubicCurve c)
Constructs a newBezierCurve
from the givenCubicCurve
.BezierCurve(Point... controlPoints)
Constructs a newBezierCurve
from the given controlPoint
s.BezierCurve(QuadraticCurve c)
Constructs a newBezierCurve
from the givenQuadraticCurve
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Overridden with public visibility as recommended withinCloneable
.boolean
contains(BezierCurve o)
Tests if thisBezierCurve
contains the given otherBezierCurve
.boolean
contains(Point p)
boolean
equals(java.lang.Object other)
Point
get(double t)
Computes thePoint
on thisBezierCurve
at parameter value t, which is expected to lie in the parameterBezierCurve.Interval
[0;1]
.Rectangle
getBounds()
BezierCurve
getClipped(double s, double e)
Rectangle
getControlBounds()
BezierCurve
getCopy()
Returns a new identical copy of thisIGeometry
.BezierCurve
getDerivative()
Computes the hodograph, the first parametric derivative, of thisBezierCurve
.BezierCurve
getElevated()
Computes aBezierCurve
with a degree of one higher than thisBezierCurve
's degree but of the same shape.Point[]
getIntersections(BezierCurve other)
Returns thePoint
s of intersection of this and the given otherBezierCurve
.Point[]
getIntersections(ICurve curve)
PolyBezier
getOffset(double distance)
Returns aPolyBezier
that represents an approximation of the refined offset of thisBezierCurve
where cusps in the input curve are approximated by arc segments in the offset and local self-intersections in the offset are removed while global self-intersections and other singularities in the offset remain unprocessed.BezierCurve
getOverlap(BezierCurve other)
Returns aBezierCurve
that represents the overlap of thisBezierCurve
and the given otherBezierCurve
.ICurve[]
getOverlaps(ICurve c)
Point
getP1()
Point
getP2()
double
getParameterAt(Point p)
Returns the parameter value of thisBezierCurve
for the givenPoint
.Point
getPoint(int i)
Returns the ith controlPoint
of thisBezierCurve
.Point[]
getPoints()
Returns the controlPoint
s of thisBezierCurve
.Point
getProjection(Point reference)
BezierCurve
getRotatedCCW(Angle angle)
BezierCurve
getRotatedCCW(Angle angle, double cx, double cy)
BezierCurve
getRotatedCCW(Angle angle, Point center)
BezierCurve
getRotatedCW(Angle angle)
BezierCurve
getRotatedCW(Angle angle, double cx, double cy)
BezierCurve
getRotatedCW(Angle angle, Point center)
BezierCurve
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its centerPoint
.BezierCurve
getScaled(double fx, double fy)
Scales a copy of the calling object by the given factors relative to its centerPoint
.BezierCurve
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).BezierCurve
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).BezierCurve
getScaled(double fx, double fy, Point center)
Scales a copy of the calling object by the given factors relative to the given centerPoint
.BezierCurve
getScaled(double factor, Point center)
Scales a copy of the calling object by the given factor relative to the given centerPoint
.BezierCurve
getTransformed(AffineTransform t)
BezierCurve
getTranslated(double dx, double dy)
Translates a copy of this object by the given values in x and y direction.BezierCurve
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()
boolean
intersects(ICurve c)
boolean
overlaps(BezierCurve other)
Checks if thisBezierCurve
and the given otherBezierCurve
overlap, i.e. an infinite set of intersectionPoint
s exists.boolean
overlaps(ICurve c)
BezierCurve
rotateCCW(Angle angle)
Directly rotates thisBezierCurve
counter-clockwise (CCW) around its centerPoint
by the givenAngle
.BezierCurve
rotateCCW(Angle angle, double cx, double cy)
Directly rotates thisBezierCurve
counter-clockwise (CCW) around thePoint
specified by the given x and y coordinate values by the givenAngle
.BezierCurve
rotateCCW(Angle angle, Point center)
Directly rotates thisBezierCurve
counter-clockwise (CCW) around the givenPoint
by the givenAngle
.BezierCurve
rotateCW(Angle angle)
BezierCurve
rotateCW(Angle angle, double cx, double cy)
Directly rotates thisBezierCurve
clockwise (CW) around thePoint
specified by the given x and y coordinate values by the givenAngle
.BezierCurve
rotateCW(Angle angle, Point center)
BezierCurve
scale(double factor)
Scales the calling object by the given factor relative to its centerPoint
.BezierCurve
scale(double fx, double fy)
Scales the calling object by the given factors relative to the given centerPoint
.BezierCurve
scale(double factor, double cx, double cy)
Scales the calling object by the given factor relative to the given centerPoint
(cx, cy).BezierCurve
scale(double fx, double fy, double cx, double cy)
Scales the calling object by the given factors relative to the given centerPoint
(cx, cy).BezierCurve
scale(double fx, double fy, Point center)
Scales the calling object by the given factors relative to the given centerPoint
.BezierCurve
scale(double factor, Point center)
Scales the calling object by the given factor relative to the given centerPoint
.BezierCurve
setP1(Point p1)
BezierCurve
setP2(Point p2)
BezierCurve
setPoint(int i, Point p)
Sets the ith controlPoint
of thisBezierCurve
.BezierCurve[]
split(double t)
Subdivides thisBezierCurve
at the given parameter value t into two newBezierCurve
s.BezierCurve[]
toBezier()
Computes a list ofBezierCurve
s that approximate theICurve
.CubicCurve
toCubic()
Returns a hard approximation of thisBezierCurve
as aCubicCurve
.Line
toLine()
Returns a hard approximation of thisBezierCurve
as aLine
.Line[]
toLineStrip(double lineSimilarity)
Computes an approximation of thisBezierCurve
by a strip ofLine
s.Line[]
toLineStrip(double lineSimilarity, org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)
Computes an approximation of thisBezierCurve
by a strip ofLine
s.Path
toPath()
Point[]
toPoints(org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)
QuadraticCurve
toQuadratic()
Returns a hard approximation of thisBezierCurve
as aQuadraticCurve
.java.lang.String
toString()
boolean
touches(IGeometry g)
BezierCurve
translate(double dx, double dy)
Translates the object by the given values in x and y direction.BezierCurve
translate(Point d)
Translates the object by the givenPoint
.
-
-
-
Constructor Detail
-
BezierCurve
public BezierCurve(CubicCurve c)
Constructs a newBezierCurve
from the givenCubicCurve
.- Parameters:
c
- theCubicCurve
of which the newBezierCurve
is constructed from
-
BezierCurve
public BezierCurve(double... controlPoints)
Constructs a newBezierCurve
from the given controlPoint
coordinates. The coordinates are expected to be in x, y order, i.e. x1, y1, x2, y2, x3, y3, ...- Parameters:
controlPoints
- the controlPoint
coordinates of the newBezierCurve
in x, y order
-
BezierCurve
public BezierCurve(Point... controlPoints)
Constructs a newBezierCurve
from the given controlPoint
s.- Parameters:
controlPoints
- the controlPoint
s of the newBezierCurve
-
BezierCurve
public BezierCurve(QuadraticCurve c)
Constructs a newBezierCurve
from the givenQuadraticCurve
.- Parameters:
c
- theQuadraticCurve
of which the newBezierCurve
is constructed from
-
-
Method Detail
-
contains
public boolean contains(BezierCurve o)
Tests if this
BezierCurve
contains the given otherBezierCurve
.The other
BezierCurve
is regarded to be contained by thisBezierCurve
if its start and endPoint
lie on thisBezierCurve
and an overlapping segment of the two curves can be detected.- Parameters:
o
- theBezierCurve
that is checked to be contained by thisBezierCurve
- Returns:
true
if the givenBezierCurve
is contained by thisBezierCurve
, otherwisefalse
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
get
public Point get(double t)
Computes thePoint
on thisBezierCurve
at parameter value t, which is expected to lie in the parameterBezierCurve.Interval
[0;1]
.- Parameters:
t
- the parameter value for which thisBezierCurve
is evaluated- Returns:
- the
Point
on thisBezierCurve
at the given parameter value
-
getClipped
public BezierCurve getClipped(double s, double e)
- Parameters:
s
- the lower limit of the parameterBezierCurve.Interval
which is clipped out of thisBezierCurve
e
- the upper limit of the parameterBezierCurve.Interval
which is clipped out of thisBezierCurve
- Returns:
- a new
BezierCurve
representing thisBezierCurve
on theBezierCurve.Interval
[s;e]
-
getControlBounds
public Rectangle getControlBounds()
- Returns:
- a
Rectangle
representing the bounds of the controlPolygon
of thisBezierCurve
-
getCopy
public BezierCurve getCopy()
Description copied from interface:IGeometry
Returns a new identical copy of thisIGeometry
.
-
getDerivative
public BezierCurve getDerivative()
Computes the hodograph, the first parametric derivative, of thisBezierCurve
.- Returns:
- the hodograph of this
BezierCurve
-
getElevated
public BezierCurve getElevated()
Computes aBezierCurve
with a degree of one higher than thisBezierCurve
's degree but of the same shape.- Returns:
- a
BezierCurve
of the same shape as thisBezierCurve
but with one more controlPoint
-
getIntersections
public Point[] getIntersections(BezierCurve other)
Returns thePoint
s of intersection of this and the given otherBezierCurve
.- Parameters:
other
- theBezierCurve
which is searched forPoint
s of intersection with thisBezierCurve
- Returns:
- the
Point
s of intersection of thisBezierCurve
and the given otherBezierCurve
-
getIntersections
public final Point[] getIntersections(ICurve curve)
Description copied from interface:ICurve
- Specified by:
getIntersections
in interfaceICurve
- Parameters:
curve
- TheICurve
to compute intersection points with.- Returns:
- The points of intersection.
-
getOffset
public PolyBezier getOffset(double distance)
Returns aPolyBezier
that represents an approximation of the refined offset of thisBezierCurve
where cusps in the input curve are approximated by arc segments in the offset and local self-intersections in the offset are removed while global self-intersections and other singularities in the offset remain unprocessed.- Parameters:
distance
- The signed distance for which to compute a refined offset approximation.- Returns:
- A
PolyBezier
representing the refined offset of thisBezierCurve
for the given distance.
-
getOverlap
public BezierCurve getOverlap(BezierCurve other)
Returns a
BezierCurve
that represents the overlap of thisBezierCurve
and the given otherBezierCurve
. If no overlap exists,null
is returned. An overlap is identified by an infinite number of intersection points.- Parameters:
other
- TheBezierCurve
to which an overlap is computed.- Returns:
- a
BezierCurve
representing the overlap of this and the given otherBezierCurve
if an overlap exists, otherwisenull
-
getOverlaps
public final 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.
-
getParameterAt
public double getParameterAt(Point p)
Returns the parameter value of thisBezierCurve
for the givenPoint
. If the givenPoint
is not on thisBezierCurve
anIllegalArgumentException
is thrown.- Parameters:
p
- thePoint
for which the parameter value on thisBezierCurve
is to be found- Returns:
- the corresponding parameter value of the given
Point
on thisBezierCurve
-
getPoint
public Point getPoint(int i)
Returns the ith controlPoint
of thisBezierCurve
. The startPoint
is at index0
, the first handle-Point
is at index1
, etc.- Parameters:
i
- the index of the controlPoint
of thisBezierCurve
to return- Returns:
- the ith control
Point
of thisBezierCurve
-
getPoints
public Point[] getPoints()
Returns the controlPoint
s of thisBezierCurve
.- Returns:
- the control
Point
s of thisBezierCurve
-
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 BezierCurve 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<BezierCurve>
- Parameters:
angle
- rotationAngle
- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCCW
public BezierCurve 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<BezierCurve>
- 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 BezierCurve 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<BezierCurve>
- Parameters:
angle
- rotationAngle
center
- relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
public BezierCurve 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<BezierCurve>
- Parameters:
angle
- rotationAngle
- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
public BezierCurve 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<BezierCurve>
- 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 BezierCurve 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<BezierCurve>
- Parameters:
angle
- rotationAngle
center
- relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getScaled
public BezierCurve 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<BezierCurve>
- Parameters:
factor
- scale-factor- Returns:
- the new, scaled object
-
getScaled
public BezierCurve 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<BezierCurve>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factor- Returns:
- the new, scaled object
-
getScaled
public BezierCurve 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<BezierCurve>
- 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 BezierCurve 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<BezierCurve>
- 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 BezierCurve 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<BezierCurve>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factorcenter
- relativePoint
for the scaling- Returns:
- the new, scaled object
-
getScaled
public BezierCurve 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<BezierCurve>
- Parameters:
factor
- scale-factorcenter
- relativePoint
for the scaling- Returns:
- the new, scaled object
-
getTransformed
public BezierCurve 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
- See Also:
IGeometry.getTransformed(AffineTransform)
-
getTranslated
public BezierCurve 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<BezierCurve>
- Parameters:
dx
- x-translationdy
- y-translation- Returns:
- a new, translated object
-
getTranslated
public BezierCurve getTranslated(Point d)
Description copied from interface:ITranslatable
Translates a copy of this object by the givenPoint
.- Specified by:
getTranslated
in interfaceITranslatable<BezierCurve>
- 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(BezierCurve other)
Checks if thisBezierCurve
and the given otherBezierCurve
overlap, i.e. an infinite set of intersectionPoint
s exists.- Parameters:
other
- theBezierCurve
to check for an overlapping segment with thisBezierCurve
- Returns:
true
if this and the given otherBezierCurve
overlap, otherwisefalse
-
overlaps
public final 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 BezierCurve rotateCCW(Angle angle)
Directly rotates thisBezierCurve
counter-clockwise (CCW) around its centerPoint
by the givenAngle
. Direct adaptation means, thatthis
BezierCurve
is modified in-place.- Parameters:
angle
- the rotationAngle
- Returns:
this
for convenience
-
rotateCCW
public BezierCurve rotateCCW(Angle angle, double cx, double cy)
Directly rotates thisBezierCurve
counter-clockwise (CCW) around thePoint
specified by the given x and y coordinate values by the givenAngle
. Direct adaptation means, thatthis
BezierCurve
is modified in-place.
-
rotateCCW
public BezierCurve rotateCCW(Angle angle, Point center)
Directly rotates thisBezierCurve
counter-clockwise (CCW) around the givenPoint
by the givenAngle
. Direct adaptation means, thatthis
BezierCurve
is modified in-place.
-
rotateCW
public BezierCurve rotateCW(Angle angle)
Directly rotates thisBezierCurve
clockwise (CW) around its centerPoint
by the givenAngle
. Direct adaptation means, thatthis
BezierCurve
is modified in-place.- Parameters:
angle
- the rotationAngle
- Returns:
this
for convenience
-
rotateCW
public BezierCurve rotateCW(Angle angle, double cx, double cy)
Directly rotates thisBezierCurve
clockwise (CW) around thePoint
specified by the given x and y coordinate values by the givenAngle
. Direct adaptation means, thatthis
BezierCurve
is modified in-place.
-
rotateCW
public BezierCurve rotateCW(Angle angle, Point center)
Directly rotates thisBezierCurve
clockwise (CW) around the givenPoint
by the givenAngle
. Direct adaptation means, thatthis
BezierCurve
is modified in-place.
-
scale
public BezierCurve 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<BezierCurve>
- Parameters:
factor
- scale-factor- Returns:
this
for convenience
-
scale
public BezierCurve 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<BezierCurve>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factor- Returns:
this
for convenience
-
scale
public BezierCurve 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<BezierCurve>
- 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 BezierCurve 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<BezierCurve>
- 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 BezierCurve 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<BezierCurve>
- Parameters:
fx
- x-scale-factorfy
- y-scale-factorcenter
- relativePoint
for the scaling- Returns:
this
for convenience
-
scale
public BezierCurve 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<BezierCurve>
- Parameters:
factor
- scale-factorcenter
- relativePoint
for the scaling- Returns:
this
for convenience
-
setP1
public BezierCurve setP1(Point p1)
- Parameters:
p1
- the new startPoint
of thisBezierCurve
- Returns:
this
for convenience
-
setP2
public BezierCurve setP2(Point p2)
- Parameters:
p2
- the new endPoint
of thisBezierCurve
- Returns:
this
for convenience
-
setPoint
public BezierCurve setPoint(int i, Point p)
Sets the ith controlPoint
of thisBezierCurve
. The startPoint
is at index0
, the first handle-Point
is at index1
, etc.- Parameters:
i
- the index of the controlPoint
of thisBezierCurve
to setp
- the new controlPoint
at the given index- Returns:
this
for convenience
-
split
public BezierCurve[] split(double t)
Subdivides thisBezierCurve
at the given parameter value t into two newBezierCurve
s. The first one is theBezierCurve
over the parameterBezierCurve.Interval
[0;t]
and the second one is theBezierCurve
over the parameterBezierCurve.Interval
[t;1]
.- Parameters:
t
- the parameter value at which thisBezierCurve
is subdivided- Returns:
- an array of two
BezierCurve
s, the left ([0;t]
) and the right ([t;1]
)
-
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
-
toCubic
public CubicCurve toCubic()
Returns a hard approximation of thisBezierCurve
as aCubicCurve
. The newCubicCurve
is constructed from the startPoint
, the first two handlePoint
s and the endPoint
of thisBezierCurve
. If thisBezierCurve
is not of degree four or higher, i.e. it does not have four or more controlPoint
s (including start and endPoint
),null
is returned.- Returns:
- a new
CubicCurve
that is constructed from the startPoint
, the first two handlePoint
s and the endPoint
of thisBezierCurve
ornull
if thisBezierCurve
does not have at least four controlPoint
s
-
toLine
public Line toLine()
Returns a hard approximation of thisBezierCurve
as aLine
. TheLine
is constructed from the start and endPoint
of thisBezierCurve
.- Returns:
- a
Line
from the startPoint
to the endPoint
of thisBezierCurve
ornull
if thisBezierCurve
does only have one controlPoint
-
toLineStrip
public Line[] toLineStrip(double lineSimilarity)
Computes an approximation of thisBezierCurve
by a strip ofLine
s. For detailed information on how the approximation is computed, seetoLineStrip(double, Interval)
.- Parameters:
lineSimilarity
- the threshold for the sum of the distances of the controlPoint
s to the baseline (toLine()
) of thisBezierCurve
- Returns:
- an approximation of this
BezierCurve
by a strip ofLine
s - See Also:
toLineStrip(double, Interval)
-
toLineStrip
public Line[] toLineStrip(double lineSimilarity, org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)
Computes an approximation of this
BezierCurve
by a strip ofLine
s.The
BezierCurve
is recursively subdivided until it is "similar" to a straightLine
. The similarity check computes the sum of the distances of the controlPoint
s to the baseline (toLine()
) of thisBezierCurve
. If this sum is smaller than the given lineSimilarity, theBezierCurve
is assumed to be "similar" to a straight line.- Parameters:
lineSimilarity
- the threshold for the sum of the distances of the control points to the baseline of thisBezierCurve
startInterval
- theBezierCurve.Interval
of thisBezierCurve
that has to be approximated by a strip ofLine
s- Returns:
Line
segments approximating thisBezierCurve
-
toPath
public Path toPath()
- Specified by:
toPath
in interfaceIGeometry
- Returns:
- a
Path
approximating thisBezierCurve
usingLine
segments
-
toPoints
public Point[] toPoints(org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)
ComputesPoint
s on thisBezierCurve
over the givenBezierCurve.Interval
. Consecutive returnedPoint
s are required to beequal
to each other.- Parameters:
startInterval
- theBezierCurve.Interval
of thisBezierCurve
to calculatePoint
s for- Returns:
Point
s on thisBezierCurve
over the given parameterBezierCurve.Interval
where consecutivePoint
s areequal
to each other
-
toQuadratic
public QuadraticCurve toQuadratic()
Returns a hard approximation of thisBezierCurve
as aQuadraticCurve
. The newQuadraticCurve
is constructed from the startPoint
, the first handlePoint
and the endPoint
of thisBezierCurve
. If thisBezierCurve
is not of degree three or higher, i.e. it does not have three or more controlPoint
s (including start and endPoint
),null
is returned.- Returns:
- a new
QuadraticCurve
that is constructed from the startPoint
, the first handlePoint
and the endPoint
of thisBezierCurve
ornull
if thisBezierCurve
does not have at least three controlPoint
s
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
translate
public BezierCurve 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<BezierCurve>
- Parameters:
dx
- x-translationdy
- y-translation- Returns:
this
for convenience
-
translate
public BezierCurve translate(Point d)
Description copied from interface:ITranslatable
Translates the object by the givenPoint
.- Specified by:
translate
in interfaceITranslatable<BezierCurve>
- 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()
-
-