Package org.eclipse.zest.layouts.algorithms

# Class TreeLayoutObserver

java.lang.Object
org.eclipse.zest.layouts.algorithms.TreeLayoutObserver

public class TreeLayoutObserver 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.

Since:
  2.0

## Nested Class Summary

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

## Constructor Summary

Constructors
Constructor
Description
`TreeLayoutObserver(LayoutContext context, TreeLayoutObserver.TreeNodeFactory nodeFactory)`
Creates a

## Method Summary

Modifier and Type
Method
Description
`void`
`addTreeListener(TreeLayoutObserver.TreeListener listener)`
Adds a listener that will be informed about changes in tree structure.
`TreeLayoutObserver.TreeNode`
`getSuperRoot()`
Returns Super Root, that is an artificial node being a common parent for all nodes in observed tree structure.
`TreeLayoutObserver.TreeNode`
`getTreeNode(NodeLayout node)`
Returns a `TreeLayoutObserver.TreeNode` related to given node layout.
`void`
`recomputeTree()`
Recomputes all the information about the tree structure (the same effect as creating new `TreeLayoutObserver`).
`void`
`removeTreeListener(TreeLayoutObserver.TreeListener listener)`
Removes a listener from list of listener to be informed about changes in tree structure.
`void`
`stop()`
Stops this observer from listening to changes in observed layout context.

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

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

## Constructor Details

### TreeLayoutObserver

public TreeLayoutObserver(LayoutContext context, TreeLayoutObserver.TreeNodeFactory nodeFactory)
Creates a

Parameters:
  `context` -
  `nodeFactory` -

## Method Details

### recomputeTree

public void recomputeTree()
Recomputes all the information about the tree structure (the same effect as creating new `TreeLayoutObserver`).

### stop

public void stop()
Stops this observer from listening to changes in observed layout context. After calling this method the information about tree structure can be updated only when `recomputeTree()` is called.

### getSuperRoot

public TreeLayoutObserver.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

public TreeLayoutObserver.TreeNode getTreeNode(NodeLayout node)
Returns a `TreeLayoutObserver.TreeNode` related to given node layout. If such a `TreeNode` doesn't exist, it's created.

Parameters:
  `node` -

### addTreeListener

public void addTreeListener(TreeLayoutObserver.TreeListener listener)
Adds a listener that will be informed about changes in tree structure.

Parameters:
  `listener` - listener to add

### removeTreeListener

public void removeTreeListener(TreeLayoutObserver.TreeListener listener)
Removes a listener from list of listener to be informed about changes in tree structure.

Parameters:
  `listener` - listener to remove