ilog.views.graphic
Class IlvPolylineLinkImage

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

public class IlvPolylineLinkImage
extends IlvLinkImage

IlvPolylineLinkImage represents the connection between two nodes in a grapher; the link is displayed as a line that traces several points. For more information about specialized link graphic objects, see IlvLinkImage.

The default values for an IlvPolylineLinkImage instance are as follows:

Example

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

   IlvGraphic node1, node2;
   IlvGrapher grapher = new IlvGrapher();
   IlvPolylineLinkImage link;
   
   //Create new ellipse node and add it to the grapher.
   node1 = new IlvEllipse(new IlvRect(30,10,50,50), true, false);
   grapher.addNode(node1,false);
   
   //Add a new rectangular node to the grapher.
   node2 = new IlvRectangle(new IlvRect(220,90,50,50), false, true);
   grapher.addNode(node2, 2, true);
   //Add points
   IlvPoint[] points = new IlvPoint[5];
   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);
   //Link the two nodes and add the link to a grapher.
   link = new IlvPolylineLinkImage(
              node1, 
              node2, 
              true,
              points);
   link.setForeground(Color.green);
   grapher.addLink(link,true);
 

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

About Graphic Objects

IlvPolylineLinkImage 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
IlvPolylineLinkImage(IlvGraphic from, IlvGraphic to, boolean oriented, IlvPoint[] points)
          Creates and initializes a new IlvPolylineLinkImage.
IlvPolylineLinkImage(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvPolylineLinkImage(IlvPolylineLinkImage source)
          Creates and initializes a new IlvPolylineLinkImage by copying an existing one.
 
Method Summary
 boolean allowsPointInsertion()
          Indicates that this link class allows the insertion of intermediate points.
 boolean allowsPointRemoval()
          Indicates if the removal of intermediate points is allowed.
 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.
 IlvPoint getPointAt(int index, IlvTransformer t)
          Returns the point at the specified index.
 int getPointsCardinal()
          Returns the number of points of the link, including the connection points.
 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 setIntermediateLinkPoints(IlvPoint[] points, int index, int length)
          Changes the intermediate points that define the link.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
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, setGraphicBag, 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

IlvPolylineLinkImage

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

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. If the array is null or its length is 0, the link is created without intermediate points.

IlvPolylineLinkImage

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

Parameters:
source - The copied object.

IlvPolylineLinkImage

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

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

getPointsCardinal

public int getPointsCardinal()
Returns the number of points of the link, including the connection points.

Specified by:
getPointsCardinal in interface IlvPolyPointsInterface
Overrides:
getPointsCardinal in class IlvLinkImage

getLinkPoints

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

Overrides:
getLinkPoints in class IlvLinkImage
Parameters:
t - The transformer through which the object is drawn.

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 IlvLinkImage
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)

getPointAt

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

Specified by:
getPointAt in interface IlvPolyPointsInterface
Overrides:
getPointAt in class IlvLinkImage
Parameters:
index - The index of the point.
t - The transformer through which the object is drawn.

allowsPointInsertion

public boolean allowsPointInsertion()
Indicates that this link class allows the insertion of intermediate points.

Specified by:
allowsPointInsertion in interface IlvPolyPointsInterface
Overrides:
allowsPointInsertion in class IlvLinkImage
Returns:
Always true.
See Also:
insertPoint(int, float, float, ilog.views.IlvTransformer)

allowsPointRemoval

public boolean allowsPointRemoval()
Indicates if the removal of intermediate points is allowed.

Specified by:
allowsPointRemoval in interface IlvPolyPointsInterface
Overrides:
allowsPointRemoval in class IlvLinkImage
Returns:
true if at least one intermediate point exists and false otherwise.
See Also:
removePoint(int, ilog.views.IlvTransformer)

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 IlvLinkImage
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 link.

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. Hence, if the specified index is the index of the first or last point, the method does nothing.

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

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 IlvLinkImage
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 IlvLinkImage
Parameters:
t - The transformer to be applied.
See Also:
IlvGraphic

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