Class CompactTreeLayout

Extends GraphLayout to implement a compact tree (Moen) algorithm. This layout is suitable for graphs that have no cycles (trees). Vertices that are not connected to the tree will be ignored by this layout.

const layout = new CompactTreeLayout(graph);
layout.execute(graph.getDefaultParent());

Hierarchy (view full)

Constructors

Properties

alignRanks: boolean = false

Whether or not the tops of cells in each rank should be aligned across the rank

channelBuffer: number = 4

The size of the vertical buffer in the center of inter-rank channels where edge control points should not be placed.

edgeRouting: boolean = true

Whether or not to apply the internal tree edge routing.

graph: Graph

Reference to the enclosing Graph.

groupPadding: number = 10

Padding added to resized parents.

10
groupPaddingBottom: number = 0

Bottom padding added to resized parents.

0
groupPaddingLeft: number = 0

Left padding added to resized parents.

0
groupPaddingRight: number = 0

Right padding added to resized parents.

0
groupPaddingTop: number = 0

Top padding added to resized parents.

0
horizontal: boolean = true

Specifies the orientation of the layout.

true
invert: boolean = false

Specifies if edge directions should be inverted.

false.
levelDistance: number = 10

Holds the levelDistance.

10
maintainParentLocation: boolean = false

Specifies if the parent location should be maintained, so that the top, left corner stays the same before and after execution of the layout. Default is false for backwards compatibility.

false
maxRankHeight: Cell[] = []

An array of the maximum height of cells (relative to the layout direction) per rank

minEdgeJetty: number = 8

The minimum distance for an edge jetty from a vertex.

moveTree: boolean = false

Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer.

false
node: null | _mxCompactTreeLayoutNode = null

The internal node representation of the root cell. Do not set directly , this value is only exposed to assist with post-processing functionality

nodeDistance: number = 20

Holds the nodeDistance.

20
parent: null | Cell = null

The parent cell of the layout, if any

null
parentsChanged: null | {
    [id: string]: Cell;
} = null

A set of the parents that need updating based on children process as part of the layout.

parentX: null | number = null
parentY: null | number = null
prefHozEdgeSep: number = 5

The preferred horizontal distance between edges exiting a vertex.

prefVertEdgeOff: number = 4

The preferred vertical offset between edges exiting a vertex.

resetEdges: boolean = true

Specifies if all edge points of traversed edges should be removed.

true
resizeParent: boolean = true

If the parents should be resized to match the width/height of the children. Default is true.

true
root: null | Cell = null

The cell to use as the root of the tree

sortEdges: boolean = false

Specifies if edges should be sorted according to the order of their opposite terminal cell in the model.

useBoundingBox: boolean = true

Boolean indicating if the bounding box of the label should be used if it iss available.

true.
visited: {
    [key: string]: Cell;
} = {}

