mxCompactTreeLayout

Extends mxGraphLayout 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

var layout = new mxCompactTreeLayout(graph);
layout.execute(graph.getDefaultParent());
Summary
mxCompactTreeLayoutExtends mxGraphLayout to implement a compact tree (Moen) algorithm.
Functions
mxCompactTreeLayoutConstructs a new compact tree layout for the specified graph and orientation.
Variables
horizontalSpecifies the orientation of the layout.
invertSpecifies if edge directions should be inverted.
resizeParentIf the parents should be resized to match the width/height of the children.
groupPaddingPadding added to resized parents.
parentsChangedA set of the parents that need updating based on children process as part of the layout.
moveTreeSpecifies if the tree should be moved to the top, left corner if it is inside a top-level layer.
levelDistanceHolds the levelDistance.
nodeDistanceHolds the nodeDistance.
resetEdgesSpecifies if all edge points of traversed edges should be removed.
prefHozEdgeSepThe preferred horizontal distance between edges exiting a vertex.
prefVertEdgeOffThe preferred vertical offset between edges exiting a vertex.
minEdgeJettyThe minimum distance for an edge jetty from a vertex.
channelBufferThe size of the vertical buffer in the center of inter-rank channels where edge control points should not be placed.
edgeRoutingWhether or not to apply the internal tree edge routing.
sortEdgesSpecifies if edges should be sorted according to the order of their opposite terminal cell in the model.
alignRanksWhether or not the tops of cells in each rank should be aligned across the rank
maxRankHeightAn array of the maximum height of cells (relative to the layout direction) per rank
Functions
isVertexIgnoredReturns a boolean indicating if the given mxCell should be ignored as a vertex.
isHorizontalReturns horizontal.
executeImplements mxGraphLayout.execute.
moveNodeMoves the specified node and all of its children by the given amount.
sortOutgoingEdgesCalled if sortEdges is true to sort the array of outgoing edges in place.
findRankHeightsStores the maximum height (relative to the layout direction) of cells in each rank
setCellHeightsSet the cells heights (relative to the layout direction) when the tops of each rank are to be aligned
dfsDoes a depth first search starting at the specified cell.
layoutStarts the actual compact tree layout algorithm at the given node.
horizontalLayout
verticalLayout
attachParent
layoutLeaf
join
merge
offset
bridge
createNode
apply
createLine
adjustParentsAdjust parent cells whose child geometries have changed.
localEdgeProcessingMoves the specified node and all of its children by the given amount.
localEdgeProcessingSeparates the x position of edges as they connect to vertices
WeightedCellSorterA utility class used to track cells whilst sorting occurs on the weighted sum of their connected edges.
Functions
WeightedCellSorterConstructs a new weighted cell sorted for the given cell and weight.
Variables
weightedValueThe weighted value of the cell stored.
nudgeWhether or not to flip equal weight values.
visitedWhether or not this cell has been visited in the current assignment.
rankIndexThe index this cell is in the model rank.
cellThe cell whose median value is being calculated.
Functions
compareCompares two WeightedCellSorters.

Functions

mxCompactTreeLayout

function mxCompactTreeLayout(graph,
horizontal,
invert)

Constructs a new compact tree layout for the specified graph and orientation.

Variables

horizontal

mxCompactTreeLayout.prototype.horizontal

Specifies the orientation of the layout.  Default is true.

invert

mxCompactTreeLayout.prototype.invert

Specifies if edge directions should be inverted.  Default is false.

resizeParent

mxCompactTreeLayout.prototype.resizeParent

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

groupPadding

mxCompactTreeLayout.prototype.groupPadding

Padding added to resized parents.

parentsChanged

mxCompactTreeLayout.prototype.parentsChanged

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

moveTree

mxCompactTreeLayout.prototype.moveTree

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

levelDistance

mxCompactTreeLayout.prototype.levelDistance

Holds the levelDistance.  Default is 10.

nodeDistance

mxCompactTreeLayout.prototype.nodeDistance

Holds the nodeDistance.  Default is 20.

resetEdges

mxCompactTreeLayout.prototype.resetEdges

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

prefHozEdgeSep

mxCompactTreeLayout.prototype.prefHozEdgeSep

The preferred horizontal distance between edges exiting a vertex.

prefVertEdgeOff

mxCompactTreeLayout.prototype.prefVertEdgeOff

The preferred vertical offset between edges exiting a vertex.

minEdgeJetty

mxCompactTreeLayout.prototype.minEdgeJetty

The minimum distance for an edge jetty from a vertex.

channelBuffer

mxCompactTreeLayout.prototype.channelBuffer

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

edgeRouting

mxCompactTreeLayout.prototype.edgeRouting

