java.awt.geom

Class Line2D

Implemented Interfaces:
Cloneable, Shape
Known Direct Subclasses:
Line2D.Double, Line2D.Float

public abstract class Line2D
extends Object
implements Shape, Cloneable

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

static class
Line2D.Double
A line segment specified with double coordinates.
static class
Line2D.Float
A line segment specified with float coordinates.

Constructor Summary

Line2D()
This is an abstract class that cannot be instantiated directly.

Method Summary

Object
clone()
Creates a new object of the same class as this object.
boolean
contains(double x, double y)
Tests if a specified coordinate is inside the boundary of this Line2D.
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.
boolean
contains(Point2D p)
Tests if a given Point2D is inside the boundary of this Line2D.
boolean
contains(Rectangle2D r)
Tests if the interior of this Line2D entirely contains the specified Rectangle2D.
Rectangle
getBounds()
Returns the bounding box of this Line2D.
abstract Point2D
getP1()
Returns the starting Point2D of this Line2D.
abstract Point2D
getP2()
Returns the end Point2D of this Line2D.
PathIterator
getPathIterator(AffineTransform at)
Returns an iteration object that defines the boundary of this Line2D.
PathIterator
getPathIterator(AffineTransform at, double flatness)
Returns an iteration object that defines the boundary of this flattened Line2D.
abstract double
getX1()
Returns the X coordinate of the start point in double precision.
abstract double
getX2()
Returns the X coordinate of the end point in double precision.
abstract double
getY1()
Returns the Y coordinate of the start point in double precision.
abstract double
getY2()
Returns the Y coordinate of the end point in double precision.
boolean
intersects(double x, double y, double w, double h)
Tests if this Line2D intersects the interior of a specified set of rectangular coordinates.
boolean
intersects(Rectangle2D r)
Tests if this Line2D intersects the interior of a specified Rectangle2D.
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 specified 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).
double
ptLineDist(double PX, double PY)
Returns the distance from a point to this line.
static double
ptLineDist(double X1, double Y1, double X2, double Y2, double PX, double PY)
Returns the distance from a point to a line.
double
ptLineDist(Point2D pt)
Returns the distance from a Point2D to this line.
double
ptLineDistSq(double PX, double PY)
Returns the square of the distance from a point to this line.
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.
double
ptLineDistSq(Point2D pt)
Returns the square of the distance from a specified Point2D to this line.
double
ptSegDist(double PX, double PY)
Returns the distance from a point to this line segment.
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.
double
ptSegDist(Point2D pt)
Returns the distance from a Point2D to this line segment.
double
ptSegDistSq(double PX, double PY)
Returns the square of the distance from a point to this line segment.
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.
double
ptSegDistSq(Point2D pt)
Returns the square of the distance from a Point2D to this line segment.
int
relativeCCW(double PX, double PY)
Returns an indicator of where the specified point (PX, PY) lies with respect to this line segment.
static int
relativeCCW(double X1, double Y1, double X2, double Y2, double PX, double PY)
Returns an indicator of where the specified point (PX, PY) lies with respect to the line segment from (X1, Y1) to (X2, Y2).
int
relativeCCW(Point2D p)
Returns an indicator of where the specified Point2D lies with respect to this line segment.
abstract 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(Line2D l)
Sets the location of the endpoints of this Line2D to the same as those endpoints of the specified Line2D.
void
setLine(Point2D p1, Point2D p2)
Sets the location of the endpoints of this Line2D to the specified Point2D coordinates.

Methods inherited from class java.lang.Object

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

Constructor Details

Line2D

protected Line2D()
This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessory methods below.

Method Details

clone

public Object clone()
Creates a new object of the same class as this object.
Overrides:
clone in interface Object
Returns:
a clone of this instance.
Since:
1.2
See Also:
Cloneable
Usages and Demos :

