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
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default curve width coefficient used in interpolateCubic(...) -
Constructor Summary
ConstructorsConstructorDescriptionPolyBezier(BezierCurve... beziers) Constructs a newPolyBezierof the givenBezierCurves. -
Method Summary
Modifier and TypeMethodDescriptionclone()Overridden with public visibility as recommended withinCloneable.booleanbooleangetCopy()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.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.final inthashCode()static PolyBezierinterpolateCubic(double... coordinates) static PolyBezierinterpolateCubic(double curveWidthCoefficient, Point... points) static PolyBezierinterpolateCubic(Angle startAngle, double startLength, Angle endAngle, double endLength, double curveWidthCoefficient, Point... wayPoints) static PolyBezierinterpolateCubic(Point... points) booleanintersects(ICurve c) booleanDirectly rotates thisPolyBeziercounter-clock-wise around the given point (specified by cx and cy) by the givenAngle.Directly rotates thisPolyBezierclock-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 ofBezierCurves that approximate theICurve.toPath()toString()booleantranslate(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 newPolyBezierof the givenBezierCurves. TheBezierCurves are expected to be connected with each other.- Parameters:
beziers- theBezierCurves 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
PolyBezierconsisting of continuousCubicCurvesegments through the givenPoints.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 ofPoints which lie on the resultingPolyBezier.- Returns:
PolyBezierconsisting of continuousCubicCurvesegments through the givenPoints
-
interpolateCubic
- Parameters:
coordinates- the coordinates of the points that are to be interpolated.- Returns:
PolyBezierwith continuousCubicCurvesegments 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 ofPoints which lie on the resultingPolyBezier.- Returns:
PolyBezierwith continuousCubicCurvesegments through the givenPoints.
-
interpolateCubic
- Parameters:
points- The array ofPoints which lie on the resultingPolyBezier.- Returns:
PolyBezierwith continuousCubicCurvesegments through the givenPoints.- See Also:
-
contains
Description copied from interface:IGeometry -
equals
-
getBounds
Description copied from interface:IGeometry -
getCopy
Description copied from interface:IGeometryReturns a new identical copy of thisIGeometry. -
getIntersections
Description copied from interface:ICurve- Specified by:
getIntersectionsin interfaceICurve- Parameters:
c- TheICurveto compute intersection points with.- Returns:
- The points of intersection.
-
getOverlaps
Description copied from interface:ICurve- Specified by:
getOverlapsin 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: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
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<PolyBezier>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCCW
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<PolyBezier>- 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
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<PolyBezier>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
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<PolyBezier>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
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<PolyBezier>- 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
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<PolyBezier>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getScaled
Description copied from interface:IScalableScales a copy of the calling object by the given factor relative to its centerPoint.- Specified by:
getScaledin interfaceIScalable<PolyBezier>- Parameters:
factor- scale-factor- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to its centerPoint.- Specified by:
getScaledin interfaceIScalable<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factor- Returns:
- the new, scaled object
-
getScaled
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<PolyBezier>- Parameters:
factor- scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
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<PolyBezier>- 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
Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to the given centerPoint.- Specified by:
getScaledin interfaceIScalable<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factorcenter- relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
Description copied from interface:IScalableScales a copy of the calling object by the given factor relative to the given centerPoint.- Specified by:
getScaledin interfaceIScalable<PolyBezier>- Parameters:
factor- scale-factorcenter- relativePointfor the scaling- Returns:
- the new, scaled object
-
getTransformed
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
-
getTranslated
Description copied from interface:ITranslatableTranslates a copy of this object by the given values in x and y direction.- Specified by:
getTranslatedin interfaceITranslatable<PolyBezier>- Parameters:
dx- x-translationdy- y-translation- Returns:
- a new, translated object
-
getTranslated
Description copied from interface:ITranslatableTranslates a copy of this object by the givenPoint.- Specified by:
getTranslatedin interfaceITranslatable<PolyBezier>- 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
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
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
Directly rotates thisPolyBeziercounter-clock-wise around its centerPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.- Parameters:
angle- rotationAngle- Returns:
thisfor convenience
-
rotateCCW
Directly rotates thisPolyBeziercounter-clock-wise around the given point (specified by cx and cy) by the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place. -
rotateCCW
Directly rotates thisPolyBeziercounter-clock-wise around the givenPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place. -
rotateCW
Directly rotates thisPolyBezierclock-wise around its centerPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.- Parameters:
angle- rotationAngle- Returns:
thisfor convenience
-
rotateCW
Directly rotates thisPolyBezierclock-wise around the given point (specified by cx and cy) by the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place. -
rotateCW
Directly rotates thisPolyBezierclock-wise around the givenPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place. -
scale
Description copied from interface:IScalableScales the calling object by the given factor relative to its centerPoint.- Specified by:
scalein interfaceIScalable<PolyBezier>- Parameters:
factor- scale-factor- Returns:
thisfor convenience
-
scale
Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint.- Specified by:
scalein interfaceIScalable<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factor- Returns:
thisfor convenience
-
scale
Description copied from interface:IScalableScales the calling object by the given factor relative to the given centerPoint(cx, cy).- Specified by:
scalein interfaceIScalable<PolyBezier>- Parameters:
factor- scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
thisfor convenience
-
scale
Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint(cx, cy).- Specified by:
scalein interfaceIScalable<PolyBezier>- 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
Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint.- Specified by:
scalein interfaceIScalable<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factorcenter- relativePointfor the scaling- Returns:
thisfor convenience
-
scale
Description copied from interface:IScalableScales the calling object by the given factor relative to the given centerPoint.- Specified by:
scalein interfaceIScalable<PolyBezier>- Parameters:
factor- scale-factorcenter- relativePointfor the scaling- Returns:
thisfor convenience
-
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
-
toPath
Description copied from interface:IGeometry -
toString
-
translate
Description copied from interface:ITranslatableTranslates the object by the given values in x and y direction.- Specified by:
translatein interfaceITranslatable<PolyBezier>- Parameters:
dx- x-translationdy- y-translation- Returns:
thisfor convenience
-
translate
Description copied from interface:ITranslatableTranslates the object by the givenPoint.- Specified by:
translatein interfaceITranslatable<PolyBezier>- Parameters:
d- translationPoint- Returns:
thisfor convenience
-
clone
Overridden with public visibility as recommended withinCloneable. -
hashCode
public final int hashCode() -
touches
Description copied from interface:IGeometry
-