ilog.views.graphlayout
Class IlvGraphLayout

java.lang.Object
  extended by ilog.views.graphlayout.IlvGraphLayout
All Implemented Interfaces:
GraphModelListener, Serializable, EventListener
Direct Known Subclasses:
IltLinkLayout, IltLocalLinkLayout, IltShortLinkLayout, IltStraightLinkLayout, IlvBusLayout, IlvCircularLayout, IlvGridLayout, IlvHierarchicalLayout, IlvLinkLayout, IlvLongLinkLayout, IlvMultipleLayout, IlvRandomLayout, IlvRecursiveLayout, IlvShortLinkLayout, IlvSpringEmbedderLayout, IlvTopologicalMeshLayout, IlvTreeLayout, IlvUniformLengthEdgesLayout

public abstract class IlvGraphLayout
extends Object
implements Serializable, GraphModelListener

The base class of the Graph Layout algorithms.

ILOG JViews provides special support for applications that need to display graphs (also called networks) of nodes and links. Using the IlvGrapher class, any graphic object can be defined to behave like a node and can be connected to other nodes with links, which themselves can have many different forms. Used in conjunction with layout algorithms, this feature is often used to create network topologies for telecommunications networks and system management applications.

The usage of the Graph Layout algorithms is not restricted to applications using an IlvGrapher to store and display the graph. You can use external graph data source structures. This is achieved through the generic graph model (see IlvGraphModel). This abstract class defines the API that is necessary to allow the graph layout algorithms to work. To use an external graph, all you need to do is to implement an adapter that connects the graph with the generic graph model. For details, see the class IlvGraphModel.

The class IlvGraphLayout is abstract and cannot be used directly. You must use one of its concrete subclasses.

You can also create your own subclasses to implement other layout algorithms. Note that, in order to be applied on any graph, the layout algorithms must be written using the API of IlvGraphModel instead of the API of IlvGrapher.

The class contains layout parameters or options that can be useful for different layout algorithms. The implementation of the layout(boolean) method is solely responsible for whether or not the current settings of the parameters are taken into account.

Note that all layout parameters that are specific to nodes or links, such as the "fixed" attribute (see setFixed(java.lang.Object, boolean), isFixed(java.lang.Object)), can be accessed only while the graph that contains the nodes or links is attached to the layout instance. Also, if the attached graph model is an IlvGrapherAdapter, layout parameters that are specific to nodes or links must be set after specifying filtering rules (see IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer), IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)).

If the documentation does not indicate a different coordinate space, all dimensional parameters are expressed in the same coordinate space as the position and dimension of the nodes and the link points. In particular, when laying out an IlvGrapher, the dimensional parameters are expressed by default in the coordinate space of the manager, not in the coordinate space of the view (IlvManagerView). However, optionally, the coordinate space of the view can be used. For details, see setCoordinatesMode(int).

If you want to perform the layout on a subset of the nodes and links of and IlvGrapher, you can use a filter (see the class IlvLayoutGraphicFilter and the method IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter), or the method IlvGrapherAdapter.addLayer(ilog.views.IlvManagerLayer)). The filter allows the layout algorithm to determine, for each node and link of a graph, if it must be taken into account or can be ignored.

If you want to perform the layout recursively over a nested graph (for instance, an IlvGrapher contained in another IlvGrapher), you can use the method performLayout(boolean, boolean, boolean) and pass true for the traverse argument. Alternatively, you can use the method PerformLayout(IlvGraphModel, IlvLayoutProvider, boolean, boolean, boolean).

To learn more about the layout algorithms and the corresponding IlvGraphLayout subclasses, read the sections of the Reference Manual describing those classes and the ILOG JViews Graph Layout User's Manual.

Note that, when implementing a subclass of IlvGraphLayout, the initialization of all instance variables of the subclass needs to be done in the overridden implementation of the method init(). This is to prevent execution of methods of the subclasses before the initialization of the instance variables of the subclasses.

Note also that you must call the method detach() when you no longer need the layout instance; otherwise, some objects may not be garbage collected. This is necessary only if the layout instance is directly created by your code. Calling detach() is not necessary if the layout instance is created internally by the ILOG JViews Graph Layout library, when using an IlvDefaultLayoutProvider for recursive layout.

