java.lang.Object
com.example.brickpaint.UndoManager
Handles undo and redo implementation for a JavaFX canvas
- Author:
- matde
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic javafx.scene.image.ImagegetUnScaledImage(javafx.scene.canvas.Canvas canvas) Helper function to return an image of the unscaled canvasvoidLogU(CanvasPanel panel) Push the current canvas to history as an image, if the stack is larger than 100 items remove the oldest itemvoidmergeToMark(CanvasPanel panel, org.apache.logging.log4j.Logger logger) Will reset the provided canvas to the point in history denoted by the mark valuevoidRedo(CanvasPanel panel, org.apache.logging.log4j.Logger logger) Re-write the last undo action to the provided canvasvoidsetMark()Sets the value of MarkvoidUndo(CanvasPanel panel, org.apache.logging.log4j.Logger logger) Resets the provided canvas to the last logged state
-
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
Will reset the provided canvas to the point in history denoted by the mark value- Parameters:
panel- The canvas to preform this action onlogger- The logger to log the undo op to
-
LogU
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
Resets the provided canvas to the last logged state- Parameters:
panel- The canvas to write the logged history tologger- The logger to log the undo op to
-
Redo
Re-write the last undo action to the provided canvas- Parameters:
panel- The canvas to re-write the logged undo tologger- The logger to log the redo op to
-