GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — CompactTreeLayout | @maxgraph/core

  • CompactTreeLayout

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.

Example

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

Hierarchy (View Summary)

  • GraphLayout
    • CompactTreeLayout
      • RadialTreeLayout
  • Defined in view/layout/CompactTreeLayout.ts:76
Index

Constructors

constructor

Properties

alignRanks channelBuffer edgeRouting graph groupPadding groupPaddingBottom groupPaddingLeft groupPaddingRight groupPaddingTop horizontal invert levelDistance maintainParentLocation maxRankHeight minEdgeJetty moveTree node nodeDistance parent parentsChanged parentX parentY prefHozEdgeSep prefVertEdgeOff resetEdges resizeParent root sortEdges useBoundingBox visited

Methods

adjustParents apply arrangeGroups attachParent bridge createLine createNode dfs execute findRankHeights getConstraint getGraph getParentOffset getVertexBounds horizontalLayout isAncestor isEdgeIgnored isHorizontal isVertexIgnored isVertexMovable join layout layoutLeaf localEdgeProcessing merge moveCell moveNode offset processNodeOutgoing resizeCell setCellHeights setEdgePoints setEdgeStyleEnabled setOrthogonalEdge setVertexLocation sortOutgoingEdges traverse verticalLayout

Constructors

constructor

  • new CompactTreeLayout(
        graph: AbstractGraph,
        horizontal?: boolean,
        invert?: boolean,
    ): CompactTreeLayout

    Parameters

    • graph: AbstractGraph
    • horizontal: boolean = true
    • invert: boolean = false

    Returns CompactTreeLayout

    Overrides GraphLayout.constructor

    • Defined in view/layout/CompactTreeLayout.ts:77

Properties

alignRanks

alignRanks: boolean = false

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

  • Defined in view/layout/CompactTreeLayout.ts:212

channelBuffer

channelBuffer: number = 4

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

  • Defined in view/layout/CompactTreeLayout.ts:195

edgeRouting

edgeRouting: boolean = true

Whether or not to apply the internal tree edge routing.

  • Defined in view/layout/CompactTreeLayout.ts:200

graph

graph: AbstractGraph

Reference to the enclosing AbstractGraph.

Inherited from GraphLayout.graph

  • Defined in view/layout/GraphLayout.ts:42

groupPadding

groupPadding: number = 10

Padding added to resized parents.

Default

10
  • Defined in view/layout/CompactTreeLayout.ts:118

groupPaddingBottom

groupPaddingBottom: number = 0

Bottom padding added to resized parents.

Default

0
  • Defined in view/layout/CompactTreeLayout.ts:136

groupPaddingLeft

groupPaddingLeft: number = 0

Left padding added to resized parents.

Default

0
  • Defined in view/layout/CompactTreeLayout.ts:142

groupPaddingRight

groupPaddingRight: number = 0

Right padding added to resized parents.

Default

0
  • Defined in view/layout/CompactTreeLayout.ts:130

groupPaddingTop

groupPaddingTop: number = 0

Top padding added to resized parents.

Default

0
  • Defined in view/layout/CompactTreeLayout.ts:124

horizontal

horizontal: boolean = true

Specifies the orientation of the layout.

Default

true
  • Defined in view/layout/CompactTreeLayout.ts:91

invert

invert: boolean = false

Specifies if edge directions should be inverted.

Default

false.
  • Defined in view/layout/CompactTreeLayout.ts:97

levelDistance

levelDistance: number = 10

Holds the levelDistance.

Default

10
  • Defined in view/layout/CompactTreeLayout.ts:161

maintainParentLocation

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.

Default

false
  • Defined in view/layout/CompactTreeLayout.ts:112

maxRankHeight

maxRankHeight: Cell[] = []

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

  • Defined in view/layout/CompactTreeLayout.ts:218

minEdgeJetty

minEdgeJetty: number = 8

The minimum distance for an edge jetty from a vertex.

  • Defined in view/layout/CompactTreeLayout.ts:189

moveTree

moveTree: boolean = false

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

Default

false
  • Defined in view/layout/CompactTreeLayout.ts:155

node

node: _mxCompactTreeLayoutNode | null = null

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

  • Defined in view/layout/CompactTreeLayout.ts:229

nodeDistance

nodeDistance: number = 20

Holds the nodeDistance.

Default

