Package org.jgraph.graph
Class DefaultGraphModel.GraphModelEdit
java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
org.jgraph.graph.DefaultGraphModel.GraphModelEdit
- All Implemented Interfaces:
Serializable
,UndoableEdit
,GraphLayoutCacheEvent.GraphLayoutCacheChange
,GraphModelEvent.GraphModelChange
- Enclosing class:
- DefaultGraphModel
public class DefaultGraphModel.GraphModelEdit
extends CompoundEdit
implements GraphModelEvent.GraphModelChange
An implementation of GraphModelChange that can be added to the model
event.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map
protected Map
protected Object[]
protected ConnectionSet
protected Object[]
protected Rectangle2D
The dirty region of the change prior to it happeningprotected Object[]
protected Object[]
protected ParentMap
protected Map
protected ConnectionSet
protected ParentMap
protected Object[]
protected Object[]
Fields inherited from class javax.swing.undo.CompoundEdit
edits
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
-
Constructor Summary
ConstructorsConstructorDescriptionGraphModelEdit
(Object[] inserted, Object[] removed, Map attributes, ConnectionSet connectionSet, ParentMap parentMap) Constructs an edit record. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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) Returns a map of (object, view attributes).Object[]
Returns the cells that have changed.Returns the connectionSet.Object[]
Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.Returns the dirty region for the original position of the changed cells before the change happened.Object[]
Returns the cells that were inserted.Returns the parentMap.Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.Returns a connection set representing the graph structure before the change was applied ( an "undo" of the change).Returns a parent map representing the group structure before the change was applied ( an "undo" of the change )Object[]
Returns the cells that were inserted.Returns the source of this change.CellView[]
getViews
(GraphLayoutCache view) Allows aGraphLayoutCache
to retrieve an array ofCellViews
that was previously stored withputViews(GraphLayoutCache, CellView[])
.protected void
handleEmptyGroups
(Object[] groups) Adds the groups that become empty to the cells that will be removed.boolean
void
putViews
(GraphLayoutCache view, CellView[] views) Allows aGraphLayoutCache
to store cell views for cells that have been removed.void
redo()
Redoes a change.void
setDirtyRegion
(Rectangle2D dirty) In some cases the class firing this event will not have access to the dirty region prior to the change.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
-
Field Details
-
insert
-
changed
-
remove
-
context
-
inserted
-
removed
-
attributes
-
previousAttributes
-
parentMap
-
previousParentMap
-
dirtyRegion
The dirty region of the change prior to it happening -
connectionSet
-
previousConnectionSet
-
cellViews
-
-
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 insertedremoved
- a set of elements that were removedattributes
- the attribute changes made by the editconnectionSet
- the set of changed connectionsparentMap
- the map of changed parents
-
-
Method Details
-
filterParents
-
changeChildCount
-
handleEmptyGroups
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 interfaceUndoableEdit
- Overrides:
isSignificant
in classCompoundEdit
-
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 interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- the source fo this change
-
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 interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- the cell changed
-
getContext
Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.- Specified by:
getContext
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- array of contextual cells
-
getInserted
Returns the cells that were inserted.- Specified by:
getInserted
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- the cells that were inserted by the change
-
getRemoved
Returns the cells that were inserted.- Specified by:
getRemoved
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- the cells that were removed by the change
-
getPreviousAttributes
Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.- Specified by:
getPreviousAttributes
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- map of attributes before the change
-
getAttributes
Returns a map of (object, view attributes). The objects are model objects which need to be mapped to views.- Specified by:
getAttributes
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
-
getConnectionSet
Returns the connectionSet.- Specified by:
getConnectionSet
in interfaceGraphModelEvent.GraphModelChange
- Returns:
- ConnectionSet
-
getPreviousConnectionSet
Description copied from interface:GraphModelEvent.GraphModelChange
Returns a connection set representing the graph structure before the change was applied ( an "undo" of the change).- Specified by:
getPreviousConnectionSet
in interfaceGraphModelEvent.GraphModelChange
- Returns:
- the connection set of the graph before the change
-
getParentMap
Returns the parentMap.- Specified by:
getParentMap
in interfaceGraphModelEvent.GraphModelChange
- Returns:
- ParentMap
-
getPreviousParentMap
Description copied from interface:GraphModelEvent.GraphModelChange
Returns a parent map representing the group structure before the change was applied ( an "undo" of the change )- Specified by:
getPreviousParentMap
in interfaceGraphModelEvent.GraphModelChange
- Returns:
- the previous parent map
-
getDirtyRegion
Description copied from interface:GraphLayoutCacheEvent.GraphLayoutCacheChange
Returns the dirty region for the original position of the changed cells before the change happened.- Specified by:
getDirtyRegion
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
- Returns:
- the dirty region prior to the event
-
setDirtyRegion
Description copied from interface:GraphLayoutCacheEvent.GraphLayoutCacheChange
In some cases the class firing this event will not have access to the dirty region prior to the change. It is then up to the receiving class to set it once.- Specified by:
setDirtyRegion
in interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
-
redo
Redoes a change.- Specified by:
redo
in interfaceUndoableEdit
- Overrides:
redo
in classCompoundEdit
- Throws:
CannotRedoException
- if the change cannot be redone
-
undo
Undoes a change.- Specified by:
undo
in interfaceUndoableEdit
- Overrides:
undo
in classCompoundEdit
- 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. -
putViews
Description copied from interface:GraphModelEvent.GraphModelChange
Allows aGraphLayoutCache
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 interfaceGraphModelEvent.GraphModelChange
- Parameters:
view
- theGraphLayoutCache
to store the removed cellsviews
- the cell views to be stored
-
getViews
Description copied from interface:GraphModelEvent.GraphModelChange
Allows aGraphLayoutCache
to retrieve an array ofCellViews
that was previously stored withputViews(GraphLayoutCache, CellView[])
.- Specified by:
getViews
in interfaceGraphModelEvent.GraphModelChange
- Parameters:
view
- theGraphLayoutCache
whose stored cells are to be retrieved
-
toString
- Overrides:
toString
in classCompoundEdit
-