Package com.j3d.engine.react.history
Class History
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Action<?>>,Collection<Action<?>>,List<Action<?>>,RandomAccess,SequencedCollection<Action<?>>
Manages a history of actions, allowing for undo and redo functionality.
It extends
ArrayList to store Action objects.- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BackupWhere actions that are undone are stored for redo functionality.static final Stringprivate static final intstatic HistoryPanelprivate static final longSerial version UID for serialization.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidApplies a given action by either redoing it from the backup or undoing actions from the history until the target action is reached.private voidAdds an action to the history, bypassing the size limit and backup clearing.voidclear()private static voidvoidredo()Removes and returns the last action in the history.private static voidrepaint()voidundo()Undoes the last action in the history.private voidUpdates the history panel with the current actions in the history and backup.Methods inherited from class java.util.ArrayList
add, addAll, addAll, addFirst, addLast, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Field Details
-
backup
Where actions that are undone are stored for redo functionality. -
logHead
- See Also:
-
panel
-
serialVersionUID
private static final long serialVersionUIDSerial version UID for serialization.- See Also:
-
MAX_HISTORY_SIZE
private static final int MAX_HISTORY_SIZE- See Also:
-
-
Constructor Details
-
History
public History()
-
-
Method Details
-
undo
public void undo()Undoes the last action in the history. -
redo
public void redo()Removes and returns the last action in the history. -
repaint
private static void repaint() -
bypassAdd
Adds an action to the history, bypassing the size limit and backup clearing. This is used for redoing actions.- Parameters:
action- The action to add.
-
add
-
clear
public void clear() -
clearLocators
private static void clearLocators() -
updateHistory
private void updateHistory()Updates the history panel with the current actions in the history and backup. This method clears the existing panels and repopulates them. -
apply
Applies a given action by either redoing it from the backup or undoing actions from the history until the target action is reached.- Parameters:
action- The action to apply.
-