Class UndoManager

java.lang.Object
com.example.brickpaint.UndoManager

public class UndoManager extends Object
Handles undo and redo implementation for a JavaFX canvas
Author:
matde
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static javafx.scene.image.Image
    getUnScaledImage(javafx.scene.canvas.Canvas canvas)
    Helper function to return an image of the unscaled canvas
    void
    Push the current canvas to history as an image, if the stack is larger than 100 items remove the oldest item
    void
    mergeToMark(CanvasPanel panel, org.apache.logging.log4j.Logger logger)
    Will reset the provided canvas to the point in history denoted by the mark value
    void
    Redo(CanvasPanel panel, org.apache.logging.log4j.Logger logger)
    Re-write the last undo action to the provided canvas
    void
    Sets the value of Mark
    void
    Undo(CanvasPanel panel, org.apache.logging.log4j.Logger logger)
    Resets the provided canvas to the last logged state

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UndoManager

      public UndoManager()
  • Method Details

    • getUnScaledImage

      public static javafx.scene.image.Image getUnScaledImage(javafx.scene.canvas.Canvas canvas)
      Helper function to return an image of the unscaled canvas
      Parameters:
      canvas - the parent Node of the canvas
      Returns:
      Unscaled javaFX image of the canvas
    • setMark

      public void setMark()
      Sets the value of Mark
    • mergeToMark

      public void mergeToMark(CanvasPanel panel, org.apache.logging.log4j.Logger logger)
      Will reset the provided canvas to the point in history denoted by the mark value
      Parameters:
      panel - The canvas to preform this action on
      logger - The logger to log the undo op to
    • LogU

      public void LogU(CanvasPanel panel)
      Push the current canvas to history as an image, if the stack is larger than 100 items remove the oldest item
      Parameters:
      panel - The canvas to take a snapshot of
    • Undo

      public void Undo(CanvasPanel panel, org.apache.logging.log4j.Logger logger)
      Resets the provided canvas to the last logged state
      Parameters:
      panel - The canvas to write the logged history to
      logger - The logger to log the undo op to
    • Redo

      public void Redo(CanvasPanel panel, org.apache.logging.log4j.Logger logger)
      Re-write the last undo action to the provided canvas
      Parameters:
      panel - The canvas to re-write the logged undo to
      logger - The logger to log the redo op to