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
BezierCurveclass individually represent an arbitrary Bezier curve. This is the base class of the special quadratic and cubic Bezier curve classes (QuadraticCurveandCubicCurve).- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BezierCurve(double... controlPoints)Constructs a newBezierCurvefrom the given controlPointcoordinates.BezierCurve(CubicCurve c)Constructs a newBezierCurvefrom the givenCubicCurve.BezierCurve(Point... controlPoints)Constructs a newBezierCurvefrom the given controlPoints.BezierCurve(QuadraticCurve c)Constructs a newBezierCurvefrom the givenQuadraticCurve.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Overridden with public visibility as recommended withinCloneable.booleancontains(BezierCurve o)Tests if thisBezierCurvecontains the given otherBezierCurve.booleancontains(Point p)booleanequals(java.lang.Object other)Pointget(double t)Computes thePointon thisBezierCurveat parameter value t, which is expected to lie in the parameterBezierCurve.Interval[0;1].RectanglegetBounds()BezierCurvegetClipped(double s, double e)RectanglegetControlBounds()BezierCurvegetCopy()Returns a new identical copy of thisIGeometry.BezierCurvegetDerivative()Computes the hodograph, the first parametric derivative, of thisBezierCurve.BezierCurvegetElevated()Computes aBezierCurvewith a degree of one higher than thisBezierCurve's degree but of the same shape.Point[]getIntersections(BezierCurve other)Returns thePoints of intersection of this and the given otherBezierCurve.Point[]getIntersections(ICurve curve)PolyBeziergetOffset(double distance)Returns aPolyBezierthat represents an approximation of the refined offset of thisBezierCurvewhere 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.BezierCurvegetOverlap(BezierCurve other)Returns aBezierCurvethat represents the overlap of thisBezierCurveand the given otherBezierCurve.ICurve[]getOverlaps(ICurve c)PointgetP1()PointgetP2()doublegetParameterAt(Point p)Returns the parameter value of thisBezierCurvefor the givenPoint.PointgetPoint(int i)Returns the ith controlPointof thisBezierCurve.Point[]getPoints()Returns the controlPoints of thisBezierCurve.PointgetProjection(Point reference)BezierCurvegetRotatedCCW(Angle angle)BezierCurvegetRotatedCCW(Angle angle, double cx, double cy)BezierCurvegetRotatedCCW(Angle angle, Point center)BezierCurvegetRotatedCW(Angle angle)BezierCurvegetRotatedCW(Angle angle, double cx, double cy)BezierCurvegetRotatedCW(Angle angle, Point center)BezierCurvegetScaled(double factor)Scales a copy of the calling object by the given factor relative to its centerPoint.BezierCurvegetScaled(double fx, double fy)Scales a copy of the calling object by the given factors relative to its centerPoint.BezierCurvegetScaled(double factor, double cx, double cy)Scales a copy of the calling object by the given factor relative to the given centerPoint(cx, cy).BezierCurvegetScaled(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).BezierCurvegetScaled(double fx, double fy, Point center)Scales a copy of the calling object by the given factors relative to the given centerPoint.BezierCurvegetScaled(double factor, Point center)Scales a copy of the calling object by the given factor relative to the given centerPoint.BezierCurvegetTransformed(AffineTransform t)BezierCurvegetTranslated(double dx, double dy)Translates a copy of this object by the given values in x and y direction.BezierCurvegetTranslated(Point d)Translates a copy of this object by the givenPoint.doublegetX1()Returns the startPoint's x coordinate.doublegetX2()Returns the endPoint's x coordinate.doublegetY1()Returns the startPoint's y coordinate.doublegetY2()Returns the endPoint's y coordinate.inthashCode()booleanintersects(ICurve c)booleanoverlaps(BezierCurve other)Checks if thisBezierCurveand the given otherBezierCurveoverlap, i.e. an infinite set of intersectionPoints exists.booleanoverlaps(ICurve c)BezierCurverotateCCW(Angle angle)Directly rotates thisBezierCurvecounter-clockwise (CCW) around its centerPointby the givenAngle.BezierCurverotateCCW(Angle angle, double cx, double cy)Directly rotates thisBezierCurvecounter-clockwise (CCW) around thePointspecified by the given x and y coordinate values by the givenAngle.BezierCurverotateCCW(Angle angle, Point center)Directly rotates thisBezierCurvecounter-clockwise (CCW) around the givenPointby the givenAngle.BezierCurverotateCW(Angle angle)BezierCurverotateCW(Angle angle, double cx, double cy)Directly rotates thisBezierCurveclockwise (CW) around thePointspecified by the given x and y coordinate values by the givenAngle.BezierCurverotateCW(Angle angle, Point center)BezierCurvescale(double factor)Scales the calling object by the given factor relative to its centerPoint.BezierCurvescale(double fx, double fy)Scales the calling object by the given factors relative to the given centerPoint.BezierCurvescale(double factor, double cx, double cy)Scales the calling object by the given factor relative to the given centerPoint(cx, cy).BezierCurvescale(double fx, double fy, double cx, double cy)Scales the calling object by the given factors relative to the given centerPoint(cx, cy).BezierCurvescale(double fx, double fy, Point center)Scales the calling object by the given factors relative to the given centerPoint.BezierCurvescale(double factor, Point center)Scales the calling object by the given factor relative to the given centerPoint.BezierCurvesetP1(Point p1)BezierCurvesetP2(Point p2)BezierCurvesetPoint(int i, Point p)Sets the ith controlPointof thisBezierCurve.BezierCurve[]split(double t)Subdivides thisBezierCurveat the given parameter value t into two newBezierCurves.BezierCurve[]toBezier()Computes a list ofBezierCurves that approximate theICurve.CubicCurvetoCubic()Returns a hard approximation of thisBezierCurveas aCubicCurve.LinetoLine()Returns a hard approximation of thisBezierCurveas aLine.Line[]toLineStrip(double lineSimilarity)Computes an approximation of thisBezierCurveby a strip ofLines.Line[]toLineStrip(double lineSimilarity, org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)Computes an approximation of thisBezierCurveby a strip ofLines.PathtoPath()Point[]toPoints(org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)QuadraticCurvetoQuadratic()Returns a hard approximation of thisBezierCurveas aQuadraticCurve.java.lang.StringtoString()booleantouches(IGeometry g)BezierCurvetranslate(double dx, double dy)Translates the object by the given values in x and y direction.BezierCurvetranslate(Point d)Translates the object by the givenPoint.
-
-
-
Constructor Detail
-
BezierCurve
public BezierCurve(CubicCurve c)
Constructs a newBezierCurvefrom the givenCubicCurve.- Parameters:
c- theCubicCurveof which the newBezierCurveis constructed from
-
BezierCurve
public BezierCurve(double... controlPoints)
Constructs a newBezierCurvefrom the given controlPointcoordinates. The coordinates are expected to be in x, y order, i.e. x1, y1, x2, y2, x3, y3, ...- Parameters:
controlPoints- the controlPointcoordinates of the newBezierCurvein x, y order
-
BezierCurve
public BezierCurve(Point... controlPoints)
Constructs a newBezierCurvefrom the given controlPoints.- Parameters:
controlPoints- the controlPoints of the newBezierCurve
-
BezierCurve
public BezierCurve(QuadraticCurve c)
Constructs a newBezierCurvefrom the givenQuadraticCurve.- Parameters:
c- theQuadraticCurveof which the newBezierCurveis constructed from
-
-
Method Detail
-
contains
public boolean contains(BezierCurve o)
Tests if this
BezierCurvecontains the given otherBezierCurve.The other
BezierCurveis regarded to be contained by thisBezierCurveif its start and endPointlie on thisBezierCurveand an overlapping segment of the two curves can be detected.- Parameters:
o- theBezierCurvethat is checked to be contained by thisBezierCurve- Returns:
trueif the givenBezierCurveis contained by thisBezierCurve, otherwisefalse
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
get
public Point get(double t)
Computes thePointon thisBezierCurveat parameter value t, which is expected to lie in the parameterBezierCurve.Interval[0;1].- Parameters:
t- the parameter value for which thisBezierCurveis evaluated- Returns:
- the
Pointon thisBezierCurveat the given parameter value
-
getClipped
public BezierCurve getClipped(double s, double e)
- Parameters:
s- the lower limit of the parameterBezierCurve.Intervalwhich is clipped out of thisBezierCurvee- the upper limit of the parameterBezierCurve.Intervalwhich is clipped out of thisBezierCurve- Returns:
- a new
BezierCurverepresenting thisBezierCurveon theBezierCurve.Interval[s;e]
-
getControlBounds
public Rectangle getControlBounds()
- Returns:
- a
Rectanglerepresenting the bounds of the controlPolygonof thisBezierCurve
-
getCopy
public BezierCurve getCopy()
Description copied from interface:IGeometryReturns 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 aBezierCurvewith a degree of one higher than thisBezierCurve's degree but of the same shape.- Returns:
- a
BezierCurveof the same shape as thisBezierCurvebut with one more controlPoint
-
getIntersections
public Point[] getIntersections(BezierCurve other)
Returns thePoints of intersection of this and the given otherBezierCurve.- Parameters:
other- theBezierCurvewhich is searched forPoints of intersection with thisBezierCurve- Returns:
- the
Points of intersection of thisBezierCurveand the given otherBezierCurve
-
getIntersections
public final Point[] getIntersections(ICurve curve)
Description copied from interface:ICurve- Specified by:
getIntersectionsin interfaceICurve- Parameters:
curve- TheICurveto compute intersection points with.- Returns:
- The points of intersection.
-
getOffset
public PolyBezier getOffset(double distance)
Returns aPolyBezierthat represents an approximation of the refined offset of thisBezierCurvewhere 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
PolyBezierrepresenting the refined offset of thisBezierCurvefor the given distance.
-
getOverlap
public BezierCurve getOverlap(BezierCurve other)
Returns a
BezierCurvethat represents the overlap of thisBezierCurveand the given otherBezierCurve. If no overlap exists,nullis returned. An overlap is identified by an infinite number of intersection points.- Parameters:
other- TheBezierCurveto which an overlap is computed.- Returns:
- a
BezierCurverepresenting the overlap of this and the given otherBezierCurveif an overlap exists, otherwisenull
-
getOverlaps
public final ICurve[] getOverlaps(ICurve c)
Description copied from interface:ICurve- Specified by:
getOverlapsin 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 thisBezierCurvefor the givenPoint. If the givenPointis not on thisBezierCurveanIllegalArgumentExceptionis thrown.- Parameters:
p- thePointfor which the parameter value on thisBezierCurveis to be found- Returns:
- the corresponding parameter value of the given
Pointon thisBezierCurve
-
getPoint
public Point getPoint(int i)
Returns the ith controlPointof thisBezierCurve. The startPointis at index0, the first handle-Pointis at index1, etc.- Parameters:
i- the index of the controlPointof thisBezierCurveto return- Returns:
- the ith control
Pointof thisBezierCurve
-
getPoints
public Point[] getPoints()
Returns the controlPoints of thisBezierCurve.- Returns:
- the control
Points of thisBezierCurve
-
getProjection
public Point getProjection(Point reference)
Description copied from interface:ICurveReturns a projection of the given referencePointonto thisICurve, i.e. aPointon thisICurvethat is closest to the given referencePoint. Note, that- Specified by:
getProjectionin interfaceICurve- Parameters:
reference- The referencePointfor which to return the projection.- Returns:
- The projection of the given reference
Pointonto thisICurve.
-
getRotatedCCW
public BezierCurve getRotatedCCW(Angle angle)
Description copied from interface:IRotatableRotates the calling object by specifiedAnglecounter-clock-wise (CCW) around its centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCWin interfaceIRotatable<BezierCurve>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCCW
public BezierCurve getRotatedCCW(Angle angle, double cx, double cy)
Description copied from interface:IRotatableRotates the calling object by the specifiedAnglecounter-clock-wise (CCW) around the specified centerPoint(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCCWin interfaceIRotatable<BezierCurve>- Parameters:
angle- rotationAnglecx- x-coordinate of the relativePointfor the rotationcy- y-coordinate of the relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCCW
public BezierCurve getRotatedCCW(Angle angle, Point center)
Description copied from interface:IRotatableRotates the calling object by the specifiedAnglecounter-clock-wise (CCW) around the specified centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCWin interfaceIRotatable<BezierCurve>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public BezierCurve getRotatedCW(Angle angle)
Description copied from interface:IRotatableRotates the calling object by specifiedAngleclock-wise (CW) around its centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCWin interfaceIRotatable<BezierCurve>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public BezierCurve getRotatedCW(Angle angle, double cx, double cy)
Description copied from interface:IRotatableRotates the calling object by the specifiedAngleclock-wise (CW) around the specified centerPoint(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCWin interfaceIRotatable<BezierCurve>- Parameters:
angle- rotationAnglecx- x-coordinate of the relativePointfor the rotationcy- y-coordinate of the relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public BezierCurve getRotatedCW(Angle angle, Point center)
Description copied from interface:IRotatableRotates the calling object by the specifiedAngleclock-wise (CW) around the specified centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCWin interfaceIRotatable<BezierCurve>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getScaled
public BezierCurve getScaled(double factor)
Description copied from interface:IScalableScales a copy of the calling object by the given factor relative to its centerPoint.- Specified by:
getScaledin interfaceIScalable<BezierCurve>- Parameters:
factor- scale-factor- Returns:
- the new, scaled object
-
getScaled
public BezierCurve getScaled(double fx, double fy)
Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to its centerPoint.- Specified by:
getScaledin 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:IScalableScales a copy of the calling object by the given factor relative to the given centerPoint(cx, cy).- Specified by:
getScaledin interfaceIScalable<BezierCurve>- Parameters:
factor- scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
public BezierCurve getScaled(double fx, double fy, double cx, double cy)
Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to the given centerPoint(cx, cy).- Specified by:
getScaledin interfaceIScalable<BezierCurve>- Parameters:
fx- x-scale-factorfy- y-scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
public BezierCurve getScaled(double fx, double fy, Point center)
Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to the given centerPoint.- Specified by:
getScaledin interfaceIScalable<BezierCurve>- Parameters:
fx- x-scale-factorfy- y-scale-factorcenter- relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
public BezierCurve getScaled(double factor, Point center)
Description copied from interface:IScalableScales a copy of the calling object by the given factor relative to the given centerPoint.- Specified by:
getScaledin interfaceIScalable<BezierCurve>- Parameters:
factor- scale-factorcenter- relativePointfor the scaling- Returns:
- the new, scaled object
-
getTransformed
public BezierCurve getTransformed(AffineTransform t)
Default implementation returning a transformedPathrepresentation of thisIGeometry. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformedin interfaceIGeometry- Parameters:
t- TheAffineTransformto be applied- Returns:
- a transformed
Pathrepresentation of thisIGeometry - See Also:
IGeometry.getTransformed(AffineTransform)
-
getTranslated
public BezierCurve getTranslated(double dx, double dy)
Description copied from interface:ITranslatableTranslates a copy of this object by the given values in x and y direction.- Specified by:
getTranslatedin interfaceITranslatable<BezierCurve>- Parameters:
dx- x-translationdy- y-translation- Returns:
- a new, translated object
-
getTranslated
public BezierCurve getTranslated(Point d)
Description copied from interface:ITranslatableTranslates a copy of this object by the givenPoint.- Specified by:
getTranslatedin interfaceITranslatable<BezierCurve>- Parameters:
d- translationPoint- Returns:
- a new, translated object
-
getX1
public double getX1()
Description copied from interface:ICurveReturns the startPoint's x coordinate.
-
getX2
public double getX2()
Description copied from interface:ICurveReturns the endPoint's x coordinate.
-
getY1
public double getY1()
Description copied from interface:ICurveReturns the startPoint's y coordinate.
-
getY2
public double getY2()
Description copied from interface:ICurveReturns the endPoint's y coordinate.
-
intersects
public boolean intersects(ICurve c)
Description copied from interface:ICurveTests if thisICurveand the givenICurveintersect, 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:
intersectsin interfaceICurve- Parameters:
c- TheICurveto test for intersections.- Returns:
trueif they intersect,falseotherwise
-
overlaps
public boolean overlaps(BezierCurve other)
Checks if thisBezierCurveand the given otherBezierCurveoverlap, i.e. an infinite set of intersectionPoints exists.- Parameters:
other- theBezierCurveto check for an overlapping segment with thisBezierCurve- Returns:
trueif this and the given otherBezierCurveoverlap, otherwisefalse
-
overlaps
public final boolean overlaps(ICurve c)
Description copied from interface:ICurveTests if thisICurveand the givenICurveoverlap, 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 thisBezierCurvecounter-clockwise (CCW) around its centerPointby the givenAngle. Direct adaptation means, thatthisBezierCurveis modified in-place.- Parameters:
angle- the rotationAngle- Returns:
thisfor convenience
-
rotateCCW
public BezierCurve rotateCCW(Angle angle, double cx, double cy)
Directly rotates thisBezierCurvecounter-clockwise (CCW) around thePointspecified by the given x and y coordinate values by the givenAngle. Direct adaptation means, thatthisBezierCurveis modified in-place.
-
rotateCCW
public BezierCurve rotateCCW(Angle angle, Point center)
Directly rotates thisBezierCurvecounter-clockwise (CCW) around the givenPointby the givenAngle. Direct adaptation means, thatthisBezierCurveis modified in-place.
-
rotateCW
public BezierCurve rotateCW(Angle angle)
Directly rotates thisBezierCurveclockwise (CW) around its centerPointby the givenAngle. Direct adaptation means, thatthisBezierCurveis modified in-place.- Parameters:
angle- the rotationAngle- Returns:
thisfor convenience
-
rotateCW
public BezierCurve rotateCW(Angle angle, double cx, double cy)
Directly rotates thisBezierCurveclockwise (CW) around thePointspecified by the given x and y coordinate values by the givenAngle. Direct adaptation means, thatthisBezierCurveis modified in-place.
-
rotateCW
public BezierCurve rotateCW(Angle angle, Point center)
Directly rotates thisBezierCurveclockwise (CW) around the givenPointby the givenAngle. Direct adaptation means, thatthisBezierCurveis modified in-place.
-
scale
public BezierCurve scale(double factor)
Description copied from interface:IScalableScales the calling object by the given factor relative to its centerPoint.- Specified by:
scalein interfaceIScalable<BezierCurve>- Parameters:
factor- scale-factor- Returns:
thisfor convenience
-
scale
public BezierCurve scale(double fx, double fy)
Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint.- Specified by:
scalein interfaceIScalable<BezierCurve>- Parameters:
fx- x-scale-factorfy- y-scale-factor- Returns:
thisfor convenience
-
scale
public BezierCurve scale(double factor, double cx, double cy)
Description copied from interface:IScalableScales the calling object by the given factor relative to the given centerPoint(cx, cy).- Specified by:
scalein interfaceIScalable<BezierCurve>- Parameters:
factor- scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
thisfor convenience
-
scale
public BezierCurve scale(double fx, double fy, double cx, double cy)
Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint(cx, cy).- Specified by:
scalein interfaceIScalable<BezierCurve>- Parameters:
fx- x-scale-factorfy- y-scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
thisfor convenience
-
scale
public BezierCurve scale(double fx, double fy, Point center)
Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint.- Specified by:
scalein interfaceIScalable<BezierCurve>- Parameters:
fx- x-scale-factorfy- y-scale-factorcenter- relativePointfor the scaling- Returns:
thisfor convenience
-
scale
public BezierCurve scale(double factor, Point center)
Description copied from interface:IScalableScales the calling object by the given factor relative to the given centerPoint.- Specified by:
scalein interfaceIScalable<BezierCurve>- Parameters:
factor- scale-factorcenter- relativePointfor the scaling- Returns:
thisfor convenience
-
setP1
public BezierCurve setP1(Point p1)
- Parameters:
p1- the new startPointof thisBezierCurve- Returns:
thisfor convenience
-
setP2
public BezierCurve setP2(Point p2)
- Parameters:
p2- the new endPointof thisBezierCurve- Returns:
thisfor convenience
-
setPoint
public BezierCurve setPoint(int i, Point p)
Sets the ith controlPointof thisBezierCurve. The startPointis at index0, the first handle-Pointis at index1, etc.- Parameters:
i- the index of the controlPointof thisBezierCurveto setp- the new controlPointat the given index- Returns:
thisfor convenience
-
split
public BezierCurve[] split(double t)
Subdivides thisBezierCurveat the given parameter value t into two newBezierCurves. The first one is theBezierCurveover the parameterBezierCurve.Interval[0;t]and the second one is theBezierCurveover the parameterBezierCurve.Interval[t;1].- Parameters:
t- the parameter value at which thisBezierCurveis subdivided- Returns:
- an array of two
BezierCurves, the left ([0;t]) and the right ([t;1])
-
toBezier
public BezierCurve[] toBezier()
Description copied from interface:ICurveComputes a list ofBezierCurves that approximate theICurve. For example, aLineor aBezierCurvein general could return a list with the curve itself as its only element. But anEllipseor anArcmay return a list of consecutiveBezierCurves which approximate theICurve.- Specified by:
toBezierin interfaceICurve- Returns:
- a list of
BezierCurves that approximate theICurve
-
toCubic
public CubicCurve toCubic()
Returns a hard approximation of thisBezierCurveas aCubicCurve. The newCubicCurveis constructed from the startPoint, the first two handlePoints and the endPointof thisBezierCurve. If thisBezierCurveis not of degree four or higher, i.e. it does not have four or more controlPoints (including start and endPoint),nullis returned.- Returns:
- a new
CubicCurvethat is constructed from the startPoint, the first two handlePoints and the endPointof thisBezierCurveornullif thisBezierCurvedoes not have at least four controlPoints
-
toLine
public Line toLine()
Returns a hard approximation of thisBezierCurveas aLine. TheLineis constructed from the start and endPointof thisBezierCurve.- Returns:
- a
Linefrom the startPointto the endPointof thisBezierCurveornullif thisBezierCurvedoes only have one controlPoint
-
toLineStrip
public Line[] toLineStrip(double lineSimilarity)
Computes an approximation of thisBezierCurveby a strip ofLines. For detailed information on how the approximation is computed, seetoLineStrip(double, Interval).- Parameters:
lineSimilarity- the threshold for the sum of the distances of the controlPoints to the baseline (toLine()) of thisBezierCurve- Returns:
- an approximation of this
BezierCurveby a strip ofLines - See Also:
toLineStrip(double, Interval)
-
toLineStrip
public Line[] toLineStrip(double lineSimilarity, org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)
Computes an approximation of this
BezierCurveby a strip ofLines.The
BezierCurveis recursively subdivided until it is "similar" to a straightLine. The similarity check computes the sum of the distances of the controlPoints to the baseline (toLine()) of thisBezierCurve. If this sum is smaller than the given lineSimilarity, theBezierCurveis 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 thisBezierCurvestartInterval- theBezierCurve.Intervalof thisBezierCurvethat has to be approximated by a strip ofLines- Returns:
Linesegments approximating thisBezierCurve
-
toPath
public Path toPath()
- Specified by:
toPathin interfaceIGeometry- Returns:
- a
Pathapproximating thisBezierCurveusingLinesegments
-
toPoints
public Point[] toPoints(org.eclipse.gef.geometry.planar.BezierCurve.Interval startInterval)
ComputesPoints on thisBezierCurveover the givenBezierCurve.Interval. Consecutive returnedPoints are required to beequalto each other.- Parameters:
startInterval- theBezierCurve.Intervalof thisBezierCurveto calculatePoints for- Returns:
Points on thisBezierCurveover the given parameterBezierCurve.Intervalwhere consecutivePoints areequalto each other
-
toQuadratic
public QuadraticCurve toQuadratic()
Returns a hard approximation of thisBezierCurveas aQuadraticCurve. The newQuadraticCurveis constructed from the startPoint, the first handlePointand the endPointof thisBezierCurve. If thisBezierCurveis not of degree three or higher, i.e. it does not have three or more controlPoints (including start and endPoint),nullis returned.- Returns:
- a new
QuadraticCurvethat is constructed from the startPoint, the first handlePointand the endPointof thisBezierCurveornullif thisBezierCurvedoes not have at least three controlPoints
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
translate
public BezierCurve translate(double dx, double dy)
Description copied from interface:ITranslatableTranslates the object by the given values in x and y direction.- Specified by:
translatein interfaceITranslatable<BezierCurve>- Parameters:
dx- x-translationdy- y-translation- Returns:
thisfor convenience
-
translate
public BezierCurve translate(Point d)
Description copied from interface:ITranslatableTranslates the object by the givenPoint.- Specified by:
translatein interfaceITranslatable<BezierCurve>- Parameters:
d- translationPoint- Returns:
thisfor convenience
-
clone
public java.lang.Object clone()
Overridden with public visibility as recommended withinCloneable.- Overrides:
clonein classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
-