ilog.views.linkconnector
Class IlvFreeLinkConnector

java.lang.Object
  extended by ilog.views.IlvLinkConnector
      extended by ilog.views.linkconnector.IlvFreeLinkConnector
All Implemented Interfaces:
IlvPersistentObject, Serializable
Direct Known Subclasses:
IlvClippingLinkConnector

public class IlvFreeLinkConnector
extends IlvLinkConnector

A link connector that allows to choose the connection points freely relative to the position of the node. Any point can be used as connection point by the method connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer). The connection points will be preserved with respect to the bounding box of the node for any change of the bounding box of the node. If the node is translated, the connection point is translated with the same distance. If the node grows or shrinks, the connection point moves proportionally.

Notice that, for links that have not been connected using connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer) and for disconnected links (see disconnectLink(ilog.views.IlvLinkImage, boolean) and disconnectAllLinks()), the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer) returns null. In this case, IlvLinkImage computes the connection point of the link using the default rules, at the center of one of the sides of the bounding box of the node or at its center.

This link connector can be used with the graph layout algorithms that need to change the connection points of the links.

Since:
JViews 6.0
See Also:
Serialized Form

Constructor Summary
IlvFreeLinkConnector()
          Creates an empty IlvFreeLinkConnector.
IlvFreeLinkConnector(IlvGraphic node)
          Creates an IlvFreeLinkConnector attached to the node node.
