Package org.eclipse.gef.geometry.planar
Interface ICurve
-
- All Superinterfaces:
java.lang.Cloneable
,IGeometry
,java.io.Serializable
- All Known Implementing Classes:
Arc
,BezierCurve
,CubicCurve
,Line
,PolyBezier
,Polyline
,QuadraticCurve
public interface ICurve extends IGeometry
TheICurve
interface provides operations that allow the analysis of linear geometric objects and the transfer toBezierCurve
segments (toBezier()
). The start and endPoint
of anICurve
can be retrieved using itsgetP1()
andgetP2()
methods. Furthermore, you can search forPoint
s of intersection using thegetIntersections(ICurve)
method. If you do only need to know if there are any intersections, and you are not interested in their exact locations, then you can use theintersects(ICurve)
method, instead. To test for an overlap, i.e. an identical segment of twoICurve
s, use theoverlaps(ICurve)
method. One may think that an overlap is a very rare case. But in practical application, objects are usually aligned to a grid, which extremely increases the probability of an overlap.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Point[]
getIntersections(ICurve c)
ICurve[]
getOverlaps(ICurve c)
Point
getP1()
Point
getP2()
Point
getProjection(Point reference)
double
getX1()
Returns the startPoint
's x coordinate.double
getX2()
Returns the endPoint
's x coordinate.double
getY1()
Returns the startPoint
's y coordinate.double
getY2()
Returns the endPoint
's y coordinate.boolean
intersects(ICurve c)
boolean
overlaps(ICurve c)
BezierCurve[]
toBezier()
Computes a list ofBezierCurve
s that approximate theICurve
.
-
-
-
Method Detail
-
getIntersections
Point[] getIntersections(ICurve c)
- Parameters:
c
- TheICurve
to compute intersection points with.- Returns:
- The points of intersection.
-
getOverlaps
ICurve[] getOverlaps(ICurve c)
- Parameters:
c
- The curve to compute overlaps with.- Returns:
- The segments where both curves overlap.
-
getX1
double getX1()
Returns the startPoint
's x coordinate.- Returns:
- the start
Point
's x coordinate
-
getY1
double getY1()
Returns the startPoint
's y coordinate.- Returns:
- the start
Point
's y coordinate
-
intersects
boolean intersects(ICurve c)
Tests if thisICurve
and the givenICurve
intersect, i.e. whether a final set of intersection points exists. Two curves intersect if they touch (seeIGeometry.touches(IGeometry)
) but do not overlap (seeoverlaps(ICurve)
).- Parameters:
c
- TheICurve
to test for intersections.- Returns:
true
if they intersect,false
otherwise
-
overlaps
boolean overlaps(ICurve c)
Tests if thisICurve
and the givenICurve
overlap, i.e. whether an infinite set of intersection points exists. Two curves overlap if they touch (seeIGeometry.touches(IGeometry)
) but not intersect (seeintersects(ICurve)
).- Parameters:
c
- TheICurve
to test for overlap.- Returns:
true
if they overlap,false
otherwise
-
toBezier
BezierCurve[] toBezier()
Computes a list ofBezierCurve
s that approximate theICurve
. For example, aLine
or aBezierCurve
in general could return a list with the curve itself as its only element. But anEllipse
or anArc
may return a list of consecutiveBezierCurve
s which approximate theICurve
.- Returns:
- a list of
BezierCurve
s that approximate theICurve
-
-