See Also:
IlvBusLayout, IlvCircularLayout, IlvGridLayout, IlvHierarchicalLayout, IlvLinkLayout, IlvShortLinkLayout, IlvLongLinkLayout, IlvRandomLayout, IlvSpringEmbedderLayout, IlvTopologicalMeshLayout, IlvTreeLayout, IlvUniformLengthEdgesLayout, IlvGraphModel, IlvGrapherAdapter, IlvGrapher, Serialized Form

Field Summary
static int INVERSE_VIEW_COORDINATES
          Inverse view coordinates mode.
static int MANAGER_COORDINATES
          Manager coordinates mode.
static int VIEW_COORDINATES
          View coordinates mode.
 
Constructor Summary
IlvGraphLayout()
          Creates a new instance of the layout algorithm.
IlvGraphLayout(IlvGraphLayout source)
          Creates a new layout instance by copying an existing one.
 
Method Summary
 void addGraphLayoutEventListener(GraphLayoutEventListener listener)
          Adds a listener for the layout events delivered during the layout.
 void addGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
          Adds a listener for the layout parameter events delivered when layout parameters change.
protected  void afterLayoutOfSubgraph(IlvGraphModel subgraph)
          Performs postprocessing operations after the layout of each subgraph or connected component.
 void attach(IlvGrapher grapher)
          Sets the grapher to be laid out.
 void attach(IlvGraphModel graphModel)
          Sets the graph model to be laid out.
protected  void beforeLayout(boolean redraw)
          Performs preprocessing operations before the layout of the entire graph.
protected  void beforeLayoutOfSubgraph(IlvGraphModel subgraph)
          Performs preprocessing operations before the layout of each subgraph or connected component.
 void callLayoutStepPerformedIfNeeded()
          Calls layoutStepPerformed when necessary.
 int checkAppropriateLink(Object link)
          Checks whether the input link is appropriate for this layout.
 void checkAppropriateLinks()
          Throws an exception if the links are not appropriate for the layout.
 void cleanGraphModel(IlvGraphModel graphModel)
          Cleans a graph model.
 void cleanLink(IlvGraphModel graphModel, Object link)
          Cleans a link.
 void cleanNode(IlvGraphModel graphModel, Object node)
          Cleans a node.
 void clipAllLinks(boolean toCenter, boolean redraw)
          Clips all links at their end nodes by using the link clip interface.
 void clipLink(Object link, boolean toCenter, boolean atFromSide, boolean atToSide, boolean redraw)
          Clips the link at both end nodes by using the link clip interface and the link connection box interface.
 void contentsChanged(GraphModelEvent event)
          Invoked when the structure or the geometry of the graph changes.
abstract  IlvGraphLayout copy()
          Copies the layout instance.
 void copyParameters(IlvGraphLayout source)
          Copies the parameters from a given layout instance.
protected  IlvGraphLayoutGrapherProperty createLayoutGrapherProperty(String name, boolean withDefaults)
          Returns a new instance of a named property that can store the parameter settings of this layout class.
protected  IlvGraphLayoutLinkProperty createLayoutLinkProperty(String name, IlvGraphic link, boolean withDefaults)
          Returns a new instance of a named property that can store the parameter settings of this layout class for links.
