mxGraphModel

Extends mxEventSource to implement a graph model.  The graph model acts as a wrapper around the cells which are in charge of storing the actual graph datastructure.  The model acts as a transactional wrapper with event notification for all changes, whereas the cells contain the atomic operations for updating the actual datastructure.

Layers

The cell hierarchy in the model must have a top-level root cell which contains the layers (typically one default layer), which in turn contain the top-level cells of the layers.  This means each cell is contained in a layer.  If no layers are required, then all new cells should be added to the default layer.

Layers are useful for hiding and showing groups of cells, or for placing groups of cells on top of other cells in the display.  To identify a layer, the isLayer function is used.  It returns true if the parent of the given cell is the root of the model.

Events

See events section for more details.  There is a new set of events for tracking transactional changes as they happen.  The events are called startEdit for the initial beginUpdate, executed for each executed change and endEdit for the terminal endUpdate.  The executed event contains a property called change which represents the change after execution.

Encoding the model

To encode a graph model, use the following code

var enc = new mxCodec();
var node = enc.encode(graph.getModel());

This will create an XML node that contains all the model information.

Encoding and decoding changes

For the encoding of changes, a graph model listener is required that encodes each change from the given array of changes.

model.addListener(mxEvent.CHANGE, function(sender, evt)
{
  var changes = evt.getProperty('edit').changes;
  var nodes = [];
  var codec = new mxCodec();

  for (var i = 0; i < changes.length; i++)
  {
    nodes.push(codec.encode(changes[i]));
  }
  // do something with the nodes
});

For the decoding and execution of changes, the codec needs a lookup function that allows it to resolve cell IDs as follows:

var codec = new mxCodec();
codec.lookup = function(id)
{
  return model.getCell(id);
}

For each encoded change (represented by a node), the following code can be used to carry out the decoding and create a change object.

var changes = [];
var change = codec.decode(node);
change.model = model;
change.execute();
changes.push(change);

The changes can then be dispatched using the model as follows.

var edit = new mxUndoableEdit(model, false);
edit.changes = changes;

edit.notify = function()
{
  edit.source.fireEvent(new mxEventObject(mxEvent.CHANGE,
     'edit', edit, 'changes', edit.changes));
  edit.source.fireEvent(new mxEventObject(mxEvent.NOTIFY,
     'edit', edit, 'changes', edit.changes));
}

model.fireEvent(new mxEventObject(mxEvent.UNDO, 'edit', edit));
model.fireEvent(new mxEventObject(mxEvent.CHANGE,
     'edit', edit, 'changes', changes));
Summary
mxGraphModelExtends mxEventSource to implement a graph model.
Events
mxEvent.CHANGEFires when an undoable edit is dispatched.
mxEvent.NOTIFYSame as mxEvent.CHANGE, this event can be used for classes that need to implement a sync mechanism between this model and, say, a remote model.
mxEvent.EXECUTEFires between begin- and endUpdate and after an atomic change was executed in the model.
mxEvent.EXECUTEDFires between START_EDIT and END_EDIT after an atomic change was executed.
mxEvent.BEGIN_UPDATEFires after the updateLevel was incremented in beginUpdate.
mxEvent.START_EDITFires after the updateLevel was changed from 0 to 1.
mxEvent.END_UPDATEFires after the updateLevel was decreased in endUpdate but before any notification or change dispatching.
mxEvent.END_EDITFires after the updateLevel was changed from 1 to 0.
mxEvent.BEFORE_UNDOFires before the change is dispatched after the update level has reached 0 in endUpdate.
mxEvent.UNDOFires after the change was dispatched in endUpdate.
Functions
mxGraphModelConstructs a new graph model.
Variables
rootHolds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.
cellsMaps from Ids to cells.
maintainEdgeParentSpecifies if edges should automatically be moved into the nearest common ancestor of their terminals.
ignoreRelativeEdgeParentSpecifies if relative edge parents should be ignored for finding the nearest common ancestors of an edge’s terminals.
createIdsSpecifies if the model should automatically create Ids for new cells.
prefixDefines the prefix of new Ids.
postfixDefines the postfix of new Ids.
nextIdSpecifies the next Id to be created.
currentEditHolds the changes for the current transaction.
updateLevelCounter for the depth of nested transactions.
endingUpdateTrue if the program flow is currently inside endUpdate.
Functions
clearSets a new root using createRoot.
isCreateIdsReturns createIds.
setCreateIdsSets createIds.
createRootCreates a new root cell with a default layer (child 0).
getCellReturns the mxCell for the specified Id or null if no cell can be found for the given Id.
filterCellsReturns the cells from the given array where the given filter function returns true.
getDescendantsReturns all descendants of the given cell and the cell itself in an array.
filterDescendantsVisits all cells recursively and applies the specified filter function to each cell.
getRootReturns the root of the model or the topmost parent of the given cell.
setRootSets the root of the model using mxRootChange and adds the change to the current transaction.
rootChangedInner callback to change the root of the model and update the internal datastructures, such as cells and nextId.
isRootReturns true if the given cell is the root of the model and a non-null value.
isLayerReturns true if isRoot returns true for the parent of the given cell.
isAncestorReturns true if the given parent is an ancestor of the given child.
containsReturns true if the model contains the given mxCell.
getParentReturns the parent of the given cell.
addAdds the specified child to the parent at the given index using mxChildChange and adds the change to the current transaction.
cellAddedInner callback to update cells when a cell has been added.
createIdHook method to create an Id for the specified cell.
updateEdgeParentsUpdates the parent for all edges that are connected to cell or one of its descendants using updateEdgeParent.
updateEdgeParentInner callback to update the parent of the specified mxCell to the nearest-common-ancestor of its two terminals.
getOriginReturns the absolute, accumulated origin for the children inside the given parent as an mxPoint.
getNearestCommonAncestorReturns the nearest common ancestor for the specified cells.
removeRemoves the specified cell from the model using mxChildChange and adds the change to the current transaction.
cellRemovedInner callback to update cells when a cell has been removed.
parentForCellChangedInner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent.
getChildCountReturns the number of children in the given cell.
getChildAtReturns the child of the given mxCell at the given index.
getChildrenReturns all children of the given mxCell as an array of mxCells.
getChildVerticesReturns the child vertices of the given parent.
getChildEdgesReturns the child edges of the given parent.
getChildCellsReturns the children of the given cell that are vertices and/or edges depending on the arguments.
getTerminalReturns the source or target mxCell of the given edge depending on the value of the boolean parameter.
setTerminalSets the source or target terminal of the given mxCell using mxTerminalChange and adds the change to the current transaction.
setTerminalsSets the source and target mxCell of the given mxCell in a single transaction using setTerminal for each end of the edge.
terminalForCellChangedInner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal.
getEdgeCountReturns the number of distinct edges connected to the given cell.
getEdgeAtReturns the edge of cell at the given index.
getDirectedEdgeCountReturns the number of incoming or outgoing edges, ignoring the given edge.
getConnectionsReturns all edges of the given cell without loops.
getIncomingEdgesReturns the incoming edges of the given cell without loops.
getOutgoingEdgesReturns the outgoing edges of the given cell without loops.
getEdgesReturns all distinct edges connected to this cell as a new array of mxCells.
getEdgesBetweenReturns all edges between the given source and target pair.
getOppositesReturns all opposite vertices wrt terminal for the given edges, only returning sources and/or targets as specified.
getTopmostCellsReturns the topmost cells of the hierarchy in an array that contains no descendants for each mxCell that it contains.
isVertexReturns true if the given cell is a vertex.
isEdgeReturns true if the given cell is an edge.
isConnectableReturns true if the given mxCell is connectable.
getValueReturns the user object of the given mxCell using mxCell.getValue.
setValueSets the user object of then given mxCell using mxValueChange and adds the change to the current transaction.
valueForCellChangedInner callback to update the user object of the given mxCell using mxCell.valueChanged and return the previous value, that is, the return value of mxCell.valueChanged.
getGeometryReturns the mxGeometry of the given mxCell.
setGeometrySets the mxGeometry of the given mxCell.
geometryForCellChangedInner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.
getStyleReturns the style of the given mxCell.
setStyleSets the style of the given mxCell using mxStyleChange and adds the change to the current transaction.
styleForCellChangedInner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.
isCollapsedReturns true if the given mxCell is collapsed.
setCollapsedSets the collapsed state of the given mxCell using mxCollapseChange and adds the change to the current transaction.
collapsedStateForCellChangedInner callback to update the collapsed state of the given mxCell using mxCell.setCollapsed and return the previous collapsed state.
isVisibleReturns true if the given mxCell is visible.
setVisibleSets the visible state of the given mxCell using mxVisibleChange and adds the change to the current transaction.
visibleStateForCellChangedInner callback to update the visible state of the given mxCell using mxCell.setCollapsed and return the previous visible state.
executeExecutes the given edit and fires events if required.
beginUpdateIncrements the updateLevel by one.
endUpdateDecrements the updateLevel by one and fires an <undo> event if the updateLevel reaches 0.
createUndoableEditCreates a new mxUndoableEdit that implements the notify function to fire a <change> and <notify> event through the mxUndoableEdit’s source.
mergeChildrenMerges the children of the given cell into the given target cell inside this model.
mergeChildrenClones the children of the source cell into the given target cell in this model and adds an entry to the mapping that maps from the source cell to the target cell with the same id or the clone of the source cell that was inserted into this model.
getParentsReturns an array that represents the set (no duplicates) of all parents for the given array of cells.
cloneCellReturns a deep clone of the given mxCell (including the children) which is created using cloneCells.
cloneCellsReturns an array of clones for the given array of mxCells.
cloneCellImplInner helper method for cloning cells recursively.
cellClonedHook for cloning the cell.
restoreCloneInner helper method for restoring the connections in a network of cloned cells.
mxRootChangeAction to change the root in a model.
Functions
mxRootChangeConstructs a change of the root in the specified model.
executeCarries out a change of the root using mxGraphModel.rootChanged.
mxChildChangeAction to add or remove a child in a model.
Functions
mxChildChangeConstructs a change of a child in the specified model.
executeChanges the parent of <child> using mxGraphModel.parentForCellChanged and removes or restores the cell’s connections.
disconnectDisconnects the given cell recursively from its terminals and stores the previous terminal in the cell’s terminals.
mxTerminalChangeAction to change a terminal in a model.
Functions
mxTerminalChangeConstructs a change of a terminal in the specified model.
executeChanges the terminal of <cell> to <previous> using mxGraphModel.terminalForCellChanged.
mxValueChangeAction to change a user object in a model.
Functions
mxValueChangeConstructs a change of a user object in the specified model.
executeChanges the value of <cell> to <previous> using mxGraphModel.valueForCellChanged.
mxStyleChangeAction to change a cell’s style in a model.
Functions
mxStyleChangeConstructs a change of a style in the specified model.
executeChanges the style of <cell> to <previous> using mxGraphModel.styleForCellChanged.
mxGeometryChangeAction to change a cell’s geometry in a model.
Functions
mxGeometryChangeConstructs a change of a geometry in the specified model.
executeChanges the geometry of <cell> ro <previous> using mxGraphModel.geometryForCellChanged.
mxCollapseChangeAction to change a cell’s collapsed state in a model.
Functions
mxCollapseChangeConstructs a change of a collapsed state in the specified model.
executeChanges the collapsed state of <cell> to <previous> using mxGraphModel.collapsedStateForCellChanged.
mxVisibleChangeAction to change a cell’s visible state in a model.
Functions
mxVisibleChangeConstructs a change of a visible state in the specified model.
executeChanges the visible state of <cell> to <previous> using mxGraphModel.visibleStateForCellChanged.
mxCellAttributeChangeAction to change the attribute of a cell’s user object.
Functions
mxCellAttributeChangeConstructs a change of a attribute of the DOM node stored as the value of the given mxCell.
executeChanges the attribute of the cell’s user object by using mxCell.setAttribute.

Events

mxEvent.CHANGE

Fires when an undoable edit is dispatched.  The <code>edit</code> property contains the mxUndoableEdit.  The <code>changes</code> property contains the array of atomic changes inside the undoable edit.  The changes property is <strong>deprecated</strong>, please use edit.changes instead.

Example

For finding newly inserted cells, the following code can be used

graph.model.addListener(mxEvent.CHANGE, function(sender, evt)
{
  var changes = evt.getProperty('edit').changes;

  for (var i = 0; i < changes.length; i++)
  {
    var change = changes[i];

    if (change instanceof mxChildChange &&
      change.change.previous == null)
    {
      graph.startEditingAtCell(change.child);
      break;
    }
  }
});

mxEvent.NOTIFY

Same as mxEvent.CHANGE, this event can be used for classes that need to implement a sync mechanism between this model and, say, a remote model.  In such a setup, only local changes should trigger a notify event and all changes should trigger a change event.

mxEvent.EXECUTE

Fires between begin- and endUpdate and after an atomic change was executed in the model.  The <code>change</code> property contains the atomic change that was executed.

mxEvent.EXECUTED

Fires between START_EDIT and END_EDIT after an atomic change was executed.  The <code>change</code> property contains the change that was executed.

mxEvent.BEGIN_UPDATE

Fires after the updateLevel was incremented in beginUpdate.  This event contains no properties.

mxEvent.START_EDIT

Fires after the updateLevel was changed from 0 to 1.  This event contains no properties.

mxEvent.END_UPDATE

Fires after the updateLevel was decreased in endUpdate but before any notification or change dispatching.  The <code>edit</code> property contains the currentEdit.

mxEvent.END_EDIT

Fires after the updateLevel was changed from 1 to 0.  This event contains no properties.

mxEvent.BEFORE_UNDO

