Package org.eclipse.gef.geometry.planar
Interface ICurve
- All Superinterfaces:
Cloneable
,IGeometry
,Serializable
- All Known Implementing Classes:
Arc
,BezierCurve
,CubicCurve
,Line
,PolyBezier
,Polyline
,QuadraticCurve
The
ICurve
interface provides operations that allow the analysis of
linear geometric objects and the transfer to BezierCurve
segments (
toBezier()
). The start and end Point
of an ICurve
can be retrieved using its getP1()
and getP2()
methods.
Furthermore, you can search for Point
s of intersection using the
getIntersections(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 the intersects(ICurve)
method, instead.
To test for an overlap, i.e. an identical segment of two ICurve
s, use
the overlaps(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
Modifier and TypeMethodDescriptionPoint[]
ICurve[]
getP1()
getP2()
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
toBezier()
Computes a list ofBezierCurve
s that approximate theICurve
.
-
Method Details
-
getIntersections
- Parameters:
c
- TheICurve
to compute intersection points with.- Returns:
- The points of intersection.
-
getOverlaps
- Parameters:
c
- The curve to compute overlaps with.- Returns:
- The segments where both curves overlap.
-
getP1
Point getP1() -
getP2
Point getP2() -
getProjection
-
getX1
double getX1()Returns the startPoint
's x coordinate.- Returns:
- the start
Point
's x coordinate
-
getX2
double getX2()Returns the endPoint
's x coordinate.- Returns:
- the end
Point
's x coordinate
-
getY1
double getY1()Returns the startPoint
's y coordinate.- Returns:
- the start
Point
's y coordinate
-
getY2
double getY2()Returns the endPoint
's y coordinate.- Returns:
- the end
Point
's y coordinate
-
intersects
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
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
-