Class SpaceTreeLayoutAlgorithm
java.lang.Object
org.eclipse.gef.layout.algorithms.SpaceTreeLayoutAlgorithm
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final int
Tree direction constant for which root is placed at the bottom and branches spread upwardsstatic final int
Tree direction constant for which root is placed at the left and branches spread to the rightstatic final int
Tree direction constant for which root is placed at the right and branches spread to the leftstatic final int
Tree direction constant for which root is placed at the top and branches spread downwards -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an instance ofSpaceTreeLayoutAlgorithm
that places the root of a tree at the top of the graph.SpaceTreeLayoutAlgorithm
(int direction) Constructs an instance ofSpaceTreeLayoutAlgorithm
that places the root of a tree according to given direction -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyLayout
(LayoutContext layoutContext, boolean clean) Makes this algorithm perform layout computation and apply it to its context.double
Returns the distance between branches.int
double
Returns the distance between layers.double
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 treevoid
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.
-
Field Details
-
TOP_DOWN
public static final int TOP_DOWNTree direction constant for which root is placed at the top and branches spread downwards- See Also:
-
BOTTOM_UP
public static final int BOTTOM_UPTree direction constant for which root is placed at the bottom and branches spread upwards- See Also:
-
LEFT_RIGHT
public static final int LEFT_RIGHTTree direction constant for which root is placed at the left and branches spread to the right- See Also:
-
RIGHT_LEFT
public static final int RIGHT_LEFTTree direction constant for which root is placed at the right and branches spread to the left- See Also:
-
-
Constructor Details
-
SpaceTreeLayoutAlgorithm
public SpaceTreeLayoutAlgorithm()Constructs an instance ofSpaceTreeLayoutAlgorithm
that places the root of a tree at the top of the graph. -
SpaceTreeLayoutAlgorithm
public SpaceTreeLayoutAlgorithm(int direction) Constructs an instance ofSpaceTreeLayoutAlgorithm
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
Description copied from interface:ILayoutAlgorithm
Makes this algorithm perform layout computation and apply it to its context.- Specified by:
applyLayout
in interfaceILayoutAlgorithm
- Parameters:
layoutContext
- TheLayoutContext
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.
-