ilog.views
Class IlvLinkConnector

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

public abstract class IlvLinkConnector
extends Object
implements Serializable, IlvPersistentObject

This class is dedicated to the computation of the connection points of links (IlvLinkImage) in a grapher (IlvGrapher).

When a link is created between two nodes, it is attached to the default connection point of each node (see the documentation of the class IlvLinkImage. Subclasses of the class IlvLinkConnector can be used to obtain different connection points than the default ones.

An IlvLinkConnector is associated with a node (returned by the method getNode()). The implementation of the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer) decides where the connection point of a link (provided as an argument) should be located.

An instance of IlvLinkConnector can be specified for each node of a grapher. To do this, simply create it using the constructor IlvLinkConnector(IlvGraphic) or use the method attach(IlvGraphic, boolean). Notice that the same instance of link connector cannot be shared by several nodes.

A link connector specified for a node controls the connection points of all the links incident to this node. If you need the connection points of the incident links to not all be computed in the same way (that is, by the same link connector), you can specify a link connector individually for each extremity of each link. To do this, simply create it using the constructor IlvLinkConnector(IlvLinkImage, boolean) or use the method attach(IlvLinkImage, boolean, boolean). Notice that the same link connector can be shared by several links incident to the same node.

To get the instance of link connector actually used to compute the connection point of a given link, use the method Get(IlvLinkImage, boolean).

See Also:
IlvGrapher, IlvLinkImage, Serialized Form

Constructor Summary
IlvLinkConnector()
          Creates an empty IlvLinkConnector.
IlvLinkConnector(IlvGraphic node)
          Creates an IlvLinkConnector attached to the node node.
IlvLinkConnector(IlvInputStream stream)
          Reads the link object from an IlvInputStream.
IlvLinkConnector(IlvLinkImage link, boolean origin)
          Creates an IlvLinkConnector attached to the origin or destination of the link link.
 
Method Summary
protected  void allLinksRemoved()
          Called when all the 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 attach(IlvGraphic node, boolean redraw)
          Installs the link connector on the node node.
 void attach(IlvLinkImage link, boolean origin, boolean redraw)
          Installs the link connector for the origin or destination of link.
abstract  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 and from the attached links (if any).
 void detach(IlvLinkImage link, boolean origin, boolean redraw)
          Detaches the link connector from the origin or the destination of a link.
 void disconnectLink(IlvLinkImage link, boolean origin)
          Disconnects a link from the link connector.
 void drawGhost(Graphics g, IlvTransformer t, Object orig, Object dest, Object linkOrClass, boolean origin)
          Draws the connection points.
static IlvLinkConnector Get(IlvGraphic node)
          Deprecated. Beginning with ILOG JViews 5.5, link connectors can be specified for both nodes and links. To get the link connector actually used to compute the connection points of a particular link, use the method Get(IlvLinkImage, boolean). To get the link connector specified for a node, use the method GetAttached(IlvGraphic). Notice that the link connector returned by this method is actually used only for links incident to node for which a specific link connector has not been specified. The latter is returned by the method GetAttached(IlvLinkImage, boolean).
static IlvLinkConnector Get(IlvLinkImage link, boolean origin)
          Returns the link connector that actually controls the connection point on the origin or destination node of link.
static IlvLinkConnector GetAttached(IlvGraphic node)
          Returns the link connector attached to node using attach(IlvGraphic, boolean), or null if none.
static IlvLinkConnector GetAttached(IlvLinkImage link, boolean origin)
          Returns the link connector attached to the origin or destination of link using attach(IlvLinkImage, boolean, boolean), or null if none.
abstract  IlvPoint getClosestConnectionPoint(IlvPoint p, Object orig, Object dest, Object linkOrClass, boolean origin, IlvTransformer t)
          Returns the connection point that is closest to a particular point p.
abstract  IlvPoint getConnectionPoint(IlvLinkImage link, boolean origin, IlvTransformer t)
          Returns the position of the point where link is connected to the origin or destination node.