IlvFreeLinkConnector(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvFreeLinkConnector(IlvLinkImage link, boolean origin)
          Creates an IlvFreeLinkConnector attached to the origin or destination of the link link.
 
Method Summary
protected  void allLinksRemoved()
          Called when all links are removed from the node.
 boolean allowsConnectionPointMove(IlvLinkImage link, boolean origin)
          Indicates whether a connection point of a link can be moved by interactors.
 void connectionPointMoveAllowed(boolean allow)
          Deprecated. Beginning with ILOG JViews 8.1, use the method setConnectionPointMoveAllowed(boolean) instead.
 void connectLink(IlvLinkImage link, IlvPoint p, boolean origin, IlvTransformer t)
          Connects a link to a specified connection point.
 void detach(boolean redraw)
          Detaches the link connector from the attached node.
 void detach(IlvLinkImage link, boolean origin, boolean redraw)
          Detaches the link connector from the origin or the destination of a link.
 void disconnectAllLinks()
          Disconnects all the links connected to the link connector.
 void disconnectLink(IlvLinkImage link, boolean origin)
          Disconnects a link from the link connector.
 IlvPoint getClosestConnectionPoint(IlvPoint p, Object orig, Object dest, Object linkOrClass, boolean origin, IlvTransformer transformer)
          Returns the connection point that is closest to a particular point.
 IlvPoint getConnectionPoint(IlvLinkImage link, boolean origin, IlvTransformer transformer)
          Returns the connection point of link.
 IlvRect getGhostBoundingBox(IlvTransformer t)
          Implements an abstract method of IlvLinkConnector to return an empty IlvRect.
protected  IlvRect getNodeBoundingBox(IlvTransformer t)
          Called by the IlvFreeLinkConnector when it needs to compute the bounding rectangle of the node.
 boolean isConnectionPointMoveAllowed()
          Tells whether the interactors are allowed to move the connection points of the links connected to the node to which this link connector is attached.
 boolean isPersistent()
          Indicates whether the link connector must be saved to an .ivl file.
 void linkRemoved(IlvLinkImage link)
          Called when a link is removed from the node.
 void read(IlvInputStream stream, IlvLinkImage link, boolean origin)
          Reads information associated with a link from an IlvInputStream.
 void setConnectionPointMoveAllowed(boolean allow)
          Allows or forbids the interactors to move the connection points of the links connected to the node to which this link connector is attached.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 void write(IlvOutputStream stream, IlvLinkImage link, boolean origin)
          Writes the information associated with a link to an IlvOutputStream.
protected  boolean zoomable()
          Indicates that this link connector is zoomable.
 
Methods inherited from class ilog.views.IlvLinkConnector
attach, attach, drawGhost, Get, Get, GetAttached, GetAttached, getNode, supportsDrawGhost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvFreeLinkConnector

public IlvFreeLinkConnector()
Creates an empty IlvFreeLinkConnector. It can be attached either to a node (using IlvLinkConnector.attach(ilog.views.IlvGraphic,boolean)) or to an extremity of a link (using IlvLinkConnector.attach(ilog.views.IlvLinkImage,boolean,boolean)).


IlvFreeLinkConnector

public IlvFreeLinkConnector(IlvGraphic node)
Creates an IlvFreeLinkConnector attached to the node node.

See Also:
IlvLinkConnector.attach(ilog.views.IlvGraphic,boolean), detach(boolean)

IlvFreeLinkConnector

public IlvFreeLinkConnector(IlvLinkImage link,
                            boolean origin)
Creates an IlvFreeLinkConnector attached to the origin or destination of the link link. If the argument origin is true, this creates a link connector for the origin of link. If the argument origin is false, this creates a link connector for the destination of link.

See Also:
IlvLinkConnector.attach(ilog.views.IlvLinkImage, boolean, boolean), detach(IlvLinkImage, boolean, boolean)

IlvFreeLinkConnector

public IlvFreeLinkConnector(IlvInputStream stream)
                     throws IlvReadFileException
Reads the object from an IlvInputStream.

Note that any subclass (except one that overrides the method isPersistent() to return false) must provide a constructor with an IlvInputStream argument. The first line of the constructor must be super(stream).

Parameters:
stream - The input stream.
Throws:
IlvReadFileException - if the format is not correct.
See Also:
write(ilog.views.io.IlvOutputStream), isPersistent(), IlvLinkConnector.attach(IlvGraphic, boolean), detach(boolean)
Method Detail

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream.

You must override this method if specific data is to be stored. Note that the first instruction in your implementation of the method must be super.write(stream).

You should not call this method directly; instead, you should use the write methods of the IlvGrapher that contains the node to which the link connector is attached.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvLinkConnector
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.
See Also:
isPersistent()

detach

public void detach(boolean redraw)
Detaches the link connector from the attached node.
When you attach a new node to the link connector, it is not necessary to detach the old node because this is done automatically when you call attach.

For details, see the documentation of the method in the parent class.

Overrides:
detach in class IlvLinkConnector
Parameters:
redraw - If true, the node to which the connector is attached and its adjacent links will be redrawn.
See Also:
IlvLinkConnector.attach(IlvGraphic, boolean)

detach

public void detach(IlvLinkImage link,
                   boolean origin,
                   boolean redraw)
Detaches the link connector from the origin or the destination of a link.

When you attach a new link to a link connector already attached to a different link but for the same extremity, it is not necessary to detach the old link because this is done automatically when you call IlvLinkConnector.attach(IlvLinkImage, boolean, boolean).

Overrides:
detach in class IlvLinkConnector
Parameters:
link - The link from which the link connector is detached.
origin - If true, the link connector is detached from the origin of link. Otherwise, it is detached from the destination of link.
redraw - If true, the node to which the connector is attached and its adjacent links will be redrawn.
See Also:
IlvLinkConnector.attach(IlvLinkImage, boolean, boolean), detach(boolean)

write

public void write(IlvOutputStream stream,
                  IlvLinkImage link,
                  boolean origin)
           throws IOException
Writes the information associated with a link to an IlvOutputStream.

If origin is true, the method saves the information about the connection point of the origin of link. Otherwise, it saves the information about the connection point of the destination of link. The method does nothing if link is not connected to the node using the method connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer).

You must override this method if specific data is to be stored. Note that the first instruction in your implementation of the method must be super.write(stream, link, origin).

You should not call this method directly. You should use the write methods of the IlvGrapher that contains the node to which the link connector is attached.

Overrides:
write in class IlvLinkConnector
Parameters:
stream - The output stream.
link - The link.
origin - If true, information about the connection of the origin of link is written. Otherwise, the method writes information about the destination of link.
Throws:
IOException
See Also:
read(ilog.views.io.IlvInputStream, ilog.views.IlvLinkImage, boolean), isPersistent()

read

public void read(IlvInputStream stream,
                 IlvLinkImage link,
                 boolean origin)
          throws IlvReadFileException
Reads information associated with a link from an IlvInputStream.

You must override this method if specific data is to be read. Note that the first instruction in your implementation of the method must be super.read(stream, link, origin).

