Package org.eclipse.gef.geometry.planar
Class Line
java.lang.Object
org.eclipse.gef.geometry.planar.BezierCurve
org.eclipse.gef.geometry.planar.Line
- All Implemented Interfaces:
- Serializable,- Cloneable,- ICurve,- IGeometry,- IRotatable<BezierCurve>,- IScalable<BezierCurve>,- ITranslatable<BezierCurve>
Represents the geometric shape of a line (or linear curve).
 Note that while all manipulations (e.g. within shrink, expand) within this
 class are based on double precision, all comparisons (e.g. within contains,
 intersects, equals, etc.) are based on a limited precision (with an accuracy
 defined within 
PrecisionUtils) to compensate for rounding effects.- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionclone()Overridden with public visibility as recommended withinCloneable.booleanbooleanequals(double x1, double y1, double x2, double y2) Tests whether thisLineis equal to the line given implicitly by the given point coordinates.get(double t) Computes thePointon thisBezierCurveat parameter value t, which is expected to lie in the parameterBezierCurve.Interval[0;1].getCopy()Returns a newLine, which has the same start and end point coordinates as this one.Returns the counter-clockwise angle between the x axis and thisLine.Returns the clockwise angle between the x axis and thisLine.Returns the single intersection point between thisLineand the given one, in case it exists.Point[]getIntersections(BezierCurve curve) Returns thePoints of intersection of this and the given otherBezierCurve.doublePoint[]final inthashCode()booleanintersects(ICurve c) booleanintersects(Line l) Provides an optimized version of theBezierCurve.intersects(ICurve)method.booleanChecks if thisBezierCurveand the given otherBezierCurveoverlap, i.e. an infinite set of intersectionPoints exists.booleansetLine(double x1, double y1, double x2, double y2) Initializes thisLinewith the given start and end point coordinatesInitializes thisLinewith the start and end point coordinates of the given one.Initializes thisLinewith the start and end point coordinates provided by the given pointssetX1(double x1) setX2(double x2) setY1(double y1) setY2(double y2) toPath()toString()booleanbooleanTests whether thisLineand the given one share at least one common point.Methods inherited from class org.eclipse.gef.geometry.planar.BezierCurvecontains, equals, getClipped, getControlBounds, getDerivative, getElevated, getIntersections, getOffset, getOverlap, getOverlaps, getP1, getP2, getParameterAt, getPoint, getRotatedCCW, getRotatedCCW, getRotatedCCW, getRotatedCW, getRotatedCW, getRotatedCW, getScaled, getScaled, getScaled, getScaled, getScaled, getScaled, getTranslated, getTranslated, getX1, getX2, getY1, getY2, overlaps, rotateCCW, rotateCCW, rotateCCW, rotateCW, rotateCW, rotateCW, scale, scale, scale, scale, scale, scale, setP1, setP2, setPoint, split, toBezier, toCubic, toLine, toLineStrip, toLineStrip, toPoints, toQuadratic, translate, translate
- 
Constructor Details- 
Linepublic Line(double... coordinates) Constructs a newLinefrom the given coordinate values.- Parameters:
- coordinates- A varargs of 4 doubles, providing the x and y coordinates of the start point, followed by those of the end point
- See Also:
 
- 
Linepublic Line(double x1, double y1, double x2, double y2) - Parameters:
- x1- the x-coordinate of the start point
- y1- the y-coordinate of the start point
- x2- the x-coordinate of the end point
- y2- the y-coordinate of the end point
 
- 
Line- Parameters:
- points- A varargs of two points serving as the start and end point of this line
 
- 
Line- Parameters:
- p1- the start point
- p2- the end point
 
 
- 
- 
Method Details- 
containsDescription copied from interface:IGeometry
- 
equalspublic boolean equals(double x1, double y1, double x2, double y2) Tests whether thisLineis equal to the line given implicitly by the given point coordinates.- Parameters:
- x1- the x-coordinate of the start point of the line to test
- y1- the y-coordinate of the start point of the line to test
- x2- the x-coordinate of the end point of the line to test
- y2- the y-coordinate of the end point of the line to test
- Returns:
- trueif the given start and end point coordinates are (imprecisely) equal to this- Line's start and end point coordinates
 
- 
getDescription copied from class:BezierCurveComputes thePointon thisBezierCurveat parameter value t, which is expected to lie in the parameterBezierCurve.Interval[0;1].- Overrides:
- getin class- BezierCurve
- Parameters:
- t- the parameter value for which this- BezierCurveis evaluated
- Returns:
- the Pointon thisBezierCurveat the given parameter value
 
