ilog.views.graphic
Class IlvArrowPolyline

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

public class IlvArrowPolyline
extends IlvPolyline

IlvArrowPolyline represents a line that follows several points and has one or more arrows along its length.

The default values for an IlvArrowPolyline instance are as follows:

Example

The following code example shows how to use IlvArrowPolyline 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);
    
   IlvArrowPolyline defaultPolyline = new IlvArrowPolyline(points, true);
   IlvArrowPolyline customPolyline = new IlvArrowPolyline(points, true);
    
   customPolyline.removePoint(6, new IlvTransformer() );
   customPolyline.setStrokeOn(true);
   customPolyline.setForeground(Color.green);
   customPolyline.setLineWidth(5);
       
   //Set the arrow to be at the end of the last stretch of the polyline.
   customPolyline.setUsingAllLines(false);
   customPolyline.setArrowPosition(.8f);
       
   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

IlvArrowPolyline 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
IlvArrowPolyline(IlvArrowPolyline source)
          Initializes a new arrow polyline by copying the source polyline.
IlvArrowPolyline(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvArrowPolyline(IlvPoint[] points)
          Initializes a new arrow polyline with a single arrow.
IlvArrowPolyline(IlvPoint[] points, boolean alllines)
          Initializes a new arrow polyline.
IlvArrowPolyline(IlvPoint[] points, boolean alllines, float atpos)
          Initializes a new arrow polyline.
IlvArrowPolyline(IlvPoint[] points, boolean alllines, float atpos, boolean copy)
          Initializes a new arrow polyline.
 
Method Summary
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
 float getArrowPosition()
          Returns the position of the arrow.
protected  float getArrowSize(float lineWidth, IlvTransformer t)
          Returns the size of the arrow for the corresponding IlvTransformer.
 boolean isUsingAllLines()
          Returns whether or not an arrow is drawn on all lines
 void setArrowPosition(float p)
          Changes the position of the arrow.
 void setUsingAllLines(boolean value)
          Specifies whether an arrow is drawn on all lines, or not.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.graphic.IlvPolyline
computeBBox, contains, finalize, getEndCap, getForeground, getIntersectionWithOutline, getLineJoin, getLineStyle, getLineWidth, getLineWidth, getMaximumLineWidth, pointsInBBox, setEndCap, setForeground, setLineJoin, setLineStyle, setLineWidth, setMaximumLineWidth
 
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

IlvArrowPolyline

public IlvArrowPolyline(IlvPoint[] points,
                        boolean alllines,
                        float atpos)
Initializes a new arrow polyline.

Parameters:
points - the array of points. This array and the points will be copied by the constructor.
alllines - indicates whether an arrow is drawn on all lines or only on the last line.
atpos - this parameter must be in the range of [0.,1.]. It indicates the position of the arrow on the line.

IlvArrowPolyline

public IlvArrowPolyline(IlvPoint[] points,
                        boolean alllines,
                        float atpos,
                        boolean copy)
Initializes a new arrow polyline.

Parameters:
points - the array of points.
alllines - indicates whether an arrow is drawn on all lines or only on the last line.
atpos - this parameter must be in the range of [0.,1.]. It indicates the position of the arrow on the line.
copy - if true then 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.

IlvArrowPolyline

public IlvArrowPolyline(IlvPoint[] points,
                        boolean alllines)
Initializes a new arrow polyline. The arrows are placed at the end of the line.

Parameters:
points - the array of points. This array and the points will be copied by the constructor.
alllines - indicates whether an arrow is drawn on all lines or only on the last line.

IlvArrowPolyline

public IlvArrowPolyline(IlvPoint[] points)
Initializes a new arrow polyline with a single arrow. The arrow is placed at the end of the line.

Parameters:
points - the array of points. This array and the points will be copied by the constructor.

IlvArrowPolyline

public IlvArrowPolyline(IlvArrowPolyline source)
Initializes a new arrow polyline by copying the source polyline.

Parameters:
source - the origin of the copy.

IlvArrowPolyline

public IlvArrowPolyline(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.

Overrides:
copy in class IlvPolyline
Returns:
a copy of the object.
See Also:
IlvGraphic

setArrowPosition

public void setArrowPosition(float p)
Changes the position of the arrow.

Parameters:
p - the new position of the arrow. The value must be in the range of [0.,1.].

getArrowPosition

public float getArrowPosition()
Returns the position of the arrow.


isUsingAllLines

public boolean isUsingAllLines()
Returns whether or not an arrow is drawn on all lines


setUsingAllLines

public void setUsingAllLines(boolean value)
Specifies whether an arrow is drawn on all lines, or not.


draw

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

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

getArrowSize

protected float getArrowSize(float lineWidth,
                             IlvTransformer t)
Returns the size of the arrow for the corresponding IlvTransformer. By redefining this method the subclass can change the default size of the arrow which by default is proportional to the link line width. If this method returns a size that is not anymore proportional to the transformer zoom factor, this may change the zoom capability of this object and the IlvGraphic.zoomable() method may also have to return something different.

Parameters:
lineWidth - The actual line width used to drawn the object in manager coordinates.
t - The transformer used to draw the object.
Since:
JViews 6.0
See Also:
IlvPolyline.getLineWidth()

boundingBox

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

Specified by:
boundingBox in interface IlvPolyPointsInterface
Overrides:
boundingBox in class IlvPolyline
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

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 IlvPolyline
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.


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