protected  IlvGraphLayoutNodeProperty createLayoutNodeProperty(String name, IlvGraphic node, boolean withDefaults)
          Returns a new instance of a named property that can store the parameter settings of this layout class for nodes.
 IlvGraphLayoutReport createLayoutReport()
          Returns a new instance of the layout report.
 void detach()
          Detaches the graph model from the layout instance.
 long getAllowedTime()
          Returns the currently allowed time for the layout algorithm in milliseconds.
 IlvAutoLayoutHandler getAutoLayoutHandler()
          Returns the auto layout handler.
 float getBalanceSplineCurveThreshold()
          Returns the threshold for spline curves at bends which the optimized spline control point routing uses to balance the curve.
 IlvRect getCalcLayoutRegion()
          Returns a copy of the rectangle that defines the layout region parameter.
 int getCoordinatesMode()
          Returns the current coordinates mode.
 IlvGrapher getGrapher()
          Returns the IlvGrapher that contains the nodes and links to be laid out.
 IlvGraphModel getGraphModel()
          Returns the graph model to lay out if a graph model is attached.
 int getInstanceId()
          A utility method that returns a unique integer value for each layout instance inside the same Java program.
 IlvGraphLayout getLayout(Object subgraph)
          Returns the layout instance for a subgraph of the nested graph encapsulated by the graph model of this layout instance.
 IlvGraphLayout getLayoutOfConnectedComponents()
          Returns the layout instance that lays out the connected components of the graph.
 IlvGraphLayoutReport getLayoutOfConnectedComponentsReport()
          Returns the layout report containing information about the behavior of the connected components layout.
 IlvRect getLayoutRegion()
          Returns a copy of the rectangle that defines the layout region, as specified using the method setLayoutRegion(IlvRect), or null if no rectangle has been specified, or the specified rectangle was null.
 IlvGraphLayoutReport getLayoutReport()
          Returns the layout report, that is, the object that contains information about the behavior of the layout algorithm.
 Enumeration getLayouts(boolean preOrder)
          Returns the instances of IlvGraphLayout for the nested graph encapsulated by the graph model of this layout instance.
 IlvLinkClipInterface getLinkClipInterface()
          Returns the clip interface used for the connection points of links during layout.
 IlvLinkConnectionBoxInterface getLinkConnectionBoxInterface()
          Returns the link connection box interface used to calculate the connection points of links during layout.
 float getMaxSplineCurveSize()
          Returns the maximum curve size used when spline control point optimization routing is enabled.
 long getMinBusyTime()
          Returns the minimal time that the layout algorithm can be busy between two calls of layoutStepPerformed() when the method callLayoutStepPerformedIfNeeded() is used.
 float getMinSplineCurveSize()
          Returns the minimum curve size used when optimized spline control points routing is enabled.
 IlvGraphicVector getMovingNodes()
          Returns the vector of nodes being moved by the graph layout algorithm.
 IlvGraphLayout getParentLayout()
          Returns the parent layout.
 Object getProperty(IlvGraphModel graphModel, Object nodeOrLink, String key)
          Returns the value of a property of the layout instance.
 Object getProperty(String key)
          Returns the value of a property of the layout instance.
 IlvRecursiveLayout getRecursiveLayout()
          Returns the instance of Recursive Layout that is used to perform this layout recursively when you call performLayout(boolean, boolean, boolean) with the traverse flag set to true.
 long getRemainingAllowedTime()
          Returns the remaining allowed time.
 long getSeedValueForRandomGenerator()
          Returns the user-defined seed value for the random generator.
 IlvRect getSpecLayoutRegion()
          Returns a copy of the rectangle that defines the layout region, as specified using the methods setLayoutRegion(IlvManagerView, IlvRect), setLayoutRegion(IlvManagerView), or setLayoutRegion(IlvRect).
 IlvSplineLinkFilter getSplineLinkFilter()
          Returns the filter that detects which links are suitable for optimized spline routing.
 void increasePercentageComplete(int newPercentage)
          Increases the percentage of completion that is stored in the layout report to the input value.
protected  void init()
          Initializes instance variables.
 boolean isAnimate()
          Returns true if the layout can perform a redraw of the graph model after each iteration or step of the layout algorithm.
 boolean isAutoLayout()
          Returns true if the auto layout mode is enabled.
 boolean isFitToView()
          Returns true if the graph drawing must fit (exactly or approximately) an area of a given manager view.
 boolean isFixed(Object nodeOrLink)
          Returns whether the node or link is specified as fixed.
 boolean isGeometryUpToDate()
          Returns whether the geometry of the graph is up to date.
 boolean isInputCheckEnabled()
          Returns true if the checks for the nodes and/or links are enabled.
protected  boolean isLayoutNeeded()
          Verifies that it is necessary to perform the layout.
 boolean isLayoutOfConnectedComponentsEnabled()
          Indicates whether the connected component layout mechanism is enabled.
protected  boolean isLayoutOfConnectedComponentsEnabledByDefault()
          Returns true if the connected components layout mechanism is enabled by default.
 boolean isLayoutRunning()
          Indicates whether the layout algorithm is running or not.
