|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.Graph2DUndoManager
public class Graph2DUndoManager
This class provides undoability and redoability support for Graph2D changes.
It must be registered
as a GraphListener and Graph2D.BackupRealizersHandler
to make this class aware of Graph2D changes. The backup mechanism of realizers depends
on a correct implementation of their createCopy method.
GraphEvent.PRE_EVENT and GraphEvent.POST_EVENT
serve as hints for the undo manager to decide which commands to group into a single
command that can be undone or redone. To group a sequence of graph changes in one
undoable command use the following code:
Graph2D graph = ... graph.firePreEvent(); //block of graph changes follows graph.firePostEvent;changes to the realizers of the nodes and edges are handled by backing up realizers that are about to change. Use the Graph2D methods
Graph2D.backupRealizers(NodeCursor) and Graph2D.backupRealizers(EdgeCursor)
in your code whenever you want to be able to revert to the former state of the realizers
at a later time.
| Nested Class Summary | |
|---|---|
static interface |
Graph2DUndoManager.UndoListener
Implementations of this interface can register with the UndoManager to receive notification whenever a new command is added to the queue of undoable events. |
| Constructor Summary | |
|---|---|
Graph2DUndoManager()
Creates a new Instance of UndoManager. |
|
| Method Summary | |
|---|---|
void |
addUndoListener(Graph2DUndoManager.UndoListener listener)
Registers the given UndoListener with the UndoManager. |
void |
backupRealizers(Graph2D graph,
EdgeCursor ec)
Graph2D.BackupRealizersHandler implementation. |
void |
backupRealizers(Graph2D graph,
NodeCursor nc)
Graph2D.BackupRealizersHandler implementation. |
boolean |
canRedo()
Returns whether or not there is a command that can be redone. |
boolean |
canUndo()
Returns whether or not there is a command that can be undone. |
protected void |
commandAdded(Command com)
Calling this method will inform all registered UndoListeners that the given command has been added to the command queue. |
Object |
getActiveToken()
Obtains a token which determines the currently active position in the stream. |
int |
getMaximumUndoDepth()
Returns the maximum number of commands stored on the undo stream. |
Action |
getRedoAction()
Returns a swing action that can be used to trigger a redo operation. |
Action |
getUndoAction()
Returns a swing action that can be used to trigger an undo operation. |
ViewContainer |
getViewContainer()
Returns the view container this undo manager is associated with. |
boolean |
isActive()
Getter for property active. |
boolean |
isActiveToken(Object token)
Determines, whether the stream is currently at the same position, the time the token was obtained using getActiveToken() |
boolean |
isSelectionStateAdjusting()
Determines whether this instance adjust the selection state
of the realizers to match that of the currently active realizers upon realizer exchange. |
void |
onGraphEvent(GraphEvent e)
Graph2DListener implementation.Structural changes of the graph will be
converted to undoable commands and stored in a command stream for later execution. |
void |
push(Command com)
This method can be used to push undoable commands on the stream. |
void |
redo()
Causes the next command in line to be redone. |
void |
removeUndoListener(Graph2DUndoManager.UndoListener listener)
Removed the given UndoListener from the UndoManager. |
void |
resetQueue()
Clears the current undo queue, i.e. canUndo() and canRedo() will return false if invoked directly after this call. |
protected void |
sanatize()
Performs the suitable number of close bracket operations, to ensure undo() and redo() will work as expected. |
boolean |
setExchangeRealizersOnBackup()
Returns the exchangeRealizerOnBackup policy used. |
void |
setExchangeRealizersOnBackup(boolean exchange)
Controls whether or not an exchange of the realizers associated with a node or edge is desired when backing them up. |
void |
setMaximumUndoDepth(int depth)
Sets the maximum number of commands stored on the undo stream. |
void |
setSelectionStateAdjusting(boolean selectionStateAdjusting)
Sets whether this instance should adjust the selection state
of the realizers to match that of the currently active realizers upon realizer exchange. |
void |
setViewContainer(ViewContainer view)
Sets the view container this undo manager is associated with. |
void |
undo()
Causes the next command in line to be undone. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Graph2DUndoManager()
| Method Detail |
|---|
public boolean isSelectionStateAdjusting()
selection state
of the realizers to match that of the currently active realizers upon realizer exchange.
true.public void setSelectionStateAdjusting(boolean selectionStateAdjusting)
selection state
of the realizers to match that of the currently active realizers upon realizer exchange.
public void setExchangeRealizersOnBackup(boolean exchange)
false.
public boolean setExchangeRealizersOnBackup()
public boolean canUndo()
public boolean canRedo()
public void push(Command com)
public void setMaximumUndoDepth(int depth)
public void resetQueue()
public int getMaximumUndoDepth()
public void undo()
public void redo()
protected void sanatize()
public Object getActiveToken()
isActiveToken(Object) can be used to determine, whether the
current stream position equals the position at the time to token was
obtained
public boolean isActiveToken(Object token)
getActiveToken()
token - the token
public boolean isActive()
public void onGraphEvent(GraphEvent e)
Graph2DListener implementation.Structural changes of the graph will be
converted to undoable commands and stored in a command stream for later execution.
onGraphEvent in interface GraphListenerpublic Action getUndoAction()
setViewContainer(ViewContainer)public Action getRedoAction()
setViewContainer(ViewContainer)public void addUndoListener(Graph2DUndoManager.UndoListener listener)
public void removeUndoListener(Graph2DUndoManager.UndoListener listener)
protected void commandAdded(Command com)
public void setViewContainer(ViewContainer view)
public ViewContainer getViewContainer()
public void backupRealizers(Graph2D graph,
NodeCursor nc)
Graph2D.BackupRealizersHandler implementation. This method
creates copies of the given realizer and stores them in undoable commands
for later reactivation.
backupRealizers in interface Graph2D.BackupRealizersHandler
public void backupRealizers(Graph2D graph,
EdgeCursor ec)
Graph2D.BackupRealizersHandler implementation. This method
creates copies of the given realizer and stores them in undoable commands
for later reactivation.
backupRealizers in interface Graph2D.BackupRealizersHandler
|
© Copyright 2000-2008, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||