ilog.views.graphic
Class IlvPolyline

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvPolyPoints
          extended by ilog.views.graphic.IlvPolyline
All Implemented Interfaces:
IlvPolyPointsInterface, IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvArrowPolyline, IlvMapPolyline

public class IlvPolyline
extends IlvPolyPoints

IlvPolyline represents a line that follows several points.

The default values for an IlvPolyline instance are as follows:

Example

The following code example shows how to use IlvPolyline in a simple Java application:

   IlvManager manager = new IlvManager();

   IlvPoint[] points = new IlvPoint[7];
   points[0] = new IlvPoint(40f, 40f);
   points[1] = new IlvPoint(50f, 20f);
   points[2] = new IlvPoint(90f, 40f);
   points[3] = new IlvPoint(70f, 70f);
   points[4] = new IlvPoint(90f, 90f);
   points[5] = new IlvPoint(40f, 90f);
   points[6] = new IlvPoint(40f, 40f);
    
   IlvPolyline defaultPolyline = new IlvPolyline(points, true);
   IlvPolyline customPolyline = new IlvPolyline(points, true);
    
   customPolyline.removePoint(6, new IlvTransformer() );
   customPolyline.setStrokeOn(true);
   customPolyline.setForeground(Color.green);
   customPolyline.setLineWidth(5);
   customPolyline.moveResize(new IlvRect(100,80,40,40));
   IlvPoint center = customPolyline.getCenter(new IlvTransformer());
   customPolyline.rotate(center, 130);
       
   manager.addObject(defaultPolyline, true);
   manager.addObject(customPolyline, true);
 

The following image shows the graphic objects created in the code example:

IlvPolyPoints

About Graphic Objects

IlvPolyline is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an instance of IlvManager or one of its subclasses, and displayed using one or more IlvManagerView instances in a Java Swing application. For information about generic features for graphic objects, see IlvGraphic.

See Also:
IlvManager, IlvManagerView, IlvStroke, Serialized Form