Fires before the change is dispatched after the update level has reached 0 in endUpdate.  The <code>edit</code> property contains the <curreneEdit>.

mxEvent.UNDO

Fires after the change was dispatched in endUpdate.  The <code>edit</code> property contains the currentEdit.

Functions

mxGraphModel

function mxGraphModel(root)

Constructs a new graph model.  If no root is specified then a new root mxCell with a default layer is created.

Parameters

rootmxCell that represents the root cell.

Variables

root

mxGraphModel.prototype.root

Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.  That is, the actual elements of the diagram are supposed to live in the third generation of cells and below.

cells

mxGraphModel.prototype.cells

Maps from Ids to cells.

maintainEdgeParent

mxGraphModel.prototype.maintainEdgeParent

Specifies if edges should automatically be moved into the nearest common ancestor of their terminals.  Default is true.

ignoreRelativeEdgeParent

mxGraphModel.prototype.ignoreRelativeEdgeParent

Specifies if relative edge parents should be ignored for finding the nearest common ancestors of an edge’s terminals.  Default is true.

createIds

mxGraphModel.prototype.createIds

Specifies if the model should automatically create Ids for new cells.  Default is true.

prefix

mxGraphModel.prototype.prefix

Defines the prefix of new Ids.  Default is an empty string.

postfix

mxGraphModel.prototype.postfix

Defines the postfix of new Ids.  Default is an empty string.

nextId

mxGraphModel.prototype.nextId

Specifies the next Id to be created.  Initial value is 0.

currentEdit

mxGraphModel.prototype.currentEdit

Holds the changes for the current transaction.  If the transaction is closed then a new object is created for this variable using createUndoableEdit.

updateLevel

mxGraphModel.prototype.updateLevel

Counter for the depth of nested transactions.  Each call to beginUpdate will increment this number and each call to endUpdate will decrement it.  When the counter reaches 0, the transaction is closed and the respective events are fired.  Initial value is 0.

endingUpdate

mxGraphModel.prototype.endingUpdate

True if the program flow is currently inside endUpdate.

Functions

clear

mxGraphModel.prototype.clear = function()

Sets a new root using createRoot.

isCreateIds

mxGraphModel.prototype.isCreateIds = function()

Returns createIds.

setCreateIds

mxGraphModel.prototype.setCreateIds = function(value)

Sets createIds.

createRoot

mxGraphModel.prototype.createRoot = function()

Creates a new root cell with a default layer (child 0).

getCell

mxGraphModel.prototype.getCell = function(id)

Returns the mxCell for the specified Id or null if no cell can be found for the given Id.

Parameters

idA string representing the Id of the cell.

filterCells

mxGraphModel.prototype.filterCells = function(cells,
filter)

Returns the cells from the given array where the given filter function returns true.

getDescendants

mxGraphModel.prototype.getDescendants = function(parent)

Returns all descendants of the given cell and the cell itself in an array.

Parameters

parentmxCell whose descendants should be returned.

filterDescendants

mxGraphModel.prototype.filterDescendants = function(filter,
parent)

Visits all cells recursively and applies the specified filter function to each cell.  If the function returns true then the cell is added to the resulting array.  The parent and result paramters are optional.  If parent is not specified then the recursion starts at root.

Example

The following example extracts all vertices from a given model:

var filter = function(cell)
{
 return model.isVertex(cell);
}
var vertices = model.filterDescendants(filter);

Parameters

filterJavaScript function that takes an mxCell as an argument and returns a boolean.
parentOptional mxCell that is used as the root of the recursion.

getRoot

mxGraphModel.prototype.getRoot = function(cell)

Returns the root of the model or the topmost parent of the given cell.

Parameters

cellOptional mxCell that specifies the child.

setRoot

mxGraphModel.prototype.setRoot = function(root)

Sets the root of the model using mxRootChange and adds the change to the current transaction.  This resets all datastructures in the model and is the preferred way of clearing an existing model.  Returns the new root.

Example

var root = new mxCell();
root.insert(new mxCell());
model.setRoot(root);

Parameters

rootmxCell that specifies the new root.

rootChanged

mxGraphModel.prototype.rootChanged = function(root)

Inner callback to change the root of the model and update the internal datastructures, such as cells and nextId.  Returns the previous root.

Parameters

rootmxCell that specifies the new root.

isRoot

mxGraphModel.prototype.isRoot = function(cell)

Returns true if the given cell is the root of the model and a non-null value.

Parameters

cellmxCell that represents the possible root.

isLayer

mxGraphModel.prototype.isLayer = function(cell)

Returns true if isRoot returns true for the parent of the given cell.

Parameters

cellmxCell that represents the possible layer.

isAncestor

mxGraphModel.prototype.isAncestor = function(parent,
child)

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

Parameters

parentmxCell that specifies the parent.
childmxCell that specifies the child.

contains

mxGraphModel.prototype.contains = function(cell)

Returns true if the model contains the given mxCell.

Parameters

cellmxCell that specifies the cell.

getParent

mxGraphModel.prototype.getParent = function(cell)

Returns the parent of the given cell.

Parameters

cellmxCell whose parent should be returned.

add

mxGraphModel.prototype.add = function(parent,
child,
index)

Adds the specified child to the parent at the given index using mxChildChange and adds the change to the current transaction.  If no index is specified then the child is appended to the parent’s array of children.  Returns the inserted child.

Parameters

parentmxCell that specifies the parent to contain the child.
childmxCell that specifies the child to be inserted.
indexOptional integer that specifies the index of the child.

cellAdded

mxGraphModel.prototype.cellAdded = function(cell)

Inner callback to update cells when a cell has been added.  This implementation resolves collisions by creating new Ids.  To change the ID of a cell after it was inserted into the model, use the following code:

