ilog.views.graphic
Class IlvArrowLine

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvLine
          extended by ilog.views.graphic.IlvArrowLine
All Implemented Interfaces:
IlvPolyPointsInterface, IlvPersistentObject, Transferable, Serializable

public class IlvArrowLine
extends IlvLine

IlvArrowLine represents a custom graphic object that shows a straight line between two given points with a small arrow head on the line trajectory.

The default values for an IlvArrowLine instance are as follows:

Example

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

   IlvManager manager = new IlvManager();
   IlvArrowLine myLine = new IlvArrowLine();
   myLine.setFrom(new IlvPoint(20,20));    
   myLine.setTo(new IlvPoint(200,150));
   myLine.setForeground(Color.green);
   myLine.setLineWidth(4);
   myLine.setArrowPosition(0.6f);
   manager.addObject(myLine, true);
 

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

IlvArrowLine

About Graphic Objects

IlvArrowLine is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an IlvManager instance 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:
IlvPoint, IlvManager, IlvManagerView, Serialized Form

Constructor Summary
IlvArrowLine()
          Creates a new arrow line starting at 0, 0 and ending at 100, 100.
IlvArrowLine(float fromx, float fromy, float tox, float toy, float atpos)
          Creates a new arrow line starting at fromx, fromy and ending at tox, toy.
IlvArrowLine(IlvArrowLine source)
          Creates a new line by copying an existing one.
IlvArrowLine(IlvInputStream stream)
          Reads the object from an IlvInputStream.
 
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.
 void setArrowPosition(float p)
          Changes the position of the arrow.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.graphic.IlvLine
allowsPointInsertion, allowsPointMove, allowsPointRemoval, applyTransform, contains, finalize, getEndCap, getForeground, getFrom, getLineStyle, getLineWidth, getLineWidth, getMaximumLineWidth, getPointAt, getPointsCardinal, getTo, insertPoint, makeSelection, movePoint, pointsInBBox, removePoint, setEndCap, setForeground, setFrom, setLineStyle, setLineWidth, setMaximumLineWidth, setTo
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, 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

IlvArrowLine

public IlvArrowLine()
Creates a new arrow line starting at 0, 0 and ending at 100, 100. With an arrow in (100, 100).

Since:
JViews 6.0
See Also:
IlvArrowLine(float, float, float, float, float)

IlvArrowLine

public IlvArrowLine(float fromx,
                    float fromy,
                    float tox,
                    float toy,
                    float atpos)
Creates a new arrow line starting at fromx, fromy and ending at tox, toy. The atpos parameter must be in the range [0.,1.]. It specifies the position of the arrow relative to the line.


IlvArrowLine

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


IlvArrowLine

public IlvArrowLine(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 IlvLine
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.


draw

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

Overrides:
draw in class IlvLine
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 no longer 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 draw the object in manager coordinates.
t - The transformer used to draw the object.
Since:
JViews 6.0
See Also:
IlvLine.getLineWidth()

boundingBox

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

Specified by:
boundingBox in interface IlvPolyPointsInterface
Overrides:
boundingBox in class IlvLine
Parameters:
t - The transformer used to draw the object.
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 IlvLine
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.