ilog.views.graphic
Class IlvSplineLinkImage

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

public class IlvSplineLinkImage
extends IlvLinkImage

IlvSplineLinkImage represents the connection between two nodes in a grapher; the link is displayed as a series of spline curves that trace the link points. For more information about specialized link graphic objects, see IlvLinkImage.

The default values for an IlvSplineLinkImage instance are as follows:

Example

The following code example shows how to use an IlvSplineLinkImage 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

IlvSplineLinkImage 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
IlvSplineLinkImage(IlvGraphic from, IlvGraphic to, boolean oriented, IlvPoint[] points)
          Creates and initializes a new IlvSplineLinkImage.
IlvSplineLinkImage(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvSplineLinkImage(IlvSplineLinkImage source)
          Creates and initializes a new IlvSplineLinkImage by copying an existing one.
 
Method Summary
 boolean allowsPointInsertion()
          Returns true if point insertion is allowed, and false otherwise.
 boolean allowsPointRemoval()
          Returns true if point removal is allowed, and false otherwise.
 void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the link.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws 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.
 float getSmoothness()
          Returns the smoothness of the spline.
 void insertPoint(int index, float x, float y, IlvTransformer t)
          Inserts a point at a specified index.
 boolean isSpline()
          Returns true if the link has spline routing functionality.
 IlvSelection makeSelection()
          Creates the selection object for this class.
 void movePoint(int index, float x, float y, IlvTransformer t)
          Changes the position of a point.
 boolean pointsInBBox()
          Returns false since the points defining the spline are not in the bounding box of the object.
 void removePoint(int index, IlvTransformer t)
          Removes the point at the specified index.
 void setIntermediateLinkPoints(IlvPoint[] points, int index, int length)
          Changes the intermediate points that define the link.
 void setSmoothness(float smoothness)
          Sets the smoothness of the spline.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.IlvLinkImage
allowsPointMove, arrowBBox, 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, 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

IlvSplineLinkImage

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

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

IlvSplineLinkImage

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

Parameters:
source - the copied object.

IlvSplineLinkImage

public IlvSplineLinkImage(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 IlvLinkImage
Returns:
a copy of the object.
See Also:
IlvGraphic

getPointsCardinal

public int getPointsCardinal()
Returns the number of 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

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 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 which 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()
Returns true if point insertion is allowed, and false otherwise. The default implementation returns true.

Specified by:
allowsPointInsertion in interface IlvPolyPointsInterface
Overrides:
allowsPointInsertion in class IlvLinkImage
Returns:
true if the insertion of intermediate points is allowed and false otherwise.
See Also:
IlvLinkImage.insertPoint(int, float, float, ilog.views.IlvTransformer)

allowsPointRemoval

public boolean allowsPointRemoval()
Returns true if point removal is allowed, and false otherwise.

Specified by:
allowsPointRemoval in interface IlvPolyPointsInterface
Overrides:
allowsPointRemoval in class IlvLinkImage
Returns:
true if the removal of intermediate points is allowed and false otherwise.
See Also:
IlvLinkImage.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 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's coordinates).
y - The y coordinate of the new point (in manager's coordinates).
t - The transformer used to draw the link.

removePoint

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

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 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 the last point, the 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 of the point (in manager's coordinates).
y - The new y coordinate of the point (in manager's 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.

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

pointsInBBox

public boolean pointsInBBox()
Returns false since the points defining the spline are not in the bounding box of the object.

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

boundingBox

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

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

Overrides:
contains in class IlvLinkImage
Parameters:
p - The point to be tested.
tp - The point p transformed by the transformer t.
t - The transformation that was applied to the object when it was drawn.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

draw

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

Overrides:
draw in class IlvLinkImage
Parameters:
dst - The destination Graphics.
t - The transformation used to draw the object.
See Also:
IlvGraphic.boundingBox(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 IlvLinkImage
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

setSmoothness

public void setSmoothness(float smoothness)
Sets the smoothness of the spline. The value range is between 0.0 (sharp bends) and 1.0 (smooth bends). A recommended value is 0.65.

A special value IlvGraphicUtil.AUTO_SMOOTHNESS can be set to use an algorithm that automatically detects an appropriate smoothness for each bend.

The default value is IlvGraphicUtil.COMPATIBLE_SMOOTHNESS. With this value, a spline looks exactly as in JViews 3.0, that is, the spline with more than two bends (4 control points) will not look smooth.

Changing the smoothness influences the bounding box of the object. Therefore it should be only done using an IlvApplyObject passed to IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean).

Parameters:
smoothness - The smoothness.
Since:
JViews 3.5
See Also:
getSmoothness()

getSmoothness

public float getSmoothness()
Returns the smoothness of the spline.

Since:
JViews 3.5
See Also:
setSmoothness(float)

isSpline

public boolean isSpline()
Returns true if the link has spline routing functionality. This implementation always returns true.

Overrides:
isSpline in class IlvLinkImage
Since:
JViews 8.1

makeSelection

public IlvSelection makeSelection()
Creates the selection object for this class. The default implementation creates an instance of IlvSplineLinkSelection.

Overrides:
makeSelection in class IlvLinkImage
Since:
JViews 8.1
See Also:
IlvSplineLinkSelection


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