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
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Overridden with public visibility as recommended withinCloneable
.boolean
boolean
equals
(double x1, double y1, double x2, double y2) Tests whether thisLine
is equal to the line given implicitly by the given point coordinates.get
(double t) Computes thePoint
on thisBezierCurve
at 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 thisLine
and the given one, in case it exists.Point[]
getIntersections
(BezierCurve curve) Returns thePoint
s of intersection of this and the given otherBezierCurve
.double
Point[]
final int
hashCode()
boolean
intersects
(ICurve c) boolean
intersects
(Line l) Provides an optimized version of theBezierCurve.intersects(ICurve)
method.boolean
Checks if thisBezierCurve
and the given otherBezierCurve
overlap, i.e. an infinite set of intersectionPoint
s exists.boolean
setLine
(double x1, double y1, double x2, double y2) Initializes thisLine
with the given start and end point coordinatesInitializes thisLine
with the start and end point coordinates of the given one.Initializes thisLine
with the start and end point coordinates provided by the given pointssetX1
(double x1) setX2
(double x2) setY1
(double y1) setY2
(double y2) toPath()
toString()
boolean
boolean
Tests whether thisLine
and 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 newLine
from 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 thisLine
is 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:
true
if the given start and end point coordinates are (imprecisely) equal to thisLine
's start and end point coordinates
-
get
Description copied from class:BezierCurve
Computes thePoint
on thisBezierCurve
at parameter value t, which is expected to lie in the parameterBezierCurve.Interval
[0;1]
.- Overrides:
get
in classBezierCurve
- Parameters:
t
- the parameter value for which thisBezierCurve
is evaluated- Returns:
- the
Point
on thisBezierCurve
at the given parameter value
-
getBounds
-
getCopy
Returns a newLine
, which has the same start and end point coordinates as this one.- Specified by:
getCopy
in interfaceIGeometry
- Overrides:
getCopy
in classBezierCurve
- Returns:
- a new
Line
with 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 thisLine
and 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
Line
and the given one, in case it intersects,null
instead
-
getIntersections
Description copied from class:BezierCurve
Returns thePoint
s of intersection of this and the given otherBezierCurve
.- Overrides:
getIntersections
in classBezierCurve
- Parameters:
curve
- theBezierCurve
which is searched forPoint
s of intersection with thisBezierCurve
- Returns:
- the
Point
s of intersection of thisBezierCurve
and the given otherBezierCurve
-
getLength
public double getLength()- Returns:
- The distance between start and end points.
- See Also:
-
getPoints
- Overrides:
getPoints
in classBezierCurve
- Returns:
- an array with two
Point
s, whose x and y coordinates match those of thisLine
's start and end point
-
getProjection
Description copied from interface:ICurve
Returns a projection of the given referencePoint
onto thisICurve
, i.e. aPoint
on thisICurve
that is closest to the given referencePoint
. Note, that- Specified by:
getProjection
in interfaceICurve
- Overrides:
getProjection
in classBezierCurve
- Parameters:
p
- The referencePoint
for which to return the projection.- Returns:
- The projection of the given reference
Point
onto thisICurve
.
-
getTransformed
Default implementation returning a transformedPath
representation of thisIGeometry
. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformed
in interfaceIGeometry
- Overrides:
getTransformed
in classBezierCurve
- Parameters:
t
- TheAffineTransform
to be applied- Returns:
- a transformed
Path
representation of thisIGeometry
- See Also:
-
intersects
Description copied from interface:ICurve
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 (seeICurve.overlaps(ICurve)
).- Specified by:
intersects
in interfaceICurve
- Overrides:
intersects
in classBezierCurve
- Parameters:
c
- TheICurve
to test for intersections.- Returns:
true
if they intersect,false
otherwise
-
intersects
Provides an optimized version of theBezierCurve.intersects(ICurve)
method.- Parameters:
l
- TheLine
to test for intersections.- Returns:
- see
BezierCurve.intersects(ICurve)
-
overlaps
Description copied from class:BezierCurve
Checks if thisBezierCurve
and the given otherBezierCurve
overlap, i.e. an infinite set of intersectionPoint
s exists.- Overrides:
overlaps
in classBezierCurve
- Parameters:
c
- theBezierCurve
to check for an overlapping segment with thisBezierCurve
- Returns:
true
if this and the given otherBezierCurve
overlap, otherwisefalse
-
overlaps
Tests whether thisLine
and the given otherLine
overlap, i.e. they share an infinite number ofPoint
s. -
setLine
Initializes thisLine
with 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:
this
for convenience
-
setLine
Initializes thisLine
with the start and end point coordinates of the given one.- Parameters:
l
- theLine
whose start and end point coordinates should be used for initialization- Returns:
this
for convenience
-
setLine
Initializes thisLine
with the start and end point coordinates provided by the given points -
setX1
-
setX2
-
setY1
-
setY2
-
toPath
Description copied from class:BezierCurve
- Specified by:
toPath
in interfaceIGeometry
- Overrides:
toPath
in classBezierCurve
- Returns:
- a
Path
approximating thisBezierCurve
usingLine
segments
-
toString
- Overrides:
toString
in classBezierCurve
-
touches
Description copied from interface:IGeometry
-
touches
Tests whether thisLine
and the given one share at least one common point. -
clone
Overridden with public visibility as recommended withinCloneable
. -
hashCode
public final int hashCode()
-