abstract  IlvRect getGhostBoundingBox(IlvTransformer t)
          Returns the bounding box of the ghost of the connection points.
 IlvGraphic getNode()
          Returns the node associated with the link connector.
 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.
 boolean supportsDrawGhost()
          Returns true if the link connector needs its drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean) method to be called.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 void write(IlvOutputStream stream, IlvLinkImage link, boolean origin)
          Writes information associated with a link to an IlvOutputStream.
protected abstract  boolean zoomable()
          Returns true if the connection points are zoomable; otherwise it returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvLinkConnector

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


IlvLinkConnector

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

The constructor calls the method attach(IlvGraphic, boolean), passing thenode argument and the argument redraw at true.

See Also:
attach(IlvGraphic,boolean), detach(boolean)

IlvLinkConnector

public IlvLinkConnector(IlvLinkImage link,
                        boolean origin)
Creates an IlvLinkConnector 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.

The constructor calls the method attach(IlvLinkImage, boolean, boolean), passing the link and origin arguments and with the argument redraw at true.

Since:
JViews 5.5
See Also:
attach(IlvLinkImage, boolean, boolean), detach(IlvLinkImage, boolean, boolean)

IlvLinkConnector

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

Note that a subclass that overrides the method isPersistent() to return true must be public and 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.
Since:
JViews 3.5
See Also:
read(ilog.views.io.IlvInputStream, IlvLinkImage, boolean), write(ilog.views.io.IlvOutputStream), isPersistent()
Method Detail

attach

public void attach(IlvGraphic node,
                   boolean redraw)
Installs the link connector on the node node. After installation, this link connector controls the connection points of all the links incident to node, except those for which a specific link connector has been installed on the corresponding extremity of the link. The method getNode() returns the node node.

The method detach(boolean) is automatically called to detach the old attached node, if any. Also, if any other link connector was attached to this node, it gets detached.

