|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--y.view.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.
GraphEvents of type 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.
Constructor Summary | |
Graph2DUndoManager()
Creates a new Instance of UndoManager. |
Method Summary | |
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. |
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 undomanager 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 Graph2DUndoManager.getActiveToken() |
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 |
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 |
setViewContainer(ViewContainer view)
Sets the view container this undomanager 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 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()
Graph2DUndoManager.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)
Graph2DUndoManager.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 GraphListener
public Action getUndoAction()
Graph2DUndoManager.setViewContainer(ViewContainer)
public Action getRedoAction()
Graph2DUndoManager.setViewContainer(ViewContainer)
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 reactviation.
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 reactviation.
backupRealizers
in interface Graph2D.BackupRealizersHandler
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |