mxGraphLayout

Base class for all layout algorithms in mxGraph.  Main public functions are moveCell for handling a moved cell within a layouted parent, and execute for running the layout on a given parent cell.

Known Subclasses

mxCircleLayout, mxCompactTreeLayout, mxCompositeLayout, mxFastOrganicLayout, mxParallelEdgeLayout, mxPartitionLayout, mxStackLayout

Summary
mxGraphLayoutBase class for all layout algorithms in mxGraph.
Functions
mxGraphLayoutConstructs a new layout using the given layouts.
Variables
graphReference to the enclosing mxGraph.
useBoundingBoxBoolean indicating if the bounding box of the label should be used if its available.
parentThe parent cell of the layout, if any
Functions
moveCellNotified when a cell is being moved in a parent that has automatic layout to update the cell state (eg.
resizeCellNotified when a cell is being resized in a parent that has automatic layout to update the other cells in the layout.
executeExecutes the layout algorithm for the children of the given parent.
getGraphReturns the graph that this layout operates on.
getConstraintReturns the constraint for the given key and cell.
traverseTraverses the (directed) graph invoking the given function for each visited vertex and edge.
isAncestorReturns true if the given parent is an ancestor of the given child.
isVertexMovableReturns a boolean indicating if the given mxCell is movable or bendable by the algorithm.
isVertexIgnoredReturns a boolean indicating if the given mxCell should be ignored by the algorithm.
isEdgeIgnoredReturns a boolean indicating if the given mxCell should be ignored by the algorithm.
setEdgeStyleEnabledDisables or enables the edge style of the given edge.
setOrthogonalEdgeDisables or enables orthogonal end segments of the given edge.
getParentOffsetDetermines the offset of the given parent to the parent of the layout
setEdgePointsReplaces the array of mxPoints in the geometry of the given edge with the given array of mxPoints.
setVertexLocationSets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true.
getVertexBoundsReturns an mxRectangle that defines the bounds of the given cell or the bounding box if useBoundingBox is true.
arrangeGroupsShortcut to mxGraph.updateGroupBounds with moveGroup set to true.
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

mxGraphLayout

function mxGraphLayout(graph)

Constructs a new layout using the given layouts.

Arguments

graphEnclosing

Variables

graph

mxGraphLayout.prototype.graph

Reference to the enclosing mxGraph.

useBoundingBox

mxGraphLayout.prototype.useBoundingBox

Boolean indicating if the bounding box of the label should be used if its available.  Default is true.

parent

mxGraphLayout.prototype.parent

The parent cell of the layout, if any

Functions

moveCell

mxGraphLayout.prototype.moveCell = function(cell,
x,
y)

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

cellmxCell which has been moved.
xX-coordinate of the new cell location.
yY-coordinate of the new cell location.

resizeCell

mxGraphLayout.prototype.resizeCell = function(cell,
bounds)

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

cellmxCell which has been moved.
boundsmxRectangle that represents the new cell bounds.

execute

mxGraphLayout.prototype.execute = function(parent)

Executes the layout algorithm for the children of the given parent.

Parameters

parentmxCell whose children should be layed out.

getGraph

mxGraphLayout.prototype.getGraph = function()

Returns the graph that this layout operates on.

getConstraint

mxGraphLayout.prototype.getConstraint = function(key,
cell,
edge,
source)

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

keyKey of the constraint to be returned.
cellmxCell whose constraint should be returned.
edgeOptional mxCell that represents the connection whose constraint should be returned.  Default is null.
sourceOptional boolean that specifies if the connection is incoming or outgoing.  Default is null.

traverse

mxGraphLayout.traverse = function(vertex,
directed,
func,
edge,
visited)

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

mxLog.show();
let cell = graph.getSelectionCell();
graph.traverse(cell, false, function(vertex, edge)
{
  mxLog.debug(graph.getLabel(vertex));
});

Parameters

vertexmxCell that represents the vertex where the traversal starts.
directedOptional boolean indicating if edges should only be traversed from source to target.  Default is true.
funcVisitor function that takes the current vertex and the incoming edge as arguments.  The traversal stops if the function returns false.
edgeOptional mxCell that represents the incoming edge.  This is null for the first step of the traversal.
visitedOptional mxDictionary of cell paths for the visited cells.

isAncestor

mxGraphLayout.prototype.isAncestor = function(parent,
child,
traverseAncestors)

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

Parameters

parentmxCell that specifies the parent.
childmxCell that specifies the child.
traverseAncestorsboolean whether to

isVertexMovable

mxGraphLayout.prototype.isVertexMovable = function(cell)

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

Parameters

cellmxCell whose movable state should be returned.

isVertexIgnored

mxGraphLayout.prototype.isVertexIgnored = function(vertex)

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

Parameters

vertexmxCell whose ignored state should be returned.

isEdgeIgnored

mxGraphLayout.prototype.isEdgeIgnored = function(edge)

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

Parameters

cellmxCell whose ignored state should be returned.

setEdgeStyleEnabled

mxGraphLayout.prototype.setEdgeStyleEnabled = function(edge,
value)

Disables or enables the edge style of the given edge.

setOrthogonalEdge

mxGraphLayout.prototype.setOrthogonalEdge = function(edge,
value)

Disables or enables orthogonal end segments of the given edge.

getParentOffset

mxGraphLayout.prototype.getParentOffset = function(parent)

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

setEdgePoints

mxGraphLayout.prototype.setEdgePoints = function(edge,
points)

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

setVertexLocation

mxGraphLayout.prototype.setVertexLocation = function(cell,
x,
y)

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

cellmxCell whose geometry is to be set.
xInteger that defines the x-coordinate of the new location.
yInteger that defines the y-coordinate of the new location.

getVertexBounds

mxGraphLayout.prototype.getVertexBounds = function(cell)

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

arrangeGroups

mxGraphLayout.prototype.arrangeGroups = function(cells,
border,
topBorder,
rightBorder,
bottomBorder,
leftBorder)

Shortcut to mxGraph.updateGroupBounds with moveGroup set to true.

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.

function mxGraphLayout(graph)
Constructs a new layout using the given layouts.
mxGraphLayout.prototype.graph
Reference to the enclosing mxGraph.
Extends mxEventSource to implement a graph component for the browser.
mxGraphLayout.prototype.useBoundingBox
Boolean indicating if the bounding box of the label should be used if its available.
mxGraphLayout.prototype.parent
The parent cell of the layout, if any
mxGraphLayout.prototype.moveCell = function(cell,
x,
y)
Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg.
mxGraphLayout.prototype.resizeCell = function(cell,
bounds)
Notified when a cell is being resized in a parent that has automatic layout to update the other cells in the layout.
mxGraphLayout.prototype.execute = function(parent)
Executes the layout algorithm for the children of the given parent.
mxGraphLayout.prototype.getGraph = function()
Returns the graph that this layout operates on.
mxGraphLayout.prototype.getConstraint = function(key,
cell,
edge,
source)
Returns the constraint for the given key and cell.
mxGraphLayout.traverse = function(vertex,
directed,
func,
edge,
visited)
Traverses the (directed) graph invoking the given function for each visited vertex and edge.
mxGraphLayout.prototype.isAncestor = function(parent,
child,
traverseAncestors)
Returns true if the given parent is an ancestor of the given child.
mxGraphLayout.prototype.isVertexMovable = function(cell)
Returns a boolean indicating if the given mxCell is movable or bendable by the algorithm.
Cells are the elements of the graph model.
mxGraphLayout.prototype.isVertexIgnored = function(vertex)
Returns a boolean indicating if the given mxCell should be ignored by the algorithm.
mxGraphLayout.prototype.isEdgeIgnored = function(edge)
Returns a boolean indicating if the given mxCell should be ignored by the algorithm.
mxGraphLayout.prototype.setEdgeStyleEnabled = function(edge,
value)
Disables or enables the edge style of the given edge.
mxGraphLayout.prototype.setOrthogonalEdge = function(edge,
value)
Disables or enables orthogonal end segments of the given edge.
mxGraphLayout.prototype.getParentOffset = function(parent)
Determines the offset of the given parent to the parent of the layout
mxGraphLayout.prototype.setEdgePoints = function(edge,
points)
Replaces the array of mxPoints in the geometry of the given edge with the given array of mxPoints.
mxGraphLayout.prototype.setVertexLocation = function(cell,
x,
y)
Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true.
mxGraphLayout.prototype.getVertexBounds = function(cell)
Returns an mxRectangle that defines the bounds of the given cell or the bounding box if useBoundingBox is true.
Extends mxPoint to implement a 2-dimensional rectangle with double precision coordinates.
mxGraphLayout.prototype.arrangeGroups = function(cells,
border,
topBorder,
rightBorder,
bottomBorder,
leftBorder)
Shortcut to mxGraph.updateGroupBounds with moveGroup set to true.
mxGraph.prototype.updateGroupBounds = function(cells,
border,
moveGroup,
topBorder,
rightBorder,
bottomBorder,
leftBorder)
Updates the bounds of the given groups to include all children and returns the passed-in cells.
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.
Extends mxGraphLayout to implement a circluar layout for a given radius.
Extends mxGraphLayout to implement a compact tree (Moen) algorithm.
Allows to compose multiple layouts into a single layout.
Extends mxGraphLayout to implement a fast organic layout algorithm.
Extends mxGraphLayout for arranging parallel edges.
Extends mxGraphLayout for partitioning the parent cell vertically or horizontally by filling the complete area with the child cells.
Extends mxGraphLayout to create a horizontal or vertical stack of the child vertices.
A wrapper class for an associative array with object keys.
Close