ilog.cpl.graphic.views
Class IlpPolyline

java.lang.Object
  extended by ilog.cpl.graphic.views.IlpPolyPoints
      extended by ilog.cpl.graphic.views.IlpPolyline
All Implemented Interfaces:
IlpPosition, Shape, Cloneable

public class IlpPolyline
extends IlpPolyPoints
implements Shape, IlpPosition, Cloneable

This class defines a polyline where the starting point and the end point are not necessarily the same.

Since:
JTGO 3.0

Constructor Summary
IlpPolyline(IlpPolyline orig)
          Creates a new polyline from a given one.
IlpPolyline(IlpPolyline orig, IlvTransformer t, boolean removeRedundant)
          Creates a new IlpPolyline instance, connecting the given points and considering that the given transformer is applied.
IlpPolyline(IlvPoint[] points)
          Creates a new IlpPolyline instance, connecting given points.
IlpPolyline(IlvPoint[] points, boolean removeRedundant)
          Creates a new IlpPolyline instance, connecting given points.
IlpPolyline(IlvPoint[] points, IlvTransformer t, boolean removeRedundant)
          Creates a new IlpPolyline instance, connecting the given points and considering that the given transformer is applied.
IlpPolyline(IlvPoint from, IlvPoint to)
          Creates a new IlpPolyline instance.
 
Method Summary
 IlvPoint[] adjustForArrow(IlpLineSegment segment, float arrowSize, float width)
          Returns the points necessary to add to the polyline to draw an arrow at one extremity of the link.
 void adjustForFromArrow(float arrowSize, float width)
          Adds one or two points depending on the shape of the polyline, which can then be used to draw a link with an arrow at the from end.
 void adjustForToArrow(float arrowSize, float width)
          Adds one or two points depending on the shape of the polyline, which can then be used to draw a link with an arrow at the to end.
 void applyTransform(IlvTransformer t)
          Applies a transform to the points, thereby destructively modifying the polyline and its segments.
 Object clone()
          Creates a copy of this polyline.
 IlpPolyline computeParallel(float apart, float miterlimit)
          Returns a parallel polyline.
 IlpPolyline computeParallel(float apart, float miterlimit, boolean reverse)
          Returns a parallel polyline.
 ilog.cpl.graphic.views.internal.IlpPolyTwoPolylines computeThickLinkShape(float thickness, float miterlimit)
          Returns the two polylines bounding the result of blowing up this polyline to a given thickness.
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double width, double height)
           
 boolean contains(Point2D p)
           
 boolean contains(Rectangle2D r)
           
 IlvPoint getFrom()
          Returns the starting point of the polyline.
 ilog.cpl.graphic.views.internal.IlpPolyPointAndDirection getMedian()
          Returns the "midpoint" of the polyline, and the direction of the segment containing it.
protected  ilog.cpl.graphic.views.internal.IlpPolyPointAndDirection getMedian(float roundingThreshold)
          Returns the "midpoint" of the polyline, and the direction of the segment containing it.
 int getNumberOfPoints()
          Returns the number of points in the polyline.
 PathIterator getPathIterator(AffineTransform transform)
           
 PathIterator getPathIterator(AffineTransform at, double flatness)
           
 IlvPoint getTo()
          Returns the end point of the polyline.
 void insertPoint(IlvPoint p)
          Inserts a point into the nearest segment.
 void insertPoint(int index, IlvPoint p)
          Inserts a point into a specific segment.
 boolean intersects(double x, double y, double width, double height)
           
 boolean intersects(Rectangle2D r)
           
 void movePoint(int index, IlvPoint p)
          Moves a specific point to a new location.
 void removePoint(int index)
          Removes a specific point.
 void removeRedundantPoints()
          Removes all redundant points (points which are between their neighbors).
 void reverse()
          Reverses the order of the points, the order of the segments, and the directions of the segments.
 
Methods inherited from class ilog.cpl.graphic.views.IlpPolyPoints
equals, getBounds, getBounds2D, getClosestSegment, getGravity0, getGravity1, getNumberOfSegments, getPoint, getPoints, getPointsCloned, getSegment, getSegments, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.Shape
getBounds, getBounds2D
 

Constructor Detail

IlpPolyline

public IlpPolyline(IlvPoint from,
                   IlvPoint to)
Creates a new IlpPolyline instance. The segments must be added afterwards.


IlpPolyline

public IlpPolyline(IlpPolyline orig)
Creates a new polyline from a given one.


IlpPolyline

public IlpPolyline(IlvPoint[] points,
                   boolean removeRedundant)
Creates a new IlpPolyline instance, connecting given points.

Parameters:
points - A non-empty array of points.
removeRedundant - Indicates whether redundant points shall be removed.

IlpPolyline

public IlpPolyline(IlvPoint[] points)
Creates a new IlpPolyline instance, connecting given points.

Parameters:
points - A non-empty array of points.

IlpPolyline

public IlpPolyline(IlpPolyline orig,
                   IlvTransformer t,
                   boolean removeRedundant)
Creates a new IlpPolyline instance, connecting the given points and considering that the given transformer is applied.

Since:
JTGO 4.5

IlpPolyline

public IlpPolyline(IlvPoint[] points,
                   IlvTransformer t,
                   boolean removeRedundant)
Creates a new IlpPolyline instance, connecting the given points and considering that the given transformer is applied.

Since:
JTGO 4.5
Method Detail

getFrom

public IlvPoint getFrom()
Returns the starting point of the polyline.


getTo

public IlvPoint getTo()
Returns the end point of the polyline.


clone

public Object clone()
Creates a copy of this polyline.

Overrides:
clone in class Object

getNumberOfPoints

