Class SpaceTreeLayoutAlgorithm
java.lang.Object
org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
org.eclipse.zest.layouts.algorithms.SpaceTreeLayoutAlgorithm
- All Implemented Interfaces:
LayoutAlgorithm
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.
It's recommended to set an
ExpandCollapseManger
returned by
getExpandCollapseManager()
in the LayoutContext
that
will be used with this layout algorithm. Other
ExpandCollapseManager
s could also work, but the algorithm's
functionality would be very limited.- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
AbstractLayoutAlgorithm.Zest1
-
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 downwardsFields inherited from class org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
context
-
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
(boolean clean) Makes this algorithm perform layout computation and apply it to its context.int
protected void
refreshLayout
(boolean animation) void
setDirection
(int direction) Sets direction (placement) of the treevoid
setLayoutContext
(LayoutContext context) Sets the layout context for this algorithm.
-
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
-
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(boolean clean) Description copied from interface:LayoutAlgorithm
Makes this algorithm perform layout computation and apply it to its context.- Parameters:
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.
-
setLayoutContext
Description copied from interface:LayoutAlgorithm
Sets the layout context for this algorithm. The receiver will unregister from its previous layout context and register to the new one (registration means for example adding listeners). After a call to this method, the receiving algorithm can compute and cache internal data related to given context and perform an initial layout.- Specified by:
setLayoutContext
in interfaceLayoutAlgorithm
- Overrides:
setLayoutContext
in classAbstractLayoutAlgorithm
- Parameters:
context
- a new layout context or null if this algorithm should not perform any layout
-
getExpandCollapseManager
- Returns:
ExpandCollapseManager
that can (and should) be used on layout context managed by this layout algorithm.
-
refreshLayout
protected void refreshLayout(boolean animation)
-