Class mxGraphModel

  • All Implemented Interfaces:
    mxIGraphModel, java.io.Serializable

    public class mxGraphModel
    extends mxEventSource
    implements mxIGraphModel, java.io.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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      mxGraphModel()
      Constructs a new empty graph model.
      mxGraphModel​(java.lang.Object root)
      Constructs a new graph model.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object add​(java.lang.Object parent, java.lang.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​(java.lang.Object cell)
      Invoked after a cell has been added to a parent.
      protected void cellRemoved​(java.lang.Object cell)
      Invoked after a cell has been removed from the model.
      void clear()
      Sets a new root using createRoot.
      protected java.lang.Object cloneCell​(java.lang.Object cell, java.util.Map<java.lang.Object,​java.lang.Object> mapping, boolean includeChildren)
      Inner helper method for cloning cells recursively.
      java.lang.Object[] cloneCells​(java.lang.Object[] cells, boolean includeChildren)
      Returns an array of clones for the given array of cells.
      protected boolean collapsedStateForCellChanged​(java.lang.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​(java.lang.Object cell)
      Returns true if the model contains the given cell.
      java.lang.String createId​(java.lang.Object cell)
      Creates a new Id for the given cell and increments the global counter for creating new Ids.
      java.lang.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 java.lang.Object[] filterCells​(java.lang.Object[] cells, mxGraphModel.Filter filter)  
      static java.util.Collection<java.lang.Object> filterDescendants​(mxIGraphModel model, mxGraphModel.Filter filter)
      Creates a collection of cells using the visitor pattern.
      static java.util.Collection<java.lang.Object> filterDescendants​(mxIGraphModel model, mxGraphModel.Filter filter, java.lang.Object parent)
      Creates a collection of cells using the visitor pattern.
      protected mxGeometry geometryForCellChanged​(java.lang.Object cell, mxGeometry geometry)
      Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.
      java.lang.Object getCell​(java.lang.String id)
      Returns the cell for the specified Id or null if no cell can be found for the given Id.
      java.util.Map<java.lang.String,​java.lang.Object> getCells()
      Returns the internal lookup table that is used to map from Ids to cells.
      java.lang.Object getChildAt​(java.lang.Object parent, int index)
      Returns the child of the given parent at the given index.
      static java.lang.Object[] getChildCells​(mxIGraphModel model, java.lang.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​(java.lang.Object cell)
      Returns the number of children in the given cell.
      static java.lang.Object[] getChildEdges​(mxIGraphModel model, java.lang.Object parent)
      Returns the child edges of the given parent.
      static java.lang.Object[] getChildren​(mxIGraphModel model, java.lang.Object parent)
      Returns all children of the given cell regardless of their type.
      static java.lang.Object[] getChildVertices​(mxIGraphModel model, java.lang.Object parent)
      Returns the child vertices of the given parent.
      static java.lang.Object[] getConnections​(mxIGraphModel model, java.lang.Object cell)
      Returns all edges connected to this cell without loops.
      static java.util.Collection<java.lang.Object> getDescendants​(mxIGraphModel model, java.lang.Object parent)
      Returns a all descendants of the given cell and the cell itself as a collection.
      static int getDirectedEdgeCount​(mxIGraphModel model, java.lang.Object cell, boolean outgoing)
      Returns the number of incoming or outgoing edges.
      static int getDirectedEdgeCount​(mxIGraphModel model, java.lang.Object cell, boolean outgoing, java.lang.Object ignoredEdge)
      Returns the number of incoming or outgoing edges, ignoring the given edge.
      java.lang.Object getEdgeAt​(java.lang.Object parent, int index)
      Returns the edge of cell at the given index.
      int getEdgeCount​(java.lang.Object cell)
      Returns the number of distinct edges connected to the given cell.
      static java.lang.Object[] getEdges​(mxIGraphModel model, java.lang.Object cell)
      Returns all edges connected to this cell including loops.
      static java.lang.Object[] getEdges​(mxIGraphModel model, java.lang.Object cell, boolean incoming, boolean outgoing, boolean includeLoops)
      Returns all distinct edges connected to this cell.
      static java.lang.Object[] getEdgesBetween​(mxIGraphModel model, java.lang.Object source, java.lang.Object target)
      Returns all edges from the given source to the given target.
      static java.lang.Object[] getEdgesBetween​(mxIGraphModel model, java.lang.Object source, java.lang.Object target, boolean directed)
      Returns all edges between the given source and target pair.
      mxGeometry getGeometry​(java.lang.Object cell)
      Returns the geometry of the given cell.
      static java.lang.Object[] getIncomingEdges​(mxIGraphModel model, java.lang.Object cell)
      Returns the incoming edges of the given cell without loops.
      java.lang.Object getNearestCommonAncestor​(java.lang.Object cell1, java.lang.Object cell2)
      Returns the nearest common ancestor for the specified cells.
      static java.lang.Object[] getOpposites​(mxIGraphModel model, java.lang.Object[] edges, java.lang.Object terminal)
      Returns all opposite cells of terminal for the given edges.
      static java.lang.Object[] getOpposites​(mxIGraphModel model, java.lang.Object[] edges, java.lang.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​(java.lang.Object cell)
      Returns the absolute, accumulated origin for the children inside the given parent.
      static java.lang.Object[] getOutgoingEdges​(mxIGraphModel model, java.lang.Object cell)
      Returns the outgoing edges of the given cell without loops.
      java.lang.Object getParent​(java.lang.Object child)
      Returns the parent of the given cell.
      static java.lang.Object[] getParents​(mxIGraphModel model, java.lang.Object[] cells)  
      java.lang.Object getRoot()
      Returns the root of the model or the topmost parent of the given cell.
      java.lang.String getStyle​(java.lang.Object cell)
      Returns the style of the given cell.
      java.lang.Object getTerminal​(java.lang.Object edge, boolean isSource)
      Returns the source or target terminal of the given edge depending on the value of the boolean parameter.
      static java.lang.Object[] getTopmostCells​(mxIGraphModel model, java.lang.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()  
      java.lang.Object getValue​(java.lang.Object cell)
      Returns the user object of the given cell.
      boolean isAncestor​(java.lang.Object parent, java.lang.Object child)
      Returns true if the given parent is an ancestor of the given child.
      boolean isCollapsed​(java.lang.Object cell)
      Returns true if the given cell is collapsed.
      boolean isConnectable​(java.lang.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​(java.lang.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​(java.lang.Object cell)
      Returns true if the given cell is a vertex.
      boolean isVisible​(java.lang.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, java.util.Hashtable<java.lang.Object,​java.lang.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 java.lang.Object parentForCellChanged​(java.lang.Object cell, java.lang.Object parent, int index)
      Inner callback to update the parent of a cell using mxCell.insert on the parent and return the previous parent.
      java.lang.Object remove​(java.lang.Object cell)
      Removes the specified cell from the model.
      protected void restoreClone​(java.lang.Object clone, java.lang.Object cell, java.util.Map<java.lang.Object,​java.lang.Object> mapping)
      Inner helper method for restoring the connections in a network of cloned cells.
      protected java.lang.Object rootChanged​(java.lang.Object root)
      Inner callback to change the root of the model and update the internal datastructures, such as cells and nextId.
      boolean setCollapsed​(java.lang.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​(java.lang.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.
      java.lang.Object setRoot​(java.lang.Object root)
      Sets the root of the model and resets all structures.
      java.lang.String setStyle​(java.lang.Object cell, java.lang.String style)
      Sets the style of the given cell.
      java.lang.Object setTerminal​(java.lang.Object edge, java.lang.Object terminal, boolean isSource)
      Sets the source or target terminal of the given edge using.
      static void setTerminals​(mxIGraphModel model, java.lang.Object edge, java.lang.Object source, java.lang.Object target)
      Sets the source and target of the given edge in a single atomic change.
      java.lang.Object setValue​(java.lang.Object cell, java.lang.Object value)
      Sets the user object of then given cell.
      boolean setVisible​(java.lang.Object cell, boolean visible)
      Sets the visible state of the given cell.
      protected java.lang.String styleForCellChanged​(java.lang.Object cell, java.lang.String style)
      Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.
      protected java.lang.Object terminalForCellChanged​(java.lang.Object edge, java.lang.Object terminal, boolean isSource)
      Inner helper function to update the terminal of the edge using mxCell.insertEdge and return the previous terminal.
      java.lang.String toString()  
      void updateEdgeParent​(java.lang.Object edge, java.lang.Object root)
      Inner helper method to update the parent of the specified edge to the nearest-common-ancestor of its two terminals.
      void updateEdgeParents​(java.lang.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​(java.lang.Object cell, java.lang.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 java.lang.Object valueForCellChanged​(java.lang.Object cell, java.lang.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​(java.lang.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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 java.util.Map<java.lang.String,​java.lang.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​(java.lang.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 java.lang.Object createRoot()
        Creates a new root cell with a default layer (child 0).
      • getCells

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

        public java.lang.Object getCell​(java.lang.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 java.lang.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 java.lang.Object setRoot​(java.lang.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 java.lang.Object rootChanged​(java.lang.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 java.lang.Object[] cloneCells​(java.lang.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 java.lang.Object cloneCell​(java.lang.Object cell,
                                             java.util.Map<java.lang.Object,​java.lang.Object> mapping,
                                             boolean includeChildren)
                                      throws java.lang.CloneNotSupportedException
        Inner helper method for cloning cells recursively.
        Throws:
        java.lang.CloneNotSupportedException
      • restoreClone

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

        public boolean isAncestor​(java.lang.Object parent,
                                  java.lang.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​(java.lang.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 java.lang.Object getParent​(java.lang.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 java.lang.Object add​(java.lang.Object parent,
                                    java.lang.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​(java.lang.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 java.lang.String createId​(java.lang.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 java.lang.Object remove​(java.lang.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​(java.lang.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 java.lang.Object parentForCellChanged​(java.lang.Object cell,
                                                        java.lang.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​(java.lang.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 java.lang.Object getChildAt​(java.lang.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 java.lang.Object getTerminal​(java.lang.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 java.lang.Object setTerminal​(java.lang.Object edge,
                                            java.lang.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 java.lang.Object terminalForCellChanged​(java.lang.Object edge,
                                                          java.lang.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​(java.lang.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​(java.lang.Object cell,
                                      java.lang.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​(java.lang.Object edge,
                                     java.lang.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​(java.lang.Object cell)
        Returns the absolute, accumulated origin for the children inside the given parent.
      • getNearestCommonAncestor

        public java.lang.Object getNearestCommonAncestor​(java.lang.Object cell1,
                                                         java.lang.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​(java.lang.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 java.lang.Object getEdgeAt​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.Object getValue​(java.lang.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 java.lang.Object setValue​(java.lang.Object cell,
                                         java.lang.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 java.lang.Object valueForCellChanged​(java.lang.Object cell,
                                                       java.lang.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​(java.lang.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​(java.lang.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​(java.lang.Object cell,
                                                    mxGeometry geometry)
        Inner callback to update the mxGeometry of the given mxCell using mxCell.setGeometry and return the previous mxGeometry.
      • getStyle

        public java.lang.String getStyle​(java.lang.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 java.lang.String setStyle​(java.lang.Object cell,
                                         java.lang.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 java.lang.String styleForCellChanged​(java.lang.Object cell,
                                                       java.lang.String style)
        Inner callback to update the style of the given mxCell using mxCell.setStyle and return the previous style.
      • isCollapsed

        public boolean isCollapsed​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.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:
        java.lang.CloneNotSupportedException
      • mergeChildrenImpl

        protected void mergeChildrenImpl​(mxICell from,
                                         mxICell to,
                                         boolean cloneAllEdges,
                                         java.util.Hashtable<java.lang.Object,​java.lang.Object> mapping)
                                  throws java.lang.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:
        java.lang.CloneNotSupportedException
      • getDirectedEdgeCount

        public static int getDirectedEdgeCount​(mxIGraphModel model,
                                               java.lang.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,
                                               java.lang.Object cell,
                                               boolean outgoing,
                                               java.lang.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 java.lang.Object[] getEdges​(mxIGraphModel model,
                                                  java.lang.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 java.lang.Object[] getConnections​(mxIGraphModel model,
                                                        java.lang.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 java.lang.Object[] getIncomingEdges​(mxIGraphModel model,
                                                          java.lang.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 java.lang.Object[] getOutgoingEdges​(mxIGraphModel model,
                                                          java.lang.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 java.lang.Object[] getEdges​(mxIGraphModel model,
                                                  java.lang.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 java.lang.Object[] getEdgesBetween​(mxIGraphModel model,
                                                         java.lang.Object source,
                                                         java.lang.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 java.lang.Object[] getEdgesBetween​(mxIGraphModel model,
                                                         java.lang.Object source,
                                                         java.lang.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 java.lang.Object[] getOpposites​(mxIGraphModel model,
                                                      java.lang.Object[] edges,
                                                      java.lang.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 java.lang.Object[] getOpposites​(mxIGraphModel model,
                                                      java.lang.Object[] edges,
                                                      java.lang.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,
                                        java.lang.Object edge,
                                        java.lang.Object source,
                                        java.lang.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 java.lang.Object[] getChildren​(mxIGraphModel model,
                                                     java.lang.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 java.lang.Object[] getChildVertices​(mxIGraphModel model,
                                                          java.lang.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 java.lang.Object[] getChildEdges​(mxIGraphModel model,
                                                       java.lang.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 java.lang.Object[] getChildCells​(mxIGraphModel model,
                                                       java.lang.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 java.lang.Object[] getParents​(mxIGraphModel model,
                                                    java.lang.Object[] cells)
      • filterCells

        public static java.lang.Object[] filterCells​(java.lang.Object[] cells,
                                                     mxGraphModel.Filter filter)
      • getDescendants

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

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

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

        public static java.lang.Object[] getTopmostCells​(mxIGraphModel model,
                                                         java.lang.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.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object