Whether or not to apply the internal tree edge routing.

sortEdges

mxCompactTreeLayout.prototype.sortEdges

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

alignRanks

mxCompactTreeLayout.prototype.alignRanks

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

maxRankHeight

mxCompactTreeLayout.prototype.maxRankHeight

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

Functions

isVertexIgnored

mxCompactTreeLayout.prototype.isVertexIgnored = function(vertex)

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

Parameters

vertexmxCell whose ignored state should be returned.

isHorizontal

mxCompactTreeLayout.prototype.isHorizontal = function()

Returns horizontal.

execute

mxCompactTreeLayout.prototype.execute = function(parent,
root)

Implements mxGraphLayout.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

parentmxCell whose children should be laid out.
rootOptional mxCell that will be used as the root of the tree.

moveNode

mxCompactTreeLayout.prototype.moveNode = function(node,
dx,
dy)

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

sortOutgoingEdges

mxCompactTreeLayout.prototype.sortOutgoingEdges = function(source,
edges)

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

findRankHeights

mxCompactTreeLayout.prototype.findRankHeights = function(node,
rank)

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

setCellHeights

mxCompactTreeLayout.prototype.setCellHeights = function(node,
rank)

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

dfs

mxCompactTreeLayout.prototype.dfs = function(cell,
parent,
visited)

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

layout

mxCompactTreeLayout.prototype.layout = function(node)

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

horizontalLayout

mxCompactTreeLayout.prototype.horizontalLayout = function(node,
x0,
y0,
bounds)

verticalLayout

mxCompactTreeLayout.prototype.verticalLayout = function(node,
parent,
x0,
y0,
bounds)

attachParent

mxCompactTreeLayout.prototype.attachParent = function(node,
height)

layoutLeaf

mxCompactTreeLayout.prototype.layoutLeaf = function(node)

join

mxCompactTreeLayout.prototype.join = function(node)

merge

mxCompactTreeLayout.prototype.merge = function(p1,
p2)

offset

mxCompactTreeLayout.prototype.offset = function(p1,
p2,
a1,
a2,
b1,
b2)

bridge

mxCompactTreeLayout.prototype.bridge = function(line1,
x1,
y1,
line2,
x2,
y2)

createNode

mxCompactTreeLayout.prototype.createNode = function(cell)

apply

mxCompactTreeLayout.prototype.apply = function(node,
bounds)

createLine

mxCompactTreeLayout.prototype.createLine = function(dx,
dy,
next)

adjustParents

mxCompactTreeLayout.prototype.adjustParents = function()

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

localEdgeProcessing

mxCompactTreeLayout.prototype.localEdgeProcessing = function(node)

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

localEdgeProcessing

Separates the x position of edges as they connect to vertices

WeightedCellSorter

A utility class used to track cells whilst sorting occurs on the weighted sum of their connected edges.  Does not violate (x.compareTo(y)==0) == (x.equals(y))

Summary
Functions
WeightedCellSorterConstructs a new weighted cell sorted for the given cell and weight.
Variables
weightedValueThe weighted value of the cell stored.
nudgeWhether or not to flip equal weight values.
visitedWhether or not this cell has been visited in the current assignment.
rankIndexThe index this cell is in the model rank.
cellThe cell whose median value is being calculated.
Functions
compareCompares two WeightedCellSorters.

Functions

WeightedCellSorter

function WeightedCellSorter(cell,
weightedValue)

Constructs a new weighted cell sorted for the given cell and weight.

Variables

weightedValue

WeightedCellSorter.prototype.weightedValue

The weighted value of the cell stored.

nudge

WeightedCellSorter.prototype.nudge

Whether or not to flip equal weight values.

visited

WeightedCellSorter.prototype.visited

Whether or not this cell has been visited in the current assignment.

rankIndex

WeightedCellSorter.prototype.rankIndex

The index this cell is in the model rank.

cell

WeightedCellSorter.prototype.cell

The cell whose median value is being calculated.

Functions

compare

WeightedCellSorter.prototype.compare = function(a,
b)

Compares two WeightedCellSorters.