- 
getBounds
- 
getCopyReturns a newLine, which has the same start and end point coordinates as this one.- Specified by:
- getCopyin interface- IGeometry
- Overrides:
- getCopyin class- BezierCurve
- Returns:
- a new Linewith the same start and end point coordinates
 
- 
getDirectionCCWReturns the counter-clockwise angle between the x axis and thisLine.- Returns:
- Returns the counter-clockwise angle between the x axis and this
         Line.
 
- 
getDirectionCWReturns the clockwise angle between the x axis and thisLine.- Returns:
- Returns the clockwise angle between the x axis and this
         Line.
 
- 
getIntersectionReturns the single intersection point between thisLineand the given one, in case it exists. Note that even in caseintersects(org.eclipse.gef.geometry.planar.ICurve)returns true, there may not be a single intersection point in case both lines overlap in more than one point.- Parameters:
- l- the Line, for which to compute the intersection point
- Returns:
- the single intersection point between this Lineand the given one, in case it intersects,nullinstead
 
- 
getIntersectionsDescription copied from class:BezierCurveReturns thePoints of intersection of this and the given otherBezierCurve.- Overrides:
- getIntersectionsin class- BezierCurve
- Parameters:
- curve- the- BezierCurvewhich is searched for- Points of intersection with this- BezierCurve
- Returns:
- the Points of intersection of thisBezierCurveand the given otherBezierCurve
 
- 
getLengthpublic double getLength()- Returns:
- The distance between start and end points.
- See Also:
 
- 
getPoints- Overrides:
- getPointsin class- BezierCurve
- Returns:
- an array with two Points, whose x and y coordinates match those of thisLine's start and end point
 
- 
getProjectionDescription copied from interface:ICurveReturns a projection of the given referencePointonto thisICurve, i.e. aPointon thisICurvethat is closest to the given referencePoint. Note, that- Specified by:
- getProjectionin interface- ICurve
- Overrides:
- getProjectionin class- BezierCurve
- Parameters:
- p- The reference- Pointfor which to return the projection.
- Returns:
- The projection of the given reference Pointonto thisICurve.
 
- 
getTransformedDefault implementation returning a transformedPathrepresentation of thisIGeometry. Subclasses may override this method to return a more specific representation.- Specified by:
- getTransformedin interface- IGeometry
- Overrides:
- getTransformedin class- BezierCurve
- Parameters:
- t- The- AffineTransformto be applied
- Returns:
- a transformed Pathrepresentation of thisIGeometry
- See Also:
 
- 
intersectsDescription copied from interface:ICurveTests 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 (seeICurve.overlaps(ICurve)).- Specified by:
- intersectsin interface- ICurve
- Overrides:
- intersectsin class- BezierCurve
- Parameters:
- c- The- ICurveto test for intersections.
- Returns:
- trueif they intersect,- falseotherwise
 
- 
intersectsProvides an optimized version of theBezierCurve.intersects(ICurve)method.- Parameters:
- l- The- Lineto test for intersections.
- Returns:
- see BezierCurve.intersects(ICurve)
 
- 
overlapsDescription copied from class:BezierCurveChecks if thisBezierCurveand the given otherBezierCurveoverlap, i.e. an infinite set of intersectionPoints exists.- Overrides:
- overlapsin class- BezierCurve
- Parameters:
- c- the- BezierCurveto check for an overlapping segment with this- BezierCurve
- Returns:
- trueif this and the given other- BezierCurveoverlap, otherwise- false
 
- 
overlapsTests whether thisLineand the given otherLineoverlap, i.e. they share an infinite number ofPoints.
- 
setLineInitializes thisLinewith the given start and end point coordinates- Parameters:
- x1- the x-coordinate of the start point
- y1- the y-coordinate of the start point
- x2- the x-coordinate of the end point
- y2- the y-coordinate of the end point
- Returns:
- thisfor convenience
 
- 
setLineInitializes thisLinewith the start and end point coordinates of the given one.- Parameters:
- l- the- Linewhose start and end point coordinates should be used for initialization
- Returns:
- thisfor convenience
 
- 
setLineInitializes thisLinewith the start and end point coordinates provided by the given points
- 
setX1
- 
setX2
- 
setY1
- 
setY2
- 
toPathDescription copied from class:BezierCurve- Specified by:
- toPathin interface- IGeometry
- Overrides:
- toPathin class- BezierCurve
- Returns:
- a Pathapproximating thisBezierCurveusingLinesegments
 
- 
toString- Overrides:
- toStringin class- BezierCurve
 
- 
touchesDescription copied from interface:IGeometry
- 
touchesTests whether thisLineand the given one share at least one common point.
- 
cloneOverridden with public visibility as recommended withinCloneable.
- 
hashCodepublic final int hashCode()
 
-