org.jgraph.graph
Class DefaultGraphModel.GraphModelEdit

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

public class DefaultGraphModel.GraphModelEdit
extends CompoundEdit
implements GraphModelEvent.GraphModelChange, GraphModelEvent.ExecutableGraphChange

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

See Also:
Serialized Form

Field Summary
protected  Map attributes
           
protected  Map cellViews
           
protected  Object[] changed
           
protected  ConnectionSet connectionSet
           
protected  Object[] context
           
protected  Object[] insert
           
protected  Object[] inserted
           
protected  ParentMap parentMap
           
protected  Map previousAttributes
           
protected  ConnectionSet previousConnectionSet
           
protected  ParentMap previousParentMap
           
protected  Object[] remove
           
protected  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(Object[] inserted, Object[] removed, Map attributes, ConnectionSet connectionSet, ParentMap parentMap)
          Constructs an edit record.
 
Method Summary
protected  void changeChildCount(Map childCount, Object parent, int change)
           
 void execute()
          Execute this edit such that the next invocation to this method will invert the last execution.
 Object[] filterParents(Map childCount, int children)
           
 Map getAttributes()
          Returns a map of (object, view attributes).
 Object[] getChanged()
          Returns the cells that have changed.
 ConnectionSet getConnectionSet()
          Returns the connectionSet.
 Object[] getContext()
          Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.
 Object[] getInserted()
          Returns the cells that were inserted.
 ParentMap getParentMap()
          Returns the parentMap.
 Map getPreviousAttributes()
          Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.
 ConnectionSet getPreviousConnectionSet()
           
 ParentMap getPreviousParentMap()
           
 Object[] getRemoved()
          Returns the cells that were inserted.
 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(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.
 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 Object[] insert

changed

protected Object[] changed

remove

protected Object[] remove

context

protected Object[] context

inserted

protected Object[] inserted

removed

protected Object[] removed

attributes

protected Map attributes

previousAttributes

protected Map previousAttributes

parentMap

protected ParentMap parentMap

previousParentMap

protected ParentMap previousParentMap

connectionSet

protected ConnectionSet connectionSet

previousConnectionSet

protected ConnectionSet previousConnectionSet

cellViews

protected Map cellViews
Constructor Detail

DefaultGraphModel.GraphModelEdit

public DefaultGraphModel.GraphModelEdit(Object[] inserted,
                                        Object[] removed,
                                        Map attributes,
                                        ConnectionSet connectionSet,
                                        ParentMap parentMap)
Constructs an edit record. NOparam e the element NOparam index the index into the model >= 0

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

filterParents

public Object[] filterParents(Map childCount,
                              int children)

changeChildCount

protected void changeChildCount(Map childCount,
                                Object parent,
                                int change)

handleEmptyGroups

protected void handleEmptyGroups(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 UndoableEdit
Overrides:
isSignificant in class CompoundEdit

getSource

public 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 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 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 Object[] getInserted()
Returns the cells that were inserted.

Specified by:
getInserted in interface GraphModelEvent.GraphModelChange

getRemoved

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

Specified by:
getRemoved in interface GraphModelEvent.GraphModelChange

getPreviousAttributes

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

Specified by:
getPreviousAttributes in interface GraphModelEvent.GraphModelChange

getAttributes

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

Specified by:
getAttributes in interface GraphModelEvent.GraphViewChange

getConnectionSet

public ConnectionSet getConnectionSet()
Returns the connectionSet.

Returns:
ConnectionSet

getPreviousConnectionSet

public ConnectionSet getPreviousConnectionSet()
Specified by:
getPreviousConnectionSet in interface GraphModelEvent.GraphModelChange

getParentMap

public ParentMap getParentMap()
Returns the parentMap.

Returns:
ParentMap

getPreviousParentMap

public ParentMap getPreviousParentMap()
Specified by:
getPreviousParentMap in interface GraphModelEvent.GraphModelChange

redo

public void redo()
          throws CannotRedoException
Redoes a change.

Specified by:
redo in interface UndoableEdit
Overrides:
redo in class CompoundEdit
Throws:
CannotRedoException - if the change cannot be redone

undo

public void undo()
          throws CannotUndoException
Undoes a change.

Specified by:
undo in interface UndoableEdit
Overrides:
undo in class CompoundEdit
Throws:
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.

Specified by:
execute in interface GraphModelEvent.ExecutableGraphChange

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

getViews

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

Specified by:
getViews in interface GraphModelEvent.GraphModelChange

toString

public String toString()
Overrides:
toString in class CompoundEdit