You should not call this method directly; instead, you should use the read methods of the IlvGrapher that contains the node to which the link connector is attached.

Overrides:
read in class IlvLinkConnector
Parameters:
stream - The input stream.
link - The link.
origin - If true, information about the connection of the origin of link is read. Otherwise, the method reads information about the destination of link.
Throws:
IlvReadFileException
See Also:
IlvLinkConnector.write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean), IlvLinkConnector.isPersistent()

isPersistent

public boolean isPersistent()
Indicates whether the link connector must be saved to an .ivl file. If this method returns true, the link connector is saved; otherwise, it is not saved.

The default implementation always returns true.

Overrides:
isPersistent in class IlvLinkConnector
See Also:
write(ilog.views.io.IlvOutputStream)

getConnectionPoint

public IlvPoint getConnectionPoint(IlvLinkImage link,
                                   boolean origin,
                                   IlvTransformer transformer)
Returns the connection point of link.

Specified by:
getConnectionPoint in class IlvLinkConnector
Parameters:
link - The link.
origin - If true, the position of the link connection point for the link origin is determined. Otherwise, the position of the link connection point for the link destination is found.
transformer - The transformer that is used to draw the node.
Returns:
The connection point or null.

connectLink

public void connectLink(IlvLinkImage link,
                        IlvPoint p,
                        boolean origin,
                        IlvTransformer t)
Connects a link to a specified connection point.

Notice that, for links that have not been connected using connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer) and for disconnected links (see disconnectLink(ilog.views.IlvLinkImage, boolean) and disconnectAllLinks()), the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer) returns null. In this case, IlvLinkImage computes the connection point of the link using the default rules, at the center of one of the sides of the bounding box of the node or at its center.

Note also that, once a link connector has been attached to a node or a link contained in an IlvGrapher, this method must be called using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean).

Specified by:
connectLink in class IlvLinkConnector
Parameters:
link - The link to be connected.
p - The point where the link must be connected. The point must be transformed by transformer t.
origin - If true, the origin of the link will be connected. Otherwise, it is the destination.
t - The transformer that is used to draw the node.
See Also:
disconnectLink(ilog.views.IlvLinkImage, boolean), disconnectAllLinks()

disconnectLink

public void disconnectLink(IlvLinkImage link,
                           boolean origin)
Disconnects a link from the link connector.

Notice that, for disconnected links and for links that have not been connected using connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer) returns null. In this case, IlvLinkImage computes the connection point of the link using the default rules, at the center of one of the sides of the bounding box of the node or at its center.

Note also that, once a link connector has been attached to a node or a link contained in an IlvGrapher, this method must be called using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean).

Overrides:
disconnectLink in class IlvLinkConnector
Parameters:
link - The link to be disconnected.
origin - If true, the origin of the link will be disconnected. Otherwise, it is the destination.
See Also:
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), disconnectAllLinks()

disconnectAllLinks

public void disconnectAllLinks()
Disconnects all the links connected to the link connector.

Notice that, for disconnected links and for links that have not been connected using connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer) returns null. In this case, IlvLinkImage computes the connection point of the link using the default rules, at the center of one of the sides of the bounding box of the node or at its center.

Note also that, once a link connector has been attached to a node or a link contained in an IlvGrapher, this method must be called using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean).

See Also:
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), disconnectLink(ilog.views.IlvLinkImage, boolean)

allowsConnectionPointMove

public boolean allowsConnectionPointMove(IlvLinkImage link,
                                         boolean origin)
Indicates whether a connection point of a link can be moved by interactors.

In this class, the default implementation of the method always returns the value that was set using the method connectionPointMoveAllowed(boolean).

Note that by default the connection points cannot be moved using the interactors. When this method returns false, only the interactors (namely, IlvLinkImageEditInteractor) are not allowed to move the connection points. The points can always be moved by calls to the method connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer).

Subclasses can override this method to indicate that only the connection points of some links can (or cannot) be moved by the interactors.

Overrides:
allowsConnectionPointMove in class IlvLinkConnector
See Also:
connectionPointMoveAllowed(boolean), IlvLinkImage.allowsPointMove(int), isConnectionPointMoveAllowed()