Notice that you are not allowed to call this method for a link connector that has been already installed for a link (that is, using the method attach(IlvLinkImage, boolean, boolean).

Parameters:
node - The node.
redraw - If true, the node to which the connector is attached and its adjacent links will be redrawn.
Since:
JViews 3.5
See Also:
detach(boolean), attach(IlvLinkImage, boolean, boolean)

attach

public void attach(IlvLinkImage link,
                   boolean origin,
                   boolean redraw)
Installs the link connector for the origin or destination of link. After installation, this link connector controls the origin or destination point of link. The corresponding origin or destination node of link is returned by the method getNode().

The method detach(IlvLinkImage, boolean, boolean) is automatically called to detach the old attached link, if any. Also, if any other link connector was installed for the origin or destination of link, it gets detached.

Parameters:
link - The link.
origin - If true, the link connector is installed for the origin node of link. Otherwise, it is installed for the destination node of link.
redraw - If true, the node to which the connector is attached and its adjacent links will be redrawn.
Since:
JViews 5.5
See Also:
detach(IlvLinkImage, boolean, boolean)

detach

public void detach(boolean redraw)
Detaches the link connector from the attached node and from the attached links (if any).

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

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 attach(IlvLinkImage, boolean, boolean).

If this link connector has been attached on a node (using attach(IlvGraphic, boolean), the method simply detaches the link connector from the node.

If this link connector has been attached to at least one link (using attach(IlvLinkImage, boolean, boolean)), this method calls detach(IlvLinkImage, boolean, boolean) for each link incident to the node returned by getNode() to which this link connector has been attached. However, this operation can be done only in the usual case, when the node is still contained in an IlvGrapher. If the node is not contained in an IlvGrapher, the method raises a RuntimeException, to indicate that the detachment from the attached links could not be performed. Note that you can detach link connectors from individual links using the method detach(IlvLinkImage, boolean, boolean) even if the node (and link) are no longer contained in an IlvGrapher.

Parameters:
redraw - If true, the node to which the connector is attached and its adjacent links will be redrawn.
Since:
JViews 3.5
See Also:
attach(IlvGraphic, boolean), detach(IlvLinkImage, boolean, 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 attach(IlvLinkImage, boolean, boolean).

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.
Since:
JViews 5.5
See Also:
attach(IlvLinkImage, boolean, boolean), detach(boolean)

GetAttached

public static IlvLinkConnector GetAttached(IlvGraphic node)
Returns the link connector attached to node using attach(IlvGraphic, boolean), or null if none. Note that the link connector that actually controls the connection point of a given link is returned by the method Get(IlvLinkImage, boolean).

Since:
JViews 5.5
See Also:
Get(IlvLinkImage, boolean), GetAttached(IlvLinkImage, boolean)

GetAttached

public static IlvLinkConnector GetAttached(IlvLinkImage link,
                                           boolean origin)
Returns the link connector attached to the origin or destination of link using attach(IlvLinkImage, boolean, boolean), or null if none. Note that the link connector that actually controls the connection point of a given link is returned by the method Get(IlvLinkImage, boolean).

Since:
JViews 5.5
See Also:
Get(IlvLinkImage, boolean), GetAttached(IlvGraphic)

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 or link to which the link connector is attached.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.
Since:
JViews 3.5
See Also:
read(ilog.views.io.IlvInputStream, IlvLinkImage, boolean), write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean), isPersistent()

write

public void write(IlvOutputStream stream,
                  IlvLinkImage link,
                  boolean origin)
           throws IOException
Writes information associated with a link to an IlvOutputStream. The default implementation of the method does nothing.

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; instead, you should use the write methods of the IlvGrapher that contains the node or link to which the link connector is attached.

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
Since:
JViews 3.5
See Also:
write(ilog.views.io.IlvOutputStream), read(ilog.views.io.IlvInputStream, IlvLinkImage, boolean), isPersistent()

read

public void read(IlvInputStream stream,
                 IlvLinkImage link,
                 boolean origin)
          throws IlvReadFileException
Reads information associated with a link from an IlvInputStream. The default implementation of the method does nothing.

You must override this method if specific data is to be read. Note that the first instruction in your implementation of the method must besuper.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 or link to which the link connector is attached.

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
Since:
JViews 3.5
See Also:
write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean), 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 false.

Note that if a subclass overrides this method to return true, it must be public and must provide a constructor with an IlvInputStream argument. The first line of the constructor must be super(stream).

Since:
JViews 3.5
See Also:
write(ilog.views.io.IlvOutputStream), write(ilog.views.io.IlvOutputStream, IlvLinkImage, boolean)

getNode

public final IlvGraphic getNode()
Returns the node associated with the link connector. For link connectors attached to a node (using attach(IlvGraphic, boolean), the method returns this node. For link connectors attached to a link (using attach(IlvLinkImage, boolean, boolean), the method returns the corresponding end node of the link.


Get

public static IlvLinkConnector Get(IlvGraphic node)
Deprecated. Beginning with ILOG JViews 5.5, link connectors can be specified for both nodes and links. To get the link connector actually used to compute the connection points of a particular link, use the method Get(IlvLinkImage, boolean). To get the link connector specified for a node, use the method GetAttached(IlvGraphic). Notice that the link connector returned by this method is actually used only for links incident to node for which a specific link connector has not been specified. The latter is returned by the method GetAttached(IlvLinkImage, boolean).

Returns the link connector attached to node using attach(IlvGraphic, boolean), or null if none.


Get

public static IlvLinkConnector Get(IlvLinkImage link,
                                   boolean origin)
Returns the link connector that actually controls the connection point on the origin or destination node of link. The method returns: If none of the above cases occurs, the method returns null.

Since:
JViews 5.5

getConnectionPoint

public abstract IlvPoint getConnectionPoint(IlvLinkImage link,
                                            boolean origin,
                                            IlvTransformer t)
Returns the position of the point where link is connected to the origin or destination node. You must implement this method in a subclass to give the position of the connection point of the link. Beginning with JViews 5.5, the implementation of that method may return null instead of an IlvPoint instance. In that case the point computation is delegated to the default mechanism.

Note that, when link connectors are used to control the connection points of a link, the bounding box of the link depends on the connection point. Therefore, once a link connector has been attached to a node or a link contained in an IlvGrapher, the connection point must be changed only using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean).

Parameters:
link - The link.
origin - If true, the position of the connection point for the link origin is determined. Otherwise the position of the connection point for the link destination is determined.
t - The transformer that is used to draw the node.
Returns:
The connection point or null.

zoomable

protected abstract boolean zoomable()
Returns true if the connection points are zoomable; otherwise it returns false.

A connection point is zoomable if calling the method getConnectionPoint(ilog.views.IlvLinkImage, boolean, ilog.views.IlvTransformer) with a transformer gives the same result as calling it with a null (identity) transformer and then applying the transformer to the result.

Note that an instance of a link connector must return the same value during its lifetime.


getClosestConnectionPoint

public abstract IlvPoint getClosestConnectionPoint(IlvPoint p,
                                                   Object orig,
                                                   Object dest,
                                                   Object linkOrClass,
                                                   boolean origin,
                                                   IlvTransformer t)
Returns the connection point that is closest to a particular point p.

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.
t - The transformer used to draw the node.
Returns:
The closest connection point already transformed.

connectLink

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

Parameters:
link - The link to be connected.
p - The point where the link must be connected. The point must be transformed by the 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:
allowsConnectionPointMove(ilog.views.IlvLinkImage, boolean)

disconnectLink

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

The default implementation does nothing.

In subclasses of IlvLinkConnector, if the implementation of connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer) stores information about the link, the method disconnectLink must be overridden to clear this data when the link is no longer connected to the link connector.

Parameters:
link - The link to be disconnected.
origin - If set to true, the origin of the link is disconnected. If false the destination link is disconnected.
Since:
JViews 6.0
See Also:
connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer)

