Package org.eclipse.gef.geometry.planar
Class CubicCurve
- java.lang.Object
-
- org.eclipse.gef.geometry.planar.BezierCurve
-
- org.eclipse.gef.geometry.planar.CubicCurve
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,ICurve,IGeometry,IRotatable<BezierCurve>,IScalable<BezierCurve>,ITranslatable<BezierCurve>
public class CubicCurve extends BezierCurve
An instance of theCubicCurveclass represents aBezierCurveof degree 3, having a start and an endPointand two handlePoints.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CubicCurve(double... coordinates)Constructs a newCubicCurveobject with the given sequence of x and y coordinates of the startPoint, the two handlePoints, and the endPoint.CubicCurve(double x1, double y1, double ctrl1X, double ctrl1Y, double ctrl2X, double ctrl2Y, double x2, double y2)Constructs a newCubicCurveobject from the given controlPointcoordinates.CubicCurve(Point... points)Constructs a newCubicCurvefrom the given sequence ofPoints, which is expected to be in the order: startPoint, first and second handlePoints, and endPoint.CubicCurve(Point start, Point ctrl1, Point ctrl2, Point end)Constructs a newCubicCurveobject from the given controlPoints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Overridden with public visibility as recommended withinCloneable.CubicCurvegetCopy()Returns a newCubicCurve, which has the same controlPoints as this one.PointgetCtrl1()Returns the first handlePoint.PointgetCtrl2()Returns the second handlePoint.doublegetCtrlX1()Returns the first handlePoint's x coordinate.doublegetCtrlX2()Returns the second handlePoint's x coordinate.doublegetCtrlY1()Returns the first handlePoint's y coordinate.doublegetCtrlY2()Returns the second handlePoint's y coordinate.CubicCurvegetTransformed(AffineTransform t)inthashCode()CubicCurvesetCtrl1(Point ctrl1)CubicCurvesetCtrl1X(double ctrl1x)Sets the x coordinate of the first handlePointof thisCubicCurveto the given value.CubicCurvesetCtrl1Y(double ctrl1y)Sets the y coordinate of the first handlePointof thisCubicCurveto the given value.CubicCurvesetCtrl2(Point ctrl2)CubicCurvesetCtrl2X(double ctrl2x)Sets the x coordinate of the second handlePointof thisCubicCurveto the given value.CubicCurvesetCtrl2Y(double ctrl2y)Sets the y coordinate of the second handlePointof thisCubicCurveto the given value.CubicCurvesetCurve(Point p1, Point ctrl1, Point ctrl2, Point p2)CubicCurve[]split(double t)Subdivides thisBezierCurveat the given parameter value t into two newBezierCurves.PathtoPath()java.lang.StringtoString()booleantouches(IGeometry g)-
Methods inherited from class org.eclipse.gef.geometry.planar.BezierCurve
contains, contains, equals, get, getBounds, getClipped, getControlBounds, getDerivative, getElevated, getIntersections, getIntersections, getOffset, getOverlap, getOverlaps, getP1, getP2, getParameterAt, getPoint, getPoints, getProjection, getRotatedCCW, getRotatedCCW, getRotatedCCW, getRotatedCW, getRotatedCW, getRotatedCW, getScaled, getScaled, getScaled, getScaled, getScaled, getScaled, getTranslated, getTranslated, getX1, getX2, getY1, getY2, intersects, overlaps, overlaps, rotateCCW, rotateCCW, rotateCCW, rotateCW, rotateCW, rotateCW, scale, scale, scale, scale, scale, scale, setP1, setP2, setPoint, toBezier, toCubic, toLine, toLineStrip, toLineStrip, toPoints, toQuadratic, translate, translate
-
-
-
-
Constructor Detail
-
CubicCurve
public CubicCurve(double... coordinates)
Constructs a newCubicCurveobject with the given sequence of x and y coordinates of the startPoint, the two handlePoints, and the endPoint.- Parameters:
coordinates- the sequence of x and y coordinates specifying thisCubicCurve's controlPoints- See Also:
CubicCurve(double, double, double, double, double, double, double, double)
-
CubicCurve
public CubicCurve(double x1, double y1, double ctrl1X, double ctrl1Y, double ctrl2X, double ctrl2Y, double x2, double y2)Constructs a newCubicCurveobject from the given controlPointcoordinates.- Parameters:
x1- the x coordinate of the startPointy1- the y coordinate of the startPointctrl1X- the x coordinate of the first handlePointctrl1Y- the y coordinate of the first handlePointctrl2X- the x coordinate of the second handlePointctrl2Y- the y coordinate of the second handlePointx2- the x coordinate of the endPointy2- the y coordinate of the endPoint
-
CubicCurve
public CubicCurve(Point... points)
Constructs a newCubicCurvefrom the given sequence ofPoints, which is expected to be in the order: startPoint, first and second handlePoints, and endPoint.- Parameters:
points- the sequence ofPoints from which thisCubicCurveis constructed- See Also:
CubicCurve(Point, Point, Point, Point),CubicCurve(double, double, double, double, double, double, double, double)
-
CubicCurve
public CubicCurve(Point start, Point ctrl1, Point ctrl2, Point end)
Constructs a newCubicCurveobject from the given controlPoints.- Parameters:
start- the startPointctrl1- the first handlePointctrl2- the second handlePointend- the endPoint- See Also:
CubicCurve(double, double, double, double, double, double, double, double)
-
-
Method Detail
-
getCopy
public CubicCurve getCopy()
Returns a newCubicCurve, which has the same controlPoints as this one.- Specified by:
getCopyin interfaceIGeometry- Overrides:
getCopyin classBezierCurve- Returns:
- a new
CubicCurvewith the same controlPoints as this one
-
getCtrlX1
public double getCtrlX1()
Returns the first handlePoint's x coordinate.- Returns:
- the first handle
Point's x coordinate
-
getCtrlX2
public double getCtrlX2()
Returns the second handlePoint's x coordinate.- Returns:
- the second handle
Point's x coordinate
-
getCtrlY1
public double getCtrlY1()
Returns the first handlePoint's y coordinate.- Returns:
- the first handle
Point's y coordinate
-
getCtrlY2
public double getCtrlY2()
Returns the second handlePoint's y coordinate.- Returns:
- the second handle
Point's y coordinate
-
getTransformed
public CubicCurve 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- Overrides:
getTransformedin classBezierCurve- Parameters:
t- TheAffineTransformto be applied- Returns:
- a transformed
Pathrepresentation of thisIGeometry - See Also:
IGeometry.getTransformed(AffineTransform)
-
setCtrl1
public CubicCurve setCtrl1(Point ctrl1)
- Parameters:
ctrl1- the new first handlePoint- Returns:
thisfor convenience
-
setCtrl1X
public CubicCurve setCtrl1X(double ctrl1x)
Sets the x coordinate of the first handlePointof thisCubicCurveto the given value.- Parameters:
ctrl1x- the new x coordinate of the first handlePointof thisCubicCurve- Returns:
thisfor convenience
-
setCtrl1Y
public CubicCurve setCtrl1Y(double ctrl1y)
Sets the y coordinate of the first handlePointof thisCubicCurveto the given value.- Parameters:
ctrl1y- the new y coordinate of the first handlePointof thisCubicCurve- Returns:
thisfor convenience
-
setCtrl2
public CubicCurve setCtrl2(Point ctrl2)
- Parameters:
ctrl2- the new second handlePointof thisCubicCurve- Returns:
thisfor convenience
-
setCtrl2X
public CubicCurve setCtrl2X(double ctrl2x)
Sets the x coordinate of the second handlePointof thisCubicCurveto the given value.- Parameters:
ctrl2x- the new x coordinate of the second handlePointof thisCubicCurve- Returns:
thisfor convenience
-
setCtrl2Y
public CubicCurve setCtrl2Y(double ctrl2y)
Sets the y coordinate of the second handlePointof thisCubicCurveto the given value.- Parameters:
ctrl2y- the new y coordinate of the second handlePointof thisCubicCurve- Returns:
thisfor convenience
-
setCurve
public CubicCurve setCurve(Point p1, Point ctrl1, Point ctrl2, Point p2)
-
split
public CubicCurve[] split(double t)
Description copied from class:BezierCurveSubdivides 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].- Overrides:
splitin classBezierCurve- Parameters:
t- the parameter value at which thisBezierCurveis subdivided- Returns:
- an array of two
BezierCurves, the left ([0;t]) and the right ([t;1])
-
toPath
public Path toPath()
Description copied from class:BezierCurve- Specified by:
toPathin interfaceIGeometry- Overrides:
toPathin classBezierCurve- Returns:
- a
Pathapproximating thisBezierCurveusingLinesegments
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBezierCurve
-
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()
-
-