View More Examples of clone()
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         Shape result = null;
   6:         if (shape instanceof Line2D) {
   7:         ...
   8:             Line2D line = (Line2D) shape;
   9:         ...
  10:             result = (Shape) line.clone();    

View Full Code Here
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:   public static Line2D resizeLine (final Line2D line,
   7:                                    final double width,
   8:         ...
   9:   {
  10:     final Line2D lineClone = (Line2D) line.clone();
  11: 
  12:         ...
  13:   {
  14:     final RectangularShape retval = (RectangularShape) rectangularShape.clone();

View Full Code Here
   1: import java.awt.Stroke;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:     final ShapeElement element =
   6:             createShapeElement(name, bounds, paint, stroke, new Line2D.Float(0, 0, 100, 0),
   7:             true, false, true);
   8:         ...
   9:     final Rectangle2D bounds = new Rectangle2D.Float((float) x, 0, 0, -100);
  10:     final ShapeElement element = createShapeElement(name, bounds, paint, stroke, new Line2D.Float(0, 0, 0, 100),
  11:             true, false, true);
  12:         ...
  13:     }
  14:     final Rectangle2D rect = (Rectangle2D) shape.clone();

View Full Code Here

contains

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.
Specified by:
contains in interface Shape
Parameters:
Returns:
false because a Line2D contains no area.

contains

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.
Specified by:
contains in interface Shape
Parameters:
w - the width of the specified rectangular area
h - the height of the specified rectangular area
Returns:
false because a Line2D contains no area.

contains

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.
Specified by:
contains in interface Shape
Parameters:
p - the specified Point2D to be tested
Returns:
false because a Line2D contains no area.

contains

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.
Specified by:
contains in interface Shape
Parameters:
r - the specified Rectangle2D to be tested
Returns:
false because a Line2D contains no area.

getBounds

public Rectangle getBounds()
Returns the bounding box of this Line2D.
Specified by:
getBounds in interface Shape
Returns:
a Rectangle that is the bounding box of the Line2D.
Usages and Demos :

View More Examples of getBounds()
   1: import java.awt.Stroke;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:         Line2D line = null;
   7:         double x = 0.0;
   8:         ...
   9:             y = barW0 + state.getBarWidth() / 2.0;
  10:             line = new Line2D.Double(barL, barW0, barL, barW0 + state.getBarWidth());
  11:         }
  12:         ...
  13:                 CategoryItemEntity entity = new CategoryItemEntity(
  14:                     line.getBounds(), tip, url, dataset, row, dataset.getColumnKey(column), column

View Full Code Here
   1: import java.awt.Stroke;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:         Line2D line = null;
   7:         double x = 0.0;
   8:         ...
   9:             y = barW0 + state.getBarWidth() / 2.0;
  10:             line = new Line2D.Double(barL, barW0, barL, 
  11:                     barW0 + state.getBarWidth());
  12:         ...
  13:                 CategoryItemEntity entity = new CategoryItemEntity(
  14:                         line.getBounds(), tip, url, dataset, row, 

View Full Code Here

getP1

public abstract Point2D getP1()
Returns the starting Point2D of this Line2D.
Returns:
the starting Point2D of this Line2D.
Usages and Demos :

View More Examples of getP1()
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         final double distance = 40;
   6:         final Line2D base = test.isoscelesTriangleBase(summit, distance);
   7:         ...
   8:         assertEquals("distance P1", distance, base.getP1().distance(summit), EPS);
   9:         assertEquals("distance P2", distance, base.getP2().distance(summit), EPS);

View Full Code Here
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.PathIterator;
   4:         ...
   5: 
   6:     public static double length(Line2D line) {
   7:         ...
   8:         return line.getP1().distance(line.getP2());
   9:     }
  10:         ...
  11:     
  12:     public static ArrayList<Line2D> splitLines(double maxLength, ArrayList<Line2D> lines) {

View Full Code Here
   1: import java.awt.geom.Ellipse2D;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         }
   6:         if (shape instanceof Line2D)
   7:         {
   8:         ...
   9:             Line2D line = (Line2D) shape;
  10:         ...
  11:             Point2D p1 = new Point2D.Double(line.getP1().getX() + translate, line.getP1().getY());

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     public static Point2D[] intersectionRectangleLine(Rectangle2D rec, Line2D line) {
   7:         double x1 = line.getX1();
   8:         ...
   9:         double r = (xmin-x1)/(x2-x1);
  10:         p0 = AlgoPoint2D.evaluate(line.getP1(),line.getP2(),r);
  11:         if ((p0!=null) && (p0.getX()<xmin || p0.getX()>xmax || p0.getY()<ymin || p0.getY()>ymax)) p0 = null;
  12:         ...
  13:         if (p0==null) 
  14:             p0 = AlgoPoint2D.evaluate(line.getP1(),line.getP2(),s);

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:     
   6:     Line2D line0;
   7:     
   8:         ...
   9:     Line2D line1;
  10:     
  11:         ...
  12:     public void setValues(Line2D line0, Line2D line1) {
  13:         Point2D p0 = line0.getP1();

View Full Code Here

getP2

public abstract Point2D getP2()
Returns the end Point2D of this Line2D.
Returns:
a Point2D that is the endpoint of this Line2D.
Usages and Demos :

View More Examples of getP2()
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.PathIterator;
   4:         ...
   5: 
   6:     public static double length(Line2D line) {
   7:         ...
   8:         return line.getP1().distance(line.getP2());
   9:     }
  10:         ...
  11:     
  12:     public static ArrayList<Line2D> splitLines(double maxLength, ArrayList<Line2D> lines) {

View Full Code Here
   1: import java.awt.geom.Ellipse2D;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         }
   6:         if (shape instanceof Line2D)
   7:         {
   8:         ...
   9:             Line2D line = (Line2D) shape;
  10:             Point2D p1 = new Point2D.Double(line.getP1().getX() + translate, line.getP1().getY());
  11:         ...
  12:             Point2D p2 = new Point2D.Double(line.getP2().getX() + translate, line.getP2().getY());

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     public static Point2D[] intersectionRectangleLine(Rectangle2D rec, Line2D line) {
   7:         double x1 = line.getX1();
   8:         ...
   9:         double r = (xmin-x1)/(x2-x1);
  10:         p0 = AlgoPoint2D.evaluate(line.getP1(),line.getP2(),r);
  11:         if ((p0!=null) && (p0.getX()<xmin || p0.getX()>xmax || p0.getY()<ymin || p0.getY()>ymax)) p0 = null;
  12:         ...
  13:         if (p0==null) 
  14:             p0 = AlgoPoint2D.evaluate(line.getP1(),line.getP2(),s);

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:     
   6:     Line2D line0;
   7:     
   8:         ...
   9:     Line2D line1;
  10:     
  11:         ...
  12:         Point2D p0 = line0.getP1();
  13:         Point2D p1 = line0.getP2();

View Full Code Here
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:   public static Line2D resizeLine (final Line2D line,
   7:                                    final double width,
   8:         ...
   9:     final Point2D p1 = newLine.getP1();
  10:     final Point2D p2 = newLine.getP2();
  11:     final double normPointX = (p1.getX() - p2.getX());
  12:         ...
  13:     final Point2D p1 = line.getP1();
  14:     final Point2D p2 = line.getP2();

View Full Code Here

getPathIterator

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.
Specified by:
getPathIterator in interface Shape
Parameters:
at - the specified AffineTransform
Returns:
a PathIterator that defines the boundary of this Line2D.

getPathIterator

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.
Specified by:
getPathIterator in interface Shape
Parameters:
at - the specified AffineTransform
flatness - the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the endpoints. Since a Line2D object is always flat, this parameter is ignored.
Returns:
a PathIterator that defines the boundary of the flattened Line2D

getX1

public abstract double getX1()
Returns the X coordinate of the start point in double precision.
Returns:
the X coordinate of this Line2D object's starting point.
Usages and Demos :

View More Examples of getX1()
   1: import java.awt.Color;
   2: import java.awt.geom.Line2D;
   3: import edu.cmu.ri.mrpl.TeRK.color.ColoredObject;
   4:         ...
   5:    {
   6:    private final Line2D line;
   7: 
   8:         ...
   9:    public ColoredLine(final Color color, final Line2D point)
  10:       {
  11:         ...
  12:       {
  13:       return (int)line.getX1();

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5:     public Line2DObjectDescription() {
   6:         super(Line2D.class);
   7:         setParameterDefinition("x1", Float.class);
   8:         ...
   9:     public Object createObject() {
  10:         final Line2D line = new Line2D.Float();
  11: 
  12:         ...
  13:         final Line2D line = (Line2D) o;
  14:         final float x1 = (float) line.getX1();

View Full Code Here
   1: 
   2:     protected transient Line2D line;
   3: 
   4:         ...
   5: 
   6:     public ZLine(Line2D aLine) {
   7:         this(aLine.getP1(), aLine.getP2());
   8:         ...
   9:         ZLine newLine = (ZLine) super.duplicateObject();
  10:         newLine.line = (Line2D) getLine().clone();
  11:         return newLine;
  12:         ...
  13:         Vector dimensions = new Vector();
  14:         dimensions.add(new Double(line.getX1()));

View Full Code Here
   1: import java.awt.geom.AffineTransform;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         super(tail, head);
   6:         setShape(new Line2D.Double());
   7:         route();
   8:         ...
   9:         }
  10:         ((Line2D)getShape()).setLine(tailPt, headPt);
  11: 
  12:         ...
  13:         line.setLine(
  14:                 line.getX1()+x, line.getY1()+y, 

View Full Code Here
   1: import java.awt.Shape;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     private Line2D      m_line = new Line2D.Double();
   7:     private Rectangle2D m_box  = new Rectangle2D.Double();
   8:         ...
   9:         } else {
  10:             m_box.add(m_line.getX1(),m_line.getY1());
  11:             m_box.add(m_line.getX2(),m_line.getY2());

View Full Code Here

getX2

public abstract double getX2()
Returns the X coordinate of the end point in double precision.
Returns:
the X coordinate of this Line2D object's starting point.
Usages and Demos :

View More Examples of getX2()
   1: 
   2:     protected transient Line2D line;
   3: 
   4:         ...
   5: 
   6:     public ZLine(Line2D aLine) {
   7:         this(aLine.getP1(), aLine.getP2());
   8:         ...
   9:         ZLine newLine = (ZLine) super.duplicateObject();
  10:         newLine.line = (Line2D) getLine().clone();
  11:         return newLine;
  12:         ...
  13:         dimensions.add(new Double(line.getY1()));
  14:         dimensions.add(new Double(line.getX2()));

View Full Code Here
   1: import java.awt.geom.AffineTransform;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         super(tail, head);
   6:         setShape(new Line2D.Double());
   7:         route();
   8:         ...
   9:         }
  10:         ((Line2D)getShape()).setLine(tailPt, headPt);
  11: 
  12:         ...
  13:                 line.getX1()+x, line.getY1()+y, 
  14:                 line.getX2()+x, line.getY2()+y);

View Full Code Here
   1: import java.awt.Shape;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     private Line2D      m_line = new Line2D.Double();
   7:     private Rectangle2D m_box  = new Rectangle2D.Double();
   8:         ...
   9:             m_box.add(m_line.getX1(),m_line.getY1());
  10:             m_box.add(m_line.getX2(),m_line.getY2());
  11:             item.setBounds(m_box.getMinX(), m_box.getMinY(),

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.RectangularShape;
   4:         ...
   5: 
   6:     public final Element newLine(Line2D shape) {
   7:         if (shape == null) {
   8:         ...
   9:         el.setAttribute("y1", String.valueOf(shape.getY1()));
  10:         el.setAttribute("x2", String.valueOf(shape.getX2()));
  11:         el.setAttribute("y2", String.valueOf(shape.getY2()));
  12:         ...
  13: 
  14:     public final Element newLine(Line2D shape, String id) {

View Full Code Here
   1: import java.awt.geom.Point2D;
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5: 
   6:     public static double calcAngle(Line2D line1, Line2D line2){
   7:         if(line1.getX1()==line2.getX1()&&line1.getY1()==line2.getY1()&&
   8:         ...
   9:                 line1.getX2()==line2.getX2()&&line1.getY2()==line2.getY2()){
  10:             return 0;
  11:         ...
  12:         }
  13:         double v1x = line1.getX2()-line1.getX1();

View Full Code Here

getY1

public abstract double getY1()
Returns the Y coordinate of the start point in double precision.
Returns:
the Y coordinate of this Line2D object's starting point.
Usages and Demos :

View More Examples of getY1()
   1: import java.awt.Color;
   2: import java.awt.geom.Line2D;
   3: import edu.cmu.ri.mrpl.TeRK.color.ColoredObject;
   4:         ...
   5:    {
   6:    private final Line2D line;
   7: 
   8:         ...
   9:    public ColoredLine(final Color color, final Line2D point)
  10:       {
  11:         ...
  12:       {
  13:       return (int)line.getY1();

View Full Code Here
   1: 
   2:     protected transient Line2D line;
   3: 
   4:         ...
   5: 
   6:     public ZLine(Line2D aLine) {
   7:         this(aLine.getP1(), aLine.getP2());
   8:         ...
   9:         ZLine newLine = (ZLine) super.duplicateObject();
  10:         newLine.line = (Line2D) getLine().clone();
  11:         return newLine;
  12:         ...
  13:         dimensions.add(new Double(line.getX1()));
  14:         dimensions.add(new Double(line.getY1()));

View Full Code Here
   1: import java.awt.geom.AffineTransform;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         super(tail, head);
   6:         setShape(new Line2D.Double());
   7:         route();
   8:         ...
   9:         }
  10:         ((Line2D)getShape()).setLine(tailPt, headPt);
  11: 
  12:         ...
  13:         line.setLine(
  14:                 line.getX1()+x, line.getY1()+y, 

View Full Code Here
   1: import java.awt.Shape;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     private Line2D      m_line = new Line2D.Double();
   7:     private Rectangle2D m_box  = new Rectangle2D.Double();
   8:         ...
   9:         } else {
  10:             m_box.add(m_line.getX1(),m_line.getY1());
  11:             m_box.add(m_line.getX2(),m_line.getY2());

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.RectangularShape;
   4:         ...
   5: 
   6:     public final Element newLine(Line2D shape) {
   7:         if (shape == null) {
   8:         ...
   9:         el.setAttribute("x1", String.valueOf(shape.getX1()));
  10:         el.setAttribute("y1", String.valueOf(shape.getY1()));
  11:         el.setAttribute("x2", String.valueOf(shape.getX2()));
  12:         ...
  13: 
  14:     public final Element newLine(Line2D shape, String id) {

View Full Code Here

getY2

public abstract double getY2()
Returns the Y coordinate of the end point in double precision.
Returns:
the Y coordinate of this Line2D object's starting point.
Usages and Demos :

View More Examples of getY2()
   1: 
   2:     protected transient Line2D line;
   3: 
   4:         ...
   5: 
   6:     public ZLine(Line2D aLine) {
   7:         this(aLine.getP1(), aLine.getP2());
   8:         ...
   9:         ZLine newLine = (ZLine) super.duplicateObject();
  10:         newLine.line = (Line2D) getLine().clone();
  11:         return newLine;
  12:         ...
  13:         dimensions.add(new Double(line.getX2()));
  14:         dimensions.add(new Double(line.getY2()));

View Full Code Here
   1: import java.awt.geom.AffineTransform;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         super(tail, head);
   6:         setShape(new Line2D.Double());
   7:         route();
   8:         ...
   9:         }
  10:         ((Line2D)getShape()).setLine(tailPt, headPt);
  11: 
  12:         ...
  13:                 line.getX1()+x, line.getY1()+y, 
  14:                 line.getX2()+x, line.getY2()+y);

View Full Code Here
   1: import java.awt.Shape;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     private Line2D      m_line = new Line2D.Double();
   7:     private Rectangle2D m_box  = new Rectangle2D.Double();
   8:         ...
   9:             m_box.add(m_line.getX1(),m_line.getY1());
  10:             m_box.add(m_line.getX2(),m_line.getY2());
  11:             item.setBounds(m_box.getMinX(), m_box.getMinY(),

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.RectangularShape;
   4:         ...
   5: 
   6:     public final Element newLine(Line2D shape) {
   7:         if (shape == null) {
   8:         ...
   9:         el.setAttribute("x2", String.valueOf(shape.getX2()));
  10:         el.setAttribute("y2", String.valueOf(shape.getY2()));
  11: 
  12:         ...
  13: 
  14:     public final Element newLine(Line2D shape, String id) {

View Full Code Here
   1: import java.awt.geom.Point2D;
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5: 
   6:     public static double calcAngle(Line2D line1, Line2D line2){
   7:         if(line1.getX1()==line2.getX1()&&line1.getY1()==line2.getY1()&&
   8:         ...
   9:                 line1.getX2()==line2.getX2()&&line1.getY2()==line2.getY2()){
  10:             return 0;
  11:         ...
  12:         double v1x = line1.getX2()-line1.getX1();
  13:         double v1y = line1.getY2()-line1.getY1();

View Full Code Here

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Tests if this Line2D intersects the interior of a specified set of rectangular coordinates.
Specified by:
intersects in interface Shape
Parameters:
w - the width of the specified rectangular area
h - the height of the specified rectangular area
Returns:
true if this Line2D intersects the interior of the specified set of rectangular coordinates; false otherwise.

intersects

public boolean intersects(Rectangle2D r)
Tests if this Line2D intersects the interior of a specified Rectangle2D.
Specified by:
intersects in interface Shape
Parameters:
r - the specified Rectangle2D to be tested
Returns:
true if this Line2D intersects the interior of the specified Rectangle2D; false otherwise.
Usages and Demos :

View More Examples of intersects(Rectangle2D r)
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:     }
   6:     Line2D line = new Line2D.Double(startPoint.getLocation(), endPoint
   7:       .getLocation());
   8:         ...
   9:     return line.intersects(point.getBounds());
  10:   }

View Full Code Here

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.
Parameters:
Returns:
if this line segment and the specified line segment intersect each other; false otherwise.

intersectsLine

public boolean intersectsLine(Line2D l)
Tests if the specified line segment intersects this line segment.
Parameters:
l - the specified Line2D
Returns:
true if this line segment and the specified line segment intersect each other; false otherwise.

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).
Parameters:
Returns:
true if the first specified line segment and the second specified line segment intersect each other; false otherwise.

ptLineDist

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.
Parameters:
Returns:
a double value that is the distance from a specified point to the current line.
Usages and Demos :

View More Examples of ptLineDist(double PX,double PY)
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         final double distance = 40;
   6:         final Line2D base = test.isoscelesTriangleBase(summit, distance);
   7:         assertEquals("distance P1", distance, base.getP1().distance(summit), EPS);
   8:         ...
   9:         final double y=8;
  10:         assertEquals("nearest colinear point", base.ptLineDist(x,y),
  11:                      test.nearestColinearPoint(new Point2D.Double(x,y)).distance(x,y), EPS);

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:         final double distance = 40;
   6:         final Line2D base = test.isoscelesTriangleBase(summit, distance);
   7:         assertEquals("distance P1", distance, base.getP1().distance(summit), EPS);
   8:         ...
   9:         final double y=8;
  10:         assertEquals("nearest colinear point", base.ptLineDist(x,y),
  11:                      test.nearestColinearPoint(new Point2D.Double(x,y)).distance(x,y), EPS);

View Full Code Here

ptLineDist

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.
Parameters:
Returns:
a double value that is the distance from the specified point to the specified line.

ptLineDist

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.
Parameters:
pt - the specified Point2D being measured
Returns:
a double value that is the distance from a specified Point2D to the current line.

ptLineDistSq

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.
Parameters:
Returns:
a double value that is the square of the distance from a specified point to the current line.

ptLineDistSq

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.
Parameters:
Returns:
a double value that is the square of the distance from the specified point to the specified line.

ptLineDistSq

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.
Parameters:
pt - the specified Point2D being measured against this line
Returns:
a double value that is the square of the distance from a specified Point2D to the current line.

ptSegDist

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 endpoints. If the specified point intersects the line segment in between the endpoints, this method returns 0.0.
Parameters:
Returns:
a double value that is the distance from the specified point to the current line segment.

ptSegDist

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 endpoints. If the specified point intersects the line segment in between the endpoints, this method returns 0.0.
Parameters:
Returns:
a double value that is the distance from the specified point to the specified line segment.
Usages and Demos :

View More Examples of ptSegDist(double X1,double Y1,double X2,double Y2,double PX,double PY)
   1: 
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5:         float[] n = item.location;
   6:         int ccw = Line2D.relativeCCW(x1,y1,x2,y2,n[0],n[1]);
   7:         ...
   8:         float r = (float)Line2D.ptSegDist(x1,y1,x2,y2,n[0],n[1]);
   9:         if ( r == 0.0 ) r = (float)Math.random() / 100.0f;

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5:         float[] n = item.location;
   6:         int ccw = Line2D.relativeCCW(x1,y1,x2,y2,n[0],n[1]);
   7:         ...
   8:         float r = (float)Line2D.ptSegDist(x1,y1,x2,y2,n[0],n[1]);
   9:         if ( r == 0.0 ) r = (float)Math.random() / 100.0f;

View Full Code Here
   1:                     currentY = cs[1];
   2:                     squareDist = Line2D.ptSegDist(lastX, lastY, currentX, currentY, px, py);
   3:                     if (squareDist <= minSquareDist) {
   4:         ...
   5:                     currentY = firstY;
   6:                     squareDist = Line2D.ptSegDist(lastX, lastY, currentX, currentY, px, py);
   7:                     if (squareDist <= minSquareDist) {
   8:                         return true;
   9:                     }

View Full Code Here

ptSegDist

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 endpoints. If the specified point intersects the line segment in between the endpoints, this method returns 0.0.
Parameters:
pt - the specified Point2D being measured against this line segment
Returns:
a double value that is the distance from the specified Point2D to the current line segment.

ptSegDistSq

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 endpoints. If the specified point intersects the line segment in between the endpoints, this method returns 0.0.
Parameters:
Returns:
a double value that is the square of the distance from the specified point to the current line segment.

ptSegDistSq

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 endpoints. If the specified point intersects the line segment in between the endpoints, this method returns 0.0.
Parameters:
Returns:
a double value that is the square of the distance from the specified point to the specified line segment.
Usages and Demos :

View More Examples of ptSegDistSq(double X1,double Y1,double X2,double Y2,double PX,double PY)
   1:         if (np == 1) {
   2:         minSquareDist = Line2D.ptSegDistSq(xp[0], yp[0], xp[0], yp[0], px, py);
   3:         } else {
   4:         ...
   5:         minSquareDist = Line2D.ptSegDistSq(xp[0], yp[0], xp[1], yp[1], px, py);
   6:         }
   7:         ...
   8:         for (i=1; i<np-1; i++) {
   9:         squareDist = Line2D.ptSegDistSq(xp[i], yp[i], xp[i+1], yp[i+1], px, py);
  10:         if (squareDist < minSquareDist) {

View Full Code Here

ptSegDistSq

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 endpoints. If the specified point intersects the line segment in between the endpoints, this method returns 0.0.
Parameters:
pt - the specified Point2D being measured against this line segment.
Returns:
a double value that is the square of the distance from the specified Point2D to the current line segment.

relativeCCW

public int relativeCCW(double PX,
                       double PY)
Returns an indicator of where the specified point (PX, PY) lies with respect to this line segment. See the method comments of relativeCCW(double,double,double,double,double,double) to interpret the return value.
Parameters:
Returns:
an integer that indicates the position of the specified coordinates with respect to the current line segment.

relativeCCW

public static int relativeCCW(double X1,
                              double Y1,
                              double X2,
                              double Y2,
                              double PX,
                              double PY)
Returns an indicator of where the specified point (PX, PY) lies with respect to the line segment from (X1, Y1) to (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 endpoint, (X1, Y1), in order to point at the specified point (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 endpoints, then the value will be -1 if the point lies "beyond (X1, Y1)" or 1 if the point lies "beyond (X2, Y2)".

Parameters:
Returns:
an integer that indicates the position of the third specified coordinates with respect to the line segment formed by the first two specified coordinates.

relativeCCW

public int relativeCCW(Point2D p)
Returns an indicator of where the specified Point2D lies with respect to this line segment. See the method comments of relativeCCW(double,double,double,double,double,double) to interpret the return value.
Parameters:
p - the specified Point2D to be compared with the current line segment
Returns:
an integer that indicates the position of the Point2D with respect to the current line segment.

setLine

public abstract void setLine(double X1,
                             double Y1,
                             double X2,
                             double Y2)
Sets the location of the endpoints of this Line2D to the specified double coordinates.
Parameters:
Usages and Demos :

View More Examples of setLine(double X1,double Y1,double X2,double Y2)
   1: import java.awt.RenderingHints;
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5: 
   6:     private Line2D _line;
   7: 
   8:         ...
   9:         super();
  10:         _line = new Line2D.Double();
  11:         _shape = new PaintedShape(_line);
  12:         ...
  13:             }
  14:             _line.setLine(_prevX, _prevY, x, y);

View Full Code Here
   1: import java.awt.Stroke;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:     static protected Line2D gridLine = new Line2D.Double();
   7:     static protected Stroke gridStroke = new BasicStroke(1);
   8:         ...
   9:                 for (double x = bx; x < rightBorder; x += gridSpacing) {
  10:                     gridLine.setLine(x, by, x, bottomBorder);
  11:                     if (clip.intersectsLine(gridLine)) {
  12:         ...
  13:                 for (double y = by; y < bottomBorder; y += gridSpacing) {
  14:                     gridLine.setLine(bx, y, rightBorder, y);

View Full Code Here
   1: 
   2: import java.awt.geom.Line2D;
   3: import java.util.Date;
   4:         ...
   5: 
   6:         Line2D line = new Line2D.Double();
   7:         for (int i = 0; i < count; i++) {
   8:         ...
   9:         for (int i = 0; i < count; i++) {
  10:             line.setLine(1.0, 1.0, 1.0, 1.0);
  11:         }

View Full Code Here
   1: import java.awt.geom.Ellipse2D;
   2: import java.awt.geom.Line2D;
   3: 
   4:         ...
   5:                 
   6:                 Line2D line = new Line2D.Double();
   7:                 Graphics2D g2 = aPaintContext.getGraphics();
   8:         ...
   9:                 for (double x = bx; x < rightBorder; x += 5) {
  10:                     line.setLine(x, by, x, bottomBorder);
  11:                     g2.draw(line);
  12:         ...
  13:                 for (double y = by; y < bottomBorder; y += 5) {
  14:                     line.setLine(bx, y, rightBorder, y);

View Full Code Here
   1:   protected GeneralPath path = new GeneralPath();
   2:   protected Line2D line = new Line2D.Double();
   3:   protected Shape head;
   4:         ...
   5:     d = d - 1.58f * w;
   6:     line.setLine(0, 0, d-length, 0);
   7:     shaft = rotation.createTransformedShape(line);
   8:     path.reset();
   9:     path.moveTo(0, 0);

View Full Code Here

setLine

public void setLine(Line2D l)
Sets the location of the endpoints of this Line2D to the same as those endpoints of the specified Line2D.
Parameters:
l - the specified Line2D
Usages and Demos :

View More Examples of setLine(Line2D l)
   1:     private int e2eIntersectIndex = 0;
   2:     private Line2D line;
   3: 
   4:         ...
   5:     super();
   6:     line = new Line2D.Double();
   7:     }
   8:         ...
   9: 
  10:         line.setLine(tempP.getX(), tempP.getY(), tempQ.getX(), tempQ.getY());
  11:         if(line.intersects(0, 0, curWinWidth, curWinHeight )) {

View Full Code Here
   1: import java.awt.Stroke;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5:     final ShapeElement element =
   6:             createShapeElement(name, bounds, paint, stroke, new Line2D.Float(0, 0, 100, 0),
   7:             true, false, true);
   8:         ...
   9:     final Rectangle2D bounds = new Rectangle2D.Float((float) x, 0, 0, -100);
  10:     final ShapeElement element = createShapeElement(name, bounds, paint, stroke, new Line2D.Float(0, 0, 0, 100),
  11:             true, false, true);
  12:         ...
  13: 
  14:       shape.setLine(shape.getX1() - bounds.getX(),

View Full Code Here
   1: import java.awt.geom.Ellipse2D;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:   {
   6:     draw(new Line2D.Float(x1, y1, x2, y2));
   7:   }
   8:         ...
   9:   {
  10:     final Line2D line = new Line2D.Double(xPoints[0], yPoints[0], xPoints[0], yPoints[0]);
  11:     for (int i = 1; i < nPoints; i++)
  12:         ...
  13:     {
  14:       line.setLine(line.getX2(), line.getY2(), xPoints[i], yPoints[i]);

View Full Code Here
   1: import java.awt.geom.Ellipse2D;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.NoninvertibleTransformException;
   4:         ...
   5:                 y = (float)((double)(y) + asPoints((double)(UnderlineThickness), (int)fontSize));
   6:                 Line2D line = new Line2D.Double((double)x, (double)y, (double)(width+x), (double)y);
   7:                 draw(line);
   8:         ...
   9:         for (int i = 1; i < nPoints; i++) {
  10:             line.setLine(line.getX2(), line.getY2(), x[i], y[i]);
  11:             draw(line);

View Full Code Here

setLine

public void setLine(Point2D p1,
                    Point2D p2)
Sets the location of the endpoints of this Line2D to the specified Point2D coordinates.
Parameters:
Usages and Demos :

View More Examples of setLine(Point2D p1,Point2D p2)
   1: import java.awt.Shape;
   2: import java.awt.geom.Line2D;
   3: import java.awt.geom.Point2D;
   4:         ...
   5: 
   6:         Line2D shape = new Line2D.Double();
   7: 
   8:         ...
   9:         double x = plotArea.getMinX() + (plotArea.getWidth() / 2);
  10:         shape.setLine(x, plotArea.getMinY(), x, plotArea.getMaxY());

View Full Code Here
   1: 
   2:   protected Line2D line = new Line2D.Double();
   3:   protected TPoint end1 = new LineEnd();
   4:         ...
   5:     Point p2 = end2.getScreenPosition(vidPanel);
   6:     line.setLine(p1, p2);
   7:     end1Rect.setLocation(p1.x - 4, p1.y - 4);
   8:     end2Rect.setLocation(p2.x - 4, p2.y - 4);
   9:     return stroke.createStrokedShape(line);

View Full Code Here
   1:     TTrack track;
   2:   protected Line2D xAxis = new Line2D.Double();
   3:         ...
   4:   protected Line2D yAxis = new Line2D.Double();
   5:   protected Point xEnd1 = new Point(), xEnd2 = new Point();
   6:         ...
   7:             xEnd2.setLocation(p.x+500, p.y);
   8:         xAxis.setLine(xEnd1, xEnd2);
   9:         xAxisShape = axisStroke.createStrokedShape(xAxis);
  10:         ...
  11:             yEnd2.setLocation(p.x, p.y+500);
  12:         yAxis.setLine(yEnd1, yEnd2);

View Full Code Here
   1:   ) {
   2:     Line2D line = new Line2D.Double();
   3:     Point2D startP;
   4:         ...
   5:     g.setPaint(getOutline());
   6:     line.setLine(startP, midP);
   7:     g.draw(line);
   8:         ...
   9:     line.setLine(midP, endP);
  10:     g.draw(line);

View Full Code Here
   1:   protected GeneralPath path = new GeneralPath();
   2:   protected Line2D line = new Line2D.Double();
   3:   protected Shape[] hitShapes = new Shape[4];
   4:         ...
   5:     Point p2 = points[1];
   6:     line.setLine(p1, p2);
   7:     return stroke.createStrokedShape(line);
   8:   }

View Full Code Here