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 doubleINTERPOLATION_CURVE_WIDTH_COEFFICIENTThe default curve width coefficient used in interpolateCubic(...)
-
Constructor Summary
Constructors Constructor Description PolyBezier(BezierCurve... beziers)Constructs a newPolyBezierof the givenBezierCurves.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Overridden with public visibility as recommended withinCloneable.booleancontains(Point p)booleanequals(java.lang.Object o)RectanglegetBounds()PolyBeziergetCopy()Returns a new identical copy of thisIGeometry.Point[]getIntersections(ICurve c)ICurve[]getOverlaps(ICurve c)PointgetP1()PointgetP2()PointgetProjection(Point reference)PolyBeziergetRotatedCCW(Angle angle)PolyBeziergetRotatedCCW(Angle angle, double cx, double cy)PolyBeziergetRotatedCCW(Angle angle, Point center)PolyBeziergetRotatedCW(Angle angle)PolyBeziergetRotatedCW(Angle angle, double cx, double cy)PolyBeziergetRotatedCW(Angle angle, Point center)PolyBeziergetScaled(double factor)Scales a copy of the calling object by the given factor relative to its centerPoint.PolyBeziergetScaled(double fx, double fy)Scales a copy of the calling object by the given factors relative to its centerPoint.PolyBeziergetScaled(double factor, double cx, double cy)Scales a copy of the calling object by the given factor relative to the given centerPoint(cx, cy).PolyBeziergetScaled(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).PolyBeziergetScaled(double fx, double fy, Point center)Scales a copy of the calling object by the given factors relative to the given centerPoint.PolyBeziergetScaled(double factor, Point center)Scales a copy of the calling object by the given factor relative to the given centerPoint.PolyBeziergetTransformed(AffineTransform t)PolyBeziergetTranslated(double dx, double dy)Translates a copy of this object by the given values in x and y direction.PolyBeziergetTranslated(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()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)booleanoverlaps(ICurve c)PolyBezierrotateCCW(Angle angle)PolyBezierrotateCCW(Angle angle, double cx, double cy)Directly rotates thisPolyBeziercounter-clock-wise around the given point (specified by cx and cy) by the givenAngle.PolyBezierrotateCCW(Angle angle, Point center)PolyBezierrotateCW(Angle angle)PolyBezierrotateCW(Angle angle, double cx, double cy)Directly rotates thisPolyBezierclock-wise around the given point (specified by cx and cy) by the givenAngle.PolyBezierrotateCW(Angle angle, Point center)PolyBezierscale(double factor)Scales the calling object by the given factor relative to its centerPoint.PolyBezierscale(double fx, double fy)Scales the calling object by the given factors relative to the given centerPoint.PolyBezierscale(double factor, double cx, double cy)Scales the calling object by the given factor relative to the given centerPoint(cx, cy).PolyBezierscale(double fx, double fy, double cx, double cy)Scales the calling object by the given factors relative to the given centerPoint(cx, cy).PolyBezierscale(double fx, double fy, Point center)Scales the calling object by the given factors relative to the given centerPoint.PolyBezierscale(double factor, Point center)Scales the calling object by the given factor relative to the given centerPoint.BezierCurve[]toBezier()Computes a list ofBezierCurves that approximate theICurve.PathtoPath()java.lang.StringtoString()booleantouches(IGeometry g)PolyBeziertranslate(double dx, double dy)Translates the object by the given values in x and y direction.PolyBeziertranslate(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 newPolyBezierof the givenBezierCurves. TheBezierCurves are expected to be connected with each other.- Parameters:
beziers- theBezierCurves 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
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
public static PolyBezier interpolateCubic(double... coordinates)
- 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(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 ofPoints which lie on the resultingPolyBezier.- Returns:
PolyBezierwith continuousCubicCurvesegments through the givenPoints.
-
interpolateCubic
public static PolyBezier interpolateCubic(Point... points)
- Parameters:
points- The array ofPoints which lie on the resultingPolyBezier.- Returns:
PolyBezierwith continuousCubicCurvesegments through the givenPoints.- See Also:
interpolateCubic(double, Point...)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
getCopy
public PolyBezier getCopy()
Description copied from interface:IGeometryReturns a new identical copy of thisIGeometry.
-
getIntersections
public Point[] getIntersections(ICurve c)
Description copied from interface:ICurve- Specified by:
getIntersectionsin interfaceICurve- Parameters:
c- TheICurveto compute intersection points with.- Returns:
- The points of intersection.
-
getOverlaps
public 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.
-
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 PolyBezier 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<PolyBezier>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCCW
public PolyBezier 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<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
public PolyBezier 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<PolyBezier>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public PolyBezier 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<PolyBezier>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public PolyBezier 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<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
public PolyBezier 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<PolyBezier>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getScaled
public PolyBezier 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<PolyBezier>- Parameters:
factor- scale-factor- Returns:
- the new, scaled object
-
getScaled
public PolyBezier 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<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: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
public PolyBezier 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<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
public PolyBezier 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<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factorcenter- relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
public PolyBezier 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<PolyBezier>- Parameters:
factor- scale-factorcenter- relativePointfor the scaling- Returns:
- the new, scaled object
-
getTransformed
public PolyBezier 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
-
getTranslated
public PolyBezier 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<PolyBezier>- Parameters:
dx- x-translationdy- y-translation- Returns:
- a new, translated object
-
getTranslated
public PolyBezier getTranslated(Point d)
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
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(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 PolyBezier rotateCCW(Angle angle)
Directly rotates thisPolyBeziercounter-clock-wise around its centerPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.- Parameters:
angle- rotationAngle- Returns:
thisfor convenience
-
rotateCCW
public PolyBezier rotateCCW(Angle angle, double cx, double cy)
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
public PolyBezier rotateCCW(Angle angle, Point center)
Directly rotates thisPolyBeziercounter-clock-wise around the givenPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.
-
rotateCW
public PolyBezier rotateCW(Angle angle)
Directly rotates thisPolyBezierclock-wise around its centerPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.- Parameters:
angle- rotationAngle- Returns:
thisfor convenience
-
rotateCW
public PolyBezier rotateCW(Angle angle, double cx, double cy)
Directly rotates thisPolyBezierclock-wise around the given point (specified by cx and cy) by the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.
-
rotateCW
public PolyBezier rotateCW(Angle angle, Point center)
Directly rotates thisPolyBezierclock-wise around the givenPointby the givenAngle. Direct adaptation means, thatthisPolyBezieris modified in-place.
-
scale
public PolyBezier scale(double factor)
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
public PolyBezier 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<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factor- Returns:
thisfor convenience
-
scale
public PolyBezier 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<PolyBezier>- Parameters:
factor- scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
thisfor convenience
-
scale
public PolyBezier 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<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
public PolyBezier 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<PolyBezier>- Parameters:
fx- x-scale-factorfy- y-scale-factorcenter- relativePointfor the scaling- Returns:
thisfor convenience
-
scale
public PolyBezier 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<PolyBezier>- Parameters:
factor- scale-factorcenter- relativePointfor the scaling- Returns:
thisfor convenience
-
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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
translate
public PolyBezier 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<PolyBezier>- Parameters:
dx- x-translationdy- y-translation- Returns:
thisfor convenience
-
translate
public PolyBezier translate(Point d)
Description copied from interface:ITranslatableTranslates the object by the givenPoint.- Specified by:
translatein interfaceITranslatable<PolyBezier>- 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()
-
-