mxLayoutManager

Implements a layout manager that runs a given layout after any changes to the graph

Example

var layoutMgr = new mxLayoutManager(graph);
layoutMgr.getLayout = function(cell, eventName)
{
  return layout;
};

See getLayout for a description of the possible eventNames.

Summary
mxLayoutManager
Events
mxEvent.LAYOUT_CELLSFires between begin- and endUpdate after all cells have been layouted in layoutCells.
Functions
mxLayoutManagerConstructs a new automatic layout for the given graph.
Variables
graphReference to the enclosing mxGraph.
bubblingSpecifies if the layout should bubble along the cell hierarchy.
enabledSpecifies if event handling is enabled.
undoHandlerHolds the function that handles the endUpdate event.
moveHandlerHolds the function that handles the move event.
resizeHandlerHolds the function that handles the resize event.
Functions
isEnabledReturns true if events are handled.
setEnabledEnables or disables event handling.
isBubblingReturns true if a layout should bubble, that is, if the parent layout should be executed whenever a cell layout (layout of the children of a cell) has been executed.
setBubblingSets bubbling.
getGraphReturns the graph that this layout operates on.
setGraphSets the graph that the layouts operate on.
hasLayoutReturns true if the given cell has a layout.
getLayoutReturns the layout for the given cell and eventName.
beforeUndoCalled from undoHandler.
cellsMovedCalled from moveHandler.
cellsResizedCalled from resizeHandler.
getCellsForChangesReturns the cells for which a layout should be executed.
getCellsForChangeExecutes all layouts which have been scheduled during the changes.
addCellsWithLayoutAdds all ancestors of the given cell that have a layout.
addAncestorsWithLayoutAdds all ancestors of the given cell that have a layout.
addDescendantsWithLayoutAdds all descendants of the given cell that have a layout.
executeLayoutForCellsExecutes all layouts for the given cells in two phases: In the first phase layouts for child cells are executed before layouts for parent cells with mxEvent.BEGIN_UPDATE, in the second phase layouts for parent cells are executed before layouts for child cells with mxEvent.END_UPDATE.
layoutCellsExecutes all layouts which have been scheduled during the changes.
executeLayoutExecutes the given layout on the given parent.
destroyRemoves all handlers from the graph and deletes the reference to it.

Events

mxEvent.LAYOUT_CELLS

Fires between begin- and endUpdate after all cells have been layouted in layoutCells.  The <code>cells</code> property contains all cells that have been passed to layoutCells.

Functions

mxLayoutManager

function mxLayoutManager(graph)

Constructs a new automatic layout for the given graph.

Arguments

graphReference to the enclosing graph.

Variables

graph

mxLayoutManager.prototype.graph

Reference to the enclosing mxGraph.

bubbling

mxLayoutManager.prototype.bubbling

Specifies if the layout should bubble along the cell hierarchy.  Default is true.

enabled

mxLayoutManager.prototype.enabled

Specifies if event handling is enabled.  Default is true.

undoHandler

mxLayoutManager.prototype.undoHandler

Holds the function that handles the endUpdate event.

moveHandler

mxLayoutManager.prototype.moveHandler

Holds the function that handles the move event.

resizeHandler

mxLayoutManager.prototype.resizeHandler

Holds the function that handles the resize event.

Functions

isEnabled

mxLayoutManager.prototype.isEnabled = function()

Returns true if events are handled.  This implementation returns enabled.

setEnabled

mxLayoutManager.prototype.setEnabled = function(enabled)

Enables or disables event handling.  This implementation updates enabled.

Parameters

enabledBoolean that specifies the new enabled state.

isBubbling

mxLayoutManager.prototype.isBubbling = function()

Returns true if a layout should bubble, that is, if the parent layout should be executed whenever a cell layout (layout of the children of a cell) has been executed.  This implementation returns bubbling.

setBubbling

mxLayoutManager.prototype.setBubbling = function(value)

Sets bubbling.

getGraph

mxLayoutManager.prototype.getGraph = function()

Returns the graph that this layout operates on.

setGraph

mxLayoutManager.prototype.setGraph = function(graph)

Sets the graph that the layouts operate on.

hasLayout

mxLayoutManager.prototype.hasLayout = function(cell)

Returns true if the given cell has a layout.  This implementation invokes getLayout with mxEvent.LAYOUT_CELLS as the eventName.  Override this if creating layouts in getLayout is expensive and return true if getLayout will return a layout for the given cell for mxEvent.BEGIN_UPDATE or mxEvent.END_UPDATE.

getLayout

mxLayoutManager.prototype.getLayout = function(cell,
eventName)

Returns the layout for the given cell and eventName.  Possible event names are mxEvent.MOVE_CELLS and mxEvent.RESIZE_CELLS when cells are moved or resized and mxEvent.BEGIN_UPDATE or mxEvent.END_UPDATE for the bottom up and top down phases after changes to the graph model.  mxEvent.LAYOUT_CELLS is used to check if a layout exists for the given cell.  This is called from hasLayout.

beforeUndo

mxLayoutManager.prototype.beforeUndo = function(undoableEdit)

Called from undoHandler.

Parameters

cellArray of mxCells that have been moved.
evtMouse event that represents the mousedown.

cellsMoved

mxLayoutManager.prototype.cellsMoved = function(cells,
evt)

Called from moveHandler.

Parameters

cellArray of mxCells that have been moved.
evtMouse event that represents the mousedown.