Methods

  • Adjust parent cells whose child geometries have changed. The default implementation adjusts the group to just fit around the children with a padding.

    Returns void

  • Starts the actual compact tree layout algorithm at the given node.

    Parameters

    • node: any
    • height: number

    Returns void

  • Parameters

    • line1: _mxCompactTreeLayoutLine
    • x1: number
    • y1: number
    • line2: _mxCompactTreeLayoutLine
    • x2: number
    • y2: number

    Returns _mxCompactTreeLayoutLine

  • Starts the actual compact tree layout algorithm at the given node.

    Parameters

    • dx: number
    • dy: number
    • next: any = null

    Returns _mxCompactTreeLayoutLine

  • Starts the actual compact tree layout algorithm at the given node.

    Parameters

    Returns _mxCompactTreeLayoutNode

  • Does a depth first search starting at the specified cell. Makes sure the specified parent is never left by the algorithm.

    Parameters

    Returns null | _mxCompactTreeLayoutNode

  • Implements GraphLayout.execute.

    If the parent has any connected edges, then it is used as the root of the tree. Else, mxGraph.findTreeRoots will be used to find a suitable root node within the set of children of the given parent.

    Parameters

    • parent: Cell

      mxCell whose children should be laid out.

    • Optionalroot: Cell

      Optional mxCell that will be used as the root of the tree. Overrides root if specified.

    Returns void

  • Stores the maximum height (relative to the layout direction) of cells in each rank

    Parameters

    • node: any
    • rank: number

    Returns void

  • Returns the constraint for the given key and cell. The optional edge and source arguments are used to return inbound and outgoing routing- constraints for the given edge and vertex. This implementation always returns the value for the given key in the style of the given cell.

    Parameters

    • key: string

      Key of the constraint to be returned.

    • cell: Cell

      Cell whose constraint should be returned.

    • Optionaledge: Cell

      Optional Cell that represents the connection whose constraint should be returned. Default is null.

    • Optionalsource: boolean

      Optional boolean that specifies if the connection is incoming or outgoing. Default is null.

    Returns any

  • Returns true if the given parent is an ancestor of the given child.

    Parameters

    • parent: Cell

      Cell that specifies the parent.

    • child: null | Cell

      Cell that specifies the child.

    • OptionaltraverseAncestors: boolean

      boolean whether to

    Returns boolean

  • Returns a boolean indicating if the given mxCell should be ignored as a vertex. This returns true if the cell has no connections.

    Parameters

    • vertex: Cell

      mxCell whose ignored state should be returned.

    Returns boolean

  • Returns a boolean indicating if the given Cell is movable or bendable by the algorithm. This implementation returns true if the given cell is movable in the graph.

    Parameters

    • cell: Cell

      Cell whose movable state should be returned.

    Returns boolean

  • Moves the specified node and all of its children by the given amount.

    Parameters

    • node: _mxCompactTreeLayoutNode

    Returns void

  • Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg. index) so that the outcome of the layout will position the vertex as close to the point (x, y) as possible.

    Empty implementation.

    Parameters

    • cell: Cell

      Cell which has been moved.

    • x: number

      X-coordinate of the new cell location.

    • y: number

      Y-coordinate of the new cell location.

    Returns void

  • Moves the specified node and all of its children by the given amount.

    Parameters

    • node: any
    • dx: number
    • dy: number

    Returns void

  • Starts the actual compact tree layout algorithm at the given node.

    Parameters

    • p1: number
    • p2: number
    • a1: number
    • a2: number
    • b1: number
    • b2: number

    Returns number

  • Separates the x position of edges as they connect to vertices

    Parameters

    • node: _mxCompactTreeLayoutNode

    Returns void

  • Set the cells heights (relative to the layout direction) when the tops of each rank are to be aligned

    Parameters

    • node: any
    • rank: number

    Returns void

  • Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true. The change is only carried out if the new location is not equal to the existing location, otherwise the geometry is not replaced with an updated instance. The new or old bounds are returned (including overlapping labels).

    Parameters

    • cell: Cell

      Cell whose geometry is to be set.

    • x: number

      Integer that defines the x-coordinate of the new location.

    • y: number

      Integer that defines the y-coordinate of the new location.

    Returns null | Rectangle

  • Traverses the (directed) graph invoking the given function for each visited vertex and edge. The function is invoked with the current vertex and the incoming edge as a parameter. This implementation makes sure each vertex is only visited once. The function may return false if the traversal should stop at the given vertex.

    Example:

    GlobalConfig.logger.show();
    const cell = graph.getSelectionCell();
    graph.traverse(cell, false, function(vertex, edge)
    {
    GlobalConfig.logger.debug(graph.getLabel(vertex));
    });

    Parameters

    • __namedParameters: GraphLayoutTraverseArgs

    Returns void

  • Starts the actual compact tree layout algorithm at the given node.

    Parameters

    • node: _mxCompactTreeLayoutNode
    • parent: null | _mxCompactTreeLayoutNode
    • x0: number
    • y0: number
    • bounds: null | Rectangle = null

    Returns null | Rectangle