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 theCubicCurve
class represents aBezierCurve
of degree 3, having a start and an endPoint
and two handlePoint
s.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CubicCurve(double... coordinates)
Constructs a newCubicCurve
object with the given sequence of x and y coordinates of the startPoint
, the two handlePoint
s, and the endPoint
.CubicCurve(double x1, double y1, double ctrl1X, double ctrl1Y, double ctrl2X, double ctrl2Y, double x2, double y2)
Constructs a newCubicCurve
object from the given controlPoint
coordinates.CubicCurve(Point... points)
Constructs a newCubicCurve
from the given sequence ofPoint
s, which is expected to be in the order: startPoint
, first and second handlePoint
s, and endPoint
.CubicCurve(Point start, Point ctrl1, Point ctrl2, Point end)
Constructs a newCubicCurve
object from the given controlPoint
s.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Overridden with public visibility as recommended withinCloneable
.CubicCurve
getCopy()
Returns a newCubicCurve
, which has the same controlPoint
s as this one.Point
getCtrl1()
Returns the first handlePoint
.Point
getCtrl2()
Returns the second handlePoint
.double
getCtrlX1()
Returns the first handlePoint
's x coordinate.double
getCtrlX2()
Returns the second handlePoint
's x coordinate.double
getCtrlY1()
Returns the first handlePoint
's y coordinate.double
getCtrlY2()
Returns the second handlePoint
's y coordinate.CubicCurve
getTransformed(AffineTransform t)
int
hashCode()
CubicCurve
setCtrl1(Point ctrl1)
CubicCurve
setCtrl1X(double ctrl1x)
Sets the x coordinate of the first handlePoint
of thisCubicCurve
to the given value.CubicCurve
setCtrl1Y(double ctrl1y)
Sets the y coordinate of the first handlePoint
of thisCubicCurve
to the given value.CubicCurve
setCtrl2(Point ctrl2)
CubicCurve
setCtrl2X(double ctrl2x)
Sets the x coordinate of the second handlePoint
of thisCubicCurve
to the given value.CubicCurve
setCtrl2Y(double ctrl2y)
Sets the y coordinate of the second handlePoint
of thisCubicCurve
to the given value.CubicCurve
setCurve(Point p1, Point ctrl1, Point ctrl2, Point p2)
CubicCurve[]
split(double t)
Subdivides thisBezierCurve
at the given parameter value t into two newBezierCurve
s.Path
toPath()
java.lang.String
toString()
boolean
touches(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 newCubicCurve
object with the given sequence of x and y coordinates of the startPoint
, the two handlePoint
s, and the endPoint
.- Parameters:
coordinates
- the sequence of x and y coordinates specifying thisCubicCurve
's controlPoint
s- 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 newCubicCurve
object from the given controlPoint
coordinates.- Parameters:
x1
- the x coordinate of the startPoint
y1
- the y coordinate of the startPoint
ctrl1X
- the x coordinate of the first handlePoint
ctrl1Y
- the y coordinate of the first handlePoint
ctrl2X
- the x coordinate of the second handlePoint
ctrl2Y
- the y coordinate of the second handlePoint
x2
- the x coordinate of the endPoint
y2
- the y coordinate of the endPoint
-
CubicCurve
public CubicCurve(Point... points)
Constructs a newCubicCurve
from the given sequence ofPoint
s, which is expected to be in the order: startPoint
, first and second handlePoint
s, and endPoint
.- Parameters:
points
- the sequence ofPoint
s from which thisCubicCurve
is 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 newCubicCurve
object from the given controlPoint
s.- Parameters:
start
- the startPoint
ctrl1
- the first handlePoint
ctrl2
- the second handlePoint
end
- 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 controlPoint
s as this one.- Specified by:
getCopy
in interfaceIGeometry
- Overrides:
getCopy
in classBezierCurve
- Returns:
- a new
CubicCurve
with the same controlPoint
s 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 transformedPath
representation of thisIGeometry
. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformed
in interfaceIGeometry
- Overrides:
getTransformed
in classBezierCurve
- Parameters:
t
- TheAffineTransform
to be applied- Returns:
- a transformed
Path
representation of thisIGeometry
- See Also:
IGeometry.getTransformed(AffineTransform)
-
setCtrl1
public CubicCurve setCtrl1(Point ctrl1)
- Parameters:
ctrl1
- the new first handlePoint
- Returns:
this
for convenience
-
setCtrl1X
public CubicCurve setCtrl1X(double ctrl1x)
Sets the x coordinate of the first handlePoint
of thisCubicCurve
to the given value.- Parameters:
ctrl1x
- the new x coordinate of the first handlePoint
of thisCubicCurve
- Returns:
this
for convenience
-
setCtrl1Y
public CubicCurve setCtrl1Y(double ctrl1y)
Sets the y coordinate of the first handlePoint
of thisCubicCurve
to the given value.- Parameters:
ctrl1y
- the new y coordinate of the first handlePoint
of thisCubicCurve
- Returns:
this
for convenience
-
setCtrl2
public CubicCurve setCtrl2(Point ctrl2)
- Parameters:
ctrl2
- the new second handlePoint
of thisCubicCurve
- Returns:
this
for convenience
-
setCtrl2X
public CubicCurve setCtrl2X(double ctrl2x)
Sets the x coordinate of the second handlePoint
of thisCubicCurve
to the given value.- Parameters:
ctrl2x
- the new x coordinate of the second handlePoint
of thisCubicCurve
- Returns:
this
for convenience
-
setCtrl2Y
public CubicCurve setCtrl2Y(double ctrl2y)
Sets the y coordinate of the second handlePoint
of thisCubicCurve
to the given value.- Parameters:
ctrl2y
- the new y coordinate of the second handlePoint
of thisCubicCurve
- Returns:
this
for convenience
-
setCurve
public CubicCurve setCurve(Point p1, Point ctrl1, Point ctrl2, Point p2)
-
split
public CubicCurve[] split(double t)
Description copied from class:BezierCurve
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]
.- Overrides:
split
in classBezierCurve
- 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]
)
-
toPath
public Path toPath()
Description copied from class:BezierCurve
- Specified by:
toPath
in interfaceIGeometry
- Overrides:
toPath
in classBezierCurve
- Returns:
- a
Path
approximating thisBezierCurve
usingLine
segments
-
toString
public java.lang.String toString()
- Overrides:
toString
in classBezierCurve
-
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()
-
-