mxGraph 2.5.0.1


com.mxgraph.model
Class mxGraphModel

java.lang.Object
  extended by com.mxgraph.util.mxEventSource
      extended by com.mxgraph.model.mxGraphModel
All Implemented Interfaces:
mxIGraphModel, Serializable

public class mxGraphModel
extends mxEventSource
implements mxIGraphModel, Serializable

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 function is used. It returns true if the parent of the given cell is the root of the model. This class fires the following events: mxEvent.CHANGE fires when an undoable edit is dispatched. The edit property contains the mxUndoableEdit. The changes property contains the list of undoable changes inside the undoable edit. The changes property is deprecated, please use edit.getChanges() instead. mxEvent.EXECUTE fires between begin- and endUpdate and after an atomic change was executed in the model. The change property contains the atomic change that was executed. mxEvent.BEGIN_UPDATE fires after the updateLevel was incremented in beginUpdate. This event contains no properties. mxEvent.END_UPDATE fires after the updateLevel was decreased in endUpdate but before any notification or change dispatching. The edit property contains the current mxUndoableEdit. mxEvent.BEFORE_UNDO fires before the change is dispatched after the update level has reached 0 in endUpdate. The edit property contains the current mxUndoableEdit. mxEvent.UNDO fires after the change was dispatched in endUpdate. The edit property contains the current mxUndoableEdit.

See Also:
Serialized Form

Nested Class Summary
static interface mxGraphModel.Filter
           
static class mxGraphModel.mxChildChange
           
static class mxGraphModel.mxCollapseChange
           
static class mxGraphModel.mxGeometryChange
           
static class mxGraphModel.mxRootChange
           
static class mxGraphModel.mxStyleChange
           
static class mxGraphModel.mxTerminalChange
           
static class mxGraphModel.mxValueChange
           
static class mxGraphModel.mxVisibleChange
           
 
Nested classes/interfaces inherited from class com.mxgraph.util.mxEventSource
mxEventSource.mxIEventListener
 
Nested classes/interfaces inherited from interface com.mxgraph.model.mxIGraphModel
mxIGraphModel.mxAtomicGraphModelChange
 
Field Summary
protected  Map<String,Object> cells
          Maps from Ids to cells.
protected  boolean createIds
          Specifies if the model should automatically create Ids for new cells.
protected  mxUndoableEdit currentEdit
          Holds the changes for the current transaction.
protected  boolean endingUpdate
           
protected  boolean maintainEdgeParent
          Specifies if edges should automatically be moved into the nearest common ancestor of their terminals.
protected  int nextId
          Specifies the next Id to be created.
protected  mxICell root
          Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.
protected  int updateLevel
          Counter for the depth of nested transactions.
 
Fields inherited from class com.mxgraph.util.mxEventSource
eventListeners, eventsEnabled, eventSource
 
Constructor Summary
mxGraphModel()
          Constructs a new empty graph model.
mxGraphModel(Object root)
          Constructs a new graph model.
 
Method Summary
 Object add(Object parent, Object child, int index)
          Adds the specified child to the parent at the given index.
 void beginUpdate()
          Increments the updateLevel by one.
protected  void cellAdded(Object cell)
          Invoked after a cell has been added to a parent.
protected  void cellRemoved(Object cell)
          Invoked after a cell has been removed from the model.
 void clear()
          Sets a new root using createRoot.
protected  Object cloneCell(Object cell, Map<Object,Object> mapping, boolean includeChildren)
          Inner helper method for cloning cells recursively.
 Object[] cloneCells(Object[] cells, boolean includeChildren)
          Returns an array of clones for the given array of cells.
protected  boolean collapsedStateForCellChanged(Object cell, boolean collapsed)
          Inner callback to update the collapsed state of the given mxCell using mxCell.setCollapsed and return the previous collapsed state.
 boolean contains(Object cell)
          Returns true if the model contains the given cell.
 String createId(Object cell)
          Creates a new Id for the given cell and increments the global counter for creating new Ids.
 Object createRoot()
          Creates a new root cell with a default layer (child 0).
protected  mxUndoableEdit createUndoableEdit()
          Creates a new undoable edit.
 void endUpdate()
          Decrements the updateLevel by one and fires a notification event if the updateLevel reaches 0.
 void execute(mxIGraphModel.mxAtomicGraphModelChange change)
          Executes the given atomic change and adds it to the current edit.
static Object[] filterCells(Object[] cells, mxGraphModel.Filter filter)
           
static Collection<Object> filterDescendants(mxIGraphModel model, mxGraphModel.Filter filter)
          Creates a collection of cells using the visitor pattern.
static Collection<Object> filterDescendants(mxIGraphModel model, mxGraphModel.Filter filter, Object parent)
          Creates a collection of cells using the visitor pattern.
protected  mxGeometry geometryForCellChanged(Object cell, mxGeometry geometry)
          Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.
 Object getCell(String id)
          Returns the cell for the specified Id or null if no cell can be found for the given Id.
 Map<String,Object> getCells()
          Returns the internal lookup table that is used to map from Ids to cells.
 Object getChildAt(Object parent, int index)
          Returns the child of the given parent at the given index.
static Object[] getChildCells(mxIGraphModel model, Object parent, boolean vertices, boolean edges)
          Returns the children of the given cell that are vertices and/or edges depending on the arguments.
 int getChildCount(Object cell)
          Returns the number of children in the given cell.
static Object[] getChildEdges(mxIGraphModel model, Object parent)
          Returns the child edges of the given parent.
static Object[] getChildren(mxIGraphModel model, Object parent)
          Returns all children of the given cell regardless of their type.
static Object[] getChildVertices(mxIGraphModel model, Object parent)
          Returns the child vertices of the given parent.
static Object[] getConnections(mxIGraphModel model, Object cell)
          Returns all edges connected to this cell without loops.
static Collection<Object> getDescendants(mxIGraphModel model, Object parent)
          Returns a all descendants of the given cell and the cell itself as a collection.
static int getDirectedEdgeCount(mxIGraphModel model, Object cell, boolean outgoing)
          Returns the number of incoming or outgoing edges.
static int getDirectedEdgeCount(mxIGraphModel model, Object cell, boolean outgoing, Object ignoredEdge)
          Returns the number of incoming or outgoing edges, ignoring the given edge.
 Object getEdgeAt(Object parent, int index)
          Returns the edge of cell at the given index.
 int getEdgeCount(Object cell)
          Returns the number of distinct edges connected to the given cell.
static Object[] getEdges(mxIGraphModel model, Object cell)
          Returns all edges connected to this cell including loops.
static Object[] getEdges(mxIGraphModel model, Object cell, boolean incoming, boolean outgoing, boolean includeLoops)
          Returns all distinct edges connected to this cell.
static Object[] getEdgesBetween(mxIGraphModel model, Object source, Object target)
          Returns all edges from the given source to the given target.
static Object[] getEdgesBetween(mxIGraphModel model, Object source, Object target, boolean directed)
          Returns all edges between the given source and target pair.
 mxGeometry getGeometry(Object cell)
          Returns the geometry of the given cell.
static Object[] getIncomingEdges(mxIGraphModel model, Object cell)
          Returns the incoming edges of the given cell without loops.
 Object getNearestCommonAncestor(Object cell1, Object cell2)
          Returns the nearest common ancestor for the specified cells.
static Object[] getOpposites(mxIGraphModel model, Object[] edges, Object terminal)
          Returns all opposite cells of terminal for the given edges.
static Object[] getOpposites(mxIGraphModel model, Object[] edges, Object terminal, boolean sources, boolean targets)
          Returns all opposite vertices wrt terminal for the given edges, only returning sources and/or targets as specified.
 mxPoint getOrigin(Object cell)
          Returns the absolute, accumulated origin for the children inside the given parent.
static Object[] getOutgoingEdges(mxIGraphModel model, Object cell)
          Returns the outgoing edges of the given cell without loops.
 Object getParent(Object child)
          Returns the parent of the given cell.
static Object[] getParents(mxIGraphModel model, Object[] cells)
           
 Object getRoot()
          Returns the root of the model or the topmost parent of the given cell.
 String getStyle(Object cell)
          Returns the style of the given cell.
 Object getTerminal(Object edge, boolean isSource)
          Returns the source or target terminal of the given edge depending on the value of the boolean parameter.