Base class for all layout algorithms in mxGraph.
function mxCompactTreeLayout(graph,
horizontal,
invert)
Constructs a new compact tree layout for the specified graph and orientation.
mxCompactTreeLayout.prototype.horizontal
Specifies the orientation of the layout.
mxCompactTreeLayout.prototype.invert
Specifies if edge directions should be inverted.
mxCompactTreeLayout.prototype.resizeParent
If the parents should be resized to match the width/height of the children.
mxCompactTreeLayout.prototype.groupPadding
Padding added to resized parents.
mxCompactTreeLayout.prototype.parentsChanged
A set of the parents that need updating based on children process as part of the layout.
mxCompactTreeLayout.prototype.moveTree
Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer.
mxCompactTreeLayout.prototype.levelDistance
Holds the levelDistance.
mxCompactTreeLayout.prototype.nodeDistance
Holds the nodeDistance.
mxCompactTreeLayout.prototype.resetEdges
Specifies if all edge points of traversed edges should be removed.
mxCompactTreeLayout.prototype.prefHozEdgeSep
The preferred horizontal distance between edges exiting a vertex.
mxCompactTreeLayout.prototype.prefVertEdgeOff
The preferred vertical offset between edges exiting a vertex.
mxCompactTreeLayout.prototype.minEdgeJetty
The minimum distance for an edge jetty from a vertex.
mxCompactTreeLayout.prototype.channelBuffer
The size of the vertical buffer in the center of inter-rank channels where edge control points should not be placed.
mxCompactTreeLayout.prototype.edgeRouting
Whether or not to apply the internal tree edge routing.
mxCompactTreeLayout.prototype.sortEdges
Specifies if edges should be sorted according to the order of their opposite terminal cell in the model.
mxCompactTreeLayout.prototype.alignRanks
Whether or not the tops of cells in each rank should be aligned across the rank
mxCompactTreeLayout.prototype.maxRankHeight
An array of the maximum height of cells (relative to the layout direction) per rank
mxCompactTreeLayout.prototype.isVertexIgnored = function(vertex)
Returns a boolean indicating if the given mxCell should be ignored as a vertex.
Cells are the elements of the graph model.
mxCompactTreeLayout.prototype.isHorizontal = function()
Returns horizontal.
mxCompactTreeLayout.prototype.execute = function(parent,
root)
Implements mxGraphLayout.execute.
mxGraphLayout.prototype.execute = function(parent)
Executes the layout algorithm for the children of the given parent.
mxCompactTreeLayout.prototype.moveNode = function(node,
dx,
dy)
Moves the specified node and all of its children by the given amount.
mxCompactTreeLayout.prototype.sortOutgoingEdges = function(source,
edges)
Called if sortEdges is true to sort the array of outgoing edges in place.
mxCompactTreeLayout.prototype.findRankHeights = function(node,
rank)
Stores the maximum height (relative to the layout direction) of cells in each rank
mxCompactTreeLayout.prototype.setCellHeights = function(node,
rank)
Set the cells heights (relative to the layout direction) when the tops of each rank are to be aligned
mxCompactTreeLayout.prototype.dfs = function(cell,
parent,
visited)
Does a depth first search starting at the specified cell.
mxCompactTreeLayout.prototype.layout = function(node)
Starts the actual compact tree layout algorithm at the given node.
mxCompactTreeLayout.prototype.horizontalLayout = function(node,
x0,
y0,
bounds)
mxCompactTreeLayout.prototype.verticalLayout = function(node,
parent,
x0,
y0,
bounds)
mxCompactTreeLayout.prototype.attachParent = function(node,
height)
mxCompactTreeLayout.prototype.layoutLeaf = function(node)
mxCompactTreeLayout.prototype.join = function(node)
mxCompactTreeLayout.prototype.merge = function(p1,
p2)
mxCompactTreeLayout.prototype.offset = function(p1,
p2,
a1,
a2,
b1,
b2)
mxCompactTreeLayout.prototype.bridge = function(line1,
x1,
y1,
line2,
x2,
y2)
mxCompactTreeLayout.prototype.createNode = function(cell)
mxCompactTreeLayout.prototype.apply = function(node,
bounds)
mxCompactTreeLayout.prototype.createLine = function(dx,
dy,
next)
mxCompactTreeLayout.prototype.adjustParents = function()
Adjust parent cells whose child geometries have changed.
mxCompactTreeLayout.prototype.localEdgeProcessing = function(node)
Moves the specified node and all of its children by the given amount.
function WeightedCellSorter(cell,
weightedValue)
Constructs a new weighted cell sorted for the given cell and weight.
WeightedCellSorter.prototype.weightedValue
The weighted value of the cell stored.
WeightedCellSorter.prototype.nudge
Whether or not to flip equal weight values.
WeightedCellSorter.prototype.visited
Whether or not this cell has been visited in the current assignment.
WeightedCellSorter.prototype.rankIndex
The index this cell is in the model rank.
WeightedCellSorter.prototype.cell
The cell whose median value is being calculated.
WeightedCellSorter.prototype.compare = function(a,
b)
Compares two WeightedCellSorters.
mxGraph.prototype.findTreeRoots = function(parent,
isolate,
invert)
Returns all children in the given parent which do not have incoming edges.
Close