java.awt.geom

Class Line2D.Float

Enclosing Class:
Line2D
Implemented Interfaces:
Cloneable, Shape

public static class Line2D.Float
extends Line2D

A line segment specified with float coordinates.

Nested Class Summary

Nested classes/interfaces inherited from class java.awt.geom.Line2D

Line2D.Double, Line2D.Float

Field Summary

float
x1
The X coordinate of the start point of the line segment.
float
x2
The X coordinate of the end point of the line segment.
float
y1
The Y coordinate of the start point of the line segment.
float
y2
The Y coordinate of the end point of the line segment.

Constructor Summary

Float()
Constructs and initializes a Line with coordinates (0, 0) -> (0, 0).
Float(float X1, float Y1, float X2, float Y2)
Constructs and initializes a Line from the specified coordinates.
Float(Point2D p1, Point2D p2)
Constructs and initializes a Line2D from the specified Point2D objects.

Method Summary

Rectangle2D
getBounds2D()
Returns the high-precision bounding box of this Line2D.
Point2D
getP1()
Returns the start point.
Point2D
getP2()
Returns the end point.
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.
void
setLine(double X1, double Y1, double X2, double Y2)
Sets the location of the endpoints of this Line2D to the specified double coordinates.
void
setLine(float X1, float Y1, float X2, float Y2)
Sets the location of the endpoints of this Line2D to the specified float coordinates.

Methods inherited from class java.awt.geom.Line2D

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 inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

x1

public float x1
The X coordinate of the start point of the line segment.

x2

public float x2
The X coordinate of the end point of the line segment.

y1

public float y1
The Y coordinate of the start point of the line segment.

y2

public float y2
The Y coordinate of the end point of the line segment.

Constructor Details

Float

public Float()
Constructs and initializes a Line with coordinates (0, 0) -> (0, 0).
Usages and Demos :

