Search this API

y.layout
Class LayoutMultiplexer

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.LayoutMultiplexer
All Implemented Interfaces:
Layouter, LayoutStage

public class LayoutMultiplexer
extends AbstractLayoutStage

A 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 DataProvider is registered with the given graph using the look-up key LAYOUTER_DPKEY, it is used for retrieving the Layouter objects that are stored for the graph's nodes. If no such DataProvider 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 Layouter instance retrieved from the DataProvider 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 ComponentLayouter) or for the contents of group nodes (when used as the core layout algorithm of RecursiveGroupLayouter).

 

Field Summary
static java.lang.Object LAYOUTER_DPKEY
          A DataProvider key for assigning layout algorithms to the nodes At runtime, the layout algorithms are determined and applied to the current graph.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
LayoutMultiplexer()
          Creates a new instance of LayoutMultiplexer.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all general graphs.
 void doLayout(LayoutGraph graph)
          Retrieves and invokes the layout algorithm that is assigned to the graph.
protected  Layouter getCoreLayouter(LayoutGraph graph)
          Returns the core layout algorithm associated with the nodes contained in the given graph.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUTER_DPKEY

public static final java.lang.Object LAYOUTER_DPKEY
A 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 Layouter instance is used for the whole graph.

Constructor Detail

LayoutMultiplexer

public LayoutMultiplexer()
Creates a new instance of LayoutMultiplexer.

Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all general graphs.

Parameters:
graph - the input graph
Returns:
true if the graph is not null, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Retrieves and invokes the layout algorithm that is assigned to the graph.

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

getCoreLayouter

protected Layouter getCoreLayouter(LayoutGraph graph)
Returns the core layout algorithm associated with the nodes contained in the given graph.

This implementation looks up the layout algorithm in the DataProvider registered with the key LAYOUTER_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 doLayout(LayoutGraph) and may be overridden to implement a different way of selecting the layout algorithms.

Parameters:
graph - the input graph
Returns:
the according layout algorithm

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.