20
  • Defined in view/layout/CompactTreeLayout.ts:167

parent

parent: Cell | null = null

The parent cell of the layout, if any

Default

null

Inherited from GraphLayout.parent

  • Defined in view/layout/GraphLayout.ts:54

parentsChanged

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

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

  • Defined in view/layout/CompactTreeLayout.ts:148

parentX

parentX: number | null = null
  • Defined in view/layout/CompactTreeLayout.ts:83

parentY

parentY: number | null = null
  • Defined in view/layout/CompactTreeLayout.ts:84

prefHozEdgeSep

prefHozEdgeSep: number = 5

The preferred horizontal distance between edges exiting a vertex.

  • Defined in view/layout/CompactTreeLayout.ts:179

prefVertEdgeOff

prefVertEdgeOff: number = 4

The preferred vertical offset between edges exiting a vertex.

  • Defined in view/layout/CompactTreeLayout.ts:184

resetEdges

resetEdges: boolean = true

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

Default

true
  • Defined in view/layout/CompactTreeLayout.ts:174

resizeParent

resizeParent: boolean = true

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

Default

true
  • Defined in view/layout/CompactTreeLayout.ts:104

root

root: Cell | null = null

The cell to use as the root of the tree

  • Defined in view/layout/CompactTreeLayout.ts:223

sortEdges

sortEdges: boolean = false

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

  • Defined in view/layout/CompactTreeLayout.ts:206

useBoundingBox

useBoundingBox: boolean = true

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

Default

true.

Inherited from GraphLayout.useBoundingBox

  • Defined in view/layout/GraphLayout.ts:48

visited

visited: { [key: string]: Cell } = {}
  • Defined in view/layout/CompactTreeLayout.ts:85

Methods

adjustParents

  • adjustParents(): void

    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

    • Defined in view/layout/CompactTreeLayout.ts:885

apply

  • apply(
        node: _mxCompactTreeLayoutNode,
        bounds?: Rectangle | null,
    ): Rectangle | null

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

    Parameters

    • node: _mxCompactTreeLayoutNode
    • bounds: Rectangle | null = null

    Returns Rectangle | null

    • Defined in view/layout/CompactTreeLayout.ts:829

arrangeGroups

  • arrangeGroups(
        cells: Cell[],
        border: number,
        topBorder: number,
        rightBorder: number,
        bottomBorder: number,
        leftBorder: number,
    ): Cell[]

    Shortcut to AbstractGraph.updateGroupBounds with moveGroup set to true.

    Parameters

    • cells: Cell[]
    • border: number
    • topBorder: number
    • rightBorder: number
    • bottomBorder: number
    • leftBorder: number

    Returns Cell[]

    Inherited from GraphLayout.arrangeGroups

    • Defined in view/layout/GraphLayout.ts:424

attachParent

  • attachParent(node: any, height: number): void

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

    Parameters

    • node: any
    • height: number

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:623

bridge

  • bridge(
        line1: _mxCompactTreeLayoutLine,
        x1: number,
        y1: number,
        line2: _mxCompactTreeLayoutLine,
        x2: number,
        y2: number,
    ): _mxCompactTreeLayoutLine

    Parameters

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

    Returns _mxCompactTreeLayoutLine

    • Defined in view/layout/CompactTreeLayout.ts:771

createLine

  • createLine(dx: number, dy: number, next?: any): _mxCompactTreeLayoutLine

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

    Parameters

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

    Returns _mxCompactTreeLayoutLine

    • Defined in view/layout/CompactTreeLayout.ts:871

createNode

  • createNode(cell: Cell): _mxCompactTreeLayoutNode

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

    Parameters

    • cell: Cell

    Returns _mxCompactTreeLayoutNode

    • Defined in view/layout/CompactTreeLayout.ts:799

dfs

  • dfs(cell: Cell, parent: Cell): _mxCompactTreeLayoutNode | null

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

    Parameters

    • cell: Cell
    • parent: Cell

    Returns _mxCompactTreeLayoutNode | null

    • Defined in view/layout/CompactTreeLayout.ts:476

execute

  • execute(parent: Cell, root?: Cell): void

    Implements GraphLayout.execute.

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

    Parameters

    • parent: Cell

      Cell whose children should be laid out.

    • Optionalroot: Cell

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

    Returns void

    Overrides GraphLayout.execute

    • Defined in view/layout/CompactTreeLayout.ts:258

