Class UndoManager

java.lang.Object
fr.istic.aco.editor.core.UndoManager

public class UndoManager extends Object
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 Details

    • UndoManager

      public UndoManager(Engine engine)
  • Method Details

    • getEngine

      public Engine getEngine()
    • getFutureStates

      public List<EngineMemento> getFutureStates()
    • getPastStates

      public List<EngineMemento> 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

      public void store(EngineMemento memento)
      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.