public int getNumberOfPoints()
Returns the number of points in the polyline.

Specified by:
getNumberOfPoints in class IlpPolyPoints

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface Shape
Internal method or field: do not use!

contains

public boolean contains(Point2D p)
Specified by:
contains in interface Shape
Internal method or field: do not use!

intersects

public boolean intersects(double x,
                          double y,
                          double width,
                          double height)
Specified by:
intersects in interface Shape
Internal method or field: do not use!

intersects

public boolean intersects(Rectangle2D r)
Specified by:
intersects in interface Shape
Internal method or field: do not use!

contains

public boolean contains(double x,
                        double y,
                        double width,
                        double height)
Specified by:
contains in interface Shape
Internal method or field: do not use!

contains

public boolean contains(Rectangle2D r)
Specified by:
contains in interface Shape
Internal method or field: do not use!

getPathIterator

public PathIterator getPathIterator(AffineTransform transform)
Specified by:
getPathIterator in interface Shape
Internal method or field: do not use!

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Specified by:
getPathIterator in interface Shape
Internal method or field: do not use!

getMedian

public ilog.cpl.graphic.views.internal.IlpPolyPointAndDirection getMedian()
Returns the "midpoint" of the polyline, and the direction of the segment containing it. For open polylines, this is the midpoint of the segment which is closest to the midpoint of the segment lengths.

Specified by:
getMedian in class IlpPolyPoints
Internal method or field: do not use!

getMedian

protected ilog.cpl.graphic.views.internal.IlpPolyPointAndDirection getMedian(float roundingThreshold)
Returns the "midpoint" of the polyline, and the direction of the segment containing it. For open polylines, this is the midpoint of the segment which is closest to the midpoint of the segment lengths. Segments which are tiny enough that they look like rounding errors are ignored.

Internal method or field: do not use!

computeParallel

public IlpPolyline computeParallel(float apart,
                                   float miterlimit)
Returns a parallel polyline.

Parameters:
apart - Distance (positive for a parallel polyline to the right of the polyline, negative for a parallel polyline to the left of the polyline).
miterlimit - see comments in class IltGraphicUtil
Internal method or field: do not use!

computeParallel

public IlpPolyline computeParallel(float apart,
                                   float miterlimit,
                                   boolean reverse)
Returns a parallel polyline.

Parameters:
apart - Distance (positive for a parallel polyline to the right of the polyline, negative for a parallel polyline to the left of the polyline).
miterlimit - see comments in class IltGraphicUtil
reverse - Whether to reverse the orientation of the resulting polyline.
Internal method or field: do not use!

computeThickLinkShape

public ilog.cpl.graphic.views.internal.IlpPolyTwoPolylines computeThickLinkShape(float thickness,
                                                                                 float miterlimit)
Returns the two polylines bounding the result of blowing up this polyline to a given thickness.

This is the same as: new IlpPolyTwoPolylines(computeParallel(-0.5f*thickness,miterlimit), computeParallel(0.5f*thickness,miterlimit))

Specified by:
computeThickLinkShape in class IlpPolyPoints
Parameters:
miterlimit - see comments in class IltGraphicUtil
Internal method or field: do not use!

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transform to the points, thereby destructively modifying the polyline and its segments.

Specified by:
applyTransform in class IlpPolyPoints

reverse

public void reverse()
Reverses the order of the points, the order of the segments, and the directions of the segments. This destructively modifies the polyline and its segments.

Specified by:
reverse in class IlpPolyPoints
Internal method or field: do not use!

insertPoint

public void insertPoint(int index,
                        IlvPoint p)
Inserts a point into a specific segment.

Specified by:
insertPoint in class IlpPolyPoints
Parameters:
index - Satisfies -1 <= index <= getNumberOfSegments(). index = -1 means to add the point as a new "from" end; index = getNumberOfSegments() means to add the point as a new "to" end.
p - The point to be inserted.

insertPoint

public void insertPoint(IlvPoint p)
Inserts a point into the nearest segment.

Specified by:
insertPoint in class IlpPolyPoints

movePoint

public void movePoint(int index,
                      IlvPoint p)
Moves a specific point to a new location.

Specified by:
movePoint in class IlpPolyPoints
Parameters:
index - Satisfies 0 <= index < getNumberOfPoints().
p - The point to be moved.

removePoint

public void removePoint(int index)
Removes a specific point.

Specified by:
removePoint in class IlpPolyPoints
Parameters:
index - Satisfies 0 <= index < getNumberOfPoints().

removeRedundantPoints

public void removeRedundantPoints()
Removes all redundant points (points which are between their neighbors).

Specified by:
removeRedundantPoints in class IlpPolyPoints

adjustForFromArrow

public void adjustForFromArrow(float arrowSize,
                               float width)
Adds one or two points depending on the shape of the polyline, which can then be used to draw a link with an arrow at the from end.

Parameters:
arrowSize - Length of the arrow in pixels.
width - Width of the arrow in pixels.
Internal method or field: do not use!

adjustForToArrow

public void adjustForToArrow(float arrowSize,
                             float width)
Adds one or two points depending on the shape of the polyline, which can then be used to draw a link with an arrow at the to end.

Parameters:
arrowSize - Length of the arrow in pixels.
width - Width of the arrow in pixels.
Internal method or field: do not use!

adjustForArrow

public IlvPoint[] adjustForArrow(IlpLineSegment segment,
                                 float arrowSize,
                                 float width)
Returns the points necessary to add to the polyline to draw an arrow at one extremity of the link.

Parameters:
segment - Oriented segment that is one end of the link. Will be replaced with an arrow.
arrowSize - Length of the arrow in pixels.
width - Width of the arrow in pixels.
Internal method or field: do not use!


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