protected  boolean isLayoutTimeElapsed()
          Returns true if, at the moment the method is called, the allowed layout time is exceeded; returns false otherwise.
 boolean isMemorySavings()
          Returns the current setting specifying whether priority is given to speed or memory usage.
 boolean isParametersUpToDate()
          Returns whether the layout parameters are up to date.
 boolean isPreserveFixedLinks()
          Returns true if the layout is not allowed to reshape the links indicated as fixed by the user.
 boolean isPreserveFixedNodes()
          Returns true if the layout is not allowed to move the nodes indicated as fixed by the user.
 boolean isSplineRoutingEnabled()
          Tests if the calculation of optimized spline control points is enabled.
 boolean isStoppedImmediately()
          Returns true if the method stopImmediately() was called.
 boolean isStructureUpToDate()
          Returns whether the structure of the graph is up to date.
 boolean isUseDefaultParameters()
          Returns the current options for the parameters.
 boolean isUseSeedValueForRandomGenerator()
          Returns true if the user-defined seed value is used for the random generator and false otherwise.
protected abstract  void layout(boolean redraw)
          Executes the layout.
 void layoutStepPerformed()
          Notifies the listeners of the layout events (if any).
 void onParameterChanged(Object nodeOrLink, String parameterName)
          Called when a layout parameter for a specific node or link has changed.
 void onParameterChanged(String parameterName)
          Called when a global layout parameter has changed.
protected  void performAutoLayout()
          Performs the layout again following a structural or geometric change of the graph.
 IlvGraphLayoutReport performLayout()
          Starts the layout algorithm using the currently attached graph model and the current settings for the layout parameters.
 IlvGraphLayoutReport performLayout(boolean force, boolean redraw)
          Starts the layout algorithm using the currently attached graph model and the current settings for the layout parameters.
 int performLayout(boolean force, boolean redraw, boolean traverse)
          Starts the layout algorithm using the currently attached graph model and the current settings for the layout parameters.
static int PerformLayout(IlvGraphModel graphModel, IlvLayoutProvider layoutProvider, boolean force, boolean redraw, boolean traverse)
          Applies layout instances recursively to the specified graph model.
protected  int performSublayout(Object subgraph, IlvGraphLayout layout, boolean force, boolean redraw)
          Starts the input layout algorithm.
 void removeGraphLayoutEventListener(GraphLayoutEventListener listener)
          Removes a listener for the layout events delivered during the layout.
 void removeGraphLayoutParameterEventListener(GraphLayoutParameterEventListener listener)
          Removes a listener for the layout parameter events when layout parameters change.
 void setAllowedTime(long time)
          Sets the upper limit for the duration of the layout algorithm.
 void setAnimate(boolean option)
          If the argument is true, specifies that layout algorithms that support the animation mechanism will require the graph model to redraw the graph after each iteration or step.
 void setAutoLayout(boolean enable)
          Sets whether the auto layout mode is enabled.
 void setAutoLayoutHandler(IlvAutoLayoutHandler handler)
          Sets the auto layout handler.
 void setBalanceSplineCurveThreshold(float threshold)
          Sets the threshold for spline curves at bends which the optimized spline control point routing uses to balance the curve.
 void setCoordinatesMode(int mode)
          Sets the coordinates mode to be used during layout.
 void setFixed(Object nodeOrLink, boolean fixed)
          Sets the specified node or link as fixed.
 void setGeometryUpToDate(boolean uptodate)
          If the argument is false, notifies the layout instance that the geometry of the graph was changed since the last time the layout was successfully performed.
 void setGrapher(IlvGrapher grapher)
          Sets the grapher to be laid out.
 void setGraphModel(IlvGraphModel graphModel)
          Sets the graph model to be laid out.
 void setInputCheckEnabled(boolean enable)
          Sets whether the checks for the nodes and/or links provided as arguments for the different methods of the layout algorithms are enabled.
 void setLayoutOfConnectedComponents(IlvGraphLayout layout)
          Sets the layout instance that lays out the connected components of the graph.
 void setLayoutOfConnectedComponentsEnabled(boolean enable)
          Sets whether the generic connected component layout mechanism is enabled.
 void setLayoutRegion(IlvManagerView view)
          Sets the layout region as the visible area of a given manager view.
 void setLayoutRegion(IlvManagerView view, IlvRect rect)
          Sets the layout region as a rectangle (the argument rect), with the dimensions of the rectangle being given in the coordinates of the manager view (the argument view).
 void setLayoutRegion(IlvRect rect)
          Sets the layout region as a rectangle rect), with the dimensions of the rectangle being given in manager (graph model) coordinates.
