Top Description Fields Constructors Methods
com.sun.javafx.geom

public Class Line2D

extends Shape
Class Inheritance
Imports
com.sun.javafx.geom.transform.BaseTransform

This Line2D represents a line segment in (x,y) coordinate space. This class, like all of the Java 2D API, uses a default coordinate system called user space in which the y-axis values increase downward and x-axis values increase to the right. For more information on the user space coordinate system, see the Coordinate Systems section of the Java 2D Programmer's Guide.
Version
1.37, 05/05/07

Field Summary

Modifier and TypeField and Description
public float
x1

The X coordinate of the start point of the line segment.

public float
x2

The X coordinate of the end point of the line segment.

public float
y1

The Y coordinate of the start point of the line segment.

public float
y2

The Y coordinate of the end point of the line segment.

Inherited from com.sun.javafx.geom.Shape:
OUT_BOTTOMOUT_LEFTOUT_RIGHTOUT_TOPRECT_INTERSECTS

Constructor Summary

AccessConstructor and Description
public
Line2D()

Constructs and initializes a Line with coordinates (0, 0) -> (0, 0).

public
Line2D(float
the X coordinate of the start point
x1
,
float
the Y coordinate of the start point
y1
,
float
the X coordinate of the end point
x2
,
float
the Y coordinate of the end point
y2
)

Constructs and initializes a Line from the specified coordinates.

public
Line2D(Point2D
the start Point2D of this line segment
p1
,
Point2D
the end Point2D of this line segment
p2
)

Constructs and initializes a Line2D from the specified Point2D objects.

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(float
the specified X coordinate to be tested
x
,
float
the specified Y coordinate to be tested
y
)

Implements abstract com.sun.javafx.geom.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape.

public boolean
contains(float
the X coordinate of the upper-left corner of the specified rectangular area
x
,
float
the Y coordinate of the upper-left corner of the specified rectangular area
y
,
float
the width of the specified rectangular area
w
,
float
the height of the specified rectangular area
h
)

Implements abstract com.sun.javafx.geom.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area.

public boolean
contains(Point2D
the specified Point2D to be tested
p
)

Overrides com.sun.javafx.geom.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape.

public Line2D
copy()

Implements abstract com.sun.javafx.geom.Shape.copy.

Returns a new copy of this Shape instance.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public RectBounds
getBounds()

Implements abstract com.sun.javafx.geom.Shape.getBounds.

Note that there is no guarantee that the returned RectBounds is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated RectBounds.

public PathIterator

Returns:

a PathIterator that defines the boundary of this Line2D.
getPathIterator
(BaseTransform
the specified BaseTransform
tx
)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this Line2D.

public PathIterator

Returns:

a PathIterator that defines the boundary of the flattened Line2D
getPathIterator
(BaseTransform
the specified BaseTransform
tx
,
float
the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the end points. Since a Line2D object is always flat, this parameter is ignored.
flatness
)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this flattened Line2D.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
intersects(float
the X coordinate of the upper-left corner of the specified rectangular area
x
,
float
the Y coordinate of the upper-left corner of the specified rectangular area
y
,
float
the width of the specified rectangular area
w
,
float
the height of the specified rectangular area
h
)

Implements abstract com.sun.javafx.geom.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.

public boolean

Returns:

if this line segment and the specified line segment intersect each other; false otherwise.
intersectsLine
(float
the X coordinate of the start point of the specified line segment
x1
,
float
the Y coordinate of the start point of the specified line segment
y1
,
float
the X coordinate of the end point of the specified line segment
x2
,
float
the Y coordinate of the end point of the specified line segment
y2
)

Tests if the line segment from (x1,y1) to (x2,y2) intersects this line segment.

public boolean

Returns:

true if this line segment and the specified line segment intersect each other; false otherwise.
intersectsLine
(Line2D
the specified Line2D
l
)

Tests if the specified line segment intersects this line segment.

public static boolean

Returns:

true if the first specified line segment and the second specified line segment intersect each other; false otherwise.
linesIntersect
(float
the X coordinate of the start point of the first specified line segment
x1
,
float
the Y coordinate of the start point of the first specified line segment
y1
,
float
the X coordinate of the end point of the first specified line segment
x2
,
float
the Y coordinate of the end point of the first specified line segment
y2
,
float
the X coordinate of the start point of the second specified line segment
x3
,
float
the Y coordinate of the start point of the second specified line segment
y3
,
float
the X coordinate of the end point of the second specified line segment
x4
,
float
the Y coordinate of the end point of the second specified line segment
y4
)

