Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.geom.Line2D

java.lang.Object
    |
    +----java.awt.geom.Line2D
Subclasses:
Line2D.Double, Line2D.Float

public abstract class Line2D
extends Object
implements Shape, Cloneable
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.


Inner Class Summary
static   Line2D.Double
A line segment specified with double coordinates.
static   Line2D.Float
A line segment specified with float coordinates.
 

Constructor Summary
 Line2D()
 
 

Method Summary
Object  clone()
Creates a new object of the same class as this object.
boolean  colinear(double x, double y)
Test if a given (x, y) coordinate is colinear with the line segment.
boolean  colinear(Point2D p)
Test if a given Point is colinear with the line segment.
boolean  contains(double x, double y)
Test if a given coordinate is inside the boundary of the shape.
boolean  contains(Point2D p)
Test if a given Point is inside the boundary of the shape.
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.
boolean  contains(Rectangle2D r)
Test if the interior of the Shape entirely contains the given Rectangle.
Rectangle  getBounds()
Return the bounding box of the shape.
PathIterator  getPathIterator(AffineTransform at)
Return an iteration object that defines the boundary of the shape.
PathIterator  getPathIterator(AffineTransform at, double flatness)
Return an iteration object that defines the boundary of the flattened shape.
double  getX1()
Returns the X coordinate of the start point in double precision.
double  getX2()
Returns the X coordinate of the end point in double precision.
double  getY1()
Returns the Y coordinate of the start point in double precision.
double  getY2()
Returns the Y coordinate of the end point in double precision.
boolean  intersects(double x, double y, double w, double h)
Test if the Shape intersects the interior of a given set of rectangular coordinates.
boolean  intersects(Rectangle2D r)
Test if the Shape intersects the interior of a given Rectangle.
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.
boolean  intersectsLine(Line2D l)
Tests if the given line segment intersects this line segment.
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).
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.
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.
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).
int  relativeCCW(double x, double y)
Return an indicator of where the specified point (x, y) lies with respect to this line segment.
int  relativeCCW(Point2D p)
Return an indicator of where the specified point lies with respect to this line segment.
void  setLine(double x1, double y1, double x2, double y2)
Sets the location of the endpoints of this line to the specified double coordinates.
void  setLine(Point2D p1, Point2D p2)
Sets the location of the endpoints of this line to the specified Point coordinates.
void  setLine(Line2D l)
Sets the location of the endpoints of this line to the same as those in the specified Line.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Line2D

protected Line2D()
Method Detail

getX1

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

getY1

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

getX2

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

getY2

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

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.

setLine

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

setLine

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

colinear

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

colinear

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

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)".

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)".

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)".

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).

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.

intersectsLine

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

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

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

contains

public boolean contains(double x,
                        double y)
Test if a given coordinate is inside the boundary of the shape.
Implements:
contains in interface Shape

contains

public boolean contains(Point2D p)
Test if a given Point is inside the boundary of the shape.
Implements:
contains in interface Shape

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.
Implements:
intersects in interface Shape

intersects

public boolean intersects(Rectangle2D r)
Test if the Shape intersects the interior of a given Rectangle.
Implements:
intersects in interface Shape

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.
Implements:
contains in interface Shape

contains

public boolean contains(Rectangle2D r)
Test if the interior of the Shape entirely contains the given Rectangle.
Implements:
contains in interface Shape

getBounds

public Rectangle getBounds()
Return the bounding box of the shape.
Implements:
getBounds in interface Shape

getPathIterator

public PathIterator getPathIterator(AffineTransform at)
Return an iteration object that defines the boundary of the shape.
Implements:
getPathIterator in interface Shape

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Return an iteration object that defines the boundary of the flattened shape.
Implements:
getPathIterator in interface Shape

clone

public Object clone()
Creates a new object of the same class as this object.
Returns:
a clone of this instance.
Throws:
OutOfMemoryError - if there is not enough memory.
Overrides:
clone in class Object
See Also:
Cloneable

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.