info.bioinfweb.treegraph.document.undo
Class ComplexDocumentEdit
java.lang.Object
info.bioinfweb.treegraph.document.undo.DocumentEdit
info.bioinfweb.treegraph.document.undo.ComplexDocumentEdit
- All Implemented Interfaces:
- UndoableEdit
- Direct Known Subclasses:
- AddSupportValuesEdit, LadderizeEdit, ReplaceInNodeDataEdit, RerootEdit, RescaleNodeDataEdit
public abstract class ComplexDocumentEdit
- extends DocumentEdit
This class is the ancestor to all edits that are too complex to have an own undo()
method. Descendant do not specify a redo()
- and an undo()
-method but
override the abstract method performRedo()
.
This class outs a copy of the old tree in the document before calling performRedo()
so all classes implementing perform redo have to translate references to elements of
the old tree by using the findEquivilant()
-methods.
- Author:
- Ben Stöver
Method Summary |
protected Branch |
findEquivilant(Branch old)
Returns the branch in the new tree (copy of the old) with the equivilant position
to old . |
protected Node |
findEquivilant(Node old)
Returns the node in the new tree (copy of the old) with the equivilant position
to old . |
protected abstract void |
performRedo()
|
void |
redo()
|
void |
undo()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
oldRoot
private Node oldRoot
newRoot
private Node newRoot
firstRedone
private boolean firstRedone
ComplexDocumentEdit
public ComplexDocumentEdit(Document document)
findEquivilant
protected Node findEquivilant(Node old)
- Returns the node in the new tree (copy of the old) with the equivilant position
to
old
.
- Parameters:
old
- the node in the old tree
- Returns:
- the node in the new tree
findEquivilant
protected Branch findEquivilant(Branch old)
- Returns the branch in the new tree (copy of the old) with the equivilant position
to
old
.
- Parameters:
old
- the branch in the old tree
- Returns:
- the branch in the new tree
performRedo
protected abstract void performRedo()
redo
public void redo()
throws CannotRedoException
- Specified by:
redo
in interface UndoableEdit
- Overrides:
redo
in class DocumentEdit
- Throws:
CannotRedoException
undo
public void undo()
throws CannotUndoException
- Specified by:
undo
in interface UndoableEdit
- Overrides:
undo
in class DocumentEdit
- Throws:
CannotUndoException