allowsConnectionPointMove

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

If the argument origin is true, the method returns true if the connection point of link on the origin node can be moved by interactors, and returns false otherwise.

If the argument origin is false, the method returns true if the connection point of link on the destination node can be moved by interactors, and returns false otherwise.

The default implementation always returns true. Subclasses can override this method to indicate to the interactors that either all or some connection points cannot be moved.

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

linkRemoved

public void linkRemoved(IlvLinkImage link)
Called when a link is removed from the node. The default implementation does nothing. You should not call this method directly. but, if the implementation of the method connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer) stores information for the link, this method should be overridden to clean out this information when the link is no longer connected to the node.


allLinksRemoved

protected void allLinksRemoved()
Called when all the links are removed from the node. The default implementation does nothing. You should not call this method directly, but, if the implementation of the method connectLink(ilog.views.IlvLinkImage, ilog.views.IlvPoint, boolean, ilog.views.IlvTransformer) stores information for the link, this method should be overridden to clean out this information when the link is no longer connected to the node.


drawGhost

public void drawGhost(Graphics g,
                      IlvTransformer t,
                      Object orig,
                      Object dest,
                      Object linkOrClass,
                      boolean origin)
Draws the connection points. This method is called when creating or editing a link, if the method supportsDrawGhost() returns true. You should not call this method directly, but you may override it to do your own type of drawing.

The default implementation does nothing.

Parameters:
g - A Graphics to perform the drawings.
t - The transformation used to draw the connection points.
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 a Class object. 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 is determined
See Also:
supportsDrawGhost(), getGhostBoundingBox(ilog.views.IlvTransformer)

getGhostBoundingBox

public abstract IlvRect getGhostBoundingBox(IlvTransformer t)
Returns the bounding box of the ghost of the connection points.

This method is called when creating or editing a link, if the method supportsDrawGhost() returns true.

You should not call this method directly. If a subclass of IlvLinkConnector does not draw a ghost, the implementation of the method can return anything. In this case, the method supportsDrawGhost() must return false and the ILOG JViews library never calls this method.

Subclasses of IlvLinkConnector that draw a ghost must implement this method to return the bounding rectangle of the ghost. In this case, the method supportsDrawGhost() must be overridden to return true.

Parameters:
t - The transformer used to draw the connection points.
Since:
JViews 5.0
See Also:
supportsDrawGhost(), drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean)

supportsDrawGhost

public boolean supportsDrawGhost()
Returns true if the link connector needs its drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean) method to be called.

The default implementation always returns false.

Since:
JViews 3.0
See Also:
drawGhost(java.awt.Graphics, ilog.views.IlvTransformer, java.lang.Object, java.lang.Object, java.lang.Object, boolean), getGhostBoundingBox(ilog.views.IlvTransformer)


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