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 Summary
Constructors -
Method Summary
Modifier 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.BezierCurve
contains, 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
-
Line
public 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:
-
Line
public Line(double x1, double y1, double x2, double y2) - Parameters:
x1- the x-coordinate of the start pointy1- the y-coordinate of the start pointx2- the x-coordinate of the end pointy2- 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 pointp2- the end point
-
-
Method Details
-
contains
Description copied from interface:IGeometry -
equals
public 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 testy1- the y-coordinate of the start point of the line to testx2- the x-coordinate of the end point of the line to testy2- 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 thisLine's start and end point coordinates
-
get
Description copied from class:BezierCurveComputes thePointon thisBezierCurveat parameter value t, which is expected to lie in the parameterBezierCurve.Interval[0;1].- Overrides:
getin classBezierCurve- Parameters:
t- the parameter value for which thisBezierCurveis evaluated- Returns:
- the
Pointon thisBezierCurveat the given parameter value
-
getBounds
-
getCopy
Returns a newLine, which has the same start and end point coordinates as this one.- Specified by:
getCopyin interfaceIGeometry- Overrides:
getCopyin classBezierCurve- Returns:
- a new
Linewith the same start and end point coordinates
-
getDirectionCCW
Returns the counter-clockwise angle between the x axis and thisLine.- Returns:
- Returns the counter-clockwise angle between the x axis and this
Line.
-
getDirectionCW
Returns the clockwise angle between the x axis and thisLine.- Returns:
- Returns the clockwise angle between the x axis and this
Line.
-
getIntersection
Returns 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
-
getIntersections
Description copied from class:BezierCurveReturns thePoints of intersection of this and the given otherBezierCurve.- Overrides:
getIntersectionsin classBezierCurve- Parameters:
curve- theBezierCurvewhich is searched forPoints of intersection with thisBezierCurve- Returns:
- the
Points of intersection of thisBezierCurveand the given otherBezierCurve
-
getLength
public double getLength()- Returns:
- The distance between start and end points.
- See Also:
-
getPoints
- Overrides:
getPointsin classBezierCurve- Returns:
- an array with two
Points, whose x and y coordinates match those of thisLine's start and end point
-
getProjection
Description 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 interfaceICurve- Overrides:
getProjectionin classBezierCurve- Parameters:
p- The referencePointfor which to return the projection.- Returns:
- The projection of the given reference
Pointonto thisICurve.
-
getTransformed
Default implementation returning a transformedPathrepresentation of thisIGeometry. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformedin interfaceIGeometry- Overrides:
getTransformedin classBezierCurve- Parameters:
t- TheAffineTransformto be applied- Returns:
- a transformed
Pathrepresentation of thisIGeometry - See Also:
-
intersects
Description 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 interfaceICurve- Overrides:
intersectsin classBezierCurve- Parameters:
c- TheICurveto test for intersections.- Returns:
trueif they intersect,falseotherwise
-
intersects
Provides an optimized version of theBezierCurve.intersects(ICurve)method.- Parameters:
l- TheLineto test for intersections.- Returns:
- see
BezierCurve.intersects(ICurve)
-
overlaps
Description copied from class:BezierCurveChecks if thisBezierCurveand the given otherBezierCurveoverlap, i.e. an infinite set of intersectionPoints exists.- Overrides:
overlapsin classBezierCurve- Parameters:
c- theBezierCurveto check for an overlapping segment with thisBezierCurve- Returns:
trueif this and the given otherBezierCurveoverlap, otherwisefalse
-
overlaps
Tests whether thisLineand the given otherLineoverlap, i.e. they share an infinite number ofPoints. -
setLine
Initializes thisLinewith the given start and end point coordinates- Parameters:
x1- the x-coordinate of the start pointy1- the y-coordinate of the start pointx2- the x-coordinate of the end pointy2- the y-coordinate of the end point- Returns:
thisfor convenience
-
setLine
Initializes thisLinewith the start and end point coordinates of the given one.- Parameters:
l- theLinewhose start and end point coordinates should be used for initialization- Returns:
thisfor convenience
-
setLine
Initializes thisLinewith the start and end point coordinates provided by the given points -
setX1
-
setX2
-
setY1
-
setY2
-
toPath
Description copied from class:BezierCurve- Specified by:
toPathin interfaceIGeometry- Overrides:
toPathin classBezierCurve- Returns:
- a
Pathapproximating thisBezierCurveusingLinesegments
-
toString
- Overrides:
toStringin classBezierCurve
-
touches
Description copied from interface:IGeometry -
touches
Tests whether thisLineand the given one share at least one common point. -
clone
Overridden with public visibility as recommended withinCloneable. -
hashCode
public final int hashCode()
-