Save This Page
Home » openjdk-7 » java » awt » geom » [javadoc | source]
java.awt.geom
abstract public class: Line2D [javadoc | source]
java.lang.Object
   java.awt.geom.Line2D

All Implemented Interfaces:
    Shape, Cloneable

Direct Known Subclasses:
    Double, Float

This Line2D represents a line segment in {@code (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.

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

Nested Class Summary:
public static class  Line2D.Float  A line segment specified with float coordinates. 
public static class  Line2D.Double  A line segment specified with double coordinates. 
Constructor:
 protected Line2D() 
Method from java.awt.geom.Line2D Summary:
clone,   contains,   contains,   contains,   contains,   getBounds,   getP1,   getP2,   getPathIterator,   getPathIterator,   getX1,   getX2,   getY1,   getY2,   intersects,   intersects,   intersectsLine,   intersectsLine,   linesIntersect,   ptLineDist,   ptLineDist,   ptLineDist,   ptLineDistSq,   ptLineDistSq,   ptLineDistSq,   ptSegDist,   ptSegDist,   ptSegDist,   ptSegDistSq,   ptSegDistSq,   ptSegDistSq,   relativeCCW,   relativeCCW,   relativeCCW,   setLine,   setLine,   setLine
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.awt.geom.Line2D Detail:
 public Object clone() 
    Creates a new object of the same class as this object.
 public boolean contains(Point2D p) 
    Tests if a given Point2D is inside the boundary of this Line2D. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.
 public boolean contains(Rectangle2D r) 
    Tests if the interior of this Line2D entirely contains the specified Rectangle2D. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.
 public boolean contains(double x,
    double y) 
    Tests if a specified coordinate is inside the boundary of this Line2D. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.
 public boolean contains(double x,
    double y,
    double w,
    double h) 
    Tests if the interior of this Line2D entirely contains the specified set of rectangular coordinates. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.
 public Rectangle getBounds() 
    {@inheritDoc}
 abstract public Point2D getP1()
    Returns the start Point2D of this Line2D.
 abstract public Point2D getP2()
    Returns the end Point2D of this Line2D.
 public PathIterator getPathIterator(AffineTransform at) 
    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.
 public PathIterator getPathIterator(AffineTransform at,
    double flatness) 
    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.
 abstract public double getX1()
    Returns the X coordinate of the start point in double precision.
 abstract public double getX2()
    Returns the X coordinate of the end point in double precision.
 abstract public double getY1()
    Returns the Y coordinate of the start point in double precision.
 abstract public double getY2()
    Returns the Y coordinate of the end point in double precision.
 public boolean intersects(Rectangle2D r) 
    {@inheritDoc}
 public boolean intersects(double x,
    double y,
    double w,
    double h) 
    {@inheritDoc}
 public boolean intersectsLine(Line2D l) 
    Tests if the specified line segment intersects this line segment.
 public boolean intersectsLine(double x1,
    double y1,
    double x2,
    double y2) 
    Tests if the line segment from {@code (x1,y1)} to {@code (x2,y2)} intersects this line segment.
 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 {@code (x1,y1)} to {@code (x2,y2)} intersects the line segment from {@code (x3,y3)} to {@code (x4,y4)}.
 public double 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.
 public double ptLineDist(double px,
    double 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.
 public static double ptLineDist(double x1,
    double y1,
    double x2,
    double y2,
    double px,
    double 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.
 public double 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.
 public double ptLineDistSq(double px,
    double 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.
 public static double ptLineDistSq(double x1,
    double y1,
    double x2,
    double y2,
    double px,
    double 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.
 public double 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.
 public double ptSegDist(double px,
    double 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.
 public static double ptSegDist(double x1,
    double y1,
    double x2,
    double y2,
    double px,
    double 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.
 public double 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.
 public double ptSegDistSq(double px,
    double 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.
 public static double ptSegDistSq(double x1,
    double y1,
    double x2,
    double y2,
    double px,
    double 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.
 public int relativeCCW(Point2D p) 
 public int relativeCCW(double px,
    double py) 
 public static int relativeCCW(double x1,
    double y1,
    double x2,
    double y2,
    double px,
    double py) 
    Returns an indicator of where the specified point {@code (px,py)} lies with respect to the line segment from {@code (x1,y1)} to {@code (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, {@code (x1,y1)}, in order to point at the specified point {@code (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 {@code (x1,y1)}" or 1 if the point lies "beyond {@code (x2,y2)}".

 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.
 public  void setLine(Point2D p1,
    Point2D p2) 
    Sets the location of the end points of this Line2D to the specified Point2D coordinates.
 abstract public  void setLine(double x1,
    double y1,
    double x2,
    double y2)
    Sets the location of the end points of this Line2D to the specified double coordinates.