ilog.cpl.graphic.views
Class IlpLineSegment

java.lang.Object
  extended by java.awt.geom.Line2D
      extended by ilog.cpl.graphic.views.IlpLineSegment
All Implemented Interfaces:
Shape, Cloneable
Direct Known Subclasses:
IltLineSegment

public class IlpLineSegment
extends Line2D
implements Cloneable

This class describes a line segment.

Since:
JTGO 3.0

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Line2D
Line2D.Double, Line2D.Float
 
Constructor Summary
IlpLineSegment(IlvPoint from, IlvPoint to)
          Creates a new line segment, connecting two points.
 
Method Summary
 Object clone()
          Returns a copy of this object.
 Rectangle2D getBounds2D()
          Returns the smallest rectangle covering all points.
 int getDirection()
          Returns the direction of this line segment.
 IlvPoint getFrom()
          Returns the starting point of this segment.
 int getOrientation()
          Returns the orientation of this line segment.
 Point2D getP1()
          Returns the starting point.
 Point2D getP2()
          Returns the end point.
 IlvPoint getTo()
          Returns the end point of this segment.
 double getX1()
          Returns the X coordinate of the starting point.
 double getX2()
          Returns the X coordinate of the end point.
 double getY1()
          Returns the Y coordinate of the starting point.
 double getY2()
          Returns the Y coordinate of the end point.
 boolean intersects(double x1, double y1, double x2, double y2)
          Tests whether this segment intersects a given rectangle x1 <= x <= x2, y1 <= y <= y2.
 boolean intersects(float x1, float y1, float x2, float y2)
          Tests whether this segment intersects a given rectangle x1 <= x <= x2, y1 <= y <= y2.
 boolean isParallelTo(IlpLineSegment other)
          Tests whether this line segment is parallel to another line segment (same orientation).
 boolean isParallelVectorTo(IlpLineSegment other)
          Tests whether this line segment is parallel to another line segment including the same direction.
 float length()
          Returns the Euclidean length of this segment.
 IlvPoint nearestTo(IlvPoint p)
          Returns the point in this segment which is closest to a given point.
protected  void setFrom(IlvPoint p)
          Sets the starting point of this segment.
 void setLine(double x1, double y1, double x2, double y2)
          Constructs and initializes a line from the specified coordinates.
protected  void setTo(IlvPoint p)
          Sets the end point of this segment.
 float sqdist(IlvPoint p)
          Returns the square of the distance of a given point to this segment.
 String toString()
           
protected  void transientInit()
          Initialize transient fields.
 
Methods inherited from class java.awt.geom.Line2D
contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlpLineSegment

public IlpLineSegment(IlvPoint from,
                      IlvPoint to)
Creates a new line segment, connecting two points. The argument points are not copied and should therefore not be modified.

Method Detail

transientInit

protected void transientInit()
Initialize transient fields.

Internal method or field: do not use!

getFrom

public IlvPoint getFrom()
Returns the starting point of this segment.


setFrom

protected void setFrom(IlvPoint p)
Sets the starting point of this segment.

Parameters:
p - Starting point
Since:
JViews 7.5

getTo

public IlvPoint getTo()
Returns the end point of this segment.


setTo

protected void setTo(IlvPoint p)
Sets the end point of this segment.

Parameters:
p - End point
Since:
JViews 7.5

getOrientation

public int getOrientation()
Returns the orientation of this line segment. This is either 0, or IlvDirection.Horizontal or IlvDirection.Vertical, or (for an empty segment) the combination of IlvDirection.Horizontal and IlvDirection.Vertical.


getDirection

public int getDirection()
Returns the direction of this line segment. This is either 0 or IlvDirection.Right, IlvDirection.Left, IlvDirection.Bottom, IlvDirection.Top, or (for an empty segment) the combination of IlvDirection.Horizontal and IlvDirection.Vertical.


length

public float length()
Returns the Euclidean length of this segment.


nearestTo

public IlvPoint nearestTo(IlvPoint p)
Returns the point in this segment which is closest to a given point.

Internal method or field: do not use!

sqdist

public float sqdist(IlvPoint p)
Returns the square of the distance of a given point to this segment.


intersects

public boolean intersects(float x1,
                          float y1,
                          float x2,
                          float y2)
Tests whether this segment intersects a given rectangle x1 <= x <= x2, y1 <= y <= y2.


intersects

public boolean intersects(double x1,
                          double y1,
                          double x2,
                          double y2)
Tests whether this segment intersects a given rectangle x1 <= x <= x2, y1 <= y <= y2.

Specified by:
intersects in interface Shape
Overrides:
intersects in class Line2D

isParallelTo

public boolean isParallelTo(IlpLineSegment other)
Tests whether this line segment is parallel to another line segment (same orientation).

Internal method or field: do not use!

isParallelVectorTo

public boolean isParallelVectorTo(IlpLineSegment other)
Tests whether this line segment is parallel to another line segment including the same direction.

Internal method or field: do not use!

clone

public Object clone()
Returns a copy of this object.

Overrides:
clone in class Line2D

getX1

public double getX1()
Returns the X coordinate of the starting point.

Specified by:
getX1 in class Line2D

getY1

public double getY1()
Returns the Y coordinate of the starting point.

Specified by:
getY1 in class Line2D

getX2

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

Specified by:
getX2 in class Line2D

getY2

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

Specified by:
getY2 in class Line2D

getP1

public Point2D getP1()
Returns the starting point.

Specified by:
getP1 in class Line2D

getP2

public Point2D getP2()
Returns the end point.

Specified by:
getP2 in class Line2D

setLine

public void setLine(double x1,
                    double y1,
                    double x2,
                    double y2)
Constructs and initializes a line from the specified coordinates.

Specified by:
setLine in class Line2D

getBounds2D

public Rectangle2D getBounds2D()
Returns the smallest rectangle covering all points.

Specified by:
getBounds2D in interface Shape
Returns:
An IlvRect object.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.