All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.geom.Line2D

java.lang.Object
    |
    +----java.awt.geom.Line2D

public abstract class Line2D
extends Object
implements Shape
A line segment in (x, y) coordinate space. For the purposes of the Shape interface, a coordinate is considered to be inside or contained by this line segment if the coordinate lies exactly on the line segment.

This class is only the abstract superclass for all objects which store a 2D line segment. The actual storage representation of the coordinates is left to the subclass.


Class Index

 o Line2D.Float
A line segment specified with float coordinates.

Constructor Index

 o Line2D()

Method Index

 o colinear(double, double)
Test if a given (x, y) coordinate is colinear with the line segment.
 o colinear(Point2D)
Test if a given Point is colinear with the line segment.
 o contains(double, double)
Test if a given coordinate is inside the boundary of the shape.
 o contains(double, double, double, double)
Test if the interior of the Shape entirely contains the given set of rectangular coordinates.
 o contains(Point2D)
Test if a given Point is inside the boundary of the shape.
 o contains(Rectangle2D)
Test if the interior of the Shape entirely contains the given Rectangle.
 o getBounds()
Return the bounding box of the shape.
 o getPathIterator(AffineTransform)
Return an iteration object that defines the boundary of the shape.
 o getPathIterator(AffineTransform, double)
Return an iteration object that defines the boundary of the flattened shape.
 o getX1()
Returns the X coordinate of the start point in double precision.
 o getX2()
Returns the X coordinate of the end point in double precision.
 o getY1()
Returns the Y coordinate of the start point in double precision.
 o getY2()
Returns the Y coordinate of the end point in double precision.
 o intersects(double, double, double, double)
Test if the Shape intersects the interior of a given set of rectangular coordinates.
 o intersects(Rectangle2D)
Test if the Shape intersects the interior of a given Rectangle.
 o intersectsLine(double, double, double, double)
Tests if the line segment from (x1, y1) to (x2, y2) intersects this line segment.
 o intersectsLine(Line2D)
Tests if the given line segment intersects this line segment.
 o linesIntersect(double, double, double, double, double, double, double, double)
Tests if the line segment from (x1, y1) to (x2, y2) intersects the line segment from (x3, y3) to (x4, y4).
 o ptSegDist(double, double, double, double, double, double)
Returns the distance from a point to a line segment.
 o ptSegDistSq(double, double, double, double, double, double)
Returns the square of the distance from a point to a line segment.
 o relativeCCW(double, double)
Return an indicator of where the specified point (x, y) lies with respect to this line segment.
 o relativeCCW(double, double, double, double, double, double)
Return an indicator of where the specified point (px, py) lies with respect to the line segment from (x1, y1) to (x2, y2).
 o relativeCCW(Point2D)
Return an indicator of where the specified point lies with respect to this line segment.
 o setLine(double, double, double, double)
Sets the location of the endpoints of this line to the specified double coordinates.
 o setLine(Line2D)
Sets the location of the endpoints of this line to the same as those in the specified Line.
 o setLine(Point2D, Point2D)
Sets the location of the endpoints of this line to the specified Point coordinates.

Constructors

 o Line2D
protected Line2D()

Methods

 o getX1
public abstract double getX1()
Returns the X coordinate of the start point in double precision.

 o getY1
public abstract double getY1()
Returns the Y coordinate of the start point in double precision.

 o getX2
public abstract double getX2()
Returns the X coordinate of the end point in double precision.

 o getY2
public abstract double getY2()
Returns the Y coordinate of the end point in double precision.

 o setLine
public abstract void setLine(double x1,
                             double y1,
                             double x2,
                             double y2)
Sets the location of the endpoints of this line to the specified double coordinates.

 o setLine
public void setLine(Point2D p1,
                    Point2D p2)
Sets the location of the endpoints of this line to the specified Point coordinates.

 o setLine
public void setLine(Line2D l)
Sets the location of the endpoints of this line to the same as those in the specified Line.

 o colinear
public boolean colinear(double x,
                        double y)
Test if a given (x, y) coordinate is colinear with the line segment.

 o colinear
