Package org.eclipse.gef.layout.algorithms

# Class TreeLayoutHelper

java.lang.Object
org.eclipse.gef.layout.algorithms.TreeLayoutHelper

public class TreeLayoutHelper extends Object
A helper class for layout algorithms that are based on tree structure. It keeps track of changes in observed layout context and stores current information about the tree structure - children of each node and several other parameters.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`TreeLayoutHelper.TreeListener`
A superclass for listeners that can be added to this observer to get notification whenever the tree structure changes.
`static class`
`TreeLayoutHelper.TreeNode`
Represents a node in a tree structure and stores all information related to it.
`static class`
`TreeLayoutHelper.TreeNodeFactory`
`TreeLayoutObserver` uses instance of this class to create instances of `TreeLayoutHelper.TreeNode`.

## Constructor Summary

Constructors
Constructor
Description
`TreeLayoutHelper(TreeLayoutHelper.TreeNodeFactory nodeFactory)`
Constructs a new `TreeLayoutHelper` for observing the given `LayoutContext`.

## Method Summary

Modifier and Type
Method
Description
`void`
`computeTree(org.eclipse.gef.graph.Node[] nodes)`
Recomputes all the information about the tree structure (the same effect as creating new `TreeLayoutObserver`).
`protected TreeLayoutHelper.TreeNode`
`getSuperRoot()`
Returns Super Root, that is an artificial node being a common parent for all nodes in observed tree structure.
`protected TreeLayoutHelper.TreeNode`
`getTreeNode(org.eclipse.gef.graph.Node node)`
Returns a `TreeLayoutHelper.TreeNode` related to given node layout.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TreeLayoutHelper

public TreeLayoutHelper(TreeLayoutHelper.TreeNodeFactory nodeFactory)
Constructs a new `TreeLayoutHelper` for observing the given `LayoutContext`. The given `TreeLayoutHelper.TreeNodeFactory` will be used for the construction of `TreeLayoutHelper.TreeNode`s. If no factory is supplied, the `TreeLayoutHelper.TreeNodeFactory` will be used.

Parameters:
  `nodeFactory` - The `TreeLayoutHelper.TreeNodeFactory` to use.

## Method Details

### computeTree

public void computeTree(org.eclipse.gef.graph.Node[] nodes)
Recomputes all the information about the tree structure (the same effect as creating new `TreeLayoutObserver`).

Parameters:
  `nodes` - nodes

### getSuperRoot

protected TreeLayoutHelper.TreeNode getSuperRoot()
Returns Super Root, that is an artificial node being a common parent for all nodes in observed tree structure.

Returns:
  Super Root

### getTreeNode

protected TreeLayoutHelper.TreeNode getTreeNode(org.eclipse.gef.graph.Node node)
Returns a `TreeLayoutHelper.TreeNode` related to given node layout. If such a `TreeNode` doesn't exist, it's created.

Parameters:
  `node` - The `Node` for which to return the corresponding `TreeLayoutHelper.TreeNode`.
Returns:
  The already existing `TreeLayoutHelper.TreeNode` related to the given `Node` or a newly created one in case there was no related `TreeLayoutHelper.TreeNode` before.