Tests if the line segment from (x1,y1) to (x2,y2) intersects the line segment from (x3,y3) to (x4,y4).

public static float

Returns:

a double value that is the distance from the specified point to the specified line.
ptLineDist
(float
the X coordinate of the start point of the specified line
x1
,
float
the Y coordinate of the start point of the specified line
y1
,
float
the X coordinate of the end point of the specified line
x2
,
float
the Y coordinate of the end point of the specified line
y2
,
float
the X coordinate of the specified point being measured against the specified line
px
,
float
the Y coordinate of the specified point being measured against the specified line
py
)

Returns the distance from a point to a line.

public float

Returns:

a double value that is the distance from a specified point to the current line.
ptLineDist
(float
the X coordinate of the specified point being measured against this line
px
,
float
the Y coordinate of the specified point being measured against this line
py
)

Returns the distance from a point to this line.

public float

Returns:

a double value that is the distance from a specified Point2D to the current line.
ptLineDist
(Point2D
the specified Point2D being measured
pt
)

Returns the distance from a Point2D to this line.

public static float

Returns:

a double value that is the square of the distance from the specified point to the specified line.
ptLineDistSq
(float
the X coordinate of the start point of the specified line
x1
,
float
the Y coordinate of the start point of the specified line
y1
,
float
the X coordinate of the end point of the specified line
x2
,
float
the Y coordinate of the end point of the specified line
y2
,
float
the X coordinate of the specified point being measured against the specified line
px
,
float
the Y coordinate of the specified point being measured against the specified line
py
)

Returns the square of the distance from a point to a line.

public float

Returns:

a double value that is the square of the distance from a specified point to the current line.
ptLineDistSq
(float
the X coordinate of the specified point being measured against this line
px
,
float
the Y coordinate of the specified point being measured against this line
py
)

Returns the square of the distance from a point to this line.

public float

Returns:

a double value that is the square of the distance from a specified Point2D to the current line.
ptLineDistSq
(Point2D
the specified Point2D being measured against this line
pt
)

Returns the square of the distance from a specified Point2D to this line.

public static float

Returns:

a double value that is the distance from the specified point to the specified line segment.
ptSegDist
(float
the X coordinate of the start point of the specified line segment
x1
,
float
the Y coordinate of the start point of the specified line segment
y1
,
float
the X coordinate of the end point of the specified line segment
x2
,
float
the Y coordinate of the end point of the specified line segment
y2
,
float
the X coordinate of the specified point being measured against the specified line segment
px
,
float
the Y coordinate of the specified point being measured against the specified line segment
py
)

Returns the distance from a point to a line segment.

public double

Returns:

a double value that is the distance from the specified point to the current line segment.
ptSegDist
(float
the X coordinate of the specified point being measured against this line segment
px
,
float
the Y coordinate of the specified point being measured against this line segment
py
)

Returns the distance from a point to this line segment.

public float

Returns:

a double value that is the distance from the specified Point2D to the current line segment.
ptSegDist
(Point2D
the specified Point2D being measured against this line segment
pt
)

Returns the distance from a Point2D to this line segment.

public static float

Returns:

a double value that is the square of the distance from the specified point to the specified line segment.
ptSegDistSq
(float
the X coordinate of the start point of the specified line segment
x1
,
float
the Y coordinate of the start point of the specified line segment
y1
,
float
the X coordinate of the end point of the specified line segment
x2
,
float
the Y coordinate of the end point of the specified line segment
y2
,
float
the X coordinate of the specified point being measured against the specified line segment
px
,
float
the Y coordinate of the specified point being measured against the specified line segment
py
)

Returns the square of the distance from a point to a line segment.

public float

Returns:

a double value that is the square of the distance from the specified point to the current line segment.
ptSegDistSq
(float
the X coordinate of the specified point being measured against this line segment
px
,
float
the Y coordinate of the specified point being measured against this line segment
py
)

Returns the square of the distance from a point to this line segment.

public float

Returns:

