Class SankeyLayout

java.lang.Object
com.codename1.ui.chart.layout.SankeyLayout

public final class SankeyLayout extends Object

Positions the nodes and links of a sankey diagram.

Nodes go into columns by their longest path from a source, with sinks pushed to the last column. Heights are proportional to the larger of a node's inflow and outflow, using one scale for every column. Vertical positions are then relaxed towards the weighted centre of each node's neighbours, which shortens and straightens links, and overlaps are pushed apart.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SankeyLayout(int nodeCount, int[] src, int[] dst, double[] value, float x, float y, float w, float h, float nodeWidth, float nodePad)
    Computes a layout.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getColumn(int i)
    The column of node i.
    int
    The number of columns.
    int
    The number of links this layout was computed for.
    float
    The top of link l where it leaves its source.
    float
    The top of link l where it enters its target.
    float
    getLinkWidth(int l)
    The thickness of link l.
    int
    The number of nodes this layout was computed for.
    float
    The height of node i.
    float
    getNodeX(int i)
    The left of node i.
    float
    getNodeY(int i)
    The top of node i.
    boolean
    isBackLink(int l)
    True when link l closes a cycle (or is a self loop): it points back to a node at or left of its source, so it does not take part in assigning columns and runs right to left.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SankeyLayout

      public SankeyLayout(int nodeCount, int[] src, int[] dst, double[] value, float x, float y, float w, float h, float nodeWidth, float nodePad)

      Computes a layout.

      Parameters
      • nodeCount: the number of nodes

      • src: source node of each link

      • dst: target node of each link

      • value: value of each link

      • x: the area's left

      • y: the area's top

      • w: the area's width

      • h: the area's height

      • nodeWidth: the width of a node bar

      • nodePad: the vertical gap between nodes of one column

  • Method Details

    • isBackLink

      public boolean isBackLink(int l)

      True when link l closes a cycle (or is a self loop): it points back to a node at or left of its source, so it does not take part in assigning columns and runs right to left.

      Parameters
      • l: the link
      Returns

      true for a back link

    • getNodeCount

      public int getNodeCount()
      The number of nodes this layout was computed for.
    • getLinkCount

      public int getLinkCount()
      The number of links this layout was computed for.
    • getColumns

      public int getColumns()
      The number of columns.
    • getColumn

      public int getColumn(int i)
      The column of node i.
    • getNodeX

      public float getNodeX(int i)
      The left of node i.
    • getNodeY

      public float getNodeY(int i)
      The top of node i.
    • getNodeHeight

      public float getNodeHeight(int i)
      The height of node i.
    • getLinkSourceY

      public float getLinkSourceY(int l)
      The top of link l where it leaves its source.
    • getLinkTargetY

      public float getLinkTargetY(int l)
      The top of link l where it enters its target.
    • getLinkWidth

      public float getLinkWidth(int l)
      The thickness of link l.