static Object[] getTopmostCells(mxIGraphModel model, Object[] cells)
          Function: getTopmostCells Returns the topmost cells of the hierarchy in an array that contains no desceandants for each that it contains.
 int getUpdateLevel()
           
 Object getValue(Object cell)
          Returns the user object of the given cell.
 boolean isAncestor(Object parent, Object child)
          Returns true if the given parent is an ancestor of the given child.
 boolean isCollapsed(Object cell)
          Returns true if the given cell is collapsed.
 boolean isConnectable(Object cell)
          Returns true if the given cell is connectable.
 boolean isCreateIds()
          Returns true if the model automatically creates Ids and resolves Id collisions.
 boolean isEdge(Object cell)
          Returns true if the given cell is an edge.
 boolean isMaintainEdgeParent()
          Returns true if the model automatically update parents of edges so that the edge is contained in the nearest-common-ancestor of its terminals.
 boolean isVertex(Object cell)
          Returns true if the given cell is a vertex.
 boolean isVisible(Object cell)
          Returns true if the given cell is visible.
 void mergeChildren(mxICell from, mxICell to, boolean cloneAllEdges)
          Merges the children of the given cell into the given target cell inside this model.
protected  void mergeChildrenImpl(mxICell from, mxICell to, boolean cloneAllEdges, Hashtable<Object,Object> 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.
protected  Object parentForCellChanged(Object cell, Object parent, int index)
          Inner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent.
 Object remove(Object cell)
          Removes the specified cell from the model.
protected  void restoreClone(Object clone, Object cell, Map<Object,Object> mapping)
          Inner helper method for restoring the connections in a network of cloned cells.
protected  Object rootChanged(Object root)
          Inner callback to change the root of the model and update the internal datastructures, such as cells and nextId.
 boolean setCollapsed(Object cell, boolean collapsed)
          Sets the collapsed state of the given cell.
 void setCreateIds(boolean value)
          Specifies if the model automatically creates Ids for new cells and resolves Id collisions.
 mxGeometry setGeometry(Object cell, mxGeometry geometry)
          Sets the geometry of the given cell.
 void setMaintainEdgeParent(boolean maintainEdgeParent)
          Specifies if the model automatically updates parents of edges so that the edge is contained in the nearest-common-ancestor of its terminals.
 Object setRoot(Object root)
          Sets the root of the model and resets all structures.
 String setStyle(Object cell, String style)
          Sets the style of the given cell.
 Object setTerminal(Object edge, Object terminal, boolean isSource)
          Sets the source or target terminal of the given edge using.
static void setTerminals(mxIGraphModel model, Object edge, Object source, Object target)
          Sets the source and target of the given edge in a single atomic change.
 Object setValue(Object cell, Object value)
          Sets the user object of then given cell.
 boolean setVisible(Object cell, boolean visible)
          Sets the visible state of the given cell.
protected  String styleForCellChanged(Object cell, String style)
          Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.
protected  Object terminalForCellChanged(Object edge, Object terminal, boolean isSource)
          Inner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal.
 void updateEdgeParent(Object edge, Object root)
          Inner helper method to update the parent of the specified edge to the nearest-common-ancestor of its two terminals.
 void updateEdgeParents(Object cell)
          Updates the parents of the edges connected to the given cell and all its descendants so that each edge is contained in the nearest common ancestor.
 void updateEdgeParents(Object cell, Object root)
          Updates the parents of the edges connected to the given cell and all its descendants so that the edge is contained in the nearest-common-ancestor.
protected  Object valueForCellChanged(Object cell, Object value)
          Inner callback to update the user object of the given mxCell using mxCell.setValue and return the previous value, that is, the return value of mxCell.getValue.
protected  boolean visibleStateForCellChanged(Object cell, boolean visible)
          Sets the visible state of the given mxCell using mxVisibleChange and adds the change to the current transaction.
 
Methods inherited from class com.mxgraph.util.mxEventSource
addListener, fireEvent, fireEvent, getEventSource, isEventsEnabled, removeListener, removeListener, setEventsEnabled, setEventSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.mxgraph.model.mxIGraphModel
addListener, removeListener, removeListener
 

Field Detail

root

protected mxICell 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 element of the diagram are supposed to live in the third generation of cells and below.


cells

protected Map<String,Object> cells
Maps from Ids to cells.


maintainEdgeParent

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


createIds

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


nextId

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


currentEdit

protected transient mxUndoableEdit 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

protected transient int updateLevel
Counter for the depth of nested transactions. Each call to beginUpdate increments this counter and each call to endUpdate decrements it. When the counter reaches 0, the transaction is closed and the respective events are fired. Initial value is 0.


endingUpdate

protected transient boolean endingUpdate
Constructor Detail

mxGraphModel

public mxGraphModel()
Constructs a new empty graph model.


mxGraphModel

public mxGraphModel(Object root)
Constructs a new graph model. If no root is specified then a new root mxCell with a default layer is created.

Parameters:
root - Cell that represents the root cell.
Method Detail

clear

public void clear()
Sets a new root using createRoot.


getUpdateLevel

public int getUpdateLevel()

createRoot

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


getCells

public Map<String,Object> getCells()
Returns the internal lookup table that is used to map from Ids to cells.


getCell

public Object getCell(String id)
Returns the cell for the specified Id or null if no cell can be found for the given Id.

Parameters:
id - A string representing the Id of the cell.
Returns:
Returns the cell for the given Id.

isMaintainEdgeParent

public boolean isMaintainEdgeParent()
Returns true if the model automatically update parents of edges so that the edge is contained in the nearest-common-ancestor of its terminals.

Returns:
Returns true if the model maintains edge parents.

setMaintainEdgeParent

public void setMaintainEdgeParent(boolean maintainEdgeParent)
Specifies if the model automatically updates parents of edges so that the edge is contained in the nearest-common-ancestor of its terminals.

Parameters:
maintainEdgeParent - Boolean indicating if the model should maintain edge parents.

isCreateIds

public boolean isCreateIds()
Returns true if the model automatically creates Ids and resolves Id collisions.

Returns:
Returns true if the model creates Ids.

setCreateIds

public void setCreateIds(boolean value)
Specifies if the model automatically creates Ids for new cells and resolves Id collisions.

Parameters:
value - Boolean indicating if the model should created Ids.

getRoot

public Object getRoot()
Description copied from interface: mxIGraphModel
Returns the root of the model or the topmost parent of the given cell.

Specified by:
getRoot in interface mxIGraphModel
Returns:
Returns the root cell.

setRoot

public Object setRoot(Object root)
Description copied from interface: mxIGraphModel
Sets the root of the model and resets all structures.

Specified by:
setRoot in interface mxIGraphModel
Parameters:
root - Cell that specifies the new root.

rootChanged

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


createUndoableEdit

protected mxUndoableEdit createUndoableEdit()
Creates a new undoable edit.


cloneCells

public Object[] cloneCells(Object[] cells,
                           boolean includeChildren)
Description copied from interface: mxIGraphModel
Returns an array of clones for the given array of cells. 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.

Specified by:
cloneCells in interface mxIGraphModel
Parameters:
cells - Array of cells to be cloned.
includeChildren - Boolean indicating if the cells should be cloned with all descendants.
Returns:
Returns a cloned array of cells.

cloneCell

protected Object cloneCell(Object cell,
                           Map<Object,Object> mapping,
                           boolean includeChildren)
                    throws CloneNotSupportedException
Inner helper method for cloning cells recursively.

Throws:
CloneNotSupportedException

restoreClone

protected void restoreClone(Object clone,
                            Object cell,
                            Map<Object,Object> mapping)
Inner helper method for restoring the connections in a network of cloned cells.


isAncestor

public boolean isAncestor(Object parent,
                          Object child)
Description copied from interface: mxIGraphModel
Returns true if the given parent is an ancestor of the given child.

Specified by:
isAncestor in interface mxIGraphModel
Parameters:
parent - Cell that specifies the parent.
child - Cell that specifies the child.
Returns:
Returns true if child is an ancestor of parent.

contains

public boolean contains(Object cell)
Description copied from interface: mxIGraphModel
Returns true if the model contains the given cell.

Specified by:
contains in interface mxIGraphModel
Parameters:
cell - Cell to be checked.
Returns:
Returns true if the cell is in the model.

getParent

public Object getParent(Object child)
Description copied from interface: mxIGraphModel
Returns the parent of the given cell.

Specified by:
getParent in interface mxIGraphModel
Parameters:
child - Cell whose parent should be returned.
Returns:
Returns the parent of the given cell.

add

public Object add(Object parent,
                  Object child,
                  int index)
Description copied from interface: mxIGraphModel
Adds the specified child to the parent at the given index. If no index is specified then the child is appended to the parent's array of children.

Specified by:
add in interface mxIGraphModel
Parameters:
parent - Cell that specifies the parent to contain the child.
child - Cell that specifies the child to be inserted.
index - Integer that specifies the index of the child.
Returns:
Returns the inserted child.

cellAdded

protected void cellAdded(Object cell)
Invoked after a cell has been added to a parent. This recursively creates an Id for the new cell and/or resolves Id collisions.

Parameters:
cell - Cell that has been added.

createId

public String createId(Object cell)
Creates a new Id for the given cell and increments the global counter for creating new Ids.

Parameters:
cell - Cell for which a new Id should be created.
Returns:
Returns a new Id for the given cell.

remove

public Object remove(Object cell)
Description copied from interface: mxIGraphModel
Removes the specified cell from the model. This operation will remove the cell and all of its children from the model.

Specified by:
remove in interface mxIGraphModel
Parameters:
cell - Cell that should be removed.
Returns:
Returns the removed cell.

cellRemoved

protected void cellRemoved(Object cell)
Invoked after a cell has been removed from the model. This recursively removes the cell from its terminals and removes the mapping from the Id to the cell.

Parameters:
cell - Cell that has been removed.

parentForCellChanged

protected Object parentForCellChanged(Object cell,
                                      Object parent,
                                      int index)
Inner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent.


getChildCount

public int getChildCount(Object cell)
Description copied from interface: mxIGraphModel
Returns the number of children in the given cell.

Specified by:
getChildCount in interface mxIGraphModel
Parameters:
cell - Cell whose number of children should be returned.
Returns:
Returns the number of children in the given cell.

getChildAt

public Object getChildAt(Object parent,
                         int index)
Description copied from interface: mxIGraphModel
Returns the child of the given parent at the given index.

Specified by:
getChildAt in interface mxIGraphModel
Parameters:
parent - Cell that represents the parent.
index - Integer that specifies the index of the child to be returned.
Returns:
Returns the child at index in parent.

getTerminal

public Object getTerminal(Object edge,
                          boolean isSource)
Description copied from interface: mxIGraphModel
Returns the source or target terminal of the given edge depending on the value of the boolean parameter.

Specified by:
getTerminal in interface mxIGraphModel
Parameters:
edge - Cell that specifies the edge.
isSource - Boolean indicating which end of the edge should be returned.
Returns:
Returns the source or target of the given edge.

setTerminal

public Object setTerminal(Object edge,
                          Object terminal,
                          boolean isSource)
Description copied from interface: mxIGraphModel
Sets the source or target terminal of the given edge using.

Specified by:
setTerminal in interface mxIGraphModel
Parameters:
edge - Cell that specifies the edge.
terminal - Cell that specifies the new terminal.
isSource - Boolean indicating if the terminal is the new source or target terminal of the edge.
Returns:
Returns the new terminal.

terminalForCellChanged

protected Object terminalForCellChanged(Object edge,
                                        Object terminal,
                                        boolean isSource)
Inner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal.


updateEdgeParents

public void updateEdgeParents(Object cell)
Updates the parents of the edges connected to the given cell and all its descendants so that each edge is contained in the nearest common ancestor.

Parameters:
cell - Cell whose edges should be checked and updated.

updateEdgeParents

public void updateEdgeParents(Object cell,
                              Object root)
Updates the parents of the edges connected to the given cell and all its descendants so that the edge is contained in the nearest-common-ancestor.

Parameters:
cell - Cell whose edges should be checked and updated.
root - Root of the cell hierarchy that contains all cells.

updateEdgeParent

public void updateEdgeParent(Object edge,
                             Object root)
Inner helper method to update the parent of the specified edge to the nearest-common-ancestor of its two terminals.

Parameters:
edge - Specifies the edge to be updated.
root - Current root of the model.

getOrigin

public mxPoint getOrigin(Object cell)
Returns the absolute, accumulated origin for the children inside the given parent.


getNearestCommonAncestor

public Object getNearestCommonAncestor(Object cell1,
                                       Object cell2)
Returns the nearest common ancestor for the specified cells.

Parameters:
cell1 - Cell that specifies the first cell in the tree.
cell2 - Cell that specifies the second cell in the tree.
Returns:
Returns the nearest common ancestor of the given cells.

getEdgeCount

public int getEdgeCount(Object cell)
Description copied from interface: mxIGraphModel
Returns the number of distinct edges connected to the given cell.

Specified by:
getEdgeCount in interface mxIGraphModel
Parameters:
cell - Cell that represents the vertex.
Returns:
Returns the number of edges connected to cell.

getEdgeAt

public Object getEdgeAt(Object parent,
                        int index)
Description copied from interface: mxIGraphModel
Returns the edge of cell at the given index.

Specified by:
getEdgeAt in interface mxIGraphModel
Parameters:
parent - Cell that specifies the vertex.
index - Integer that specifies the index of the edge to return.
Returns:
Returns the edge at the given index.

isVertex

public boolean isVertex(Object cell)
Description copied from interface: mxIGraphModel
Returns true if the given cell is a vertex.

Specified by:
isVertex in interface mxIGraphModel
Parameters:
cell - Cell that represents the possible vertex.
Returns:
Returns true if the given cell is a vertex.

isEdge

public boolean isEdge(Object cell)
Description copied from interface: mxIGraphModel
Returns true if the given cell is an edge.

Specified by:
isEdge in interface mxIGraphModel
Parameters:
cell - Cell that represents the possible edge.
Returns:
Returns true if the given cell is an edge.

isConnectable

public boolean isConnectable(Object cell)
Description copied from interface: mxIGraphModel
Returns true if the given cell is connectable.

Specified by:
isConnectable in interface mxIGraphModel
Parameters:
cell - Cell whose connectable state should be returned.
Returns:
Returns the connectable state of the given cell.

getValue

public Object getValue(Object cell)
Description copied from interface: mxIGraphModel
Returns the user object of the given cell.

Specified by:
getValue in interface mxIGraphModel
Parameters:
cell - Cell whose user object should be returned.
Returns:
Returns the user object of the given cell.

setValue

public Object setValue(Object cell,
                       Object value)
Description copied from interface: mxIGraphModel
Sets the user object of then given cell.

Specified by:
setValue in interface mxIGraphModel
Parameters:
cell - Cell whose user object should be changed.
value - Object that defines the new user object.
Returns:
Returns the new value.

valueForCellChanged

protected Object valueForCellChanged(Object cell,
                                     Object value)
Inner callback to update the user object of the given mxCell using mxCell.setValue and return the previous value, that is, the return value of mxCell.getValue.


getGeometry

public mxGeometry getGeometry(Object cell)
Description copied from interface: mxIGraphModel
Returns the geometry of the given cell.

Specified by:
getGeometry in interface mxIGraphModel
Parameters:
cell - Cell whose geometry should be returned.
Returns:
Returns the geometry of the given cell.

setGeometry

public mxGeometry setGeometry(Object cell,
                              mxGeometry geometry)
Description copied from interface: mxIGraphModel
Sets the geometry of the given cell.

Specified by:
setGeometry in interface mxIGraphModel
Parameters:
cell - Cell whose geometry should be changed.
geometry - Object that defines the new geometry.
Returns:
Returns the new geometry.

geometryForCellChanged

protected mxGeometry geometryForCellChanged(Object cell,
                                            mxGeometry geometry)
Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.


getStyle

public String getStyle(Object cell)
Description copied from interface: mxIGraphModel
Returns the style of the given cell.

Specified by:
getStyle in interface mxIGraphModel
Parameters:
cell - Cell whose style should be returned.
Returns:
Returns the style of the given cell.

setStyle

public String setStyle(Object cell,
                       String style)
Description copied from interface: mxIGraphModel
Sets the style of the given cell.

Specified by:
setStyle in interface mxIGraphModel
Parameters:
cell - Cell whose style should be changed.
style - String of the form stylename[;key=value] to specify the new cell style.
Returns:
Returns the new style.

styleForCellChanged

protected String styleForCellChanged(Object cell,
                                     String style)
Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.


isCollapsed

public boolean isCollapsed(Object cell)
Description copied from interface: mxIGraphModel
Returns true if the given cell is collapsed.

Specified by:
isCollapsed in interface mxIGraphModel
Parameters:
cell - Cell whose collapsed state should be returned.
Returns:
Returns the collapsed state of the given cell.

setCollapsed

public boolean setCollapsed(Object cell,
                            boolean collapsed)
Description copied from interface: mxIGraphModel
Sets the collapsed state of the given cell.

Specified by:
setCollapsed in interface mxIGraphModel
Parameters:
cell - Cell whose collapsed state should be changed.
collapsed - Boolean that specifies the new collpased state.
Returns:
Returns the new collapsed state.

collapsedStateForCellChanged

protected boolean collapsedStateForCellChanged(Object cell,
                                               boolean collapsed)
Inner callback to update the collapsed state of the given mxCell using mxCell.setCollapsed and return the previous collapsed state.


isVisible

public boolean isVisible(Object cell)
Description copied from interface: mxIGraphModel
Returns true if the given cell is visible.

Specified by:
isVisible in interface mxIGraphModel
Parameters:
cell - Cell whose visible state should be returned.
Returns:
Returns the visible state of the given cell.

setVisible

public boolean setVisible(Object cell,
                          boolean visible)
Description copied from interface: mxIGraphModel
Sets the visible state of the given cell.

Specified by:
setVisible in interface mxIGraphModel
Parameters:
cell - Cell whose visible state should be changed.
visible - Boolean that specifies the new visible state.
Returns:
Returns the new visible state.

visibleStateForCellChanged

protected boolean visibleStateForCellChanged(Object cell,
                                             boolean visible)
Sets the visible state of the given mxCell using mxVisibleChange and adds the change to the current transaction.


execute

public void execute(mxIGraphModel.mxAtomicGraphModelChange change)
Executes the given atomic change and adds it to the current edit.

Parameters:
change - Atomic change to be executed.

beginUpdate

public void beginUpdate()
Description copied from interface: mxIGraphModel
Increments the updateLevel by one. The event notification is queued until updateLevel reaches 0 by use of endUpdate.

Specified by:
beginUpdate in interface mxIGraphModel

endUpdate

public void endUpdate()
Description copied from interface: mxIGraphModel
Decrements the updateLevel by one and fires a notification event if the updateLevel reaches 0.

Specified by:
endUpdate in interface mxIGraphModel

mergeChildren

public void mergeChildren(mxICell from,
                          mxICell to,
                          boolean cloneAllEdges)
                   throws CloneNotSupportedException
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.

Parameters:
from -
to -
cloneAllEdges -
Throws:
CloneNotSupportedException

mergeChildrenImpl

protected void mergeChildrenImpl(mxICell from,
                                 mxICell to,
                                 boolean cloneAllEdges,
                                 Hashtable<Object,Object> mapping)
                          throws CloneNotSupportedException
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.

Throws:
CloneNotSupportedException

getDirectedEdgeCount

public static int getDirectedEdgeCount(mxIGraphModel model,
                                       Object cell,
                                       boolean outgoing)
Returns the number of incoming or outgoing edges.

Parameters:
model - Graph model that contains the connection data.
cell - Cell whose edges should be counted.
outgoing - Boolean that specifies if the number of outgoing or incoming edges should be returned.
Returns:
Returns the number of incoming or outgoing edges.

getDirectedEdgeCount

public static int getDirectedEdgeCount(mxIGraphModel model,
                                       Object cell,
                                       boolean outgoing,
                                       Object ignoredEdge)
Returns the number of incoming or outgoing edges, ignoring the given edge.

Parameters:
model - Graph model that contains the connection data.
cell - Cell whose edges should be counted.
outgoing - Boolean that specifies if the number of outgoing or incoming edges should be returned.
ignoredEdge - Object that represents an edge to be ignored.
Returns:
Returns the number of incoming or outgoing edges.

getEdges

public static Object[] getEdges(mxIGraphModel model,
                                Object cell)
Returns all edges connected to this cell including loops.

Parameters:
model - Model that contains the connection information.
cell - Cell whose connections should be returned.
Returns:
Returns the array of connected edges for the given cell.

getConnections

public static Object[] getConnections(mxIGraphModel model,
                                      Object cell)
Returns all edges connected to this cell without loops.

Parameters:
model - Model that contains the connection information.
cell - Cell whose connections should be returned.
Returns:
Returns the connected edges for the given cell.

getIncomingEdges

public static Object[] getIncomingEdges(mxIGraphModel model,
                                        Object cell)
Returns the incoming edges of the given cell without loops.

Parameters:
model - Graphmodel that contains the edges.
cell - Cell whose incoming edges should be returned.
Returns:
Returns the incoming edges for the given cell.

getOutgoingEdges

public static Object[] getOutgoingEdges(mxIGraphModel model,
                                        Object cell)
Returns the outgoing edges of the given cell without loops.

Parameters:
model - Graphmodel that contains the edges.
cell - Cell whose outgoing edges should be returned.
Returns:
Returns the outgoing edges for the given cell.

getEdges

public static Object[] getEdges(mxIGraphModel model,
                                Object cell,
                                boolean incoming,
                                boolean outgoing,
                                boolean includeLoops)
Returns all distinct edges connected to this cell.

Parameters:
model - Model that contains the connection information.
cell - Cell whose connections should be returned.
incoming - Specifies if incoming edges should be returned.
outgoing - Specifies if outgoing edges should be returned.
includeLoops - Specifies if loops should be returned.
Returns:
Returns the array of connected edges for the given cell.

getEdgesBetween

public static Object[] getEdgesBetween(mxIGraphModel model,
                                       Object source,
                                       Object target)
Returns all edges from the given source to the given target.

Parameters:
model - The graph model that contains the graph.
source - Object that defines the source cell.
target - Object that defines the target cell.
Returns:
Returns all edges from source to target.

getEdgesBetween

public static Object[] getEdgesBetween(mxIGraphModel model,
                                       Object source,
                                       Object target,
                                       boolean 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:
model - The graph model that contains the graph.
source - Object that defines the source cell.
target - Object that defines the target cell.
directed - Boolean that specifies if the direction of the edge should be taken into account.
Returns:
Returns all edges between the given source and target.

getOpposites

public static Object[] getOpposites(mxIGraphModel model,
                                    Object[] edges,
                                    Object terminal)
Returns all opposite cells of terminal for the given edges.

Parameters:
model - Model that contains the connection information.
edges - Array of edges to be examined.
terminal - Cell that specifies the known end of the edges.
Returns:
Returns the opposite cells of the given terminal.

getOpposites

public static Object[] getOpposites(mxIGraphModel model,
                                    Object[] edges,
                                    Object terminal,
                                    boolean sources,
                                    boolean 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:
model - Model that contains the connection information.
edges - Array of edges to be examined.
terminal - Cell that specifies the known end of the edges.
sources - Boolean that specifies if source terminals should be contained in the result. Default is true.
targets - Boolean that specifies if target terminals should be contained in the result. Default is true.
Returns:
Returns the array of opposite terminals for the given edges.

setTerminals

public static void setTerminals(mxIGraphModel model,
                                Object edge,
                                Object source,
                                Object target)
Sets the source and target of the given edge in a single atomic change.

Parameters:
edge - Cell that specifies the edge.
source - Cell that specifies the new source terminal.
target - Cell that specifies the new target terminal.

getChildren

public static Object[] getChildren(mxIGraphModel model,
                                   Object parent)
Returns all children of the given cell regardless of their type.

Parameters:
model - Model that contains the hierarchical information.
parent - Cell whose child vertices or edges should be returned.
Returns:
Returns the child vertices and/or edges of the given parent.

getChildVertices

public static Object[] getChildVertices(mxIGraphModel model,
                                        Object parent)
Returns the child vertices of the given parent.

Parameters:
model - Model that contains the hierarchical information.
parent - Cell whose child vertices should be returned.
Returns:
Returns the child vertices of the given parent.

getChildEdges

public static Object[] getChildEdges(mxIGraphModel model,
                                     Object parent)
Returns the child edges of the given parent.

Parameters:
model - Model that contains the hierarchical information.
parent - Cell whose child edges should be returned.
Returns:
Returns the child edges of the given parent.

getChildCells

public static Object[] getChildCells(mxIGraphModel model,
                                     Object parent,
                                     boolean vertices,
                                     boolean edges)
Returns the children of the given cell that are vertices and/or edges depending on the arguments. If both arguments are false then all children are returned regardless of their type.

Parameters:
model - Model that contains the hierarchical information.
parent - Cell whose child vertices or edges should be returned.
vertices - Boolean indicating if child vertices should be returned.
edges - Boolean indicating if child edges should be returned.
Returns:
Returns the child vertices and/or edges of the given parent.

getParents

public static Object[] getParents(mxIGraphModel model,
                                  Object[] cells)

filterCells

public static Object[] filterCells(Object[] cells,
                                   mxGraphModel.Filter filter)

getDescendants

public static Collection<Object> getDescendants(mxIGraphModel model,
                                                Object parent)
Returns a all descendants of the given cell and the cell itself as a collection.


filterDescendants

public static Collection<Object> filterDescendants(mxIGraphModel model,
                                                   mxGraphModel.Filter filter)
Creates a collection of cells using the visitor pattern.


filterDescendants

public static Collection<Object> filterDescendants(mxIGraphModel model,
                                                   mxGraphModel.Filter filter,
                                                   Object parent)
Creates a collection of cells using the visitor pattern.


getTopmostCells

public static Object[] getTopmostCells(mxIGraphModel model,
                                       Object[] cells)
Function: getTopmostCells Returns the topmost cells of the hierarchy in an array that contains no desceandants for each that it contains. Duplicates should be removed in the cells array to improve performance. Parameters: cells - Array of whose topmost ancestors should be returned.


mxGraph 2.5.0.1


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.