Package org.eclipse.gef.layout.algorithms

# Class SpaceTreeLayoutAlgorithm

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

All Implemented Interfaces:
  `ILayoutAlgorithm`

public class SpaceTreeLayoutAlgorithm extends Object implements ILayoutAlgorithm
Layout algorithm implementing SpaceTree. It assumes that nodes in the layout context make a tree structure. It expands and collapses nodes to optimize use of available space. In order to keep the tree structure clearly visible, it also keeps track of the nodes' positions to makes sure they stay in their current layer and don't overlap with each other.

## Field Summary

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

## Constructor Summary

Constructors
Constructor
Description
`SpaceTreeLayoutAlgorithm()`
Constructs an instance of `SpaceTreeLayoutAlgorithm` that places the root of a tree at the top of the graph.
`SpaceTreeLayoutAlgorithm(int direction)`
Constructs an instance of `SpaceTreeLayoutAlgorithm` that places the root of a tree according to given direction

## Method Summary

Modifier and Type
Method
Description
`void`
`applyLayout(LayoutContext layoutContext, boolean clean)`
Makes this algorithm perform layout computation and apply it to its context.
`double`
`getBranchGap()`
Returns the distance between branches.
`int`
`getDirection()`
`double`
`getLayerGap()`
Returns the distance between layers.
`double`
`getLeafGap()`
Returns the distance between leaf nodes.
`void`
`setBranchGap(double value)`
Sets the distance between branches to the given value.
`void`
`setDirection(int direction)`
Sets direction (placement) of the tree
`void`
`setLayerGap(double value)`
Sets the distance between layers to the given value.
`void`
`setLeafGap(double value)`
Sets the distance between leaf nodes to the given value.

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

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

## Field Details

### 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 Details

### SpaceTreeLayoutAlgorithm

public SpaceTreeLayoutAlgorithm()
Constructs an instance of `SpaceTreeLayoutAlgorithm` that places the root of a tree at the top of the graph.

### SpaceTreeLayoutAlgorithm

public SpaceTreeLayoutAlgorithm(int direction)
Constructs an instance of `SpaceTreeLayoutAlgorithm` that places the root of a tree according to given direction

Parameters:
  `direction` - direction of the tree, sould be one of the following: `TOP_DOWN`, `BOTTOM_UP`, `LEFT_RIGHT`, `RIGHT_LEFT`.

## Method Details

### setLeafGap

public void setLeafGap(double value)
Sets the distance between leaf nodes to the given value. Default value is 15.

Parameters:
  `value` - The new distance between leaf nodes.

### setBranchGap

public void setBranchGap(double value)
Sets the distance between branches to the given value. Default value is 20.

Parameters:
  `value` - The new distance between branches.

### setLayerGap

public void setLayerGap(double value)
Sets the distance between layers to the given value. Default value is 20.

Parameters:
  `value` - The new distance between layers.

### getLeafGap

public double getLeafGap()
Returns the distance between leaf nodes. Default value is 15.

Returns:
  The distance between leaf nodes.

### getBranchGap

public double getBranchGap()
Returns the distance between branches. Default value is 20.

Returns:
  The distance between branches.

### getLayerGap

public double getLayerGap()
Returns the distance between layers. Default value is 20.

Returns:
  The distance between layers.

### getDirection

public int getDirection()

Returns:
  current direction (placement) of the tree

### setDirection

public void setDirection(int direction)
Sets direction (placement) of the tree

Parameters:
  `direction` - direction of the tree, sould be one of the following: `TOP_DOWN`, `BOTTOM_UP`, `LEFT_RIGHT`, `RIGHT_LEFT`.

### 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.