public class LayoutMultiplexer extends AbstractLayoutStage
LayoutMultiplexer
delegates its layout calls to a core layout algorithm that is dynamically chosen at runtime
by inspecting the nodes of the input graph.
If a IDataProvider
is registered with the given graph using the look-up key LAYOUT_DPKEY
, it is used
for retrieving the ILayoutAlgorithm
objects that are stored for the graph's nodes. If no such IDataProvider
is registered, this layout stage's core layout algorithm
(if any) is used
for the layout calculation of all nodes.
Note that the first non-null
ILayoutAlgorithm
instance retrieved from the IDataProvider
is used
for all nodes.
The main purpose of this class is to enable the use of individual layout algorithms for different components (when used
as the core layout algorithm of ComponentLayout
) or for the contents of group nodes (when used as the core
layout algorithm of RecursiveGroupLayout
).
Modifier and Type | Field and Description |
---|---|
static NodeDpKey<ILayoutAlgorithm> |
LAYOUT_DPKEY
A
DataProvider key for assigning layout algorithms to the nodes
At runtime, the layout algorithms are determined and applied to the current graph. |
Constructor and Description |
---|
LayoutMultiplexer()
Creates a new instance of
LayoutMultiplexer . |
Modifier and Type | Method and Description |
---|---|
void |
applyLayout(LayoutGraph graph)
Retrieves and invokes the
layout algorithm that is assigned to the graph. |
protected ILayoutAlgorithm |
getCoreLayout(LayoutGraph graph)
Returns the core layout algorithm associated with the nodes contained in the given graph.
|
applyLayoutCore, getCoreLayout, setCoreLayout
public static final NodeDpKey<ILayoutAlgorithm> LAYOUT_DPKEY
DataProvider
key for assigning layout algorithms to the nodes
At runtime, the layout algorithms are determined and applied to the current graph. The first non-null
ILayoutAlgorithm
instance is used for the whole graph.
public LayoutMultiplexer()
LayoutMultiplexer
.public void applyLayout(LayoutGraph graph)
layout algorithm
that is assigned to the graph.applyLayout
in interface ILayoutAlgorithm
applyLayout
in class AbstractLayoutStage
graph
- the input graphprotected ILayoutAlgorithm getCoreLayout(LayoutGraph graph)
This implementation looks up the layout algorithm in the IDataProvider
registered with the key
LAYOUT_DPKEY
. The first non-null
layout algorithm
instance found for a
node of the given graph will be returned by this method. If no algorithm is registered at all, it will fall back to the
default core layout algorithm
.
This method is called in applyLayout(LayoutGraph)
and may be overridden to implement a different way of
selecting the layout algorithms
.
graph
- the input graph