ilog.cpl.graph.graphlayout
Class IlpDefaultGraphLayoutSupport

java.lang.Object
  extended by ilog.cpl.graph.graphlayout.IlpDefaultGraphLayoutSupport
All Implemented Interfaces:
IlpGraphLayoutSupport

public class IlpDefaultGraphLayoutSupport
extends Object
implements IlpGraphLayoutSupport

Default implementation of Graph Layout support.

Since:
JViews 7.5

Constructor Summary
IlpDefaultGraphLayoutSupport()
          Default constructor
 
Method Summary
 void attach(IlpGraphView view)
          Attaches this object to a given view.
 void attach(IlpGraphView view, boolean init)
          Attaches this object to a given view.
 IlvGraphModel createGraphModel()
          Creates the graph model used for the manager content.
 void detach()
          Detaches this object from its current view.
 int getAutoLayoutIndex()
          Returns the index of the graph layout that should be executed automatically when the view contents change.
 int getAutoLayoutIndex(IlpRepresentationObject ro)
          Returns the index of the graph layout that should be executed automatically in the subnetwork when the view contents change.
 IlvGraphLayout[] getGraphLayouts()
          Returns the list of graph layouts that have been configured to this view.
 IlvGraphLayout[] getGraphLayouts(IlpRepresentationObject ro)
          Returns the list of graph layouts that have been configured to the given subnetwork object.
 IlvGraphLayout getGraphLayouts(IlpRepresentationObject ro, int index)
          Returns the graph layout that is configured at the given index for the given subnetwork object.
 IlvGraphLayout getGraphLayouts(int index)
          Returns the graph layout that is configured at the given index.
 IlvGraphLayout getLinkLayout()
          Returns the graph layout for links.
 IlvGraphLayout getLinkLayout(IlpRepresentationObject ro)
          Returns the graph layout for links in the subnetwork of the given representation object.
 IlvGraphLayout getNodeLayout()
          Returns the graph layout of the view for nodes.
 void optimizeLayout()
          Applies the registered node and/or a link layout algorithm to the manager content.
 void performAttachedLayout(int index)
          Applies a given graph layout algorithm once to the manager content.
 void performLayoutOnce(IlvGraphLayout layout, Runnable initializations, Runnable postprocessing)
          Applies a given graph layout algorithm once to the manager content.
 void setAutoLayoutIndex(IlpRepresentationObject ro, int index)
          Sets the index of the graph layout that should be executed automatically in the subnetwork objects when the view contents change.
 void setAutoLayoutIndex(int index)
          Sets the index of the graph layout that should be executed automatically when the view contents change.
 void setGraphLayouts(IlpRepresentationObject ro, IlvGraphLayout[] layouts)
          Changes the layouts that can be applied to the subnetwork that represents the given representation object.
 void setGraphLayouts(IlpRepresentationObject ro, int index, IlvGraphLayout layout)
          Sets a new graph layout to this view.
 void setGraphLayouts(IlvGraphLayout[] layouts)
          Changes the layouts that can be applied to this view.
 void setGraphLayouts(int index, IlvGraphLayout layout)
          Sets a new graph layout to this view.
 void setLinkLayout(IlpRepresentationObject ro, IlvGraphLayout layout)
          Changes the link layout of subnetwork for the given representation object.
 void setLinkLayout(IlvGraphLayout layout, boolean relayout)
          Changes the link layout of this view.
 void setNodeLayout(IlvGraphLayout layout, boolean relayout)
          Changes the node layout of this view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlpDefaultGraphLayoutSupport

public IlpDefaultGraphLayoutSupport()
Default constructor

Since:
JViews 7.5
Method Detail

attach

public void attach(IlpGraphView view)
Attaches this object to a given view.

Specified by:
attach in interface IlpGraphLayoutSupport
Since:
JViews 7.5

attach

public void attach(IlpGraphView view,
                   boolean init)
Attaches this object to a given view.

Parameters:
view - Graphic view
init - Indicates if layouts should be initialized.
Since:
JViews 7.5

detach

public void detach()
Detaches this object from its current view.

Specified by:
detach in interface IlpGraphLayoutSupport
Since:
JViews 7.5

setGraphLayouts

public void setGraphLayouts(IlvGraphLayout[] layouts)
Changes the layouts that can be applied to this view. All given graph layouts are attached to the view.

One of the graph layouts can be configured to run automatically when the view contents change. The layout that should be run automatically has to be defined using method setAutoLayoutIndex(int).

The other layouts can be executed on demand using method performAttachedLayout(int)

Note: For performance reasons this method does not perform any of the layouts automatically. Once you have configured the layouts and the index of the layout that shall be performed automatically, you can run the layout using optimizeLayout().

