public class UndoModel<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
extends java.lang.Object
UndoStates
. Possible operations are "undo" and
"redo". If a map is changed after performing one or more "undo" operations,
the previously recorded "redo" operations are discarded.Constructor and Description |
---|
UndoModel(@NotNull GameObjectFactory<G,A,R> gameObjectFactory,
@NotNull GameObjectMatchers gameObjectMatchers,
@NotNull MapTransactionListener<G,A,R> mapTransactionListener)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRedo()
Return whether a "redo" operation is possible.
|
boolean |
canUndo()
Return whether an "undo" operation is possible.
|
void |
finish()
Finishes an undo or redo operation.
|
void |
finish(@NotNull UndoState<G,A,R> undoState)
Finishes an undo or redo operation.
|
@NotNull MapTransactionListener<G,A,R> |
getMapTransactionListener()
Returns the
MapTransactionListener that was passed to the
constructor. |
@NotNull UndoState<G,A,R> |
redo()
Perform a "redo" operation.
|
java.lang.String |
redoName()
Return the "redo" operation name.
|
void |
trimToSize(int maxUndoStates)
Discard old undo information.
|
@NotNull UndoState<G,A,R> |
undo()
Perform an "undo" operation.
|
java.lang.String |
undoName()
Return the "undo" operation name.
|
public UndoModel(@NotNull @NotNull GameObjectFactory<G,A,R> gameObjectFactory, @NotNull @NotNull GameObjectMatchers gameObjectMatchers, @NotNull @NotNull MapTransactionListener<G,A,R> mapTransactionListener)
gameObjectFactory
- the game object factory to usegameObjectMatchers
- the game object matchers to usemapTransactionListener
- the map transaction listener to store@NotNull public @NotNull MapTransactionListener<G,A,R> getMapTransactionListener()
MapTransactionListener
that was passed to the
constructor.public void trimToSize(int maxUndoStates)
maxUndoStates
- the maximum number of undo states to savepublic boolean canUndo()
true
if an "undo" operation is possible, false
otherwisepublic boolean canRedo()
true
if a "redo" operation is possible, false
otherwisepublic java.lang.String undoName()
public java.lang.String redoName()
@NotNull public @NotNull UndoState<G,A,R> undo()
@NotNull public @NotNull UndoState<G,A,R> redo()
public void finish(@NotNull @NotNull UndoState<G,A,R> undoState)
undoState
- the changes of the operationpublic void finish()