public interface IlvLayoutProvider
This interface is mainly useful when laying out nested graphs, that is, graphs containing nodes that are other graphs.
The following code is an example of the implementation of the method
getGraphLayout(ilog.views.graphlayout.IlvGraphModel)
. In this example, the criteria used for
choosing the layout instance is the value of a property stored in
advance in the graph model:
public IlvGraphLayout getGraphLayout(IlvGraphModel graphModel) { Object prop = graphModel.getProperty("layout type"); // if none, return null (no layout needed for this graph) if (!(prop instanceof String)) return null; IlvGraphLayout layout = null; String name = (String)prop; if (name.equals("tree")) layout = new IlvTreeLayout(); else if (name.equals("flow"); layout = new IlvHierarchicalLayout(); else throw new RuntimeException("unsupported layout choice: " + name); layout.attach(graphModel); return layout; }Of course, many other criteria can be used.
Note that in many cases, it is simpler either to use the subclass
IlvDefaultLayoutProvider
as is, or to subclass it, instead of
directly implementing this interface.
IlvDefaultLayoutProvider
,
IlvGraphLayout.performLayout()
,
IlvGraphModel.performLayout(IlvLayoutProvider, boolean, boolean, boolean)
Modifier and Type | Method and Description |
---|---|
IlvGraphLayout |
getGraphLayout(IlvGraphModel graphModel)
Returns the layout instance to be used for laying out
graphModel . |
IlvGraphLayout getGraphLayout(IlvGraphModel graphModel)
graphModel
. The layout instance that is returned must be
attached to graphModel
via the method IlvGraphLayout.attach(IlvGraphModel)
.
Note that this method must return a different layout instance for each subgraph. The same layout instance should not be returned for two different subgraphs of the same graph. Also, the layout instance returned for a subgraph should not be the same as the one returned for the topmost graph.
This method is called during the recursive layout of a nested graph
using the methods IlvGraphLayout.PerformLayout(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider, boolean, boolean, boolean)
and IlvGraphModel.performLayout(IlvLayoutProvider, boolean, boolean,
boolean)
. If the method returns null
, this means that
no layout is needed for graphModel
.
graphModel
- The graph model (eventually the graph model that
encapsulates the topmost grapher).graphModel
, or
null
if no layout is need for graphModel
.IlvGraphLayout.attach(IlvGraphModel)
,
IlvGraphLayout.attach(ilog.views.IlvGrapher)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.