View More Examples of Float()
   1:       {
   2:          Line2D l1 = new Line2D.Float();
   3:         ...
   4:          Line2D l2 = new Line2D.Float();
   5:         ...
   6:          Line2D l3 = new Line2D.Float();
   7:          Line2D l4 = new Line2D.Float();

View Full Code Here
   1:     public Object createObject() {
   2:         final Line2D line = new Line2D.Float();
   3: 
   4:         final float x1 = getFloatParameter("x1");
   5:         final float x2 = getFloatParameter("x2");

View Full Code Here
   1:   private void renderTrace(int[] baseCalls, int[] trace, Graphics2D g, SequenceRenderContext ctxt, int min, int max) {
   2:     Line2D line = new Line2D.Float();
   3:     for(int pos = min; pos <= max; pos++) {
   4:       int minT;
   5:       int maxT;

View Full Code Here
   1: 
   2:         Line2D shape = new Line2D.Float();
   3:         Shape d = null;
   4: 
   5:         float x = (float) (plotArea.getMinX() +  (plotArea.getWidth() / 2));

View Full Code Here
   1:         private Rectangle graphOutlineRect = new Rectangle();
   2:         private Rectangle2D mfRect = new Rectangle2D.Float();
   3:         ...
   4:         private Rectangle2D muRect = new Rectangle2D.Float();
   5:         ...
   6:         private Line2D graphLine = new Line2D.Float();
   7:         private Color graphColor = new Color(46, 139, 87);

View Full Code Here

Float

public Float(float X1,
             float Y1,
             float X2,
             float Y2)
Constructs and initializes a Line from the specified coordinates.
Parameters:
Usages and Demos :

View More Examples of Float(float X1,float Y1,float X2,float Y2)
   1:   {
   2:     return new Line2D.Float(0, 0, 0, 100);
   3:   }
   4: }

View Full Code Here
   1:   {
   2:     return new Line2D.Float(0, 0, 100, 0);
   3:   }
   4: }

View Full Code Here
   1:     public Transforms() {
   2:     path.append(new Line2D.Float(0.0f, 0.0f, 0.0f, 100.0f), false);
   3:         ...
   4:     path.append(new Line2D.Float(-10.0f, 50.0f, 10.0f, 50.0f), false);
   5:     path.append(new Polygon(new int[] { -5, 0, 5 },
   6:                 new int[] { 5, 0, 5 }, 3), false);

View Full Code Here
   1:     public Transforms() {
   2:     path.append(new Line2D.Float(0.0f, 0.0f, 0.0f, 100.0f), false);
   3:         ...
   4:     path.append(new Line2D.Float(-10.0f, 50.0f, 10.0f, 50.0f), false);
   5:     path.append(new Polygon(new int[] { -5, 0, 5 },
   6:                 new int[] { 5, 0, 5 }, 3), false);

View Full Code Here
   1:             g2.setColor(SystemColor.controlDkShadow);
   2:             g2.draw(new Line2D.Float(0, h - 1, w, h - 1));
   3:             g2.setColor(SystemColor.controlShadow);
   4:         ...
   5:             g2.draw(new Line2D.Float(w12, 0, w, h - 1));
   6:             g2.setColor(SystemColor.controlLtHighlight);
   7:         ...
   8:             g2.draw(new Line2D.Float(0, h - 1, w12, 0));
   9:             break;

View Full Code Here

Float

public Float(Point2D p1,
             Point2D p2)
Constructs and initializes a Line2D from the specified Point2D objects.
Parameters:
p1 - the first specified Point2D
p2 - the second specified Point2D
Usages and Demos :

View More Examples of Float(Point2D p1,Point2D p2)
   1:       rect1.setRect(p1.x-100, p1.y-25, width, height);
   2:       g2D.draw(new Line2D.Float(p1, p2));
   3:       g2D.drawString("Acyclic Gradient Paint", p1.x-100, p1.y-50);
   4:       g2D.drawString("p1", p1.x-20, p1.y);
   5:       g2D.drawString("p2", p2.x+10, p2.y);

View Full Code Here
   1:             g2.setStroke(new BasicStroke(15, cap[i], BasicStroke.JOIN_MITER));
   2:             g2.draw(new Line2D.Float(w/4,(i+1)*h/4,w-w/4,(i+1)*h/4));
   3:             TextLayout tl = new TextLayout(desc[i], font, frc);
   4:             tl.draw(g2,(float)(w/2-tl.getBounds().getWidth()/2),(i+1)*h/4-10);
   5:         }

View Full Code Here
   1:             g2.draw(new Line2D.Float((getWidth() - 1) / 2, 0, (getWidth() - 1) / 2, getH() - 1));
   2:             g2.draw(new Line2D.Float(0, getH() - 1, (getWidth() - 1) / 2, getH() - 1));
   3:         }
   4:         else
   5:         {

View Full Code Here
   1:             if (shape == null) {
   2:                 final Point2D.Float po = new Point2D.Float(ox, oy);
   3:         ...
   4:                 final Point2D.Float pp = new Point2D.Float(px, py);
   5:                 transform.inverseTransform(po, po);
   6:         ...
   7:                 transform.inverseTransform(pp, pp);
   8:                 return new Line2D.Float(po, pp);
   9:             } else {

View Full Code Here
   1:       }
   2:       return new Line2D.Float(clipped[0], clipped[1]);
   3:     }
   4: 
   5:     final Rectangle2D boundsCorrected = bounds.getBounds2D();

View Full Code Here

Method Details

getBounds2D

public Rectangle2D getBounds2D()
Returns the high-precision bounding box of this Line2D.
Specified by:
getBounds2D in interface Shape
Returns:
a Rectangle2D that is the high-precision bounding box of this Line2D.

getP1

public Point2D getP1()
Returns the start point.
Overrides:
getP1 in interface Line2D
Returns:
the starting Point2D object of this Line2D.

getP2

public Point2D getP2()
Returns the end point.
Overrides:
getP2 in interface Line2D
Returns:
the ending Point2D object of this Line2D.

getX1

public double getX1()
Returns the X coordinate of the start point in double precision.
Overrides:
getX1 in interface Line2D
Returns:
the x coordinate of this Line2D object's starting point in double precision.

getX2

public double getX2()
Returns the X coordinate of the end point in double precision.
Overrides:
getX2 in interface Line2D
Returns:
the x coordinate of this Line2D object's ending point in double precision.

getY1

public double getY1()
Returns the Y coordinate of the start point in double precision.
Overrides:
getY1 in interface Line2D
Returns:
the x coordinate of this Line2D object's starting point in double precision.

getY2

public double getY2()
Returns the Y coordinate of the end point in double precision.
Overrides:
getY2 in interface Line2D
Returns:
the Y coordinate of this Line2D object's ending point in double precision.

setLine

public void setLine(double X1,
                    double Y1,
                    double X2,
                    double Y2)
Sets the location of the endpoints of this Line2D to the specified double coordinates.
Overrides:
setLine in interface Line2D
Parameters:

setLine

public void setLine(float X1,
                    float Y1,
                    float X2,
                    float Y2)
Sets the location of the endpoints of this Line2D to the specified float coordinates.
Parameters: