java.awt.geom

Class Line2D.Double

public static class Line2D.Double extends Line2D

This class defines a point in double precision.

Since: 1.2

UNKNOWN: updated to 1.4

Field Summary
doublex1
The x coordinate of the first point.
doublex2
The x coordinate of the second point.
doubley1
The y coordinate of the first point.
doubley2
The y coordinate of the second point.
Constructor Summary
Double()
Construct the line segment (0,0)->(0,0).
Double(double x1, double y1, double x2, double y2)
Construct the line segment with the specified points.
Double(Point2D p1, Point2D p2)
Construct the line segment with the specified points.
Method Summary
Rectangle2DgetBounds2D()
Return the exact bounds of this line segment.
Point2DgetP1()
Return the first point.
Point2DgetP2()
Return the second point.
doublegetX1()
Return the x coordinate of the first point.
doublegetX2()
Return the x coordinate of the second point.
doublegetY1()
Return the y coordinate of the first point.
doublegetY2()
Return the y coordinate of the second point.
voidsetLine(double x1, double y1, double x2, double y2)
Set this line to the given points.

Field Detail

x1

public double x1
The x coordinate of the first point.

x2

public double x2
The x coordinate of the second point.

y1

public double y1
The y coordinate of the first point.

y2

public double y2
The y coordinate of the second point.

Constructor Detail

Double

public Double()
Construct the line segment (0,0)->(0,0).

Double

public Double(double x1, double y1, double x2, double y2)
Construct the line segment with the specified points.

Parameters: x1 the x coordinate of the first point y1 the y coordinate of the first point x2 the x coordinate of the second point y2 the y coordinate of the second point

Double

public Double(Point2D p1, Point2D p2)
Construct the line segment with the specified points.

Parameters: p1 the first point p2 the second point

Throws: NullPointerException if either point is null

Method Detail

getBounds2D

public Rectangle2D getBounds2D()
Return the exact bounds of this line segment.

Returns: the bounding box

getP1

public Point2D getP1()
Return the first point.

Returns: the point (x1,y1)

getP2

public Point2D getP2()
Return the second point.

Returns: the point (x2,y2)

getX1

public double getX1()
Return the x coordinate of the first point.

Returns: the value of x1

getX2

public double getX2()
Return the x coordinate of the second point.

Returns: the value of x2

getY1

public double getY1()
Return the y coordinate of the first point.

Returns: the value of y1

getY2

public double getY2()
Return the y coordinate of the second point.

Returns: the value of y2

setLine

public void setLine(double x1, double y1, double x2, double y2)
Set this line to the given points.

Parameters: x1 the new x coordinate of the first point y1 the new y coordinate of the first point x2 the new x coordinate of the second point y2 the new y coordinate of the second point