protected  void setLayoutReport(IlvGraphLayoutReport report)
          Sets the layout report, that is, the object that contains information about the behavior of the layout algorithm.
 void setLinkClipInterface(IlvLinkClipInterface linkClipInterface)
          Sets the clip interface for the connection points of links.
 void setLinkConnectionBoxInterface(IlvLinkConnectionBoxInterface linkConnectionBoxInterface)
          Sets the link connection box interface for the connection points of links.
 void setMaxSplineCurveSize(float size)
          Sets the maximum curve size used when optimized spline control point routing is enabled.
 void setMemorySavings(boolean option)
          Sets whether the layout algorithm uses the memory saving mode.
 void setMinBusyTime(long time)
          Sets the minimal time that the layout algorithm can be busy.
 void setMinSplineCurveSize(float size)
          Sets the minimum curve size used when optimized spline control point routing is enabled.
 void setParametersUpToDate(boolean uptodate)
          If the argument is false, notifies the layout instance that a parameter value was changed.
 void setParentLayout(IlvGraphLayout parent)
          Sets the parent layout of this layout instance.
 void setPreserveFixedLinks(boolean option)
          Sets whether the layout avoids movement of fixed links.
 void setPreserveFixedNodes(boolean option)
          Sets whether the layout avoids movement of fixed nodes.
 Object setProperty(IlvGraphModel graphModel, Object nodeOrLink, String key, Object value)
          Sets the value of a property for a node or a link, using a given graph model.
 Object setProperty(String key, Object value)
          Sets the value of a property for the layout instance.
 void setSeedValueForRandomGenerator(long seed)
          Sets the seed value for the random generator.
 void setSplineLinkFilter(IlvSplineLinkFilter filter)
          Sets the filter that detects which links are suitable for optimized spline routing.
 void setSplineRoutingEnabled(boolean flag)
          Sets whether the calculation of optimized spline control points is enabled.
 void setStructureUpToDate(boolean uptodate)
          If the argument is false, notifies the layout instance that the structure of the graph was changed since the last time the layout was successfully performed.
 void setUseDefaultParameters(boolean option)
          If the argument is true, specifies that the layout uses the default values of all the parameters, that is, the getter methods return the default values.
 void setUseSeedValueForRandomGenerator(boolean option)
          Sets whether the user-defined seed value should be used for the random generator.
 boolean stopImmediately()
          Stops the running layout algorithm as soon as possible.
 boolean supportsAllowedTime()
          Indicates whether the layout class can stop the layout computation when a user-defined allowed time is exceeded.
 boolean supportsAnimation()
          Indicates whether the layout class can perform a redraw of the graph model after each step or iteration.
 boolean supportsLayoutOfConnectedComponents()
          Indicates whether the layout class can cut the attached graph into connected components, apply itself on each connected component separately, and then use the layout instance returned by the method getLayoutOfConnectedComponents() to position the connected components.
 boolean supportsLayoutRegion()
          Indicates whether the layout class can control the position and/or size of the graph drawing according to a user-defined region (a rectangle) or a user-defined area of a manager view.
 boolean supportsLinkClipping()
          Indicates whether the layout class can use a link clip interface to clip the end points of a link.
 boolean supportsLinkConnectionBox()
          Indicates whether the layout class can use a link connection box interface to calculate the end points of a link.
 boolean supportsMemorySavings()
          Indicates whether the layout class can perform the layout using two partially different implementations: one that gives priority to speed, the other that gives priority to memory usage.
 boolean supportsPercentageComplete()
          Indicates whether the layout class can estimate the percentage of completion during the run of layout.
 boolean supportsPreserveFixedLinks()
          Indicates whether the layout class allows the user to specify fixed links.
 boolean supportsPreserveFixedNodes()
          Indicates whether the layout class allows the user to specify fixed nodes.
 boolean supportsRandomGenerator()
          Indicates whether the layout class uses randomly generated numbers (or randomly chosen parameters) for which it can accept a user-defined seed value.
 boolean supportsSaveParametersToNamedProperties()
          Indicates whether the layout class can transfer the layout parameters to named properties.
 boolean supportsSplineRouting()
          Indicates whether the layout class supports the generic optimization of spline control points.
 boolean supportsStopImmediately()
          Indicates whether the layout class can interrupt the current run of layout immediately in a controlled way.
 void unfixAllLinks()
          Removes the fixed attribute from all links in the graph model.
 void unfixAllNodes()
          Removes the fixed attribute from all nodes in the graph model.
 boolean useAnimateRedraw()
          Returns true if animation is supported and enabled for this graph layout or any sublayout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVERSE_VIEW_COORDINATES