findRankHeights

  • findRankHeights(node: any, rank: number): void

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

    Parameters

    • node: any
    • rank: number

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:441

getConstraint

  • getConstraint(key: string, cell: Cell, edge?: Cell, source?: boolean): any

    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

    Inherited from GraphLayout.getConstraint

    • Defined in view/layout/GraphLayout.ts:115

getGraph

  • getGraph(): AbstractGraph

    Returns the graph that this layout operates on.

    Returns AbstractGraph

    Inherited from GraphLayout.getGraph

    • Defined in view/layout/GraphLayout.ts:98

getParentOffset

  • getParentOffset(parent: Cell | null): Point

    Determines the offset of the given parent to the parent of the layout

    Parameters

    • parent: Cell | null

    Returns Point

    Inherited from GraphLayout.getParentOffset

    • Defined in view/layout/GraphLayout.ts:261

getVertexBounds

  • getVertexBounds(cell: Cell): Rectangle

    Returns an Rectangle that defines the bounds of the given cell or the bounding box if useBoundingBox is true.

    Parameters

    • cell: Cell

    Returns Rectangle

    Inherited from GraphLayout.getVertexBounds

    • Defined in view/layout/GraphLayout.ts:380

horizontalLayout

  • horizontalLayout(
        node: any,
        x0: number,
        y0: number,
        bounds?: Rectangle | null,
    ): Rectangle | null

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

    Parameters

    • node: any
    • x0: number
    • y0: number
    • bounds: Rectangle | null = null

    Returns Rectangle | null

    • Defined in view/layout/CompactTreeLayout.ts:558

isAncestor

  • isAncestor(
        parent: Cell,
        child: Cell | null,
        traverseAncestors?: boolean,
    ): boolean

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

    Parameters

    • parent: Cell

      Cell that specifies the parent.

    • child: Cell | null

      Cell that specifies the child.

    • OptionaltraverseAncestors: boolean

      boolean whether to

    Returns boolean

    Inherited from GraphLayout.isAncestor

    • Defined in view/layout/GraphLayout.ts:191

isEdgeIgnored

  • isEdgeIgnored(edge: Cell): boolean

    Returns a boolean indicating if the given Cell should be ignored by the algorithm. This implementation returns false for all vertices.

    Parameters

    • edge: Cell

      Cell whose ignored state should be returned.

    Returns boolean

    Inherited from GraphLayout.isEdgeIgnored

    • Defined in view/layout/GraphLayout.ts:234

isHorizontal

  • isHorizontal(): boolean

    Returns horizontal.

    Returns boolean

    • Defined in view/layout/CompactTreeLayout.ts:244

isVertexIgnored

  • isVertexIgnored(vertex: Cell): boolean

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

    Parameters

    • vertex: Cell

      Cell whose ignored state should be returned.

    Returns boolean

    Overrides GraphLayout.isVertexIgnored

    • Defined in view/layout/CompactTreeLayout.ts:237

isVertexMovable

  • isVertexMovable(cell: Cell): 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

    Inherited from GraphLayout.isVertexMovable

    • Defined in view/layout/GraphLayout.ts:214

join

  • join(node: any): number

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

    Parameters

    • node: any

    Returns number

    • Defined in view/layout/CompactTreeLayout.ts:665

layout

  • layout(node: any): void

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

    Parameters

    • node: any

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:539

layoutLeaf

  • layoutLeaf(node: any): void

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

    Parameters

    • node: any

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:648

localEdgeProcessing

  • localEdgeProcessing(node: _mxCompactTreeLayoutNode): void

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

    Parameters

    • node: _mxCompactTreeLayoutNode

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:905

merge

  • merge(p1: any, p2: any): number

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

    Parameters

    • p1: any
    • p2: any

    Returns number

    • Defined in view/layout/CompactTreeLayout.ts:690

moveCell

  • moveCell(cell: Cell, x: number, y: number): 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

    Inherited from GraphLayout.moveCell

    • Defined in view/layout/GraphLayout.ts:68

moveNode

  • moveNode(node: any, dx: number, dy: number): void

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

    Parameters

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

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:397

offset

  • offset(
        p1: number,
        p2: number,
        a1: number,
        a2: number,
        b1: number,
        b2: number,
    ): number

    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

    • Defined in view/layout/CompactTreeLayout.ts:736