public boolean colinear(Point2D p)
Test if a given Point is colinear with the line segment.

 o relativeCCW
public static int relativeCCW(double x1,
                              double y1,
                              double x2,
                              double y2,
                              double px,
                              double py)
Return an indicator of where the specified point (px, py) lies with respect to the line segment from (x1, y1) to (x2, y2). The value will be 1 if the line segment must turn counterclockwise to point at the specified point, -1 if it must turn clockwise, or 0 if the point lies exactly on the line segment. If the point is colinear with the line segment, but not between the endpoints, then the value will be -1 if the point lies "beyond (x1, y1)" or 1 if the point lies "beyond (x2, y2)".

 o relativeCCW
public int relativeCCW(double x,
                       double y)
Return an indicator of where the specified point (x, y) lies with respect to this line segment. The value will be 1 if the line segment must turn counterclockwise to point at the specified point, -1 if it must turn clockwise, or 0 if the point lies exactly on the line segment. If the point is colinear with the line segment, but not between the endpoints, then the value will be -1 if the point lies "beyond (x1, y1)" or 1 if the point lies "beyond (x2, y2)".

 o relativeCCW
public int relativeCCW(Point2D p)
Return an indicator of where the specified point lies with respect to this line segment. The value will be 1 if the line segment must turn counterclockwise to point at the specified point, -1 if it must turn clockwise, or 0 if the point lies exactly on the line segment. If the point is colinear with the line segment, but not between the endpoints, then the value will be -1 if the point lies "beyond (x1, y1)" or 1 if the point lies "beyond (x2, y2)".

 o linesIntersect
public static boolean linesIntersect(double x1,
                                     double y1,
                                     double x2,
                                     double y2,
                                     double x3,
                                     double y3,
                                     double x4,
                                     double y4)
Tests if the line segment from (x1, y1) to (x2, y2) intersects the line segment from (x3, y3) to (x4, y4).

 o intersectsLine
public boolean intersectsLine(double x1,
                              double y1,
                              double x2,
                              double y2)
Tests if the line segment from (x1, y1) to (x2, y2) intersects this line segment.

 o intersectsLine
public boolean intersectsLine(Line2D l)
Tests if the given line segment intersects this line segment.

 o ptSegDistSq
public static double ptSegDistSq(double x0,
                                 double y0,
                                 double x1,
                                 double y1,
                                 double px,
                                 double py)
Returns the square of the distance from a point to a line segment.

Parameters:
x0 - the x coordinate of the beginning of the line segment
y0 - the y coordinate of the beginning of the line segment
x1 - the x coordinate of the end of the line segment
y1 - the y coordinate of the end of the line segment
px - the x coordinate of the point being measured
py - the y coordinate of the point being measured
 o ptSegDist
public static double ptSegDist(double x0,
                               double y0,
                               double x1,
                               double y1,
                               double px,
                               double py)
Returns the distance from a point to a line segment.

Parameters:
x0 - the x coordinate of the beginning of the line segment
y0 - the y coordinate of the beginning of the line segment
x1 - the x coordinate of the end of the line segment
y1 - the y coordinate of the end of the line segment
px - the x coordinate of the point being measured
py - the y coordinate of the point being measured
 o contains
public boolean contains(double x,
                        double y)
Test if a given coordinate is inside the boundary of the shape.

 o contains
public boolean contains(Point2D p)
Test if a given Point is inside the boundary of the shape.

 o intersects
public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Test if the Shape intersects the interior of a given set of rectangular coordinates.

 o intersects
public boolean intersects(Rectangle2D r)
Test if the Shape intersects the interior of a given Rectangle.

 o contains
public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Test if the interior of the Shape entirely contains the given set of rectangular coordinates.

 o contains
public boolean contains(Rectangle2D r)
Test if the interior of the Shape entirely contains the given Rectangle.

 o getBounds
public Rectangle getBounds()
Return the bounding box of the shape.

 o getPathIterator
public PathIterator getPathIterator(AffineTransform at)
Return an iteration object that defines the boundary of the shape.

 o getPathIterator
public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Return an iteration object that defines the boundary of the flattened shape.


All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature