com.jgraph.graph
Class DefaultGraphModel.GraphModelEdit

java.lang.Object
  extended byjavax.swing.undo.AbstractUndoableEdit
      extended byjavax.swing.undo.CompoundEdit
          extended bycom.jgraph.graph.DefaultGraphModel.GraphModelEdit
All Implemented Interfaces:
GraphModelEvent.GraphModelChange, GraphModelEvent.GraphViewChange, java.io.Serializable, javax.swing.undo.UndoableEdit
Enclosing class:
DefaultGraphModel

public class DefaultGraphModel.GraphModelEdit
extends javax.swing.undo.CompoundEdit
implements GraphModelEvent.GraphModelChange

An implementation of GraphModelChange that can be added to the model event.

See Also:
Serialized Form

Field Summary
protected  java.util.Map attributeMap
           
protected  java.util.Map cellViews
           
protected  java.lang.Object[] changed
           
protected  ConnectionSet connectionSet
           
protected  java.lang.Object[] context
           
protected  java.lang.Object[] insert
           
protected  java.lang.Object[] inserted
           
protected  java.util.Map lastPropertyMap
           
protected  ParentMap parentMap
           
protected  java.util.Map propertyMap
           
protected  java.lang.Object[] remove
           
protected  java.lang.Object[] removed
           
 
Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
DefaultGraphModel.GraphModelEdit(ConnectionSet cs, java.util.Map propertyMap, ParentMap parentMap)
          Constructs an edit that represents a change.
DefaultGraphModel.GraphModelEdit(java.lang.Object[] removed, ConnectionSet cs, ParentMap parentMap)
          Constructs an edit that represents a remove.
DefaultGraphModel.GraphModelEdit(java.lang.Object[] inserted, ConnectionSet cs, ParentMap parentMap, java.util.Map attributeMap)
          Constructs an edit that represents an insert.
DefaultGraphModel.GraphModelEdit(java.lang.Object[] inserted, java.lang.Object[] removed, ConnectionSet connectionSet, java.util.Map propertyMap, ParentMap parentMap, java.util.Map attributeMap)
          Constructs an edit record.
 
Method Summary
 void execute()
          Execute this edit such that the next invocation to this method will invert the last execution.
 java.util.Map getAttributeMap()
          Returns a map of (object, view attributes).
 java.lang.Object[] getChanged()
          Returns the cells that have changed.
 java.lang.Object[] getContext()
          Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.
 java.lang.Object[] getInserted()
          Returns the cells that were inserted.
 java.lang.Object[] getRemoved()
          Returns the cells that were inserted.
 java.lang.Object getSource()
          Returns the source of this change.
 java.util.Map getStoredAttributeMap()
          Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.
 CellView[] getViews(GraphView view)
          Allows a GraphView to retrieve an array of CellViews that was previously stored with putViews(GraphView, 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(GraphView view, CellView[] views)
          Allows a GraphView to store an array of CellViews (used for command history).
 void redo()
          Redoes a 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

propertyMap

protected java.util.Map propertyMap

attributeMap

protected java.util.Map attributeMap

lastPropertyMap

protected java.util.Map lastPropertyMap

parentMap

protected ParentMap parentMap

connectionSet

protected ConnectionSet connectionSet

cellViews

protected java.util.Map cellViews
Constructor Detail

DefaultGraphModel.GraphModelEdit

public DefaultGraphModel.GraphModelEdit(java.lang.Object[] removed,
                                        ConnectionSet cs,
                                        ParentMap parentMap)
Constructs an edit that represents a remove.


DefaultGraphModel.GraphModelEdit

public DefaultGraphModel.GraphModelEdit(java.lang.Object[] inserted,
                                        ConnectionSet cs,
                                        ParentMap parentMap,
                                        java.util.Map attributeMap)
Constructs an edit that represents an insert.


DefaultGraphModel.GraphModelEdit

public DefaultGraphModel.GraphModelEdit(ConnectionSet cs,
                                        java.util.Map propertyMap,
                                        ParentMap parentMap)
Constructs an edit that represents a change.


DefaultGraphModel.GraphModelEdit

public DefaultGraphModel.GraphModelEdit(java.lang.Object[] inserted,
                                        java.lang.Object[] removed,
                                        ConnectionSet connectionSet,
                                        java.util.Map propertyMap,
                                        ParentMap parentMap,
                                        java.util.Map attributeMap)
Constructs an edit record.

Parameters:
removed - a set of elements that were removed
inserted - a set of roots that were inserted
Method Detail

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

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 GraphModelEvent.GraphViewChange

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 GraphModelEvent.GraphViewChange

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 GraphModelEvent.GraphViewChange

getInserted

public java.lang.Object[] getInserted()
Returns the cells that were inserted.

Specified by:
getInserted in interface GraphModelEvent.GraphModelChange

getRemoved

public java.lang.Object[] getRemoved()
Returns the cells that were inserted.

Specified by:
getRemoved in interface GraphModelEvent.GraphModelChange

getStoredAttributeMap

public java.util.Map getStoredAttributeMap()
Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.

Specified by:
getStoredAttributeMap in interface GraphModelEvent.GraphModelChange

getAttributeMap

public java.util.Map getAttributeMap()
Returns a map of (object, view attributes). The objects are model objects which need to be mapped to views.

Specified by:
getAttributeMap in interface GraphModelEvent.GraphViewChange

redo

public void redo()
          throws javax.swing.undo.CannotRedoException
Redoes a change.

Specified by:
redo in interface javax.swing.undo.UndoableEdit
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
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(GraphView view,
                     CellView[] views)
Description copied from interface: GraphModelEvent.GraphModelChange
Allows a GraphView to store an array of CellViews (used for command history).

Specified by:
putViews in interface GraphModelEvent.GraphModelChange

getViews

public CellView[] getViews(GraphView view)
Description copied from interface: GraphModelEvent.GraphModelChange
Allows a GraphView to retrieve an array of CellViews that was previously stored with putViews(GraphView, CellView[]).

Specified by:
getViews in interface GraphModelEvent.GraphModelChange

toString

public java.lang.String toString()