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
TheICurveinterface provides operations that allow the analysis of linear geometric objects and the transfer toBezierCurvesegments (toBezier()). The start and endPointof anICurvecan be retrieved using itsgetP1()andgetP2()methods. Furthermore, you can search forPoints 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 twoICurves, 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)PointgetP1()PointgetP2()PointgetProjection(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)booleanoverlaps(ICurve c)BezierCurve[]toBezier()Computes a list ofBezierCurves that approximate theICurve.
-
-
-
Method Detail
-
getIntersections
Point[] getIntersections(ICurve c)
- Parameters:
c- TheICurveto 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 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
boolean overlaps(ICurve c)
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
-
-