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 Points 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 ICurves, 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) 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.booleanintersects(ICurve c) booleantoBezier()Computes a list ofBezierCurves that approximate theICurve.
-
Method Details
-
getIntersections
- Parameters:
c- TheICurveto 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 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 (seeoverlaps(ICurve)).- Parameters:
c- TheICurveto test for intersections.- Returns:
trueif they intersect,falseotherwise
-
overlaps
Tests 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 (seeintersects(ICurve)).- Parameters:
c- TheICurveto test for overlap.- Returns:
trueif they overlap,falseotherwise
-
toBezier
BezierCurve[] toBezier()Computes 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.- Returns:
- a list of
BezierCurves that approximate theICurve
-