org.jgraph.graph

Class DefaultGraphModel.GraphModelEdit

Enclosing Class:
DefaultGraphModel
Implemented Interfaces:
GraphLayoutCacheEvent.GraphLayoutCacheChange, GraphModelEvent.GraphModelChange

public class DefaultGraphModel.GraphModelEdit
extends CompoundEdit
implements GraphModelEvent.GraphModelChange

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

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

Constructor Summary

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)
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)
void
redo()
Redoes a change.
String
toString()
void
undo()
Undoes a change.

Field Details

attributes

protected Map attributes

cellViews

protected Map cellViews

changed

protected Object[] changed

connectionSet

protected ConnectionSet connectionSet

context

protected Object[] context

insert

protected Object[] insert

inserted

protected Object[] inserted

parentMap

protected ParentMap parentMap

previousAttributes

protected Map previousAttributes

previousConnectionSet

protected ConnectionSet previousConnectionSet

previousParentMap

protected ParentMap previousParentMap

remove

protected Object[] remove

removed

protected Object[] removed

Constructor Details

GraphModelEdit

public GraphModelEdit(Object[] inserted,
                      Object[] removed,
                      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 Details

changeChildCount

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

execute

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

filterParents

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

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 GraphLayoutCacheEvent.GraphLayoutCacheChange

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 GraphLayoutCacheEvent.GraphLayoutCacheChange

getConnectionSet

public ConnectionSet getConnectionSet()
Returns the connectionSet.
Specified by:
getConnectionSet in interface GraphModelEvent.GraphModelChange
Returns:
ConnectionSet

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 GraphLayoutCacheEvent.GraphLayoutCacheChange

getInserted

public Object[] getInserted()
Returns the cells that were inserted.
Specified by:
getInserted in interface GraphLayoutCacheEvent.GraphLayoutCacheChange

getParentMap

public ParentMap getParentMap()
Returns the parentMap.
Specified by:
getParentMap in interface GraphModelEvent.GraphModelChange
Returns:
ParentMap

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 GraphLayoutCacheEvent.GraphLayoutCacheChange

getPreviousConnectionSet

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

getPreviousParentMap

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

getRemoved

public Object[] getRemoved()
Returns the cells that were inserted.
Specified by:
getRemoved in interface GraphLayoutCacheEvent.GraphLayoutCacheChange

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 GraphLayoutCacheEvent.GraphLayoutCacheChange

getViews

public CellView[] getViews(GraphLayoutCache view)
Specified by:
getViews in interface GraphModelEvent.GraphModelChange

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()

putViews

public void putViews(GraphLayoutCache view,
                     CellView[] views)
Specified by:
putViews in interface GraphModelEvent.GraphModelChange

redo

public void redo()
            throws CannotRedoException
Redoes a change.

toString

public String toString()

undo

public void undo()
            throws CannotUndoException
Undoes a change.

Copyright (C) 2001-2006 Gaudenz Alder. All rights reserved.