a double value that is the square of the distance from the specified Point2D to the current line segment.
ptSegDistSq
(Point2D
the specified Point2D being measured against this line segment.
pt
)

Returns the square of the distance from a Point2D to this line segment.

public static int

Returns:

an integer that indicates the position of the third specified coordinates with respect to the line segment formed by the first two specified coordinates.
relativeCCW
(float
the X coordinate of the start point of the specified line segment
x1
,
float
the Y coordinate of the start point of the specified line segment
y1
,
float
the X coordinate of the end point of the specified line segment
x2
,
float
the Y coordinate of the end point of the specified line segment
y2
,
float
the X coordinate of the specified point to be compared with the specified line segment
px
,
float
the Y coordinate of the specified point to be compared with the specified line segment
py
)

Returns an indicator of where the specified point (px,py) lies with respect to the line segment from (x1,y1) to (x2,y2).

public int

Returns:

an integer that indicates the position of the specified coordinates with respect to this Line2D
relativeCCW
(float
the X coordinate of the specified point to be compared with this Line2D
px
,
float
the Y coordinate of the specified point to be compared with this Line2D
py
)

Returns an indicator of where the specified point (px,py) lies with respect to this line segment.

public int

Returns:

an integer that indicates the position of the specified Point2D with respect to this Line2D
relativeCCW
(Point2D
the specified Point2D to be compared with this Line2D
p
)

Returns an indicator of where the specified Point2D lies with respect to this line segment.

public void
setLine(float
the X coordinate of the start point
x1
,
float
the Y coordinate of the start point
y1
,
float
the X coordinate of the end point
x2
,
float
the Y coordinate of the end point
y2
)

Sets the location of the end points of this Line2D to the specified float coordinates.

public void
setLine(Point2D
the start Point2D of the line segment
p1
,
Point2D
the end Point2D of the line segment
p2
)

Sets the location of the end points of this Line2D to the specified Point2D coordinates.

public void
setLine(Line2D
the specified Line2D
l
)

Sets the location of the end points of this Line2D to the same as those end points of the specified Line2D.

Inherited from com.sun.javafx.geom.Shape:
accumulateaccumulateCubicaccumulateCubicaccumulateQuadcontainsintersectsintersectsLineoutcodepointCrossingsForCubicpointCrossingsForLinepointCrossingsForPathpointCrossingsForQuadrectCrossingsForCubicrectCrossingsForLinerectCrossingsForPathrectCrossingsForQuad

Field Detail

x1back to summary
public float x1

The X coordinate of the start point of the line segment.

x2back to summary
public float x2

The X coordinate of the end point of the line segment.

y1back to summary
public float y1

The Y coordinate of the start point of the line segment.

y2back to summary
public float y2

The Y coordinate of the end point of the line segment.

Constructor Detail

Line2Dback to summary
public Line2D()

Constructs and initializes a Line with coordinates (0, 0) -> (0, 0).

Line2Dback to summary
public Line2D(float x1, float y1, float x2, float y2)

Constructs and initializes a Line from the specified coordinates.

Parameters
x1:float

the X coordinate of the start point

y1:float

the Y coordinate of the start point

x2:float

the X coordinate of the end point

y2:float

the Y coordinate of the end point

Line2Dback to summary
public Line2D(Point2D p1, Point2D p2)

Constructs and initializes a Line2D from the specified Point2D objects.

Parameters
p1:Point2D

the start Point2D of this line segment

p2:Point2D

the end Point2D of this line segment

Method Detail

containsback to summary
public boolean contains(float x, float y)

Implements abstract com.sun.javafx.geom.Shape.contains.

Doc from com.sun.javafx.geom.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape.

Parameters
x:float

the specified X coordinate to be tested

y:float

the specified Y coordinate to be tested

Returns:boolean

true if the specified coordinates are inside the Shape boundary; false otherwise.

