Class DefaultGraphModel.GraphModelEdit

    • Constructor Summary

      Constructors 
      Constructor Description
      GraphModelEdit​(java.lang.Object[] inserted, java.lang.Object[] removed, java.util.Map attributes, ConnectionSet connectionSet, ParentMap parentMap)
      Constructs an edit record.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void changeChildCount​(java.util.Map childCount, java.lang.Object parent, int change)  
      void execute()
      Execute this edit such that the next invocation to this method will invert the last execution.
      java.lang.Object[] filterParents​(java.util.Map childCount, int children)  
      java.util.Map getAttributes()
      Returns a map of (object, view attributes).
      java.lang.Object[] getChanged()
      Returns the cells that have changed.
      ConnectionSet getConnectionSet()
      Returns the connectionSet.
      java.lang.Object[] getContext()
      Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.
      java.awt.geom.Rectangle2D getDirtyRegion()
      Returns the dirty region for the original position of the changed cells before the change happened.
      java.lang.Object[] getInserted()
      Returns the cells that were inserted.
      ParentMap getParentMap()
      Returns the parentMap.
      java.util.Map getPreviousAttributes()
      Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.
      ConnectionSet getPreviousConnectionSet()
      Returns a connection set representing the graph structure before the change was applied ( an "undo" of the change).
      ParentMap getPreviousParentMap()
      Returns a parent map representing the group structure before the change was applied ( an "undo" of the change )
      java.lang.Object[] getRemoved()
      Returns the cells that were inserted.
      java.lang.Object getSource()
      Returns the source of this change.
      CellView[] getViews​(GraphLayoutCache view)
      Allows a GraphLayoutCache to retrieve an array of CellViews that was previously stored with putViews(GraphLayoutCache, CellView[]).
      protected void handleEmptyGroups​(java.lang.Object[] groups)
      Adds the groups that become empty to the cells that will be removed.
      boolean isSignificant()  
      void putViews​(GraphLayoutCache view, CellView[] views)
      Allows a GraphLayoutCache to store cell views for cells that have been removed.
      void redo()
      Redoes a change.
      void setDirtyRegion​(java.awt.geom.Rectangle2D dirty)
      In some cases the class firing this event will not have access to the dirty region prior to the change.
      java.lang.String toString()  
      void undo()
      Undoes a change.
      • Methods inherited from class javax.swing.undo.CompoundEdit

        addEdit, canRedo, canUndo, die, end, getPresentationName, getRedoPresentationName, getUndoPresentationName, isInProgress, lastEdit
      • Methods inherited from class javax.swing.undo.AbstractUndoableEdit

        replaceEdit
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • insert

        protected java.lang.Object[] insert
      • changed

        protected java.lang.Object[] changed
      • remove

        protected java.lang.Object[] remove
      • context

        protected java.lang.Object[] context
      • inserted

        protected java.lang.Object[] inserted
      • removed

        protected java.lang.Object[] removed
      • attributes

        protected java.util.Map attributes
      • previousAttributes

        protected java.util.Map previousAttributes
      • previousParentMap

        protected ParentMap previousParentMap
      • dirtyRegion

        protected java.awt.geom.Rectangle2D dirtyRegion
        The dirty region of the change prior to it happening
      • previousConnectionSet

        protected ConnectionSet previousConnectionSet
      • cellViews

        protected java.util.Map cellViews
    • Constructor Detail

      • GraphModelEdit

        public GraphModelEdit​(java.lang.Object[] inserted,
                              java.lang.Object[] removed,
                              java.util.Map attributes,
                              ConnectionSet connectionSet,
                              ParentMap parentMap)
        Constructs an edit record.
        Parameters:
        inserted - a set of roots that were inserted
        removed - a set of elements that were removed
        attributes - the attribute changes made by the edit
        connectionSet - the set of changed connections
        parentMap - the map of changed parents
    • Method Detail

      • filterParents

        public java.lang.Object[] filterParents​(java.util.Map childCount,
                                                int children)
      • changeChildCount

        protected void changeChildCount​(java.util.Map childCount,
                                        java.lang.Object parent,
                                        int change)
      • handleEmptyGroups

        protected void handleEmptyGroups​(java.lang.Object[] groups)
        Adds the groups that become empty to the cells that will be removed. (Auto remove empty cells.) Removed cells will be re-inserted on undo, and the parent- child relations will be restored.
      • isSignificant

        public boolean isSignificant()
        Specified by:
        isSignificant in interface javax.swing.undo.UndoableEdit
        Overrides:
        isSignificant in class javax.swing.undo.CompoundEdit
      • getSource

        public java.lang.Object getSource()
        Returns the source of this change. This can either be a view or a model, if this change is a GraphModelChange.
        Specified by:
        getSource in interface GraphLayoutCacheEvent.GraphLayoutCacheChange
        Returns:
        the source fo this change
      • getChanged

        public java.lang.Object[] getChanged()
        Returns the cells that have changed. This includes the cells that have been changed through a call to getAttributes and the edges that have been changed with the ConnectionSet.
        Specified by:
        getChanged in interface GraphLayoutCacheEvent.GraphLayoutCacheChange
        Returns:
        the cell changed
      • getContext

        public java.lang.Object[] getContext()
        Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.
        Specified by:
        getContext in interface GraphLayoutCacheEvent.GraphLayoutCacheChange
        Returns:
        array of contextual cells
      • redo

        public void redo()
                  throws javax.swing.undo.CannotRedoException
        Redoes a change.
        Specified by:
        redo in interface javax.swing.undo.UndoableEdit
        Overrides:
        redo in class javax.swing.undo.CompoundEdit
        Throws:
        javax.swing.undo.CannotRedoException - if the change cannot be redone
      • undo

        public void undo()
                  throws javax.swing.undo.CannotUndoException
        Undoes a change.
        Specified by:
        undo in interface javax.swing.undo.UndoableEdit
        Overrides:
        undo in class javax.swing.undo.CompoundEdit
        Throws:
        javax.swing.undo.CannotUndoException - if the change cannot be undone
      • execute

        public void execute()
        Execute this edit such that the next invocation to this method will invert the last execution.
      • putViews

        public void putViews​(GraphLayoutCache view,
                             CellView[] views)
        Description copied from interface: GraphModelEvent.GraphModelChange
        Allows a GraphLayoutCache to store cell views for cells that have been removed. Such cell views are used for re-insertion and restoring the visual attributes.
        Specified by:
        putViews in interface GraphModelEvent.GraphModelChange
        Parameters:
        view - the GraphLayoutCache to store the removed cells
        views - the cell views to be stored
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class javax.swing.undo.CompoundEdit