Class SpaceTreeLayoutAlgorithm

java.lang.Object
org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm
org.eclipse.zest.layouts.algorithms.SpaceTreeLayoutAlgorithm
All Implemented Interfaces:
LayoutAlgorithm

public class SpaceTreeLayoutAlgorithm extends AbstractLayoutAlgorithm
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 ExpandCollapseManagers could also work, but the algorithm's functionality would be very limited.
Since:
2.0
  • 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:
    • 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:
    • 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:
    • 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:
  • 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

    • 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

      public void setLayoutContext(LayoutContext context)
      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 interface LayoutAlgorithm
      Overrides:
      setLayoutContext in class AbstractLayoutAlgorithm
      Parameters:
      context - a new layout context or null if this algorithm should not perform any layout
    • getExpandCollapseManager

      public ExpandCollapseManager getExpandCollapseManager()
      Returns:
      ExpandCollapseManager that can (and should) be used on layout context managed by this layout algorithm.
    • refreshLayout

      protected void refreshLayout(boolean animation)