Specified by:
setGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
layouts - Graph layouts
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5
See Also:
getGraphLayouts(), setAutoLayoutIndex(int), performAttachedLayout(int)

getGraphLayouts

public IlvGraphLayout[] getGraphLayouts()
Returns the list of graph layouts that have been configured to this view.

Specified by:
getGraphLayouts in interface IlpGraphLayoutSupport
Returns:
Graph layouts
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5
See Also:
setGraphLayouts(IlvGraphLayout[])

setGraphLayouts

public void setGraphLayouts(int index,
                            IlvGraphLayout layout)
Sets a new graph layout to this view. The graph layout is immediately attached to the view.

Note: For performance reasons this method does not perform any of the layouts automatically. Once you have configured the layouts and the index of the layout that shall be performed automatically, you can run the layout using IlpGraphView.optimizeLayout().

Specified by:
setGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
index - Layout index
layout - Layout
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

getGraphLayouts

public IlvGraphLayout getGraphLayouts(int index)
Returns the graph layout that is configured at the given index.

Specified by:
getGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
index - Layout index
Returns:
Graph layout or null if none is defined.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

setAutoLayoutIndex

public void setAutoLayoutIndex(int index)
Sets the index of the graph layout that should be executed automatically when the view contents change.

Note: For performance reasons this method does not perform any of the layouts automatically. Once you have configured the layouts and the index of the layout that shall be performed automatically, you can run the layout using IlpGraphView.optimizeLayout().

Default value is 0.

Specified by:
setAutoLayoutIndex in interface IlpGraphLayoutSupport
Parameters:
index - Layout index
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

getAutoLayoutIndex

public int getAutoLayoutIndex()
Returns the index of the graph layout that should be executed automatically when the view contents change.

Specified by:
getAutoLayoutIndex in interface IlpGraphLayoutSupport
Returns:
Layout index or -1 if none shall be executed automatically.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

getNodeLayout

public IlvGraphLayout getNodeLayout()
Returns the graph layout of the view for nodes.

Specified by:
getNodeLayout in interface IlpGraphLayoutSupport
Returns:
The graph layout that is configure to perform automatically, or null if none has been specified.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

setNodeLayout

public void setNodeLayout(IlvGraphLayout layout,
                          boolean relayout)
Changes the node layout of this view.

Use this function with relayout set to false if you need to set some layout parameters after the layout has been attached. This is needed for setting the layout region and for passing any layout proxies to the graph layout (for example, using IlvBusLayout.setBus, IlvTreeLayout.setRoot, IlvCircularLayout.setClusterId).

This method corresponds to:

 setGraphLayouts(new IlvGraphLayout[] { layout });
 setAutoLayoutIndex(0);
 if (relayout)
   optimizeLayout();
 

Specified by:
setNodeLayout in interface IlpGraphLayoutSupport
Parameters:
layout - A graph layout or null.
relayout - Specifies whether the layout optimizers should be called immediately.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5
See Also:
setGraphLayouts(IlvGraphLayout[]), setGraphLayouts(int, IlvGraphLayout)

getLinkLayout

public IlvGraphLayout getLinkLayout()
Returns the graph layout for links.

Specified by:
getLinkLayout in interface IlpGraphLayoutSupport
Returns:
A graph layout, or null if none has been specified.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

setLinkLayout

public void setLinkLayout(IlvGraphLayout layout,
                          boolean relayout)
Changes the link layout of this view.

If layout is null, and the node layout does not update links, a default link layout is substituted. It can be obtained using getLinkLayout().

Specified by:
setLinkLayout in interface IlpGraphLayoutSupport
Parameters:
layout - A graph layout or null.
relayout - Indicates if the layout should be reapplied immediately.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

setGraphLayouts

public void setGraphLayouts(IlpRepresentationObject ro,
                            IlvGraphLayout[] layouts)
Changes the layouts that can be applied to the subnetwork that represents the given representation object. All given graph layouts are attached to the subnetwork.

One of the graph layouts can be configured to run automatically when the view contents change. The layout that should be run automatically has to be defined using method setAutoLayoutIndex(IlpRepresentationObject, int).

The other layouts can be executed on demand using method performAttachedLayout(int)

Note: For performance reasons this method does not perform any of the layouts automatically. Once you have configured the layouts and the index of the layout that shall be performed automatically, you can run the layout using optimizeLayout().

Specified by:
setGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
ro - Subnetwork representation object
layouts - Graph layouts
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5
See Also:
getGraphLayouts(IlpRepresentationObject), setAutoLayoutIndex(IlpRepresentationObject, int), performAttachedLayout(int)