Annotations
@Override
containsback to summary
public boolean contains(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.contains.

Doc from com.sun.javafx.geom.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape.

The Shape.contains() method allows a Shape implementation to conservatively return false when:

  • the intersect method returns true and
  • the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive.
This means that for some Shapes this method might return false even though the Shape contains the rectangular area. The Area class performs more accurate geometric computations than most Shape objects and therefore can be used if a more precise answer is required.
Parameters
x:float

the X coordinate of the upper-left corner of the specified rectangular area

y:float

the Y coordinate of the upper-left corner of the specified rectangular area

w:float

the width of the specified rectangular area

h:float

the height of the specified rectangular area

Returns:boolean

true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape contains the rectangular area and the intersects method returns true and the containment calculations would be too expensive to perform.

Annotations
@Override
containsback to summary
public boolean contains(Point2D p)

Overrides com.sun.javafx.geom.Shape.contains.

Doc from com.sun.javafx.geom.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape.

Parameters
p:Point2D

the specified Point2D to be tested

Returns:boolean

true if the specified Point2D is inside the boundary of the Shape; false otherwise.

Annotations
@Override
copyback to summary
public Line2D copy()

Implements abstract com.sun.javafx.geom.Shape.copy.

Doc from com.sun.javafx.geom.Shape.copy.

Returns a new copy of this Shape instance.

Returns:Line2D

a copy of this shape

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getBoundsback to summary
public RectBounds getBounds()

Implements abstract com.sun.javafx.geom.Shape.getBounds.

Doc from com.sun.javafx.geom.Shape.getBounds.

Note that there is no guarantee that the returned RectBounds is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated RectBounds.

Returns:RectBounds

an instance of RectBounds

Annotations
@Override
getPathIteratorback to summary
public PathIterator getPathIterator(BaseTransform tx)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this Line2D. The iterator for this class is not multi-threaded safe, which means that this Line2D class does not guarantee that modifications to the geometry of this Line2D object do not affect any iterations of that geometry that are already in process.

Parameters
tx:BaseTransform

the specified BaseTransform

Returns:PathIterator

a PathIterator that defines the boundary of this Line2D.

Annotations
@Override
getPathIteratorback to summary
public PathIterator getPathIterator(BaseTransform tx, float flatness)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this flattened Line2D. The iterator for this class is not multi-threaded safe, which means that this Line2D class does not guarantee that modifications to the geometry of this Line2D object do not affect any iterations of that geometry that are already in process.

Parameters
tx:BaseTransform

the specified BaseTransform

flatness:float

the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the end points. Since a Line2D object is always flat, this parameter is ignored.

Returns:PathIterator

a PathIterator that defines the boundary of the flattened Line2D

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
intersectsback to summary
public boolean intersects(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.intersects.

Doc from com.sun.javafx.geom.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.

The Shape.intersects() method allows a Shape implementation to conservatively return true when:

  • there is a high probability that the rectangular area and the Shape intersect, but
  • the calculations to accurately determine this intersection are prohibitively expensive.
This means that for some Shapes this method might return true even though the rectangular area does not intersect the Shape. The Area class performs more accurate computations of geometric intersection than most Shape objects and therefore can be used if a more precise answer is required.
Parameters
x:float

the X coordinate of the upper-left corner of the specified rectangular area

y:float

the Y coordinate of the upper-left corner of the specified rectangular area

w:float

the width of the specified rectangular area

h:float

the height of the specified rectangular area

Returns:boolean

true if the interior of the Shape and the interior of the rectangular area intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise.

Annotations
@Override
intersectsLineback to summary
public boolean intersectsLine(float x1, float y1, float x2, float y2)

Tests if the line segment from (x1,y1) to (x2,y2) intersects this line segment.

Parameters
x1:float

the X coordinate of the start point of the specified line segment

y1:float

the Y coordinate of the start point of the specified line segment

x2:float

the X coordinate of the end point of the specified line segment

y2:float

the Y coordinate of the end point of the specified line segment

Returns:boolean

if this line segment and the specified line segment intersect each other; false otherwise.

intersectsLineback to summary
public boolean intersectsLine(Line2D l)

Tests if the specified line segment intersects this line segment.

Parameters
l:Line2D

the specified Line2D

Returns:boolean

true if this line segment and the specified line segment intersect each other; false otherwise.

linesIntersectback to summary
public static boolean linesIntersect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)

Tests if the line segment from (x1,y1) to (x2,y2) intersects the line segment from (x3,y3) to (x4,y4).

Parameters
x1:float

the X coordinate of the start point of the first specified line segment

y1:float

the Y coordinate of the start point of the first specified line segment

x2:float

the X coordinate of the end point of the first specified line segment

y2:float

the Y coordinate of the end point of the first specified line segment

x3:float

the X coordinate of the start point of the second specified line segment

y3:float

the Y coordinate of the start point of the second specified line segment

x4:float

the X coordinate of the end point of the second specified line segment

y4:float

the Y coordinate of the end point of the second specified line segment

Returns:boolean

true if the first specified line segment and the second specified line segment intersect each other; false otherwise.

ptLineDistback to summary
public static float ptLineDist(float x1, float y1, float x2, float y2, float px, float py)

Returns the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.

Parameters
x1:float

the X coordinate of the start point of the specified line

y1:float

the Y coordinate of the start point of the specified line

x2:float

the X coordinate of the end point of the specified line

y2:float

the Y coordinate of the end point of the specified line

px:float

the X coordinate of the specified point being measured against the specified line

py:float

the Y coordinate of the specified point being measured against the specified line

Returns:float

a double value that is the distance from the specified point to the specified line.

See Also
ptSegDist(double, double, double, double, double, double)
ptLineDistback to summary
public float ptLineDist(float px, float py)

Returns the distance from a point to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Parameters
px:float

the X coordinate of the specified point being measured against this line

py:float

the Y coordinate of the specified point being measured against this line

Returns:float

a double value that is the distance from a specified point to the current line.

See Also
ptSegDist(double, double)
ptLineDistback to summary
public float ptLineDist(Point2D pt)

Returns the distance from a Point2D to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Parameters
pt:Point2D

the specified Point2D being measured

Returns:float

a double value that is the distance from a specified Point2D to the current line.

See Also
ptSegDist(Point2D)
ptLineDistSqback to summary
public static float ptLineDistSq(float x1, float y1, float x2, float y2, float px, float py)

Returns the square of the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.

Parameters
x1:float

the X coordinate of the start point of the specified line

y1:float

the Y coordinate of the start point of the specified line

x2:float

the X coordinate of the end point of the specified line

y2:float

the Y coordinate of the end point of the specified line

px:float

the X coordinate of the specified point being measured against the specified line

py:float

the Y coordinate of the specified point being measured against the specified line

Returns:float

a double value that is the square of the distance from the specified point to the specified line.

See Also
ptSegDistSq(double, double, double, double, double, double)
ptLineDistSqback to summary
public float ptLineDistSq(float px, float py)

Returns the square of the distance from a point to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Parameters
px:float

the X coordinate of the specified point being measured against this line

py:float

the Y coordinate of the specified point being measured against this line

Returns:float

a double value that is the square of the distance from a specified point to the current line.

See Also
ptSegDistSq(double, double)
ptLineDistSqback to summary
public float ptLineDistSq(Point2D pt)

Returns the square of the distance from a specified Point2D to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Parameters
pt:Point2D

the specified Point2D being measured against this line

Returns:float

a double value that is the square of the distance from a specified Point2D to the current line.

See Also
ptSegDistSq(Point2D)
ptSegDistback to summary
public static float ptSegDist(float x1, float y1, float x2, float y2, float px, float py)

Returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters
x1:float

the X coordinate of the start point of the specified line segment

y1:float

the Y coordinate of the start point of the specified line segment

x2:float

the X coordinate of the end point of the specified line segment

y2:float

the Y coordinate of the end point of the specified line segment

px:float

the X coordinate of the specified point being measured against the specified line segment

py:float

the Y coordinate of the specified point being measured against the specified line segment

Returns:float

a double value that is the distance from the specified point to the specified line segment.

See Also
ptLineDist(double, double, double, double, double, double)
ptSegDistback to summary
public double ptSegDist(float px, float py)

Returns the distance from a point to this line segment. The distance measured is the distance between the specified point and the closest point between the current line's end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters
px:float

the X coordinate of the specified point being measured against this line segment

py:float

the Y coordinate of the specified point being measured against this line segment

Returns:double

a double value that is the distance from the specified point to the current line segment.

See Also
ptLineDist(double, double)
ptSegDistback to summary
public float ptSegDist(Point2D pt)

Returns the distance from a Point2D to this line segment. The distance measured is the distance between the specified point and the closest point between the current line's end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters
pt:Point2D

the specified Point2D being measured against this line segment

Returns:float

a double value that is the distance from the specified Point2D to the current line segment.

See Also
ptLineDist(Point2D)
ptSegDistSqback to summary
public static float ptSegDistSq(float x1, float y1, float x2, float y2, float px, float py)

Returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters
x1:float

the X coordinate of the start point of the specified line segment

y1:float

the Y coordinate of the start point of the specified line segment

x2:float

the X coordinate of the end point of the specified line segment

y2:float

the Y coordinate of the end point of the specified line segment

px:float

the X coordinate of the specified point being measured against the specified line segment

py:float

the Y coordinate of the specified point being measured against the specified line segment

Returns:float

a double value that is the square of the distance from the specified point to the specified line segment.

See Also
ptLineDistSq(double, double, double, double, double, double)
ptSegDistSqback to summary
public float ptSegDistSq(float px, float py)

Returns the square of the distance from a point to this line segment. The distance measured is the distance between the specified point and the closest point between the current line's end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters
px:float

the X coordinate of the specified point being measured against this line segment

py:float

the Y coordinate of the specified point being measured against this line segment

Returns:float

a double value that is the square of the distance from the specified point to the current line segment.

See Also
ptLineDistSq(double, double)
ptSegDistSqback to summary
public float ptSegDistSq(Point2D pt)

Returns the square of the distance from a Point2D to this line segment. The distance measured is the distance between the specified point and the closest point between the current line's end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

Parameters
pt:Point2D

the specified Point2D being measured against this line segment.

Returns:float

a double value that is the square of the distance from the specified Point2D to the current line segment.

See Also
ptLineDistSq(Point2D)
relativeCCWback to summary
public static int relativeCCW(float x1, float y1, float x2, float y2, float px, float py)

Returns an indicator of where the specified point (px,py) lies with respect to the line segment from (x1,y1) to (x2,y2). The return value can be either 1, -1, or 0 and indicates in which direction the specified line must pivot around its first end point, (x1,y1), in order to point at the specified point (px,py).

A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise.

A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system, this direction is clockwise.

A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues.

If the point is colinear with the line segment, but not between the end points, then the value will be -1 if the point lies "beyond (x1,y1)" or 1 if the point lies "beyond (x2,y2)".

Parameters
x1:float

the X coordinate of the start point of the specified line segment

y1:float

the Y coordinate of the start point of the specified line segment

x2:float

the X coordinate of the end point of the specified line segment

y2:float

the Y coordinate of the end point of the specified line segment

px:float

the X coordinate of the specified point to be compared with the specified line segment

py:float

the Y coordinate of the specified point to be compared with the specified line segment

Returns:int

an integer that indicates the position of the third specified coordinates with respect to the line segment formed by the first two specified coordinates.

relativeCCWback to summary
public int relativeCCW(float px, float py)

Returns an indicator of where the specified point (px,py) lies with respect to this line segment. See the method comments of relativeCCW(double, double, double, double, double, double) to interpret the return value.

Parameters
px:float

the X coordinate of the specified point to be compared with this Line2D

py:float

the Y coordinate of the specified point to be compared with this Line2D

Returns:int

an integer that indicates the position of the specified coordinates with respect to this Line2D

See Also
relativeCCW(double, double, double, double, double, double)
relativeCCWback to summary
public int relativeCCW(Point2D p)

Returns an indicator of where the specified Point2D lies with respect to this line segment. See the method comments of relativeCCW(double, double, double, double, double, double) to interpret the return value.

Parameters
p:Point2D

the specified Point2D to be compared with this Line2D

Returns:int

an integer that indicates the position of the specified Point2D with respect to this Line2D

See Also
relativeCCW(double, double, double, double, double, double)
setLineback to summary
public void setLine(float x1, float y1, float x2, float y2)

Sets the location of the end points of this Line2D to the specified float coordinates.

Parameters
x1:float

the X coordinate of the start point

y1:float

the Y coordinate of the start point

x2:float

the X coordinate of the end point

y2:float

the Y coordinate of the end point

setLineback to summary
public void setLine(Point2D p1, Point2D p2)

Sets the location of the end points of this Line2D to the specified Point2D coordinates.

Parameters
p1:Point2D

the start Point2D of the line segment

p2:Point2D

the end Point2D of the line segment

setLineback to summary
public void setLine(Line2D l)

Sets the location of the end points of this Line2D to the same as those end points of the specified Line2D.

Parameters
l:Line2D

the specified Line2D