Package com.mxgraph.model
Class mxGraphModel
java.lang.Object
com.mxgraph.util.mxEventSource
com.mxgraph.model.mxGraphModel
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
static class
static class
static class
static class
static class
static class
static class
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
FieldsModifier and TypeFieldDescriptionMaps from Ids to cells.protected boolean
Specifies if the model should automatically create Ids for new cells.protected mxUndoableEdit
Holds the changes for the current transaction.protected boolean
protected boolean
Specifies if edges should automatically be moved into the nearest common ancestor of their terminals.protected int
Specifies the next Id to be created.protected mxICell
Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.protected int
Counter for the depth of nested transactions.Fields inherited from class com.mxgraph.util.mxEventSource
eventListeners, eventsEnabled, eventSource
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new empty graph model.mxGraphModel
(Object root) Constructs a new graph model. -
Method Summary
Modifier and TypeMethodDescriptionAdds the specified child to the parent at the given index.void
Increments the updateLevel by one.protected void
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
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
Returns true if the model contains the given cell.Creates a new Id for the given cell and increments the global counter for creating new Ids.Creates a new root cell with a default layer (child 0).protected mxUndoableEdit
Creates a new undoable edit.void
Decrements the updateLevel by one and fires a notification event if the updateLevel reaches 0.void
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.Returns the cell for the specified Id or null if no cell can be found for the given Id.getCells()
Returns the internal lookup table that is used to map from Ids to cells.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.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.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.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.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.Returns the parent of the given cell.static Object[]
getParents
(mxIGraphModel model, Object[] cells) getRoot()
Returns the root of the model or the topmost parent of the given cell.Returns the style of the given cell.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 eachthat it contains. int
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
Returns true if the model automatically creates Ids and resolves Id collisions.boolean
Returns true if the given cell is an edge.boolean
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
Returns true if the given cell is a vertex.boolean
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.Removes the specified cell from the model.protected void
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.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.Sets the root of the model and resets all structures.Sets the style of the given cell.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.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.toString()
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, wait, wait, wait
Methods inherited from interface com.mxgraph.model.mxIGraphModel
addListener, removeListener, removeListener
-
Field Details
-
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
Maps from Ids to cells. -
maintainEdgeParent
protected boolean maintainEdgeParentSpecifies if edges should automatically be moved into the nearest common ancestor of their terminals. Default is true. -
createIds
protected boolean createIdsSpecifies if the model should automatically create Ids for new cells. Default is true. -
nextId
protected int nextIdSpecifies the next Id to be created. Initial value is 0. -
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 updateLevelCounter 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 Details
-
mxGraphModel
public mxGraphModel()Constructs a new empty graph model. -
mxGraphModel
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 Details
-
clear
public void clear()Sets a new root using createRoot. -
getUpdateLevel
public int getUpdateLevel() -
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. -
getCell
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
Description copied from interface:mxIGraphModel
Returns the root of the model or the topmost parent of the given cell.- Specified by:
getRoot
in interfacemxIGraphModel
- Returns:
- Returns the root cell.
-
setRoot
Description copied from interface:mxIGraphModel
Sets the root of the model and resets all structures.- Specified by:
setRoot
in interfacemxIGraphModel
- Parameters:
root
- Cell that specifies the new root.
-
rootChanged
Inner callback to change the root of the model and update the internal datastructures, such as cells and nextId. Returns the previous root. -
createUndoableEdit
Creates a new undoable edit. -
cloneCells
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 interfacemxIGraphModel
- 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 CloneNotSupportedExceptionInner helper method for cloning cells recursively.- Throws:
CloneNotSupportedException
-
restoreClone
Inner helper method for restoring the connections in a network of cloned cells. -
isAncestor
Description copied from interface:mxIGraphModel
Returns true if the given parent is an ancestor of the given child.- Specified by:
isAncestor
in interfacemxIGraphModel
- Parameters:
parent
- Cell that specifies the parent.child
- Cell that specifies the child.- Returns:
- Returns true if child is an ancestor of parent.
-
contains
Description copied from interface:mxIGraphModel
Returns true if the model contains the given cell.- Specified by:
contains
in interfacemxIGraphModel
- Parameters:
cell
- Cell to be checked.- Returns:
- Returns true if the cell is in the model.
-
getParent
Description copied from interface:mxIGraphModel
Returns the parent of the given cell.- Specified by:
getParent
in interfacemxIGraphModel
- Parameters:
child
- Cell whose parent should be returned.- Returns:
- Returns the parent of the given cell.
-
add
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 interfacemxIGraphModel
- 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
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
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
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 interfacemxIGraphModel
- Parameters:
cell
- Cell that should be removed.- Returns:
- Returns the removed cell.
-
cellRemoved
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
Inner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent. -
getChildCount
Description copied from interface:mxIGraphModel
Returns the number of children in the given cell.- Specified by:
getChildCount
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose number of children should be returned.- Returns:
- Returns the number of children in the given cell.
-
getChildAt
Description copied from interface:mxIGraphModel
Returns the child of the given parent at the given index.- Specified by:
getChildAt
in interfacemxIGraphModel
- 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
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 interfacemxIGraphModel
- 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
Description copied from interface:mxIGraphModel
Sets the source or target terminal of the given edge using.- Specified by:
setTerminal
in interfacemxIGraphModel
- 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
Inner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal. -
updateEdgeParents
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
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
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
Returns the absolute, accumulated origin for the children inside the given parent. -
getNearestCommonAncestor
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
Description copied from interface:mxIGraphModel
Returns the number of distinct edges connected to the given cell.- Specified by:
getEdgeCount
in interfacemxIGraphModel
- Parameters:
cell
- Cell that represents the vertex.- Returns:
- Returns the number of edges connected to cell.
-
getEdgeAt
Description copied from interface:mxIGraphModel
Returns the edge of cell at the given index.- Specified by:
getEdgeAt
in interfacemxIGraphModel
- 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
Description copied from interface:mxIGraphModel
Returns true if the given cell is a vertex.- Specified by:
isVertex
in interfacemxIGraphModel
- Parameters:
cell
- Cell that represents the possible vertex.- Returns:
- Returns true if the given cell is a vertex.
-
isEdge
Description copied from interface:mxIGraphModel
Returns true if the given cell is an edge.- Specified by:
isEdge
in interfacemxIGraphModel
- Parameters:
cell
- Cell that represents the possible edge.- Returns:
- Returns true if the given cell is an edge.
-
isConnectable
Description copied from interface:mxIGraphModel
Returns true if the given cell is connectable.- Specified by:
isConnectable
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose connectable state should be returned.- Returns:
- Returns the connectable state of the given cell.
-
getValue
Description copied from interface:mxIGraphModel
Returns the user object of the given cell.- Specified by:
getValue
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose user object should be returned.- Returns:
- Returns the user object of the given cell.
-
setValue
Description copied from interface:mxIGraphModel
Sets the user object of then given cell.- Specified by:
setValue
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose user object should be changed.value
- Object that defines the new user object.- Returns:
- Returns the new value.
-
valueForCellChanged
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
Description copied from interface:mxIGraphModel
Returns the geometry of the given cell.- Specified by:
getGeometry
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose geometry should be returned.- Returns:
- Returns the geometry of the given cell.
-
setGeometry
Description copied from interface:mxIGraphModel
Sets the geometry of the given cell.- Specified by:
setGeometry
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose geometry should be changed.geometry
- Object that defines the new geometry.- Returns:
- Returns the new geometry.
-
geometryForCellChanged
Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry. -
getStyle
Description copied from interface:mxIGraphModel
Returns the style of the given cell.- Specified by:
getStyle
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose style should be returned.- Returns:
- Returns the style of the given cell.
-
setStyle
Description copied from interface:mxIGraphModel
Sets the style of the given cell.- Specified by:
setStyle
in interfacemxIGraphModel
- 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
Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style. -
isCollapsed
Description copied from interface:mxIGraphModel
Returns true if the given cell is collapsed.- Specified by:
isCollapsed
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose collapsed state should be returned.- Returns:
- Returns the collapsed state of the given cell.
-
setCollapsed
Description copied from interface:mxIGraphModel
Sets the collapsed state of the given cell.- Specified by:
setCollapsed
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose collapsed state should be changed.collapsed
- Boolean that specifies the new collpased state.- Returns:
- Returns the new collapsed state.
-
collapsedStateForCellChanged
Inner callback to update the collapsed state of the given mxCell using mxCell.setCollapsed and return the previous collapsed state. -
isVisible
Description copied from interface:mxIGraphModel
Returns true if the given cell is visible.- Specified by:
isVisible
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose visible state should be returned.- Returns:
- Returns the visible state of the given cell.
-
setVisible
Description copied from interface:mxIGraphModel
Sets the visible state of the given cell.- Specified by:
setVisible
in interfacemxIGraphModel
- Parameters:
cell
- Cell whose visible state should be changed.visible
- Boolean that specifies the new visible state.- Returns:
- Returns the new visible state.
-
visibleStateForCellChanged
Sets the visible state of the given mxCell using mxVisibleChange and adds the change to the current transaction. -
execute
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 interfacemxIGraphModel
-
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 interfacemxIGraphModel
-
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 CloneNotSupportedExceptionClones 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
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
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
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
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
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
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
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
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
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
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
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
-
filterCells
-
getDescendants
Returns a all descendants of the given cell and the cell itself as a collection. -
filterDescendants
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
Function: getTopmostCells Returns the topmost cells of the hierarchy in an array that contains no desceandants for eachthat it contains. Duplicates should be removed in the cells array to improve performance. Parameters: cells - Array of whose topmost ancestors should be returned. -
toString
-