getGraphLayouts

public IlvGraphLayout[] getGraphLayouts(IlpRepresentationObject ro)
Returns the list of graph layouts that have been configured to the given subnetwork object.

Specified by:
getGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
ro - Subnetwork representation object
Returns:
Graph layouts or empty list if nothing has been configured for the given object.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5
See Also:
setGraphLayouts(IlpRepresentationObject, IlvGraphLayout[])

setGraphLayouts

public void setGraphLayouts(IlpRepresentationObject ro,
                            int index,
                            IlvGraphLayout layout)
Sets a new graph layout to this view. The graph layout is immediately attached to the view.

Specified by:
setGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
ro - Subnetwork representation object
index - Layout index
layout - Layout
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

getGraphLayouts

public IlvGraphLayout getGraphLayouts(IlpRepresentationObject ro,
                                      int index)
Returns the graph layout that is configured at the given index for the given subnetwork object.

Specified by:
getGraphLayouts in interface IlpGraphLayoutSupport
Parameters:
ro - Subnetwork representation object
index - Layout index
Returns:
Graph layout or null if none is defined.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

setAutoLayoutIndex

public void setAutoLayoutIndex(IlpRepresentationObject ro,
                               int index)
Sets the index of the graph layout that should be executed automatically in the subnetwork objects when the view contents change.

Default value is 0.

Specified by:
setAutoLayoutIndex in interface IlpGraphLayoutSupport
Parameters:
ro - Representation object
index - Layout index
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

getAutoLayoutIndex

public int getAutoLayoutIndex(IlpRepresentationObject ro)
Returns the index of the graph layout that should be executed automatically in the subnetwork when the view contents change.

Default value is 0.

Specified by:
getAutoLayoutIndex in interface IlpGraphLayoutSupport
Parameters:
ro - Subnetwork representation object
Returns:
Layout index
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

setLinkLayout

public void setLinkLayout(IlpRepresentationObject ro,
                          IlvGraphLayout layout)
Changes the link layout of subnetwork for the given representation object.

Since this layout is applied to a subnetwork, using this method does not trigger the automatic layout execution. This will be done in the view when some of its contents is changed.

Specified by:
setLinkLayout in interface IlpGraphLayoutSupport
Parameters:
ro - The container representation object.
layout - A graph layout or null.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

getLinkLayout

public IlvGraphLayout getLinkLayout(IlpRepresentationObject ro)
Returns the graph layout for links in the subnetwork of the given representation object.

Specified by:
getLinkLayout in interface IlpGraphLayoutSupport
Returns:
A graph layout, or null if none has been specified.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

optimizeLayout

public void optimizeLayout()
Applies the registered node and/or a link layout algorithm to the manager content.

Since the registered node and/or link layout is invoked automatically, this function needs to be used:


performAttachedLayout

public void performAttachedLayout(int index)
Applies a given graph layout algorithm once to the manager content. The graph layout is identified by its index when configured in the view (@see #setGraphLayouts(int, IlvGraphLayout)).

In contrast to the node and link layout optimizers that are registered in the grapher and called automatically when needed, this function allows you to call a layout only once. It is useful when the layout takes a lot of time.

Specified by:
performAttachedLayout in interface IlpGraphLayoutSupport
Parameters:
index - Layout index
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5
See Also:
setGraphLayouts(IlvGraphLayout[]), setGraphLayouts(int, IlvGraphLayout)

performLayoutOnce

public void performLayoutOnce(IlvGraphLayout layout,
                              Runnable initializations,
                              Runnable postprocessing)
Applies a given graph layout algorithm once to the manager content.

In contrast to the node and link layout optimizers, that are registered in the grapher and called automatically when needed, this function allows you to call a layout only once. It is useful when the layout takes a lot of time to perform.

Specified by:
performLayoutOnce in interface IlpGraphLayoutSupport
Parameters:
layout - A graph layout that is not attached to any grapher or graph model.
initializations - Code that performs initializations of the layout after the layout is attached, but before it is run.
postprocessing - Code that performs post-processing of the layout after the layout has been run, but before it is detached.
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5

createGraphModel

public IlvGraphModel createGraphModel()
Creates the graph model used for the manager content.

This graph model represents the whole Network component graph model. In order to specify a different graph model for each subnetwork, override the method IlvGraphModel.getGraphModel(java.lang.Object), where the argument is the subnetwork grapher.

Specified by:
createGraphModel in interface IlpGraphLayoutSupport
Returns:
An instance of IltGrapherAdapter
Throws:
RuntimeException - if this instance is not attached to a view.
Since:
JViews 7.5


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