processNodeOutgoing

  • processNodeOutgoing(node: _mxCompactTreeLayoutNode): void

    Separates the x position of edges as they connect to vertices

    Parameters

    • node: _mxCompactTreeLayoutNode

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:918

resizeCell

  • resizeCell(cell: Cell, bounds: Rectangle, prev?: Cell): void

    Notified when a cell is being resized in a parent that has automatic layout to update the other cells in the layout.

    Empty implementation.

    Parameters

    • cell: Cell

      Cell which has been moved.

    • bounds: Rectangle

      Rectangle that represents the new cell bounds.

    • Optionalprev: Cell

    Returns void

    Inherited from GraphLayout.resizeCell

    • Defined in view/layout/GraphLayout.ts:82

setCellHeights

  • setCellHeights(node: any, rank: number): 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

    • Defined in view/layout/CompactTreeLayout.ts:458

setEdgePoints

  • setEdgePoints(edge: Cell, points: Point[] | null): void

    Replaces the array of Point in the geometry of the given edge with the given array of Point.

    Parameters

    • edge: Cell
    • points: Point[] | null

    Returns void

    Inherited from GraphLayout.setEdgePoints

    • Defined in view/layout/GraphLayout.ts:286

setEdgeStyleEnabled

  • setEdgeStyleEnabled(edge: Cell, value: boolean): void

    Disables or enables the edge style of the given edge.

    Parameters

    • edge: Cell
    • value: boolean

    Returns void

    Inherited from GraphLayout.setEdgeStyleEnabled

    • Defined in view/layout/GraphLayout.ts:246

setOrthogonalEdge

  • setOrthogonalEdge(edge: Cell, value: boolean): void

    Disables or enables orthogonal end segments of the given edge.

    Parameters

    • edge: Cell
    • value: boolean

    Returns void

    Inherited from GraphLayout.setOrthogonalEdge

    • Defined in view/layout/GraphLayout.ts:253

setVertexLocation

  • setVertexLocation(cell: Cell, x: number, y: number): Rectangle | null

    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 Rectangle | null

    Inherited from GraphLayout.setVertexLocation

    • Defined in view/layout/GraphLayout.ts:324

sortOutgoingEdges

  • sortOutgoingEdges(source: Cell, edges: Cell[]): void

    Called if sortEdges is true to sort the array of outgoing edges in place.

    Parameters

    • source: Cell
    • edges: Cell[]

    Returns void

    • Defined in view/layout/CompactTreeLayout.ts:413

traverse

  • traverse(vertex: GraphLayoutTraverseArgs): void

    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

    • vertex: GraphLayoutTraverseArgs

      Cell that represents the vertex where the traversal starts.

    Returns void

    Inherited from GraphLayout.traverse

    • Defined in view/layout/GraphLayout.ts:147

verticalLayout

  • verticalLayout(
        node: _mxCompactTreeLayoutNode,
        parent: _mxCompactTreeLayoutNode | null,
        x0: number,
        y0: number,
        bounds?: Rectangle | null,
    ): Rectangle | null

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

    Parameters

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

    Returns Rectangle | null

    • Defined in view/layout/CompactTreeLayout.ts:587

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Example
Constructors
constructor
Properties
alignRankschannelBufferedgeRoutinggraphgroupPaddinggroupPaddingBottomgroupPaddingLeftgroupPaddingRightgroupPaddingTophorizontalinvertlevelDistancemaintainParentLocationmaxRankHeightminEdgeJettymoveTreenodenodeDistanceparentparentsChangedparentXparentYprefHozEdgeSepprefVertEdgeOffresetEdgesresizeParentrootsortEdgesuseBoundingBoxvisited
Methods
adjustParentsapplyarrangeGroupsattachParentbridgecreateLinecreateNodedfsexecutefindRankHeightsgetConstraintgetGraphgetParentOffsetgetVertexBoundshorizontalLayoutisAncestorisEdgeIgnoredisHorizontalisVertexIgnoredisVertexMovablejoinlayoutlayoutLeaflocalEdgeProcessingmergemoveCellmoveNodeoffsetprocessNodeOutgoingresizeCellsetCellHeightssetEdgePointssetEdgeStyleEnabledsetOrthogonalEdgesetVertexLocationsortOutgoingEdgestraverseverticalLayout
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.