org.jgraph.graph

Class DefaultGraphModel.GraphModelEdit

public class DefaultGraphModel.GraphModelEdit extends CompoundEdit implements GraphModelEvent.GraphModelChange

An implementation of GraphModelChange that can be added to the model event.
Field Summary
protected Mapattributes
protected MapcellViews
protected Object[]changed
protected ConnectionSetconnectionSet
protected Object[]context
protected Rectangle2DdirtyRegion
The dirty region of the change prior to it happening
protected Object[]insert
protected Object[]inserted
protected ParentMapparentMap
protected MappreviousAttributes
protected ConnectionSetpreviousConnectionSet
protected ParentMappreviousParentMap
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 voidchangeChildCount(Map childCount, Object parent, int change)
voidexecute()
Execute this edit such that the next invocation to this method will invert the last execution.
Object[]filterParents(Map childCount, int children)
MapgetAttributes()
Returns a map of (object, view attributes).
Object[]getChanged()
Returns the cells that have changed.
ConnectionSetgetConnectionSet()
Returns the connectionSet.
Object[]getContext()
Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.
Rectangle2DgetDirtyRegion()
Object[]getInserted()
Returns the cells that were inserted.
ParentMapgetParentMap()
Returns the parentMap.
MapgetPreviousAttributes()
Returns a map that contains (object, map) pairs of the attributes that have been stored in the model.
ConnectionSetgetPreviousConnectionSet()
ParentMapgetPreviousParentMap()
Object[]getRemoved()
Returns the cells that were inserted.
ObjectgetSource()
Returns the source of this change.
CellView[]getViews(GraphLayoutCache view)
protected voidhandleEmptyGroups(Object[] groups)
Adds the groups that become empty to the cells that will be removed.
booleanisSignificant()
voidputViews(GraphLayoutCache view, CellView[] views)
voidredo()
Redoes a change.
voidsetDirtyRegion(Rectangle2D dirty)
StringtoString()
voidundo()
Undoes a change.

Field Detail

attributes

protected Map attributes

cellViews

protected Map cellViews

changed

protected Object[] changed

connectionSet

protected ConnectionSet connectionSet

context

protected Object[] context

dirtyRegion

protected Rectangle2D dirtyRegion
The dirty region of the change prior to it happening

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 Detail

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 Detail

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.

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.

getConnectionSet

public ConnectionSet getConnectionSet()
Returns the connectionSet.

Returns: ConnectionSet

getContext

public Object[] getContext()
Returns the objects that have not changed explicitly, but implicitly because one of their dependent cells has changed.

getDirtyRegion

public Rectangle2D getDirtyRegion()

getInserted

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

getParentMap

public ParentMap getParentMap()
Returns the parentMap.

Returns: ParentMap

getPreviousAttributes

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

getPreviousConnectionSet

public ConnectionSet getPreviousConnectionSet()

getPreviousParentMap

public ParentMap getPreviousParentMap()

getRemoved

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

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.

getViews

public CellView[] getViews(GraphLayoutCache view)

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)

redo

public void redo()
Redoes a change.

Throws: CannotRedoException if the change cannot be redone

setDirtyRegion

public void setDirtyRegion(Rectangle2D dirty)

toString

public String toString()

undo

public void undo()
Undoes a change.

Throws: CannotUndoException if the change cannot be undone

Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.