public static final int INVERSE_VIEW_COORDINATES
Inverse view coordinates mode. When used as the argument of the method setCoordinatesMode(int), the geometry of the graph is computed by inverting the coordinate system of the view.

Since:
JViews 5.0
See Also:
Constant Field Values

MANAGER_COORDINATES

public static final int MANAGER_COORDINATES
Manager coordinates mode. When used as the argument of the method setCoordinatesMode(int), the geometry of the graph is computed in the coordinate system of the manager.

Since:
JViews 5.0
See Also:
Constant Field Values

VIEW_COORDINATES

public static final int VIEW_COORDINATES
View coordinates mode. When used as the argument of the method setCoordinatesMode(int), the geometry of the graph is computed in the coordinate system of the view.

Since:
JViews 5.0
See Also:
Constant Field Values
Constructor Detail

IlvGraphLayout

public IlvGraphLayout()
Creates a new instance of the layout algorithm.


IlvGraphLayout

public IlvGraphLayout(IlvGraphLayout source)
Creates a new layout instance by copying an existing one. This constructor is used by the copy() method. Any subclass should provide a copy constructor.

The parameters of the source layout are copied using the method copyParameters(ilog.views.graphlayout.IlvGraphLayout). The attached graph is not copied.

Parameters:
source - The layout instance that is copied.
Since:
JViews 5.0
Method Detail

copyParameters

public void copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.

Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the link clip and link connection box interfaces, are also copied. If the method supportsLayoutOfConnectedComponents() returns true, a copy of the layout instance used for laying out the connected components is set on this layout instance.

If a method of the type supportsXXX is associated with a parameter, the parameter is copied only if the corresponding method returns true.

Subclasses that need to copy additional parameters must override this method. The method can be implemented as follows:

 public void copyParameters(IlvGraphLayout source)
 {
   super.copyParameters(source);
   // MyLayout is the name of the subclass
   if (source instanceof MyLayout) {
     MyLayout msource = (MyLayout)source;
     // copy the attribute of the subclass
     setMyParameter(msource.getMyParameter());
   }
 }
 

Parameters:
source - The layout instance from which the parameters are copied.
Since:
JViews 5.0

init

protected void init()
Initializes instance variables.

You should not call this method directly. The method is called internally by the constructor without arguments and by the copy constructor.

The method must be overridden by subclasses that need to initialize additional instance variables. The initialization of all the instance variables of the subclasses must be done in this method.

Since:
JViews 5.0

copy

public abstract IlvGraphLayout copy()
Copies the layout instance.

This method must return a copy of this layout instance by calling a constructor defined as follows: public <CLASSNAME>(<CLASSNAME> source).

When performing a recursive layout on a nested graph, this method is used by IlvLayoutProvider to "clone" the layout instance of a parent graph.

Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the link clip and link connection box interfaces, are also copied. If the method supportsLayoutOfConnectedComponents() returns true, a copy of the layout instance used for laying out the connected components is set on the new instance.

If a method of the type supportsXXX is associated with a parameter, the parameter is copied only if the corresponding method returns true.

Returns:
A copy of the layout instance.
Since:
JViews 5.0

getInstanceId

