Package org.eclipse.gef.layout.algorithms

## Class TreeLayoutAlgorithm

- java.lang.Object
- - org.eclipse.gef.layout.algorithms.TreeLayoutAlgorithm

All Implemented Interfaces:
  `ILayoutAlgorithm`

    public class TreeLayoutAlgorithm
    extends java.lang.Object
    implements ILayoutAlgorithm

The TreeLayoutAlgorithm class implements a simple algorithm to arrange graph nodes in a layered tree-like layout.

### Field Summary

Fields
`static int` `BOTTOM_UP` Tree direction constant for which root is placed at the bottom and branches spread upwards
`static int` `LEFT_RIGHT` Tree direction constant for which root is placed at the left and branches spread to the right
`static int` `RIGHT_LEFT` Tree direction constant for which root is placed at the right and branches spread to the left
`static int` `TOP_DOWN` Tree direction constant for which root is placed at the top and branches spread downwards

### Constructor Summary

Constructors
`TreeLayoutAlgorithm()` Create a default Tree Layout.
`TreeLayoutAlgorithm​(int direction)` Create a Tree Layout with a specified direction.
`TreeLayoutAlgorithm​(int direction, Dimension nodeSpace)` Create a Tree Layout with fixed size spacing around nodes.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `applyLayout​(LayoutContext layoutContext, boolean clean)` Makes this algorithm perform layout computation and apply it to its context.
`int` `getDirection()` Returns the direction of this `TreeLayoutAlgorithm`.
`boolean` `isResizing()`
`void` `setDirection​(int direction)` Changes the direction of this `TreeLayoutAlgorithm` to the given value.
`void` `setNodeSpace​(Dimension nodeSpace)`
`void` `setResizing​(boolean resizing)`
`java.lang.String` `toString()`

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

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

### Field Detail

#### TOP_DOWN

    public static final int TOP_DOWN

Tree direction constant for which root is placed at the top and branches spread downwards

See Also:
  Constant Field Values

#### BOTTOM_UP

    public static final int BOTTOM_UP

Tree direction constant for which root is placed at the bottom and branches spread upwards

See Also:
  Constant Field Values

#### LEFT_RIGHT

    public static final int LEFT_RIGHT

Tree direction constant for which root is placed at the left and branches spread to the right

See Also:
  Constant Field Values

#### RIGHT_LEFT

    public static final int RIGHT_LEFT

Tree direction constant for which root is placed at the right and branches spread to the left

See Also:
  Constant Field Values

### Constructor Detail

#### TreeLayoutAlgorithm

    public TreeLayoutAlgorithm()

Create a default Tree Layout.

#### TreeLayoutAlgorithm

    public TreeLayoutAlgorithm​(int direction)

Create a Tree Layout with a specified direction.

Parameters:
  `direction` - The direction, one of `BOTTOM_UP`, `LEFT_RIGHT`, `RIGHT_LEFT`, `TOP_DOWN`

#### TreeLayoutAlgorithm

    public TreeLayoutAlgorithm​(int direction,
                               Dimension nodeSpace)

Create a Tree Layout with fixed size spacing around nodes. If nodeSpace is not null, the layout will size the container to the ideal space to just contain all nodes of fixed size without any overlap. Otherwise, the algorithm will size for the container's available space.

Parameters:
  `direction` - The direction, one of `BOTTOM_UP`, `LEFT_RIGHT`, `RIGHT_LEFT`, `TOP_DOWN`
  `nodeSpace` - the size to make each node. May be null.

### Method Detail

#### setNodeSpace

    public void setNodeSpace​(Dimension nodeSpace)

Parameters:
  `nodeSpace` - the nodeSpace size to set

#### getDirection

    public int getDirection()

Returns the direction of this `TreeLayoutAlgorithm`.

Returns:
  The direction of this `TreeLayoutAlgorithm`.

#### setDirection

    public void setDirection​(int direction)

Changes the direction of this `TreeLayoutAlgorithm` to the given value. The direction may either be `TOP_DOWN`, `BOTTOM_UP`, `LEFT_RIGHT`, or `RIGHT_LEFT`.

Parameters:
  `direction` - The new direction for this `TreeLayoutAlgorithm`.

#### isResizing

    public boolean isResizing()

Returns:
  true if this algorithm is set to resize elements

#### setResizing

    public void setResizing​(boolean resizing)

Parameters:
  `resizing` - true if this algorithm should resize elements (default is false)

#### applyLayout

    public void applyLayout​(LayoutContext layoutContext,
                            boolean clean)

Description copied from interface: `ILayoutAlgorithm`
Makes this algorithm perform layout computation and apply it to its context.

Specified by:
  `applyLayout` in interface `ILayoutAlgorithm`
Parameters:
  `layoutContext` - The `LayoutContext` that provides all relevant information about what to layout.
  `clean` - if true the receiver should assume that the layout context has changed significantly and recompute the whole layout even if it keeps track of changes with listeners. False can be used after dynamic layout in a context is turned back on so that layout algorithm working in background can apply accumulated changes. Static layout algorithm can ignore this call entirely if clean is false.

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`