connectionPointMoveAllowed

public void connectionPointMoveAllowed(boolean allow)
Deprecated. Beginning with ILOG JViews 8.1, use the method setConnectionPointMoveAllowed(boolean) instead.

Allows or forbids the interactors to move the connection points of the links connected to the node to which this link connector is attached.

By default, moving a connection point using the interactors is not allowed. To enable the interactors to move connection points, call this method with a true argument.

Note that subclasses can override the method allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean) to indicate that only the connection points of some links can (or cannot) be moved using the interactors.

See Also:
allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean), connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), IlvLinkImage.allowsPointMove(int)

setConnectionPointMoveAllowed

public final void setConnectionPointMoveAllowed(boolean allow)
Allows or forbids the interactors to move the connection points of the links connected to the node to which this link connector is attached.

By default, moving a connection point using the interactors is not allowed. To enable the interactors to move connection points, call this method with a true argument.

Note that subclasses can override the method allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean) to indicate that only the connection points of some links can (or cannot) be moved using the interactors.

Since:
JViews 8.1
See Also:
allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean), connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), IlvLinkImage.allowsPointMove(int)

isConnectionPointMoveAllowed

public final boolean isConnectionPointMoveAllowed()
Tells whether the interactors are allowed to move the connection points of the links connected to the node to which this link connector is attached.

Note that, for each individual connection point, the interactors decide whether they are allowed to move the connection point by calling the method allowsConnectionPointMove(IlvLinkImage, boolean). The default implementation of this method relies on the value returned by isConnectionPointMoveAllowed(), but subclasses can provide an overridden implementation.

Since:
JViews 8.1
See Also:
allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean), connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer), IlvLinkImage.allowsPointMove(int)

zoomable

protected boolean zoomable()
Indicates that this link connector is zoomable. It always returns true.

Specified by:
zoomable in class IlvLinkConnector

getClosestConnectionPoint

public IlvPoint getClosestConnectionPoint(IlvPoint p,
                                          Object orig,
                                          Object dest,
                                          Object linkOrClass,
                                          boolean origin,
                                          IlvTransformer transformer)
Returns the connection point that is closest to a particular point. This implementation of the abstract method returns the point p without any transformation.

Specified by:
getClosestConnectionPoint in class IlvLinkConnector
Parameters:
p - The transformed point.
orig - The graphic object origin of the link or the class of the origin object. This depends on whether the link has already been created or not.
dest - The graphic object destination of the link or the class of the destination object. This depends on whether the link has already been created or not.
linkOrClass - An instance of IlvLinkImage or an instance of the class. This parameter enables you to allow or inhibit connection points, depending on the link or the class of link. The class is useful when the link is not already created.
origin - If true, the position of the link connection point for the link origin is determined. Otherwise the position of the link connection point for the link destination is found.
transformer - The transformer used to draw the node.
Returns:
The closest connection point already transformed.

linkRemoved

public void linkRemoved(IlvLinkImage link)
Called when a link is removed from the node. This implementation of the method clears internal data stored for the link. You should not call this method directly.

Overrides:
linkRemoved in class IlvLinkConnector

allLinksRemoved

protected void allLinksRemoved()
Called when all links are removed from the node. This implementation of the method clears internal data.

Overrides:
allLinksRemoved in class IlvLinkConnector

getNodeBoundingBox

protected IlvRect getNodeBoundingBox(IlvTransformer t)
Called by the IlvFreeLinkConnector when it needs to compute the bounding rectangle of the node. By default, it returns getNode().boundingBox(t). You can override this method to return a different bounding rectangle. This is useful, in particular, if you use a link layout algorithm and you specified an IlvNodeBoxInterface.

Parameters:
t - The transformer used to compute the bounding rectangle of the node.

getGhostBoundingBox

public IlvRect getGhostBoundingBox(IlvTransformer t)
Implements an abstract method of IlvLinkConnector to return an empty IlvRect. This method is not called since IlvLinkConnector.supportsDrawGhost() returns false for this class.

Specified by:
getGhostBoundingBox in class IlvLinkConnector
Parameters:
t - The transformer used to draw the connection points.
See Also:
IlvLinkConnector.supportsDrawGhost(), IlvLinkConnector.drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)


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