ilog.views.graphic.linkpolicy
Class IlvPolicyAwareLinkImage

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.IlvLinkImage
          extended by ilog.views.graphic.IlvPolylineLinkImage
              extended by ilog.views.graphic.linkpolicy.IlvPolicyAwareLinkImage
All Implemented Interfaces:
IlvPolyPointsInterface, IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvCrossingAwareLinkImage

public class IlvPolicyAwareLinkImage
extends IlvPolylineLinkImage

IlvPolicyAwareLinkImage is a subclass of IlvPolylineLinkImage used to set the format of the line linking two nodes. For example, you can set the line shape to remain orthogonal as it traces the points in the link. The available link shape policies are as follows:

The default values for an IlvPolicyAwareLinkImage instance are as follows:

For more information about specialized link graphic objects, see IlvLinkImage.

Example

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

   IlvGrapher grapher = new IlvGrapher();
   IlvRectangle origin1 = new IlvReliefRectangle(new IlvRect(200, 110, 40, 40));
   IlvRectangle dest1 = new IlvReliefRectangle(new IlvRect(140, 20, 40, 40));
   grapher.addNode(origin1, false);
   grapher.addNode(dest1, false);
   
   IlvPoint[] points = new IlvPoint[5];
   points[0] = new IlvPoint(40, 40);
   points[1] = new IlvPoint(60, 20);
   points[2] = new IlvPoint(50, 40);
   points[3] = new IlvPoint(50, 70);
   points[4] = new IlvPoint(90, 90);
       
   IlvOrthogonalLinkShapePolicy policy = new IlvOrthogonalLinkShapePolicy();
   // the policy can be shared among links
   IlvPolicyAwareLinkImage link1 = new IlvPolicyAwareLinkImage(origin1, dest1, true, points);
   link1.setLinkShapePolicy(policy);
       
   // insert the links into the grapher only AFTER installing the policy
   grapher.addLink(link1, true);
 

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

About Graphic Objects

IlvPolicyAwareLinkImage 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.

Since:
JViews 6.0
See Also:
IlvManager, IlvManagerView, setLinkShapePolicy(IlvLinkShapePolicy), Serialized Form

Constructor Summary
IlvPolicyAwareLinkImage(IlvGraphic from, IlvGraphic to, boolean oriented, IlvPoint[] points)
          Creates and initializes a new IlvPolicyAwareLinkImage.
