Class TreeArrangement

java.lang.Object
com.codename1.graph.arrange.TreeArrangement
All Implemented Interfaces:
GraphArrangement

public class TreeArrangement extends Object implements GraphArrangement

An arrangement for hierarchies, such as an org chart or a file tree: every node below its parent, parents centred over their children, and no subtree overlapping another.

A graph that is not a tree is laid out by a spanning tree found breadth first from the root (setRootId, or every node no edge enters); the other edges are drawn straight between wherever their ends land. Several roots make a forest, laid out side by side.

  • Field Details

    • TOP_TO_BOTTOM

      public static final int TOP_TO_BOTTOM
      Children below their parent.
      See Also:
    • LEFT_TO_RIGHT

      public static final int LEFT_TO_RIGHT
      Children to the right of their parent, as in a mind map or file tree.
      See Also:
  • Constructor Details

    • TreeArrangement

      public TreeArrangement()
  • Method Details

    • getDirection

      public int getDirection()
      TOP_TO_BOTTOM, the default, or LEFT_TO_RIGHT.
    • setDirection

      public void setDirection(int direction)
      Sets the direction the tree grows.
    • getLevelGap

      public double getLevelGap()
      The space between a parent and its children in world units.
    • setLevelGap

      public void setLevelGap(double levelGap)
      Sets the space between levels.
    • getSiblingGap

      public double getSiblingGap()
      The space between neighbouring subtrees in world units.
    • setSiblingGap

      public void setSiblingGap(double siblingGap)
      Sets the space between neighbouring subtrees.
    • getRootId

      public String getRootId()
      The id of the root, or null to start from every node no edge enters.
    • setRootId

      public void setRootId(String rootId)
      Sets the root.
    • arrange

      public ArrangementResult arrange(GraphModel model)
      Description copied from interface: GraphArrangement
      Computes a position for every node, and a route for edges the arrangement bends.
      Specified by:
      arrange in interface GraphArrangement