Search this API

y.layout
Class TemporaryGroupNodeInsertionStage

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

public class TemporaryGroupNodeInsertionStage
extends AbstractLayoutStage

TemporaryGroupNodeInsertionStage is useful if nodes should be treated by layout algorithms as if they were actually grouped without the need to manually create a grouped graph for the layout process.

This stage converts given component Ids into a valid, temporary grouping structure that is visible for the core layout algorithm and is obeyed by it if it supports grouped graphs. Importantly, it is not possible to realize a nested grouping structure using this stage. If nested groups are required during layout, they need to be defined the usual way by using DataProvider keys specified in GroupingKeys.

This stage works as follows:

  1. A graph grouping is derived from the given component Ids. All nodes with the same Id are assigned to a newly created group node that is inserted into the graph.
  2. The core layout algorithm is executed. It works on the graph containing the inserted group nodes.
  3. The temporarily inserted group nodes are removed, restoring the original graph structure.
In case that the input graph is already grouped, the following should be noted:

 
This stage is especially convenient if RecursiveGroupLayouter should be applied but the graph is not grouped. This way a layout algorithm (or different ones) can be applied independently for different sub-graphs without manually grouping the graph only for the layout process. To map a specific Layouter instance to a component defined by this stage, use a DataProvider registered with the input graph with key COMPONENT_LAYOUT_ALGORITHM_DPKEY. It is then not necessary to use RecursiveGroupLayouter.GROUP_NODE_LAYOUTER_DPKEY at all.
See Also:
COMPONENT_ID_DPKEY, COMPONENT_LAYOUT_ALGORITHM_DPKEY
 

Field Summary
static java.lang.Object COMPONENT_ID_DPKEY
          A DataProvider key for specifying components of the input graph Nodes with the same component Id constitute a component and are assigned to the same, temporary, group node, which is visible during the execution of the core layout algorithm and again removed afterwards.
static java.lang.Object COMPONENT_LAYOUT_ALGORITHM_DPKEY
          A DataProvider key for specifying a layout algorithm for each component node when used with the recursive group layout stage If this stage is used in conjunction with RecursiveGroupLayouter, the layout algorithm specified here is mapped to be responsible for the arrangement of the nodes forming a specified component.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
TemporaryGroupNodeInsertionStage()
          Creates a new TemporaryGroupNodeInsertionStage with default settings.
TemporaryGroupNodeInsertionStage(Layouter core)
          Creates a new TemporaryGroupNodeInsertionStage with the given layout algorithm as core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that can be handled by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Creates temporary group nodes based on the sub-graphs define by the component Id mapping, executes the core layout algorithm, and, finally, removes the temporary group nodes.
 
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

COMPONENT_ID_DPKEY

public static final java.lang.Object COMPONENT_ID_DPKEY
A DataProvider key for specifying components of the input graph

Nodes with the same component Id constitute a component and are assigned to the same, temporary, group node, which is visible during the execution of the core layout algorithm and again removed afterwards.

 
It is not allowed to define nested components. If nesting is required, define a real grouping structure - see GroupingKeys.

COMPONENT_LAYOUT_ALGORITHM_DPKEY

public static final java.lang.Object COMPONENT_LAYOUT_ALGORITHM_DPKEY
A DataProvider key for specifying a layout algorithm for each component node when used with the recursive group layout stage

If this stage is used in conjunction with RecursiveGroupLayouter, the layout algorithm specified here is mapped to be responsible for the arrangement of the nodes forming a specified component. The first found Layouter instance bound to any node of a component is applied to that component. Internally, the temporary group node that encloses the component nodes is automatically mapped in a DataProvider registered with key RecursiveGroupLayouter.GROUP_NODE_LAYOUTER_DPKEY.

 
A mapping registered with this key has an effect only if the core layout algorithm is of type RecursiveGroupLayouter.
Constructor Detail

TemporaryGroupNodeInsertionStage

public TemporaryGroupNodeInsertionStage()
Creates a new TemporaryGroupNodeInsertionStage with default settings.


TemporaryGroupNodeInsertionStage

public TemporaryGroupNodeInsertionStage(Layouter core)
Creates a new TemporaryGroupNodeInsertionStage with the given layout algorithm as core layout algorithm.

Parameters:
core - the core layout algorithm
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm.

If there is no core layout algorithm, all graphs are accepted.

Parameters:
graph - the input graph
Returns:
true if there is no core layout algorithm or the core layout algorithm accepts the graph, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Creates temporary group nodes based on the sub-graphs define by the component Id mapping, executes the core layout algorithm, and, finally, removes the temporary group nodes.

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

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