IlvPolicyAwareLinkImage(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvPolicyAwareLinkImage(IlvPolicyAwareLinkImage source)
          Creates and initializes a new IlvPolicyAwareLinkImage by copying an existing one.
 
Method Summary
 void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvGraphic copy()
          Copies the object.
 IlvPoint[] getLinkPoints(IlvTransformer t)
          Returns the points that define the link.
 IlvLinkShapePolicy getLinkShapePolicy()
          Returns the link shape policy.
 IlvPoint getPointAt(int index, IlvTransformer t)
          Returns the point at a given index.
 void insertPoint(int index, float x, float y, IlvTransformer t)
          Inserts a point at a specified index.
 void movePoint(int index, float x, float y, IlvTransformer t)
          Changes the position of a point.
 void removePoint(int index, IlvTransformer t)
          Removes the point at a specified index.
 void setGraphicBag(IlvGraphicBag bag)
          Changes the bag that contains the object.
 void setIntermediateLinkPoints(IlvPoint[] points, int index, int length)
          Changes the intermediate points that define the link.
 void setLinkShapePolicy(IlvLinkShapePolicy policy)
          Sets the link shape policy.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.graphic.IlvPolylineLinkImage
allowsPointInsertion, allowsPointRemoval, getPointsCardinal
 
Methods inherited from class ilog.views.IlvLinkImage
allowsPointMove, arrowBBox, boundingBox, contains, draw, drawArrow, finalize, getArrowSize, getConnectionPoints, getConnectionReferencePoint, getEndCap, getForeground, getFrom, getFromBoundingBox, getFromTransformer, getLineJoin, getLineStyle, getLineWidth, getLineWidth, getLinkConnectorConnectionPoint, getLocalTransformerOf, getMaximumLineWidth, getOpposite, getTo, getToBoundingBox, getToTransformer, getVisibleFrom, getVisibleTo, isOriented, isPersistent, isSpline, makeSelection, pointsInBBox, setEndCap, setForeground, setFrom, setLineJoin, setLineStyle, setLineWidth, setMaximumLineWidth, setOriented, setTo, zoomable
 
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, isSelectable, isVisible, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvPolicyAwareLinkImage

public IlvPolicyAwareLinkImage(IlvGraphic from,
                               IlvGraphic to,
                               boolean oriented,
                               IlvPoint[] points)
Creates and initializes a new IlvPolicyAwareLinkImage.

Parameters:
from - The origin object.
to - The destination object.
oriented - Specifies whether an arrow is drawn at the end of the link or not.
points - The intermediate points of the polylink.

IlvPolicyAwareLinkImage

public IlvPolicyAwareLinkImage(IlvPolicyAwareLinkImage source)
Creates and initializes a new IlvPolicyAwareLinkImage by copying an existing one.

Parameters:
source - The copied object.

IlvPolicyAwareLinkImage

public IlvPolicyAwareLinkImage(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. An instance of IlvLinkImage cannot be copied. This method returns null.

Overrides:
copy in class IlvPolylineLinkImage
Returns:
A copy of this IlvGraphic instance.
See Also:
IlvGraphic

setLinkShapePolicy

public void setLinkShapePolicy(IlvLinkShapePolicy policy)
Sets the link shape policy. This can only be done while the link is outside a grapher, or through IlvManager.applyToObject since it may change the shape of the link. You should not manipulate link connectors directly while having a link shape policy installed. In order to change the link connector, first deinstall all link shape policies and reinstall them later.


getLinkShapePolicy

public final IlvLinkShapePolicy getLinkShapePolicy()
Returns the link shape policy.


setGraphicBag

public void setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object. You should not call this method directly.

Overrides:
setGraphicBag in class IlvGraphic
Parameters:
bag - The graphic bag.
See Also:
IlvGraphic

setIntermediateLinkPoints

public void setIntermediateLinkPoints(IlvPoint[] points,
                                      int index,
                                      int length)
Changes the intermediate points that define the link. This method will take length points in the points array beginning at the index point and will use them for a new intermediate points array. If the array is null or the length parameter is 0, intermediate points are removed.

Overrides:
setIntermediateLinkPoints in class IlvPolylineLinkImage
Parameters:
points - An array of points.
index - The index of the point that will be the first intermediate point.

length - The number of intermediate points taken in the points array.
See Also:
IlvApplyObject, IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)

insertPoint

public void insertPoint(int index,
                        float x,
                        float y,
                        IlvTransformer t)
Inserts a point at a specified index. Elements with an index greater than or equal to the current index are shifted up.

Specified by:
insertPoint in interface IlvPolyPointsInterface
Overrides:
insertPoint in class IlvPolylineLinkImage
Parameters:
index - The index at which the new point will be inserted.
x - The x coordinate of the new point (in manager coordinates).
y - The y coordinate of the new point (in manager coordinates).
t - The transformer used to draw the polypoint.

removePoint

public void removePoint(int index,
                        IlvTransformer t)
Removes the point at a specified index. Note that the first and last points cannot be removed because they are the connection points of the link.

Specified by:
removePoint in interface IlvPolyPointsInterface
Overrides:
removePoint in class IlvPolylineLinkImage
Parameters:
index - The index of the point to be removed.
t - The transformer used to draw the polypoint.

movePoint

public void movePoint(int index,
                      float x,
                      float y,
                      IlvTransformer t)
Changes the position of a point. If index is the index of the first or last point, this method calls the movePoint method of the superclass. Otherwise, the method simply moves the point to the new coordinates.

Specified by:
movePoint in interface IlvPolyPointsInterface
Overrides:
movePoint in class IlvPolylineLinkImage
Parameters:
index - The index of the point to be moved.
x - The new x coordinate (in manager coordinates).
y - The new y coordinate (in manager coordinates).
t - The transformer through which the object is drawn.
See Also:
IlvApplyObject, IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object. The method applies the transformer t to the intermediate points of the link, if any.

Overrides:
applyTransform in class IlvPolylineLinkImage
Parameters:
t - The transformer to be applied.
See Also:
IlvGraphic

getLinkPoints

public IlvPoint[] getLinkPoints(IlvTransformer t)
Returns the points that define the link.

Overrides:
getLinkPoints in class IlvPolylineLinkImage
Parameters:
t - The transformer to be applied.

getPointAt

public IlvPoint getPointAt(int index,
                           IlvTransformer t)
Returns the point at a given index.

Specified by:
getPointAt in interface IlvPolyPointsInterface
Overrides:
getPointAt in class IlvPolylineLinkImage
Parameters:
index - The index of the point.
t - The transformer to be applied.

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream. You should not call this method directly; instead, you should use the write methods of the manager.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvPolylineLinkImage
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.