public final int getInstanceId()
A utility method that returns a unique integer value for each layout instance inside the same Java program. This method can be used to obtain names for properties that are unique for each layout instance.


attach

public void attach(IlvGrapher grapher)
Sets the grapher to be laid out. This method automatically creates an IlvGrapherAdapter to encapsulate the grapher. Then, the adapter is attached to the layout instance by calling the method attach(IlvGraphModel).

You must attach the grapher before performing the layout, that is, before calling the method performLayout(), and before specifying layout parameters for specific nodes or links.

The method does nothing if the grapher is already attached.

You can get the IlvGrapherAdapter instance created by this method using getGraphModel(). However, notice that you are not allowed to do the following:

In case you need to be able to do any of the above operations, create directly the instance of IlvGrapherAdapter and attach it using attach(IlvGraphModel).

To determine whether a given IlvGraphModel instance has been created using attach(IlvGrapher), you can use the method IlvGraphModel.getOriginatingLayout(). This method returns a non-null object if the model has not been created using attach(IlvGrapher).

Parameters:
grapher - The grapher.
See Also:
attach(ilog.views.graphlayout.IlvGraphModel), detach(), getGraphModel(), getGrapher()

attach

public void attach(IlvGraphModel graphModel)
Sets the graph model to be laid out.

You must attach the graph model before performing the layout, that is, before calling the method performLayout(), and before specifying layout parameters for specific nodes or links.

This method first calls detach() if a graph model is already attached. After attaching the model, the method IlvGraphModel.afterAttach(ilog.views.graphlayout.IlvGraphLayout) is called, passing this layout instance as argument.

Parameters:
graphModel - The graph model to lay out.
Since:
JViews 3.0
See Also:
attach(ilog.views.IlvGrapher), detach(), getGraphModel()

detach

public void detach()
Detaches the graph model from the layout instance.

When a new graph model is attached to the layout instance, it is not necessary to detach the previously attached graph model because this is done automatically when the method attach(IlvGraphModel) is called.

This method performs cleaning operations on the graph model (for example, properties added to the graph model objects and graph model listeners are removed). The method cleanGraphModel(ilog.views.graphlayout.IlvGraphModel) is called with the currently attached graph model as the argument. The methods cleanNode(ilog.views.graphlayout.IlvGraphModel, java.lang.Object) and cleanLink(ilog.views.graphlayout.IlvGraphModel, java.lang.Object) are called for each node and link returned by the methods IlvGraphModel.getNodes(), IlvGraphModel.getLinks() and IlvGraphModel.getInterGraphLinks().

If the model currently attached is an IlvGrapherAdapter internally created using the method attach(IlvGrapher), the method IlvGraphModel.dispose() is called on it. Notice that in this case you can no longer use the adapter instance.

Subclasses can override this method to remove additional information stored in the layout instance.

After detaching the model, the method IlvGraphModel.afterDetach(ilog.views.graphlayout.IlvGraphLayout) is called, passing this layout instance as an argument. If the model has been internally created using the method attach(IlvGrapher), the method IlvGraphModel.afterDetach(ilog.views.graphlayout.IlvGraphLayout) is called just before disposing of the model.

Note that you must call this method when you no longer need the layout instance; otherwise, some objects may not be garbage collected.

See Also:
attach(ilog.views.IlvGrapher), attach(ilog.views.graphlayout.IlvGraphModel), cleanGraphModel(ilog.views.graphlayout.IlvGraphModel), cleanNode(ilog.views.graphlayout.IlvGraphModel, java.lang.Object), cleanLink(ilog.views.graphlayout.IlvGraphModel, java.lang.Object), IlvGraphModel.dispose()

cleanGraphModel

public void cleanGraphModel(IlvGraphModel graphModel)
Cleans a graph model. This method removes any data that has been stored by the layout algorithm on a graph model.

Subclasses can override this method to remove additional information stored in the graph model.

Parameters:
graphModel - The graph model to be cleaned.
Since:
JViews 5.0
See Also:
detach(), IlvGraphModel.dispose()

cleanNode

public void cleanNode(IlvGraphModel graphModel,
                      Object node)
Cleans a node. This method removes any data that has been stored by the layout algorithm on a node.