cellsResized

mxLayoutManager.prototype.cellsResized = function(cells,
bounds,
prev)

Called from resizeHandler.

Parameters

cellArray of mxCells that have been resized.
boundsmxRectangle taht represents the new bounds.

getCellsForChanges

mxLayoutManager.prototype.getCellsForChanges = function(changes)

Returns the cells for which a layout should be executed.

getCellsForChange

mxLayoutManager.prototype.getCellsForChange = function(change)

Executes all layouts which have been scheduled during the changes.

addCellsWithLayout

mxLayoutManager.prototype.addCellsWithLayout = function(cell,
result)

Adds all ancestors of the given cell that have a layout.

addAncestorsWithLayout

mxLayoutManager.prototype.addAncestorsWithLayout = function(cell,
result)

Adds all ancestors of the given cell that have a layout.

addDescendantsWithLayout

mxLayoutManager.prototype.addDescendantsWithLayout = function(cell,
result)

Adds all descendants of the given cell that have a layout.

executeLayoutForCells

mxLayoutManager.prototype.executeLayoutForCells = function(cells)

Executes all layouts for the given cells in two phases: In the first phase layouts for child cells are executed before layouts for parent cells with mxEvent.BEGIN_UPDATE, in the second phase layouts for parent cells are executed before layouts for child cells with mxEvent.END_UPDATE.

layoutCells

mxLayoutManager.prototype.layoutCells = function(cells,
bubble)

Executes all layouts which have been scheduled during the changes.

executeLayout

mxLayoutManager.prototype.executeLayout = function(cell,
bubble)

Executes the given layout on the given parent.

destroy

mxLayoutManager.prototype.destroy = function()

Removes all handlers from the graph and deletes the reference to it.

mxLayoutManager.prototype.layoutCells = function(cells,
bubble)
Executes all layouts which have been scheduled during the changes.
function mxLayoutManager(graph)
Constructs a new automatic layout for the given graph.
mxLayoutManager.prototype.graph
Reference to the enclosing mxGraph.
Extends mxEventSource to implement a graph component for the browser.
mxLayoutManager.prototype.bubbling
Specifies if the layout should bubble along the cell hierarchy.
mxLayoutManager.prototype.enabled
Specifies if event handling is enabled.
mxLayoutManager.prototype.undoHandler
Holds the function that handles the endUpdate event.
mxLayoutManager.prototype.moveHandler
Holds the function that handles the move event.
mxLayoutManager.prototype.resizeHandler
Holds the function that handles the resize event.
mxLayoutManager.prototype.isEnabled = function()
Returns true if events are handled.
mxLayoutManager.prototype.setEnabled = function(enabled)
Enables or disables event handling.
mxLayoutManager.prototype.isBubbling = function()
Returns true if a layout should bubble, that is, if the parent layout should be executed whenever a cell layout (layout of the children of a cell) has been executed.
mxLayoutManager.prototype.setBubbling = function(value)
Sets bubbling.
mxLayoutManager.prototype.getGraph = function()
Returns the graph that this layout operates on.
mxLayoutManager.prototype.setGraph = function(graph)
Sets the graph that the layouts operate on.
mxLayoutManager.prototype.hasLayout = function(cell)
Returns true if the given cell has a layout.
mxLayoutManager.prototype.getLayout = function(cell,
eventName)
Returns the layout for the given cell and eventName.
mxLayoutManager.prototype.beforeUndo = function(undoableEdit)
Called from undoHandler.
mxLayoutManager.prototype.cellsMoved = function(cells,
evt)
Called from moveHandler.
mxLayoutManager.prototype.cellsResized = function(cells,
bounds,
prev)
Called from resizeHandler.
mxLayoutManager.prototype.getCellsForChanges = function(changes)
Returns the cells for which a layout should be executed.
mxLayoutManager.prototype.getCellsForChange = function(change)
Executes all layouts which have been scheduled during the changes.
mxLayoutManager.prototype.addCellsWithLayout = function(cell,
result)
Adds all ancestors of the given cell that have a layout.
mxLayoutManager.prototype.addAncestorsWithLayout = function(cell,
result)
Adds all ancestors of the given cell that have a layout.
mxLayoutManager.prototype.addDescendantsWithLayout = function(cell,
result)
Adds all descendants of the given cell that have a layout.
mxLayoutManager.prototype.executeLayoutForCells = function(cells)
Executes all layouts for the given cells in two phases: In the first phase layouts for child cells are executed before layouts for parent cells with mxEvent.BEGIN_UPDATE, in the second phase layouts for parent cells are executed before layouts for child cells with mxEvent.END_UPDATE.
BEGIN_UPDATE: 'beginUpdate'
Specifies the event name for beginUpdate.
END_UPDATE: 'endUpdate'
Specifies the event name for endUpdate.
mxLayoutManager.prototype.executeLayout = function(cell,
bubble)
Executes the given layout on the given parent.
mxLayoutManager.prototype.destroy = function()
Removes all handlers from the graph and deletes the reference to it.
Fires between begin- and endUpdate after all cells have been layouted in layoutCells.
MOVE_CELLS: 'moveCells'
Specifies the event name for moveCells.
RESIZE_CELLS: 'resizeCells'
Specifies the event name for resizeCells.
Cells are the elements of the graph model.
Extends mxPoint to implement a 2-dimensional rectangle with double precision coordinates.
Close