org.eclipse.zest.layouts.algorithms

## Class TreeLayoutAlgorithm

- java.lang.Object
- - org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
  - - org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm

All Implemented Interfaces:
  LayoutAlgorithm, Stoppable

Direct Known Subclasses:
  HorizontalTreeLayoutAlgorithm, RadialLayoutAlgorithm

    public class TreeLayoutAlgorithm
    extends AbstractLayoutAlgorithm

The TreeLayoutAlgorithm class implements a simple algorithm to arrange graph nodes in a layered vertical tree-like layout. This is by no means an efficiently coded algorithm.

### Field Summary

### Fields inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm

`comparator, filter, internalAsynchronous, internalContinuous, layout_styles, layoutStopped, MIN_ENTITY_SIZE, resizeEntitiesAfterLayout`

### Constructor Summary

Constructors
Constructor and Description
`TreeLayoutAlgorithm()` Tree layout algorithm Constructor with NO Style
`TreeLayoutAlgorithm(int styles)` Constructs a new TreeLayoutAlgorithm object.

### Method Summary

Methods
`protected void` `applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout, org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight)` Apply the layout to the given entities.
`protected int` `getCurrentLayoutStep()` Gets the current layout step
`java.util.List` `getRoots()` Returns the last found roots
`protected int` `getTotalNumberOfLayoutSteps()` Gets the total number of steps in this layout
`protected boolean` `isValidConfiguration(boolean asynchronous, boolean continueous)` Determines if the configuration is valid for this layout
`protected void` `postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout, org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)` Code called after the layout algorithm ends
`protected void` `preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout, org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height)` Executes this TreeLayoutAlgorithm layout algorithm by referencing the data stored in the repository system.
`void` `setLayoutArea(double x, double y, double width, double height)`

### Methods inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm

`addEntity, addProgressListener, addRelationship, applyLayout, defaultFitWithinBounds, defaultFitWithinBounds, fireProgressEnded, fireProgressEvent, fireProgressStarted, getEntityAspectRatio, getLayoutBounds, getLocalLocation, getNumberOfProgressListeners, getStyle, isRunning, removeEntity, removeProgressListener, removeRelationship, removeRelationships, removeRelationships, setComparator, setEntityAspectRatio, setFilter, setStyle, stop, updateBendPoints, updateEntities, updateLayoutLocations, updateRelationships, verifyInput`

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

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

### Constructor Detail

#### TreeLayoutAlgorithm

    public TreeLayoutAlgorithm(int styles)

Constructs a new TreeLayoutAlgorithm object.

#### TreeLayoutAlgorithm

    public TreeLayoutAlgorithm()

Tree layout algorithm Constructor with NO Style

### Method Detail

#### setLayoutArea

    public void setLayoutArea(double x,
                     double y,
                     double width,
                     double height)

Specified by:
  `setLayoutArea` in class `AbstractLayoutAlgorithm`

#### getCurrentLayoutStep

    protected int getCurrentLayoutStep()

Description copied from class: `AbstractLayoutAlgorithm`
Gets the current layout step

Specified by:
  `getCurrentLayoutStep` in class `AbstractLayoutAlgorithm`
Returns:

#### getTotalNumberOfLayoutSteps

    protected int getTotalNumberOfLayoutSteps()

Description copied from class: `AbstractLayoutAlgorithm`
Gets the total number of steps in this layout

Specified by:
  `getTotalNumberOfLayoutSteps` in class `AbstractLayoutAlgorithm`

#### preLayoutAlgorithm

    protected void preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
                          org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
                          double x,
                          double y,
                          double width,
                          double height)

Executes this TreeLayoutAlgorithm layout algorithm by referencing the data stored in the repository system. Once done, the result will be saved to the data repository.

Specified by:
  `preLayoutAlgorithm` in class `AbstractLayoutAlgorithm`
Parameters:
  `entitiesToLayout` - Apply the algorithm to these entities
  `relationshipsToConsider` - Only consider these relationships when applying the algorithm.
  `boundsX` - The left side of the bounds in which the layout can place the entities.
  `boundsY` - The top side of the bounds in which the layout can place the entities.
  `boundsWidth` - The width of the bounds in which the layout can place the entities.
  `boundsHeight` - The height of the bounds in which the layout can place the entities.
Throws:
  `java.lang.RuntimeException` - Thrown if entitiesToLayout doesn't contain all of the endpoints for each relationship in relationshipsToConsider

#### applyLayoutInternal

    protected void applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
                           org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
                           double boundsX,
                           double boundsY,
                           double boundsWidth,
                           double boundsHeight)

Description copied from class: `AbstractLayoutAlgorithm`
Apply the layout to the given entities. The entities will be moved and resized based on the algorithm.

Specified by:
  `applyLayoutInternal` in class `AbstractLayoutAlgorithm`
Parameters:
  `entitiesToLayout` - Apply the algorithm to these entities
  `relationshipsToConsider` - Only consider these relationships when applying the algorithm.

#### postLayoutAlgorithm

    protected void postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
                           org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)

Description copied from class: `AbstractLayoutAlgorithm`
Code called after the layout algorithm ends

Specified by:
  `postLayoutAlgorithm` in class `AbstractLayoutAlgorithm`

#### getRoots

    public java.util.List getRoots()

Returns the last found roots

#### isValidConfiguration

    protected boolean isValidConfiguration(boolean asynchronous,
                               boolean continueous)

Description copied from class: `AbstractLayoutAlgorithm`
Determines if the configuration is valid for this layout

Specified by:
  `isValidConfiguration` in class `AbstractLayoutAlgorithm`