Constructor Summary
IlvPolyline(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvPolyline(IlvPoint[] points)
          Creates a new IlvPolyline.
IlvPolyline(IlvPoint[] points, boolean copy)
          Creates a new IlvPolyline.
IlvPolyline(IlvPolyline source)
          Creates a new IlvPolyline by copying an existing one.
 
Method Summary
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object.
protected  void computeBBox(IlvRect bbox)
          Recomputes the bounding rectangle of the object.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the object.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
protected  void finalize()
          Overrides the method to clean some resources.
 int getEndCap()
          Returns the decoration applied at the end of the polyline.
 Color getForeground()
          Returns the color of the object.
 IlvPoint getIntersectionWithOutline(IlvPoint innerPoint, IlvPoint outerPoint, IlvTransformer t)
          Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object.
 int getLineJoin()
          Returns the decoration applied when two segments are joined.
 float[] getLineStyle()
          Returns the array representing the lengths of the dash segments.
 float getLineWidth()
          Returns the line width of the object.
 float getLineWidth(IlvTransformer t)
          Returns the line width that is really displayed when the object is drawn with the specified transformer.
 float getMaximumLineWidth()
          Returns the maximum line width of the polyline.
 boolean pointsInBBox()
          Returns true if all points of the polypoint object are contained in the bounding box.
 void setEndCap(int endCap)
          Changes the decoration applied at the end of the polyline.
 void setForeground(Color c)
          Changes the color of the object.
 void setLineJoin(int lineJoin)
          Changes the decoration applied when two segments are joined.
 void setLineStyle(float[] lineStyle)
          Changes the array representing the lengths of the dash segments.
 void setLineWidth(float lineWidth)
          Changes the line width of the object.
 void setMaximumLineWidth(float maximumLineWidth)
          Changes the maximum line width of the polyline.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.graphic.IlvPolyPoints
allowsPointInsertion, allowsPointMove, allowsPointRemoval, applyTransform, getPointAt, getPoints, getPointsCardinal, inBBox, insertPoint, intersects, makeSelection, movePoint, recomputeBBox, removePoint
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isPersistent, isSelectable, isVisible, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvPolyline

public IlvPolyline(IlvPoint[] points)
Creates a new IlvPolyline. Note that this constructor will copy the array and the points in the array, so you can reuse the same array for another operation.

Parameters:
points - the points of the polyline.

IlvPolyline

public IlvPolyline(IlvPoint[] points,
                   boolean copy)
Creates a new IlvPolyline.

Parameters:
points - the array of points.
copy - if true, the array of points and the points of the first parameter will be copied, otherwise this array will be used by the object and you must not use this array anymore.

IlvPolyline

public IlvPolyline(IlvPolyline source)
Creates a new IlvPolyline by copying an existing one.

Parameters:
source - the copied object.

IlvPolyline

public IlvPolyline(IlvInputStream stream)
            throws IlvReadFileException
Reads the object from an IlvInputStream.

Parameters:
stream - the input stream.
Throws:
IlvReadFileException - if the format is not correct.
Method Detail

copy

public IlvGraphic copy()
Copies the object. This method copies the object by calling the copy constructor.

Specified by:
copy in class IlvGraphic
Returns:
a copy of the object.
See Also:
IlvGraphic

pointsInBBox

public boolean pointsInBBox()
Returns true if all points of the polypoint object are contained in the bounding box. Since this is the case for the class IlvPolyline this method simply returns true.


getLineWidth

public float getLineWidth()
Returns the line width of the object. The default value is 0.


setLineWidth

public void setLineWidth(float lineWidth)
Changes the line width of the object.

Parameters:
lineWidth - the new line width.

getEndCap

public int getEndCap()
Returns the decoration applied at the end of the polyline. The values are defined in the class IlvStroke. The default value is CAP_SQUARE.

See Also:
IlvStroke

setEndCap

public void setEndCap(int endCap)
Changes the decoration applied at the end of the polyline.

Parameters:
endCap - the new decoration style. The values are defined in the class IlvStroke. The default value is CAP_SQUARE.
See Also:
IlvStroke

getLineJoin

public int getLineJoin()
Returns the decoration applied when two segments are joined. The values are defined in the class IlvStroke. The default value is JOIN_MITER.

See Also:
IlvStroke

setLineJoin

public void setLineJoin(int lineJoin)
Changes the decoration applied when two segments are joined.

Parameters:
lineJoin - the new decoration style. The values are defined in the class IlvStroke. The default value is JOIN_MITER.
See Also:
IlvStroke

getMaximumLineWidth

public float getMaximumLineWidth()
Returns the maximum line width of the polyline. If the maximum line width is specified and not equal to zero, then the width of the polyline will stop zooming when the maximum line width is reached.


setMaximumLineWidth

public void setMaximumLineWidth(float maximumLineWidth)
Changes the maximum line width of the polyline. If the maximum line width is specified and not equal to zero, then the width of the polyline will stop zooming when the maximum line width is reached. A value of zero, means that there is no limit.


getLineStyle

public float[] getLineStyle()
Returns the array representing the lengths of the dash segments. Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes.


setLineStyle

public void setLineStyle(float[] lineStyle)
Changes the array representing the lengths of the dash segments. Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes.


computeBBox

protected void computeBBox(IlvRect bbox)
Recomputes the bounding rectangle of the object. This method is called when the points change, or when the style of the line changes (line width, end cap style, line join).

Overrides:
computeBBox in class IlvPolyPoints
Parameters:
bbox - the rectangle to store the resulting bounding box.

boundingBox

public IlvRect boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.

Specified by:
boundingBox in interface IlvPolyPointsInterface
Overrides:
boundingBox in class IlvPolyPoints
Parameters:
t - The transformer used to draw the object.
Returns:
The bounding rectangle of the object in transformed coordinates.
See Also:
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

contains

public boolean contains(IlvPoint p,
                        IlvPoint tp,
                        IlvTransformer t)
Tests if a point lies within the outline of the object.

Overrides:
contains in class IlvGraphic
Parameters:
p - The point to be tested, in untransformed coordinates.
tp - The point p transformed by the transformer t.
t - The transformer used to draw the object.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

getIntersectionWithOutline

public IlvPoint getIntersectionWithOutline(IlvPoint innerPoint,
                                           IlvPoint outerPoint,
                                           IlvTransformer t)
Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object. This method is used the clip links against the shape of the node. The implementation of this method must be robust with respect to the input points: Even if innerPoint is not inside the graphic object, or if outerPoint is not outside the graphic object, it must return a valid point. For instance, if there is no intersection, it can return the start point.

Overrides:
getIntersectionWithOutline in class IlvGraphic
Parameters:
innerPoint - A point usually inside the graphic object, given in manager view coordinates.
outerPoint - A point usually outside of the graphic object, given in manager view coordinates.
t - The transformation used to draw the object.
Since:
JViews 8.1
See Also:
IlvClippingLinkConnector

getLineWidth

public float getLineWidth(IlvTransformer t)
Returns the line width that is really displayed when the object is drawn with the specified transformer.

Parameters:
t - the transformer used to draw the object.

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the object.

Specified by:
draw in class IlvGraphic
Parameters:
dst - The destination Graphics.
t - The transformation used to draw the object.
See Also:
IlvGraphic.boundingBox(ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

setForeground

public void setForeground(Color c)
Changes the color of the object.

Overrides:
setForeground in class IlvGraphic
Parameters:
c - the new color.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

getForeground

public Color getForeground()
Returns the color of the object.

Returns:
the color of the object.

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream. Note that even if this is a public method, you should not call it directly, you should use the write methods of the manager.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvPolyPoints
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

finalize

protected void finalize()
                 throws Throwable
Overrides the method to clean some resources.

Overrides:
finalize in class Object
Throws:
Throwable


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