Class LayeredArrangement

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

public class LayeredArrangement extends Object implements GraphArrangement

An arrangement for flows: every edge points the same way, from one layer to the next, with as few crossings as it can find.

This is the method of Sugiyama, Tagawa and Toda in four passes. Cycles are broken by reversing the edges a depth first search finds going back; nodes are put on layers by their longest path from a source; an edge that spans several layers gets a hidden point on each so it bends around the nodes between; the order inside each layer is improved by sweeping down and up, moving each node to the median of its neighbours; and each node is then pulled towards its neighbours without overlapping the next one.

The edges get routes through their hidden points. Pinned nodes are placed like any other: a layered picture has no room for a node that stays put.

  • Field Details

    • TOP_TO_BOTTOM

      public static final int TOP_TO_BOTTOM
      Layers run down the screen and edges point down.
      See Also:
    • LEFT_TO_RIGHT

      public static final int LEFT_TO_RIGHT
      Layers run across the screen and edges point right.
      See Also:
  • Constructor Details

    • LayeredArrangement

      public LayeredArrangement()
  • Method Details

    • getDirection

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

      public void setDirection(int direction)
      Sets the direction edges point.
    • getLayerGap

      public double getLayerGap()
      The space between layers in world units.
    • setLayerGap

      public void setLayerGap(double layerGap)
      Sets the space between layers.
    • getNodeGap

      public double getNodeGap()
      The space between nodes on one layer in world units.
    • setNodeGap

      public void setNodeGap(double nodeGap)
      Sets the space between nodes on one layer.
    • 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