Class UndoManager
java.lang.Object
fr.istic.aco.editor.core.UndoManager
The UndoManager class is responsible for managing the undo and redo operations.
It tracks the history of the engine's states and allows the engine to revert to previous states (undo)
or reapply a reverted state (redo). It uses mementos to store and restore states.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
redo()
void
store
(EngineMemento memento) Saves the given engine state (memento) to the pastStates list If the futureStates list is not empty, it is clearedvoid
undo()
-
Constructor Details
-
UndoManager
-
-
Method Details
-
getEngine
-
getFutureStates
-
getPastStates
-
undo
public void undo()- Throws:
IllegalStateException
- if there is nothing to undo reverts the state of the engine to its previous state the current state is removed from pastStates and is placed in the future states uses the memento to retrieve the state of the engine
-
redo
public void redo()- Throws:
IllegalStateException
- if there is nothing to redo reverts the state of the engine to its next state the current state is added to PastStates using a memento the first FutureStates is removed from the List and is used to set the state of the engine
-
store
Saves the given engine state (memento) to the pastStates list If the futureStates list is not empty, it is cleared- Parameters:
memento
- The current state of the engine encapsulated as an EngineMemento.
-