Cells are the elements of the graph model. They represent the state of the groups, vertices and edges in a graph.

Fires a graphModelChanged event after each group of changes.

Summary

mxGraphModel | Cells are the elements of the graph model. |

Variables | |

root | Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells. |

cells | Maps from Ids to cells. |

maintainEdgeParent | Specifies if edges should automatically be moved into the nearest common ancestor of their terminals. |

createIds | Specifies if the model should automatically create Ids for new cells. |

nextId | Specifies the next Id to be created. |

updateLevel | Counter for the depth of nested transactions. |

Functions | |

mxGraphModel | Constructs a new graph model using the specified root cell. |

clear | Sets a new root using createRoot. |

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

getCells | Returns the internal lookup table that is used to map from Ids to cells. |

setRoot | |

getRoot | Returns the root of the model. |

setRoot | Sets the root of the model using <mxRootChange> and adds the change to the current transaction. |

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

cloneCells | Returns an array of clones for the given array of mxCells. |

cloneCellImpl | Inner helper method for cloning cells recursively. |

cellCloned | Hook for cloning the cell. |

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

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

contains | Returns true if the model contains the given mxCell. |

getParent | Returns the parent of the given cell. |

add | Adds the specified child to the parent at the given index using <mxChildChange> and adds the change to the current transaction. |

cellAdded | Inner callback to update cells when a cell has been added. |

createId | Hook method to create an Id for the specified cell. |

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

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

getOrigin | Returns the absolute, cummulated origin for the children inside the given parent as an mxPoint. |

getNearestCommonAncestor | Returns the nearest common ancestor for the specified cells. |

remove | Removes the specified cell from the model using <mxChildChange> and adds the change to the current transaction. |

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

getChildCount | Returns the number of children in the given cell. |

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

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

setTerminal | Sets the source or target terminal of the given mxCell using <mxTerminalChange> and adds the change to the current transaction. |

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

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

getEdgeAt | Returns the edge of cell at the given index. |

getEdges | Returns all distinct edges connected to this cell as an array of mxCells. |

isVertex | Returns true if the given cell is a vertex. |

isEdge | Returns true if the given cell is an edge. |

isConnectable | Returns true if the given mxCell is connectable. |

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

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

getGeometry | Returns the mxGeometry of the given mxCell. |

setGeometry | Sets the mxGeometry of the given mxCell. |

getStyle | Returns the style of the given mxCell. |

setStyle | Sets the style of the given mxCell using <mxStyleChange> and adds the change to the current transaction. |

isCollapsed | Returns true if the given mxCell is collapsed. |

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

isVisible | Returns true if the given mxCell is visible. |

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

mergeChildren | Merges the children of the given cell into the given target cell inside this model. |

mergeChildrenImpl | 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. |

beginUpdate | Increments the updateLevel by one. |

endUpdate | Decrements the updateLevel by one and fires a notification event if the updateLevel reaches 0. |

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

var $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.

function clear()

Sets a new root using createRoot.

function cloneCell( $cell )

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

cell | mxCell to be cloned. |

function cloneCells( $cells, $includeChildren = true )

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.

cells | Array of mxCell to be cloned. |

includeChildren | Boolean indicating if the cells should be cloned with all descendants. |

function getParent( $cell )

Returns the parent of the given cell.

cell | mxCell whose parent should be returned. |

function add( $parent, $child, $index = null )

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.

parent | mxCell that specifies the parent to contain the child. |

child | mxCell that specifies the child to be inserted. |

index | Optional integer that specifies the index of the child. |

function updateEdgeParents( $cell, $root = null )

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

function getOrigin( $cell )

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

function remove( $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.

cell | mxCell that should be removed. |

function getChildCount( $cell )

Returns the number of children in the given cell.

cell | mxCell whose number of children should be returned. |

function setTerminal( $edge, $terminal, $source )

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.

edge | mxCell that specifies the edge. |

terminal | mxCell that specifies the new terminal. |

isSource | Boolean indicating if the terminal is the new source or target terminal of the edge. |

function setTerminals( $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.

edge | mxCell that specifies the edge. |

source | mxCell that specifies the new source terminal. |

target | mxCell that specifies the new target terminal. |

function getEdgeCount( $cell )

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

cell | mxCell that represents the vertex. |

function getEdgeAt( $cell, $index )

Returns the edge of cell at the given index.

cell | mxCell that specifies the vertex. |

index | Integer that specifies the index of the edge to return. |

function isVertex( $cell )

Returns true if the given cell is a vertex.

cell | mxCell that represents the possible vertex. |

function isEdge( $cell )

Returns true if the given cell is an edge.

cell | mxCell that represents the possible edge. |

function isConnectable( $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.

cell | mxCell whose connectable state should be returned. |

function getValue( $cell )

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

cell | mxCell whose user object should be returned. |

function getGeometry( $cell )

Returns the mxGeometry of the given mxCell.

cell | mxCell whose geometry should be returned. |

function setGeometry( $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.

cell | mxCell whose geometry should be changed. |

geometry | mxGeometry that defines the new geometry. |

function mergeChildren( $from, $to, $cloneAllEdges = true )

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.

function mergeChildrenImpl( $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.

function beginUpdate()

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

function endUpdate()

Decrements the updateLevel by one and fires a notification event if the updateLevel reaches 0. This function indirectly fires a notification.

function getDirectedEdgeCount( $cell, $outgoing, $ignoredEdge = null )

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

cell | mxCell whose edge count should be returned. |

outgoing | Boolean that specifies if the number of outgoing or incoming edges should be returned. |

ignoredEdge | mxCell that represents an edge to be ignored. |

Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.

var $root

Maps from Ids to cells.

var $cells

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

var $maintainEdgeParent

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

var $createIds

Specifies the next Id to be created.

var $nextId

Counter for the depth of nested transactions.

var $updateLevel

Constructs a new graph model using the specified root cell.

function mxGraphModel( $root = null )

Sets a new root using createRoot.

function clear()

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

function createRoot()

Returns the internal lookup table that is used to map from Ids to cells.

function getCells()

Returns the root of the model.

function getRoot()

Sets the root of the model using mxRootChange and adds the change to the current transaction.

function setRoot( $root )

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

function cloneCell( $cell )

Cells are the elements of the graph model.

Returns an array of clones for the given array of mxCells.

function cloneCells( $cells, $includeChildren = true )

Inner helper method for cloning cells recursively.

function cloneCellImpl( $cell, $mapping, $includeChildren )

Hook for cloning the cell.

function cellCloned( $cell )

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

function restoreClone( $clne, $cell, $mapping )

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

function isAncestor( $parent, $child )

Returns true if the model contains the given mxCell.

function contains( $cell )

Returns the parent of the given cell.

function getParent( $cell )

Adds the specified child to the parent at the given index using mxChildChange and adds the change to the current transaction.

function add( $parent, $child, $index = null )

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

function cellAdded( $cell )

Hook method to create an Id for the specified cell.

function createId( $cell )

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

function updateEdgeParents( $cell, $root = null )

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

function updateEdgeParent( $edge, $root )

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

function getOrigin( $cell )

Implements a 2-dimensional point with double precision coordinates.

Returns the nearest common ancestor for the specified cells.

function getNearestCommonAncestor( $cell1, $cell2 )

Removes the specified cell from the model using mxChildChange and adds the change to the current transaction.

function remove( $cell )

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

function cellRemoved( $cell )

Returns the number of children in the given cell.

function getChildCount( $cell )

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

function getChildAt( $cell, $index )

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

function getTerminal( $edge, $cource )

Sets the source or target terminal of the given mxCell using mxTerminalChange and adds the change to the current transaction.

function setTerminal( $edge, $terminal, $source )

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

function setTerminals( $edge, $source, $target )

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

function getEdgeCount( $cell )

Returns the edge of cell at the given index.

function getEdgeAt( $cell, $index )

Returns all distinct edges connected to this cell as an array of mxCells.

function getEdges( $cell )

Returns true if the given cell is a vertex.

function isVertex( $cell )

Returns true if the given cell is an edge.

function isEdge( $cell )

Returns true if the given mxCell is connectable.

function isConnectable( $cell )

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

function getValue( $cell )

Returns the user object of the cell.

function getValue()

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

function setValue( $cell, $value )

Returns the mxGeometry of the given mxCell.

function getGeometry( $cell )

Represents the geometry of a cell.

Sets the mxGeometry of the given mxCell.

function setGeometry( $cell, $geometry )

Returns the style of the given mxCell.

function getStyle( $cell )

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

function setStyle( $cell, $style )

Returns true if the given mxCell is collapsed.

function isCollapsed( $cell )

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

function setCollapsed( $cell, $isCollapsed )

Returns true if the given mxCell is visible.

function isVisible( $cell )

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

function setVisible( $cell, $visible )

Merges the children of the given cell into the given target cell inside this model.

function mergeChildren( $from, $to, $cloneAllEdges = true )

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.

function mergeChildrenImpl( $from, $to, $cloneAllEdges, $mapping )

Increments the updateLevel by one.

function beginUpdate()

Decrements the updateLevel by one and fires a notification event if the updateLevel reaches 0.

function endUpdate()

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

function getDirectedEdgeCount( $cell, $outgoing, $ignoredEdge = null )

Returns true if the cell is connectable.

function isConnectable()