Search this API

y.layout.tree
Class TreeComponentLayouter

java.lang.Object
  extended by y.layout.tree.TreeComponentLayouter
All Implemented Interfaces:
Layouter, LayoutStage

public class TreeComponentLayouter
extends java.lang.Object
implements LayoutStage

The TreeComponentLayouter arranges tree-like subgraph structures in a mixed layout style.


The tree components are marked

 

Field Summary
static java.lang.Object DUMMY_NODE_DPKEY
          A DataProvider key for identifying dummy nodes during the layout calculation This DataProvider is registered and also removed in doLayoutUsingDummies(LayoutGraph, DataProvider).
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
TreeComponentLayouter(Layouter treeCoreLayouter)
          Creates a new TreeComponentLayouter instance using the specified layouter for arranging the subtrees.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs if there is a core layout algorithm and a tree layout algorithm.
 void doLayout(LayoutGraph graph)
          Finds the tree components inside the given graph and applies a tree layout to them.
protected  void doLayoutUsingDummies(LayoutGraph graph, DataProvider dummyDp)
          Delegates the layout calculation to the core layout algorithm and handles the dummy nodes.
 Layouter getCoreLayouter()
          Returns the core layout algorithm.
 Layouter getTreeComponentCoreLayouter()
          Returns the layout algorithm that is applied to tree components.
 boolean isOrientationOptimizationActive()
          Returns whether or not tree component arrangement is improved by changing the orientation of components.
 boolean isUndirectedTreeConsiderationEnabled()
          Returns whether or not undirected tree sub-graphs should be detected and handled.
 void setCoreLayouter(Layouter l)
          Specifies the core layout algorithm.
 void setOrientationOptimizationActive(boolean orientationOptimizationActive)
          Specifies whether or not tree component arrangement is improved by changing the orientation of components.
 void setTreeComponentCoreLayouter(Layouter treeComponentCoreLayouter)
          Specifies the layout algorithm that is applied to tree components.
 void setUndirectedTreeConsiderationEnabled(boolean undirectedTreeConsiderationEnabled)
          Specifies whether or not undirected tree sub-graphs should be detected and handled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUMMY_NODE_DPKEY

public static final java.lang.Object DUMMY_NODE_DPKEY
A DataProvider key for identifying dummy nodes during the layout calculation

This DataProvider is registered and also removed in doLayoutUsingDummies(LayoutGraph, DataProvider).

See Also:
doLayoutUsingDummies(LayoutGraph, DataProvider)
Constructor Detail

TreeComponentLayouter

public TreeComponentLayouter(Layouter treeCoreLayouter)
Creates a new TreeComponentLayouter instance using the specified layouter for arranging the subtrees.

Parameters:
treeCoreLayouter - the layout algorithm used for arranging the tree components
Throws:
java.lang.IllegalArgumentException - if the specified layout algorithm is null
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs if there is a core layout algorithm and a tree layout algorithm.

Specified by:
canLayout in interface Layouter
Parameters:
graph - the input graph
Returns:
true if both a core layout algorithm and a tree layout algorithm are specified, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Finds the tree components inside the given graph and applies a tree layout to them.

Specified by:
doLayout in interface Layouter
Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

doLayoutUsingDummies

protected void doLayoutUsingDummies(LayoutGraph graph,
                                    DataProvider dummyDp)
Delegates the layout calculation to the core layout algorithm and handles the dummy nodes. The dummy nodes are marked using the given DataProvider.

This implementation just registers the dummy node DataProvider with the graph with key DUMMY_NODE_DPKEY, executes the core layout algorithm and finally removes the data provider again.

This method is called by doLayout(LayoutGraph) to invoke the core layout algorithm. It may be overridden to customize the handling of the dummy nodes.

 
Does nothing if the core layout algorithm is null.
Parameters:
graph - the input graph
dummyDp - the DataProvider which marks the dummy nodes

getCoreLayouter

public Layouter getCoreLayouter()
Description copied from interface: LayoutStage
Returns the core layout algorithm. This algorithm is wrapped by this stage. It is invoked in Layouter.doLayout(LayoutGraph). The LayoutStage may add pre- and post-processing steps before and after calling the core layout algorithm.

Specified by:
getCoreLayouter in interface LayoutStage
Returns:
the core layout algorithm

setCoreLayouter

public void setCoreLayouter(Layouter l)
Description copied from interface: LayoutStage
Specifies the core layout algorithm. This algorithm is wrapped by this stage. It is invoked in Layouter.doLayout(LayoutGraph). The LayoutStage may add pre- and post-processing steps before and after calling the core layout algorithm.

Specified by:
setCoreLayouter in interface LayoutStage
Parameters:
l - the core layout algorithm

getTreeComponentCoreLayouter

public Layouter getTreeComponentCoreLayouter()
Returns the layout algorithm that is applied to tree components.

Returns:
the layout algorithm for tree components
See Also:
setTreeComponentCoreLayouter(Layouter)

setTreeComponentCoreLayouter

public void setTreeComponentCoreLayouter(Layouter treeComponentCoreLayouter)
Specifies the layout algorithm that is applied to tree components.

Parameters:
treeComponentCoreLayouter - the layout algorithm for tree components
Throws:
java.lang.IllegalArgumentException - if the specified layout algorithm is null

isOrientationOptimizationActive

public boolean isOrientationOptimizationActive()
Returns whether or not tree component arrangement is improved by changing the orientation of components.

Returns:
true if the component arrangement is optimized, false otherwise
See Also:
setOrientationOptimizationActive(boolean)

setOrientationOptimizationActive

public void setOrientationOptimizationActive(boolean orientationOptimizationActive)
Specifies whether or not tree component arrangement is improved by changing the orientation of components.

Default Value:
The default value is false. Components keep their orientation.
Parameters:
orientationOptimizationActive - true if the component arrangement should be optimized, false otherwise

isUndirectedTreeConsiderationEnabled

public boolean isUndirectedTreeConsiderationEnabled()
Returns whether or not undirected tree sub-graphs should be detected and handled.

When enabled, the direction of the edges that define a subtree is not relevant. Therefore, also undirected trees are detected and handled as a tree component. Otherwise, only trees that are consistently directed from the root are handled (directed rooted trees).

Returns:
true if undirected subtrees are considered, false otherwise
See Also:
setUndirectedTreeConsiderationEnabled(boolean)

setUndirectedTreeConsiderationEnabled

public void setUndirectedTreeConsiderationEnabled(boolean undirectedTreeConsiderationEnabled)
Specifies whether or not undirected tree sub-graphs should be detected and handled.

When enabled, the direction of the edges that define a subtree is not relevant. Therefore, also undirected trees are detected and handled as a tree component. Otherwise, only trees that are consistently directed from the root are handled (directed rooted trees).

Default Value:
The default value is false. Only directed subtrees are handled
Parameters:
undirectedTreeConsiderationEnabled - true if undirected subtrees should be considered, false otherwise

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