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:
java.io.Serializable,javax.swing.undo.UndoableEdit,GraphLayoutCacheEvent.GraphLayoutCacheChange,GraphModelEvent.GraphModelChange
- 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
Fields Modifier and Type Field Description protected java.util.Mapattributesprotected java.util.MapcellViewsprotected java.lang.Object[]changedprotected ConnectionSetconnectionSetprotected java.lang.Object[]contextprotected java.awt.geom.Rectangle2DdirtyRegionThe dirty region of the change prior to it happeningprotected java.lang.Object[]insertprotected java.lang.Object[]insertedprotected ParentMapparentMapprotected java.util.MappreviousAttributesprotected ConnectionSetpreviousConnectionSetprotected ParentMappreviousParentMapprotected java.lang.Object[]removeprotected java.lang.Object[]removed
-
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 voidchangeChildCount(java.util.Map childCount, java.lang.Object parent, int change)voidexecute()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.MapgetAttributes()Returns a map of (object, view attributes).java.lang.Object[]getChanged()Returns the cells that have changed.ConnectionSetgetConnectionSet()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.Rectangle2DgetDirtyRegion()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.ParentMapgetParentMap()Returns the parentMap.java.util.MapgetPreviousAttributes()Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.ConnectionSetgetPreviousConnectionSet()Returns a connection set representing the graph structure before the change was applied ( an "undo" of the change).ParentMapgetPreviousParentMap()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.ObjectgetSource()Returns the source of this change.CellView[]getViews(GraphLayoutCache view)Allows aGraphLayoutCacheto retrieve an array ofCellViewsthat was previously stored withputViews(GraphLayoutCache, CellView[]).protected voidhandleEmptyGroups(java.lang.Object[] groups)Adds the groups that become empty to the cells that will be removed.booleanisSignificant()voidputViews(GraphLayoutCache view, CellView[] views)Allows aGraphLayoutCacheto store cell views for cells that have been removed.voidredo()Redoes a change.voidsetDirtyRegion(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.StringtoString()voidundo()Undoes a change.
-
-
-
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
-
parentMap
protected ParentMap parentMap
-
previousParentMap
protected ParentMap previousParentMap
-
dirtyRegion
protected java.awt.geom.Rectangle2D dirtyRegion
The dirty region of the change prior to it happening
-
connectionSet
protected ConnectionSet connectionSet
-
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 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 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:
isSignificantin interfacejavax.swing.undo.UndoableEdit- Overrides:
isSignificantin classjavax.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:
getSourcein interfaceGraphLayoutCacheEvent.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:
getChangedin interfaceGraphLayoutCacheEvent.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:
getContextin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange- Returns:
- array of contextual cells
-
getInserted
public java.lang.Object[] getInserted()
Returns the cells that were inserted.- Specified by:
getInsertedin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange- Returns:
- the cells that were inserted by the change
-
getRemoved
public java.lang.Object[] getRemoved()
Returns the cells that were inserted.- Specified by:
getRemovedin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange- Returns:
- the cells that were removed by the change
-
getPreviousAttributes
public java.util.Map getPreviousAttributes()
Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.- Specified by:
getPreviousAttributesin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange- Returns:
- map of attributes before the change
-
getAttributes
public java.util.Map getAttributes()
Returns a map of (object, view attributes). The objects are model objects which need to be mapped to views.- Specified by:
getAttributesin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
-
getConnectionSet
public ConnectionSet getConnectionSet()
Returns the connectionSet.- Specified by:
getConnectionSetin interfaceGraphModelEvent.GraphModelChange- Returns:
- ConnectionSet
-
getPreviousConnectionSet
public ConnectionSet getPreviousConnectionSet()
Description copied from interface:GraphModelEvent.GraphModelChangeReturns a connection set representing the graph structure before the change was applied ( an "undo" of the change).- Specified by:
getPreviousConnectionSetin interfaceGraphModelEvent.GraphModelChange- Returns:
- the connection set of the graph before the change
-
getParentMap
public ParentMap getParentMap()
Returns the parentMap.- Specified by:
getParentMapin interfaceGraphModelEvent.GraphModelChange- Returns:
- ParentMap
-
getPreviousParentMap
public ParentMap getPreviousParentMap()
Description copied from interface:GraphModelEvent.GraphModelChangeReturns a parent map representing the group structure before the change was applied ( an "undo" of the change )- Specified by:
getPreviousParentMapin interfaceGraphModelEvent.GraphModelChange- Returns:
- the previous parent map
-
getDirtyRegion
public java.awt.geom.Rectangle2D getDirtyRegion()
Description copied from interface:GraphLayoutCacheEvent.GraphLayoutCacheChangeReturns the dirty region for the original position of the changed cells before the change happened.- Specified by:
getDirtyRegionin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange- Returns:
- the dirty region prior to the event
-
setDirtyRegion
public void setDirtyRegion(java.awt.geom.Rectangle2D dirty)
Description copied from interface:GraphLayoutCacheEvent.GraphLayoutCacheChangeIn 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:
setDirtyRegionin interfaceGraphLayoutCacheEvent.GraphLayoutCacheChange
-
redo
public void redo() throws javax.swing.undo.CannotRedoExceptionRedoes a change.- Specified by:
redoin interfacejavax.swing.undo.UndoableEdit- Overrides:
redoin classjavax.swing.undo.CompoundEdit- Throws:
javax.swing.undo.CannotRedoException- if the change cannot be redone
-
undo
public void undo() throws javax.swing.undo.CannotUndoExceptionUndoes a change.- Specified by:
undoin interfacejavax.swing.undo.UndoableEdit- Overrides:
undoin classjavax.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.GraphModelChangeAllows aGraphLayoutCacheto store cell views for cells that have been removed. Such cell views are used for re-insertion and restoring the visual attributes.- Specified by:
putViewsin interfaceGraphModelEvent.GraphModelChange- Parameters:
view- theGraphLayoutCacheto store the removed cellsviews- the cell views to be stored
-
getViews
public CellView[] getViews(GraphLayoutCache view)
Description copied from interface:GraphModelEvent.GraphModelChangeAllows aGraphLayoutCacheto retrieve an array ofCellViewsthat was previously stored withputViews(GraphLayoutCache, CellView[]).- Specified by:
getViewsin interfaceGraphModelEvent.GraphModelChange- Parameters:
view- theGraphLayoutCachewhose stored cells are to be retrieved
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjavax.swing.undo.CompoundEdit
-
-