(code delete model.cells[cell.getId()]; cell.setId(newId); model.cells[cell.getId()] = cell; (end)

If the change of the ID should be part of the command history, then the cell should be removed from the model and a clone with the new ID should be reinserted into the model instead.

Parameters

cellmxCell that specifies the cell that has been added.

createId

mxGraphModel.prototype.createId = function(cell)

Hook method to create an Id for the specified cell.  This implementation concatenates prefix, id and postfix to create the Id and increments nextId.  The cell is ignored by this implementation, but can be used in overridden methods to prefix the Ids with eg. the cell type.

Parameters

cellmxCell to create the Id for.

updateEdgeParents

mxGraphModel.prototype.updateEdgeParents = function(cell,
root)

Updates the parent for all edges that are connected to cell or one of its descendants using updateEdgeParent.

updateEdgeParent

mxGraphModel.prototype.updateEdgeParent = function(edge,
root)

Inner callback to update the parent of the specified mxCell to the nearest-common-ancestor of its two terminals.

Parameters

edgemxCell that specifies the edge.
rootmxCell that represents the current root of the model.

getOrigin

mxGraphModel.prototype.getOrigin = function(cell)

Returns the absolute, accumulated origin for the children inside the given parent as an mxPoint.

getNearestCommonAncestor

mxGraphModel.prototype.getNearestCommonAncestor = function(cell1,
cell2)

Returns the nearest common ancestor for the specified cells.

Parameters

cell1mxCell that specifies the first cell in the tree.
cell2mxCell that specifies the second cell in the tree.

remove

mxGraphModel.prototype.remove = function(cell)

Removes the specified cell from the model using mxChildChange and adds the change to the current transaction.  This operation will remove the cell and all of its children from the model.  Returns the removed cell.

Parameters

cellmxCell that should be removed.

cellRemoved

mxGraphModel.prototype.cellRemoved = function(cell)

Inner callback to update cells when a cell has been removed.

Parameters

cellmxCell that specifies the cell that has been removed.

parentForCellChanged

mxGraphModel.prototype.parentForCellChanged = function(cell,
parent,
index)

Inner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent.

Parameters

cellmxCell to update the parent for.
parentmxCell that specifies the new parent of the cell.
indexOptional integer that defines the index of the child in the parent’s child array.

getChildCount

mxGraphModel.prototype.getChildCount = function(cell)

Returns the number of children in the given cell.

Parameters

cellmxCell whose number of children should be returned.

getChildAt

mxGraphModel.prototype.getChildAt = function(cell,
index)

Returns the child of the given mxCell at the given index.

Parameters

cellmxCell that represents the parent.
indexInteger that specifies the index of the child to be returned.

getChildren

mxGraphModel.prototype.getChildren = function(cell)

Returns all children of the given mxCell as an array of mxCells.  The return value should be only be read.

Parameters

cellmxCell the represents the parent.

getChildVertices

mxGraphModel.prototype.getChildVertices = function(parent)

Returns the child vertices of the given parent.

Parameters

cellmxCell whose child vertices should be returned.

getChildEdges

mxGraphModel.prototype.getChildEdges = function(parent)

Returns the child edges of the given parent.

Parameters

cellmxCell whose child edges should be returned.

getChildCells

mxGraphModel.prototype.getChildCells = function(parent,
vertices,
edges)

Returns the children of the given cell that are vertices and/or edges depending on the arguments.

Parameters

cellmxCell the represents the parent.
verticesBoolean indicating if child vertices should be returned.  Default is false.
edgesBoolean indicating if child edges should be returned.  Default is false.

getTerminal

mxGraphModel.prototype.getTerminal = function(edge,
isSource)

Returns the source or target mxCell of the given edge depending on the value of the boolean parameter.

Parameters

edgemxCell that specifies the edge.
isSourceBoolean indicating which end of the edge should be returned.

setTerminal

mxGraphModel.prototype.setTerminal = function(edge,
terminal,
isSource)

Sets the source or target terminal of the given mxCell using mxTerminalChange and adds the change to the current transaction.  This implementation updates the parent of the edge using updateEdgeParent if required.

Parameters

edgemxCell that specifies the edge.
terminalmxCell that specifies the new terminal.
isSourceBoolean indicating if the terminal is the new source or target terminal of the edge.

setTerminals

mxGraphModel.prototype.setTerminals = function(edge,
source,
target)

Sets the source and target mxCell of the given mxCell in a single transaction using setTerminal for each end of the edge.

Parameters

edgemxCell that specifies the edge.
sourcemxCell that specifies the new source terminal.
targetmxCell that specifies the new target terminal.

terminalForCellChanged

mxGraphModel.prototype.terminalForCellChanged = function(edge,
terminal,
isSource)

Inner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal.

Parameters

edgemxCell that specifies the edge to be updated.
terminalmxCell that specifies the new terminal.
isSourceBoolean indicating if the terminal is the new source or target terminal of the edge.

getEdgeCount

mxGraphModel.prototype.getEdgeCount = function(cell)

Returns the number of distinct edges connected to the given cell.

Parameters

cellmxCell that represents the vertex.

getEdgeAt

mxGraphModel.prototype.getEdgeAt = function(cell,
index)

Returns the edge of cell at the given index.

Parameters

cellmxCell that specifies the vertex.
indexInteger that specifies the index of the edge to return.

getDirectedEdgeCount

mxGraphModel.prototype.getDirectedEdgeCount = function(cell,
outgoing,
ignoredEdge)

Returns the number of incoming or outgoing edges, ignoring the given edge.

Parameters

cellmxCell whose edge count should be returned.
outgoingBoolean that specifies if the number of outgoing or incoming edges should be returned.
ignoredEdgemxCell that represents an edge to be ignored.

getConnections

mxGraphModel.prototype.getConnections = function(cell)

Returns all edges of the given cell without loops.

Parameters

cellmxCell whose edges should be returned.

getIncomingEdges

mxGraphModel.prototype.getIncomingEdges = function(cell)

Returns the incoming edges of the given cell without loops.

Parameters

cellmxCell whose incoming edges should be returned.

getOutgoingEdges

mxGraphModel.prototype.getOutgoingEdges = function(cell)

Returns the outgoing edges of the given cell without loops.

Parameters

cellmxCell whose outgoing edges should be returned.

getEdges

mxGraphModel.prototype.getEdges = function(cell,
incoming,
outgoing,
includeLoops)

Returns all distinct edges connected to this cell as a new array of mxCells.  If at least one of incoming or outgoing is true, then loops are ignored, otherwise if both are false, then all edges connected to the given cell are returned including loops.

Parameters

cellmxCell that specifies the cell.
incomingOptional boolean that specifies if incoming edges should be returned.  Default is true.
outgoingOptional boolean that specifies if outgoing edges should be returned.  Default is true.
includeLoopsOptional boolean that specifies if loops should be returned.  Default is true.

getEdgesBetween

mxGraphModel.prototype.getEdgesBetween = function(source,
target,
directed)

Returns all edges between the given source and target pair.  If directed is true, then only edges from the source to the target are returned, otherwise, all edges between the two cells are returned.

Parameters

sourcemxCell that defines the source terminal of the edge to be returned.
targetmxCell that defines the target terminal of the edge to be returned.
directedOptional boolean that specifies if the direction of the edge should be taken into account.  Default is false.

getOpposites

mxGraphModel.prototype.getOpposites = function(edges,
terminal,
sources,
targets)

Returns all opposite vertices wrt terminal for the given edges, only returning sources and/or targets as specified.  The result is returned as an array of mxCells.

Parameters

edgesArray of mxCells that contain the edges to be examined.
terminalmxCell that specifies the known end of the edges.
sourcesBoolean that specifies if source terminals should be contained in the result.  Default is true.
targetsBoolean that specifies if target terminals should be contained in the result.  Default is true.

getTopmostCells

mxGraphModel.prototype.getTopmostCells = function(cells)

Returns the topmost cells of the hierarchy in an array that contains no descendants for each mxCell that it contains.  Duplicates should be removed in the cells array to improve performance.

Parameters

cellsArray of mxCells whose topmost ancestors should be returned.

isVertex

mxGraphModel.prototype.isVertex = function(cell)

Returns true if the given cell is a vertex.

Parameters

cellmxCell that represents the possible vertex.

isEdge

mxGraphModel.prototype.isEdge = function(cell)

Returns true if the given cell is an edge.

Parameters

cellmxCell that represents the possible edge.

isConnectable

mxGraphModel.prototype.isConnectable = function(cell)

Returns true if the given mxCell is connectable.  If <edgesConnectable> is false, then this function returns false for all edges else it returns the return value of mxCell.isConnectable.

Parameters

cellmxCell whose connectable state should be returned.

getValue

mxGraphModel.prototype.getValue = function(cell)

Returns the user object of the given mxCell using mxCell.getValue.

Parameters

cellmxCell whose user object should be returned.

setValue

mxGraphModel.prototype.setValue = function(cell,
value)

Sets the user object of then given mxCell using mxValueChange and adds the change to the current transaction.

Parameters

cellmxCell whose user object should be changed.
valueObject that defines the new user object.

valueForCellChanged

mxGraphModel.prototype.valueForCellChanged = function(cell,
value)

Inner callback to update the user object of the given mxCell using mxCell.valueChanged and return the previous value, that is, the return value of mxCell.valueChanged.

To change a specific attribute in an XML node, the following code can be used.

graph.getModel().valueForCellChanged = function(cell, value)
{
  var previous = cell.value.getAttribute('label');
  cell.value.setAttribute('label', value);

  return previous;
};

getGeometry

mxGraphModel.prototype.getGeometry = function(cell)

Returns the mxGeometry of the given mxCell.

Parameters

cellmxCell whose geometry should be returned.

setGeometry

mxGraphModel.prototype.setGeometry = function(cell,
geometry)

Sets the mxGeometry of the given mxCell.  The actual update of the cell is carried out in geometryForCellChanged.  The mxGeometryChange action is used to encapsulate the change.

Parameters

cellmxCell whose geometry should be changed.
geometrymxGeometry that defines the new geometry.

geometryForCellChanged

mxGraphModel.prototype.geometryForCellChanged = function(cell,
geometry)

Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.

getStyle

mxGraphModel.prototype.getStyle = function(cell)

Returns the style of the given mxCell.

Parameters

cellmxCell whose style should be returned.

setStyle

mxGraphModel.prototype.setStyle = function(cell,
style)

Sets the style of the given mxCell using mxStyleChange and adds the change to the current transaction.

Parameters

cellmxCell whose style should be changed.
styleString of the form [stylename;|key=value;] to specify the new cell style.

styleForCellChanged

mxGraphModel.prototype.styleForCellChanged = function(cell,
style)

Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.

Parameters

cellmxCell that specifies the cell to be updated.
styleString of the form [stylename;|key=value;] to specify the new cell style.

isCollapsed

mxGraphModel.prototype.isCollapsed = function(cell)

Returns true if the given mxCell is collapsed.

Parameters

cellmxCell whose collapsed state should be returned.

setCollapsed

mxGraphModel.prototype.setCollapsed = function(cell,
collapsed)

Sets the collapsed state of the given mxCell using mxCollapseChange and adds the change to the current transaction.

Parameters

cellmxCell whose collapsed state should be changed.
collapsedBoolean that specifies the new collpased state.

collapsedStateForCellChanged

mxGraphModel.prototype.collapsedStateForCellChanged = function(cell,
collapsed)

Inner callback to update the collapsed state of the given mxCell using mxCell.setCollapsed and return the previous collapsed state.

Parameters

cellmxCell that specifies the cell to be updated.
collapsedBoolean that specifies the new collpased state.

isVisible

mxGraphModel.prototype.isVisible = function(cell)

Returns true if the given mxCell is visible.

Parameters

cellmxCell whose visible state should be returned.

setVisible

mxGraphModel.prototype.setVisible = function(cell,
visible)

Sets the visible state of the given mxCell using mxVisibleChange and adds the change to the current transaction.

Parameters

cellmxCell whose visible state should be changed.
visibleBoolean that specifies the new visible state.

visibleStateForCellChanged

mxGraphModel.prototype.visibleStateForCellChanged = function(cell,
visible)

Inner callback to update the visible state of the given mxCell using mxCell.setCollapsed and return the previous visible state.

Parameters

cellmxCell that specifies the cell to be updated.
visibleBoolean that specifies the new visible state.

execute

mxGraphModel.prototype.execute = function(change)

Executes the given edit and fires events if required.  The edit object requires an execute function which is invoked.  The edit is added to the currentEdit between beginUpdate and endUpdate calls, so that events will be fired if this execute is an individual transaction, that is, if no previous beginUpdate calls have been made without calling endUpdate.  This implementation fires an execute event before executing the given change.

Parameters

changeObject that described the change.

beginUpdate

mxGraphModel.prototype.beginUpdate = function()

Increments the updateLevel by one.  The event notification is queued until updateLevel reaches 0 by use of endUpdate.

All changes on mxGraphModel are transactional, that is, they are executed in a single undoable change on the model (without transaction isolation).  Therefore, if you want to combine any number of changes into a single undoable change, you should group any two or more API calls that modify the graph model between beginUpdate and endUpdate calls as shown here:

var model = graph.getModel();
var parent = graph.getDefaultParent();
var index = model.getChildCount(parent);
model.beginUpdate();
try
{
  model.add(parent, v1, index);
  model.add(parent, v2, index+1);
}
finally
{
  model.endUpdate();
}

Of course there is a shortcut for appending a sequence of cells into the default parent:

graph.addCells([v1, v2]).

endUpdate

mxGraphModel.prototype.endUpdate = function()

Decrements the updateLevel by one and fires an <undo> event if the updateLevel reaches 0.  This function indirectly fires a <change> event by invoking the notify function on the currentEdit und then creates a new currentEdit using createUndoableEdit.

The <undo> event is fired only once per edit, whereas the <change> event is fired whenever the notify function is invoked, that is, on undo and redo of the edit.

createUndoableEdit

mxGraphModel.prototype.createUndoableEdit = function(significant)

Creates a new mxUndoableEdit that implements the notify function to fire a <change> and <notify> event through the mxUndoableEdit’s source.

Parameters

significantOptional boolean that specifies if the edit to be created is significant.  Default is true.

mergeChildren

mxGraphModel.prototype.mergeChildren = function(from,
to,
cloneAllEdges)

Merges the children of the given cell into the given target cell inside this model.  All cells are cloned unless there is a corresponding cell in the model with the same id, in which case the source cell is ignored and all edges are connected to the corresponding cell in this model.  Edges are considered to have no identity and are always cloned unless the cloneAllEdges flag is set to false, in which case edges with the same id in the target model are reconnected to reflect the terminals of the source edges.

mergeChildren

mxGraphModel.prototype.mergeChildrenImpl = function(from,
to,
cloneAllEdges,
mapping)

Clones the children of the source cell into the given target cell in this model and adds an entry to the mapping that maps from the source cell to the target cell with the same id or the clone of the source cell that was inserted into this model.

getParents

mxGraphModel.prototype.getParents = function(cells)

Returns an array that represents the set (no duplicates) of all parents for the given array of cells.

Parameters

cellsArray of cells whose parents should be returned.

cloneCell

mxGraphModel.prototype.cloneCell = function(cell,
includeChildren)

Returns a deep clone of the given mxCell (including the children) which is created using cloneCells.

Parameters

cellmxCell to be cloned.
includeChildrenOptional boolean indicating if the cells should be cloned with all descendants.  Default is true.

cloneCells

mxGraphModel.prototype.cloneCells = function(cells,
includeChildren,
mapping)

Returns an array of clones for the given array of mxCells.  Depending on the value of includeChildren, a deep clone is created for each cell.  Connections are restored based if the corresponding cell is contained in the passed in array.

Parameters

cellsArray of mxCell to be cloned.
includeChildrenOptional boolean indicating if the cells should be cloned with all descendants.  Default is true.
mappingOptional mapping for existing clones.

cloneCellImpl

mxGraphModel.prototype.cloneCellImpl = function(cell,
mapping,
includeChildren)

Inner helper method for cloning cells recursively.

cellCloned

mxGraphModel.prototype.cellCloned = function(cell)

Hook for cloning the cell.  This returns cell.clone() or any possible exceptions.

restoreClone

mxGraphModel.prototype.restoreClone = function(clone,
cell,
mapping)

Inner helper method for restoring the connections in a network of cloned cells.

mxRootChange

Action to change the root in a model.

Summary
Functions
mxRootChangeConstructs a change of the root in the specified model.
executeCarries out a change of the root using mxGraphModel.rootChanged.

Functions

mxRootChange

function mxRootChange(model,
root)

Constructs a change of the root in the specified model.

execute

mxRootChange.prototype.execute = function()

Carries out a change of the root using mxGraphModel.rootChanged.

mxChildChange

Action to add or remove a child in a model.

Summary
Functions
mxChildChangeConstructs a change of a child in the specified model.
executeChanges the parent of <child> using mxGraphModel.parentForCellChanged and removes or restores the cell’s connections.
disconnectDisconnects the given cell recursively from its terminals and stores the previous terminal in the cell’s terminals.

Functions

mxChildChange

function mxChildChange(model,
parent,
child,
index)

Constructs a change of a child in the specified model.

execute

mxChildChange.prototype.execute = function()

Changes the parent of <child> using mxGraphModel.parentForCellChanged and removes or restores the cell’s connections.

disconnect

Disconnects the given cell recursively from its terminals and stores the previous terminal in the cell’s terminals.

mxTerminalChange

Action to change a terminal in a model.

Summary
Functions
mxTerminalChangeConstructs a change of a terminal in the specified model.
executeChanges the terminal of <cell> to <previous> using mxGraphModel.terminalForCellChanged.

Functions

mxTerminalChange

function mxTerminalChange(model,
cell,
terminal,
source)

Constructs a change of a terminal in the specified model.

execute

mxTerminalChange.prototype.execute = function()

Changes the terminal of <cell> to <previous> using mxGraphModel.terminalForCellChanged.

mxValueChange

Action to change a user object in a model.

Summary
Functions
mxValueChangeConstructs a change of a user object in the specified model.
executeChanges the value of <cell> to <previous> using mxGraphModel.valueForCellChanged.

Functions

mxValueChange

function mxValueChange(model,
cell,
value)

Constructs a change of a user object in the specified model.

execute

mxValueChange.prototype.execute = function()

Changes the value of <cell> to <previous> using mxGraphModel.valueForCellChanged.

mxStyleChange

Action to change a cell’s style in a model.

Summary
Functions
mxStyleChangeConstructs a change of a style in the specified model.
executeChanges the style of <cell> to <previous> using mxGraphModel.styleForCellChanged.

Functions

mxStyleChange

function mxStyleChange(model,
cell,
style)

Constructs a change of a style in the specified model.

execute

mxStyleChange.prototype.execute = function()

Changes the style of <cell> to <previous> using mxGraphModel.styleForCellChanged.

mxGeometryChange

Action to change a cell’s geometry in a model.

Summary
Functions
mxGeometryChangeConstructs a change of a geometry in the specified model.
executeChanges the geometry of <cell> ro <previous> using mxGraphModel.geometryForCellChanged.

Functions

mxGeometryChange

function mxGeometryChange(model,
cell,
geometry)

Constructs a change of a geometry in the specified model.

execute

mxGeometryChange.prototype.execute = function()

Changes the geometry of <cell> ro <previous> using mxGraphModel.geometryForCellChanged.

mxCollapseChange

Action to change a cell’s collapsed state in a model.

Summary
Functions
mxCollapseChangeConstructs a change of a collapsed state in the specified model.
executeChanges the collapsed state of <cell> to <previous> using mxGraphModel.collapsedStateForCellChanged.

Functions

mxCollapseChange

function mxCollapseChange(model,
cell,
collapsed)

Constructs a change of a collapsed state in the specified model.

execute

mxCollapseChange.prototype.execute = function()

Changes the collapsed state of <cell> to <previous> using mxGraphModel.collapsedStateForCellChanged.

mxVisibleChange

Action to change a cell’s visible state in a model.

Summary
Functions
mxVisibleChangeConstructs a change of a visible state in the specified model.
executeChanges the visible state of <cell> to <previous> using mxGraphModel.visibleStateForCellChanged.

Functions

mxVisibleChange

function mxVisibleChange(model,
cell,
visible)

Constructs a change of a visible state in the specified model.

execute

mxVisibleChange.prototype.execute = function()

Changes the visible state of <cell> to <previous> using mxGraphModel.visibleStateForCellChanged.

mxCellAttributeChange

Action to change the attribute of a cell’s user object.  There is no method on the graph model that uses this action.  To use the action, you can use the code shown in the example below.

Example

To change the attributeName in the cell’s user object to attributeValue, use the following code:

model.beginUpdate();
try
{
  var edit = new mxCellAttributeChange(
    cell, attributeName, attributeValue);
  model.execute(edit);
}
finally
{
  model.endUpdate();
}
Summary
Functions
mxCellAttributeChangeConstructs a change of a attribute of the DOM node stored as the value of the given mxCell.
executeChanges the attribute of the cell’s user object by using mxCell.setAttribute.

Functions

mxCellAttributeChange

function mxCellAttributeChange(cell,
attribute,
value)

Constructs a change of a attribute of the DOM node stored as the value of the given mxCell.

execute

mxCellAttributeChange.prototype.execute = function()

Changes the attribute of the cell’s user object by using mxCell.setAttribute.

Base class for objects that dispatch named events.
Fires when an undoable edit is dispatched.
mxGraphModel.prototype.updateLevel
Counter for the depth of nested transactions.
mxGraphModel.prototype.beginUpdate = function()
Increments the updateLevel by one.
mxGraphModel.prototype.endUpdate = function()
Decrements the updateLevel by one and fires an undo event if the updateLevel reaches 0.
function mxGraphModel(root)
Constructs a new graph model.
mxGraphModel.prototype.root
Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.
mxGraphModel.prototype.cells
Maps from Ids to cells.
mxGraphModel.prototype.maintainEdgeParent
Specifies if edges should automatically be moved into the nearest common ancestor of their terminals.
mxGraphModel.prototype.ignoreRelativeEdgeParent
Specifies if relative edge parents should be ignored for finding the nearest common ancestors of an edge’s terminals.
mxGraphModel.prototype.createIds
Specifies if the model should automatically create Ids for new cells.
mxGraphModel.prototype.prefix
Defines the prefix of new Ids.
mxGraphModel.prototype.postfix
Defines the postfix of new Ids.
mxGraphModel.prototype.nextId
Specifies the next Id to be created.
mxGraphModel.prototype.currentEdit
Holds the changes for the current transaction.
mxGraphModel.prototype.endingUpdate
True if the program flow is currently inside endUpdate.
mxGraphModel.prototype.clear = function()
Sets a new root using createRoot.
mxGraphModel.prototype.createRoot = function()
Creates a new root cell with a default layer (child 0).
mxGraphModel.prototype.isCreateIds = function()
Returns createIds.
mxGraphModel.prototype.setCreateIds = function(value)
Sets createIds.
mxGraphModel.prototype.getCell = function(id)
Returns the mxCell for the specified Id or null if no cell can be found for the given Id.
Cells are the elements of the graph model.
mxGraphModel.prototype.filterCells = function(cells,
filter)
Returns the cells from the given array where the given filter function returns true.
mxGraphModel.prototype.getDescendants = function(parent)
Returns all descendants of the given cell and the cell itself in an array.
mxGraphModel.prototype.filterDescendants = function(filter,
parent)
Visits all cells recursively and applies the specified filter function to each cell.
mxGraphModel.prototype.getRoot = function(cell)
Returns the root of the model or the topmost parent of the given cell.
mxGraphModel.prototype.setRoot = function(root)
Sets the root of the model using mxRootChange and adds the change to the current transaction.
Action to change the root in a model.
mxGraphModel.prototype.rootChanged = function(root)
Inner callback to change the root of the model and update the internal datastructures, such as cells and nextId.
mxGraphModel.prototype.isRoot = function(cell)
Returns true if the given cell is the root of the model and a non-null value.
mxGraphModel.prototype.isLayer = function(cell)
Returns true if isRoot returns true for the parent of the given cell.
mxGraphModel.prototype.isAncestor = function(parent,
child)
Returns true if the given parent is an ancestor of the given child.
mxGraphModel.prototype.contains = function(cell)
Returns true if the model contains the given mxCell.
mxGraphModel.prototype.getParent = function(cell)
Returns the parent of the given cell.
mxGraphModel.prototype.add = function(parent,
child,
index)
Adds the specified child to the parent at the given index using mxChildChange and adds the change to the current transaction.
Action to add or remove a child in a model.
mxGraphModel.prototype.cellAdded = function(cell)
Inner callback to update cells when a cell has been added.
mxGraphModel.prototype.createId = function(cell)
Hook method to create an Id for the specified cell.
mxGraphModel.prototype.updateEdgeParents = function(cell,
root)
Updates the parent for all edges that are connected to cell or one of its descendants using updateEdgeParent.
mxGraphModel.prototype.updateEdgeParent = function(edge,
root)
Inner callback to update the parent of the specified mxCell to the nearest-common-ancestor of its two terminals.
mxGraphModel.prototype.getOrigin = function(cell)
Returns the absolute, accumulated origin for the children inside the given parent as an mxPoint.
Implements a 2-dimensional vector with double precision coordinates.
mxGraphModel.prototype.getNearestCommonAncestor = function(cell1,
cell2)
Returns the nearest common ancestor for the specified cells.
mxGraphModel.prototype.remove = function(cell)
Removes the specified cell from the model using mxChildChange and adds the change to the current transaction.
mxGraphModel.prototype.cellRemoved = function(cell)
Inner callback to update cells when a cell has been removed.
mxGraphModel.prototype.parentForCellChanged = function(cell,
parent,
index)
Inner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent.
mxCell.prototype.insert = function(child,
index)
Inserts the specified child into the child array at the specified index and updates the parent reference of the child.
mxGraphModel.prototype.getChildCount = function(cell)
Returns the number of children in the given cell.
mxGraphModel.prototype.getChildAt = function(cell,
index)
Returns the child of the given mxCell at the given index.
mxGraphModel.prototype.getChildren = function(cell)
Returns all children of the given mxCell as an array of mxCells.
mxGraphModel.prototype.getChildVertices = function(parent)
Returns the child vertices of the given parent.
mxGraphModel.prototype.getChildEdges = function(parent)
Returns the child edges of the given parent.
mxGraphModel.prototype.getChildCells = function(parent,
vertices,
edges)
Returns the children of the given cell that are vertices and/or edges depending on the arguments.
mxGraphModel.prototype.getTerminal = function(edge,
isSource)
Returns the source or target mxCell of the given edge depending on the value of the boolean parameter.
mxGraphModel.prototype.setTerminal = function(edge,
terminal,
isSource)
Sets the source or target terminal of the given mxCell using mxTerminalChange and adds the change to the current transaction.
Action to change a terminal in a model.
mxGraphModel.prototype.setTerminals = function(edge,
source,
target)
Sets the source and target mxCell of the given mxCell in a single transaction using setTerminal for each end of the edge.
mxGraphModel.prototype.terminalForCellChanged = function(edge,
terminal,
isSource)
Inner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal.
mxCell.prototype.insertEdge = function(edge,
isOutgoing)
Inserts the specified edge into the edge array and returns the edge.
mxGraphModel.prototype.getEdgeCount = function(cell)
Returns the number of distinct edges connected to the given cell.
mxGraphModel.prototype.getEdgeAt = function(cell,
index)
Returns the edge of cell at the given index.
mxGraphModel.prototype.getDirectedEdgeCount = function(cell,
outgoing,
ignoredEdge)
Returns the number of incoming or outgoing edges, ignoring the given edge.
mxGraphModel.prototype.getConnections = function(cell)
Returns all edges of the given cell without loops.
mxGraphModel.prototype.getIncomingEdges = function(cell)
Returns the incoming edges of the given cell without loops.
mxGraphModel.prototype.getOutgoingEdges = function(cell)
Returns the outgoing edges of the given cell without loops.
mxGraphModel.prototype.getEdges = function(cell,
incoming,
outgoing,
includeLoops)
Returns all distinct edges connected to this cell as a new array of mxCells.
mxGraphModel.prototype.getEdgesBetween = function(source,
target,
directed)
Returns all edges between the given source and target pair.
mxGraphModel.prototype.getOpposites = function(edges,
terminal,
sources,
targets)
Returns all opposite vertices wrt terminal for the given edges, only returning sources and/or targets as specified.
mxGraphModel.prototype.getTopmostCells = function(cells)
Returns the topmost cells of the hierarchy in an array that contains no descendants for each mxCell that it contains.
mxGraphModel.prototype.isVertex = function(cell)
Returns true if the given cell is a vertex.
mxGraphModel.prototype.isEdge = function(cell)
Returns true if the given cell is an edge.
mxGraphModel.prototype.isConnectable = function(cell)
Returns true if the given mxCell is connectable.
mxGraphModel.prototype.getValue = function(cell)
Returns the user object of the given mxCell using mxCell.getValue.
mxCell.prototype.getValue = function()
Returns the user object of the cell.
mxGraphModel.prototype.setValue = function(cell,
value)
Sets the user object of then given mxCell using mxValueChange and adds the change to the current transaction.
Action to change a user object in a model.
mxGraphModel.prototype.valueForCellChanged = function(cell,
value)
Inner callback to update the user object of the given mxCell using mxCell.valueChanged and return the previous value, that is, the return value of mxCell.valueChanged.
mxCell.prototype.valueChanged = function(newValue)
Changes the user object after an in-place edit and returns the previous value.
mxGraphModel.prototype.getGeometry = function(cell)
Returns the mxGeometry of the given mxCell.
Extends mxRectangle to represent the geometry of a cell.
mxGraphModel.prototype.setGeometry = function(cell,
geometry)
Sets the mxGeometry of the given mxCell.
mxGraphModel.prototype.geometryForCellChanged = function(cell,
geometry)
Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.
mxCell.prototype.setGeometry = function(geometry)
Sets the mxGeometry to be used as the geometry.
mxGraphModel.prototype.getStyle = function(cell)
Returns the style of the given mxCell.
mxGraphModel.prototype.setStyle = function(cell,
style)
Sets the style of the given mxCell using mxStyleChange and adds the change to the current transaction.
Action to change a cell’s style in a model.
mxGraphModel.prototype.styleForCellChanged = function(cell,
style)
Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.
mxCell.prototype.setStyle = function(style)
Sets the string to be used as the style.
mxGraphModel.prototype.isCollapsed = function(cell)
Returns true if the given mxCell is collapsed.
mxGraphModel.prototype.setCollapsed = function(cell,
collapsed)
Sets the collapsed state of the given mxCell using mxCollapseChange and adds the change to the current transaction.
Action to change a cell’s collapsed state in a model.
mxGraphModel.prototype.collapsedStateForCellChanged = function(cell,
collapsed)
Inner callback to update the collapsed state of the given mxCell using mxCell.setCollapsed and return the previous collapsed state.
mxCell.prototype.setCollapsed = function(collapsed)
Sets the collapsed state.
mxGraphModel.prototype.isVisible = function(cell)
Returns true if the given mxCell is visible.
mxGraphModel.prototype.setVisible = function(cell,
visible)
Sets the visible state of the given mxCell using mxVisibleChange and adds the change to the current transaction.
Action to change a cell’s visible state in a model.
mxGraphModel.prototype.visibleStateForCellChanged = function(cell,
visible)
Inner callback to update the visible state of the given mxCell using mxCell.setCollapsed and return the previous visible state.
mxGraphModel.prototype.execute = function(change)
Executes the given edit and fires events if required.
mxGraphModel.prototype.createUndoableEdit = function(significant)
Creates a new mxUndoableEdit that implements the notify function to fire a change and notify event through the mxUndoableEdit’s source.
Implements a composite undoable edit.
mxGraphModel.prototype.mergeChildren = function(from,
to,
cloneAllEdges)
Merges the children of the given cell into the given target cell inside this model.
mxGraphModel.prototype.getParents = function(cells)
Returns an array that represents the set (no duplicates) of all parents for the given array of cells.
mxGraphModel.prototype.cloneCell = function(cell,
includeChildren)
Returns a deep clone of the given mxCell (including the children) which is created using cloneCells.
mxGraphModel.prototype.cloneCells = function(cells,
includeChildren,
mapping)
Returns an array of clones for the given array of mxCells.
mxGraphModel.prototype.cloneCellImpl = function(cell,
mapping,
includeChildren)
Inner helper method for cloning cells recursively.
mxGraphModel.prototype.cellCloned = function(cell)
Hook for cloning the cell.
mxGraphModel.prototype.restoreClone = function(clone,
cell,
mapping)
Inner helper method for restoring the connections in a network of cloned cells.
function mxRootChange(model,
root)
Constructs a change of the root in the specified model.
mxRootChange.prototype.execute = function()
Carries out a change of the root using mxGraphModel.rootChanged.
function mxChildChange(model,
parent,
child,
index)
Constructs a change of a child in the specified model.
mxChildChange.prototype.execute = function()
Changes the parent of child using mxGraphModel.parentForCellChanged and removes or restores the cell’s connections.
function mxTerminalChange(model,
cell,
terminal,
source)
Constructs a change of a terminal in the specified model.
mxTerminalChange.prototype.execute = function()
Changes the terminal of cell to previous using mxGraphModel.terminalForCellChanged.
function mxValueChange(model,
cell,
value)
Constructs a change of a user object in the specified model.
mxValueChange.prototype.execute = function()
Changes the value of cell to previous using mxGraphModel.valueForCellChanged.
function mxStyleChange(model,
cell,
style)
Constructs a change of a style in the specified model.
mxStyleChange.prototype.execute = function()
Changes the style of cell to previous using mxGraphModel.styleForCellChanged.
function mxGeometryChange(model,
cell,
geometry)
Constructs a change of a geometry in the specified model.
mxGeometryChange.prototype.execute = function()
Changes the geometry of cell ro previous using mxGraphModel.geometryForCellChanged.
function mxCollapseChange(model,
cell,
collapsed)
Constructs a change of a collapsed state in the specified model.
mxCollapseChange.prototype.execute = function()
Changes the collapsed state of cell to previous using mxGraphModel.collapsedStateForCellChanged.
function mxVisibleChange(model,
cell,
visible)
Constructs a change of a visible state in the specified model.
mxVisibleChange.prototype.execute = function()
Changes the visible state of cell to previous using mxGraphModel.visibleStateForCellChanged.
function mxCellAttributeChange(cell,
attribute,
value)
Constructs a change of a attribute of the DOM node stored as the value of the given mxCell.
mxCellAttributeChange.prototype.execute = function()
Changes the attribute of the cell’s user object by using mxCell.setAttribute.
mxCell.prototype.setAttribute = function(name,
value)
Sets the specified attribute on the user object if it is an XML node.
mxCell.prototype.isConnectable = function()
Returns true if the cell is connectable.
Action to change a cell’s geometry in a model.
Close