The method is automatically called by contentsChanged(ilog.views.graphlayout.GraphModelEvent) whenever a GraphModelEvent of type GraphModelEvent.NODE_REMOVED is received.

Subclasses can override this method to remove additional information stored in the nodes.

Notice that the method may be called multiple times for the same node. At the time this method is called, the node may already be removed; therefore, overridden versions of this method should be implemented so that they work even if the object is no longer a node of graphModel.

Parameters:
graphModel - The graph model to which the node belongs.
node - The node to be cleaned.
Since:
JViews 5.0
See Also:
detach(), IlvGraphModel.dispose()

cleanLink

public void cleanLink(IlvGraphModel graphModel,
                      Object link)
Cleans a link. This method removes any data that has been stored by the layout algorithm on a regular link or on an intergraph link.

The method is automatically called by contentsChanged(ilog.views.graphlayout.GraphModelEvent) whenever a GraphModelEvent of type GraphModelEvent.LINK_REMOVED is received.

Subclasses can override this method to remove additional information stored in the links.

Notice that the method may be called multiple times for the same link. At the time this method is called, the link may already be removed; therefore, overridden versions of this method should be implemented so that they work even if the object is no longer a link of graphModel.

Parameters:
graphModel - The graph model to which the link belongs.
link - The link to be cleaned.
Since:
JViews 5.0
See Also:
detach(), IlvGraphModel.dispose()

setGraphModel

public void setGraphModel(IlvGraphModel graphModel)
Sets the graph model to be laid out. You should not call this method. Instead, use the methods attach(IlvGrapher) or attach(IlvGraphModel).

Since:
JViews 5.0

getGraphModel

public IlvGraphModel getGraphModel()
Returns the graph model to lay out if a graph model is attached. Otherwise, the method returns null.

If an IlvGrapher is attached directly using attach(IlvGrapher), the method returns the instance of IlvGrapherAdapter that has been created internally. Note that in this case the model cannot be used once the detach() method has been called and cannot be attached to any other layout instance.

Note that, during the layout of a disconnected graph by a layout class that supports the connected components layout mechanism (see supportsLayoutOfConnectedComponents()) and for which this mechanism is enabled (see isLayoutOfConnectedComponentsEnabled()), the method getGraphModel() may return a different graph model than the one originally attached using the method attach(IlvGraphModel). For details, see the method performLayout(boolean, boolean, boolean).

Since:
JViews 3.0
See Also:
attach(ilog.views.graphlayout.IlvGraphModel), attach(ilog.views.IlvGrapher)

setGrapher

public void setGrapher(IlvGrapher grapher)
Sets the grapher to be laid out. This method exists for JavaBean support. The method simply calls attach(IlvGrapher).

Since:
JViews 3.0
See Also:
attach(ilog.views.IlvGrapher), getGrapher()

getGrapher

public IlvGrapher getGrapher()
Returns the IlvGrapher that contains the nodes and links to be laid out.

The method returns null if no graph is attached to the layout instance. Otherwise, it returns the object returned by the method IlvGraphModel.getGrapher() called on the attached graph model.

This means that the method returns the instance of IlvGrapher that has been attached directly using the method attach(IlvGrapher) or indirectly by passing an IlvGrapherAdapter as an argument to the method attach(IlvGraphModel). If the nodes and links are not contained in an IlvGrapher, the method returns null.

See Also:
setGrapher(ilog.views.IlvGrapher), attach(ilog.views.IlvGrapher)

setParentLayout

public void setParentLayout(IlvGraphLayout parent)
Sets the parent layout of this layout instance. You should not call this method directly.

Since:
JViews 3.5
See Also:
getParentLayout()

getParentLayout

public IlvGraphLayout getParentLayout()
Returns the parent layout. If a layout instance A creates or uses another layout instance B to accomplish a part of or the total layout work, the layout instance A is called the "parent" of the layout instance B. The parent layout instance is responsible for declaring itself as a parent of B by calling the method setParentLayout(ilog.views.graphlayout.IlvGraphLayout) on it. The layout instance B is called a sublayout of A.

Sublayouts never have their own local layout listeners. Layout events have parent layouts as the source.

The method returns null if the layout instance has no parent.

Since:
JViews 3.5
See Also: