20 package net.sf.gridarta.actions;
28 import org.jetbrains.annotations.NotNull;
47 public static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
void undo(@NotNull
final UndoModel<G, A, R> undoModel, @NotNull
final MapModel<G, A, R> mapModel) {
48 applyChange(undoModel, mapModel, undoModel.undo());
56 public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends
Archetype<G, A, R>>
void redo(@NotNull
final UndoModel<G, A, R> undoModel, @NotNull
final MapModel<G, A, R> mapModel) {
57 applyChange(undoModel, mapModel, undoModel.redo());
66 private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends
Archetype<G, A, R>>
void applyChange(@NotNull
final UndoModel<G, A, R> undoModel, @NotNull
final MapModel<G, A, R> mapModel, @NotNull
final UndoState<G, A, R> undoState) {
68 mapModel.beginTransaction(undoState.getName());
70 final A newMapArchObject = undoState.getMapArchObject();
71 final MapArchObject<A> mapArchObject = mapModel.getMapArchObject();
72 mapArchObject.
setMapSize(newMapArchObject.getMapSize());
75 mapArchObject.
setState(newMapArchObject);
79 undoState.getSavedSquares().applyChanges(mapModel);
81 mapModel.endTransaction();
A MapModel reflects the data of a map.
Maintains the undo state for one map control.
void setState(@NotNull A mapArchObject)
Resets the state of this object to the state of the given map arch object.
void beginTransaction()
Starts a new transaction.
Holds information to undo/redo one edit operation.
UndoActions()
Private constructor to prevent instantiation.
Base package of all Gridarta classes.
void setMapSize(@NotNull Size2D mapSize)
Sets the map size.
Reflects a game object (object on a map).
GameObjects are the objects based on Archetypes found on maps.
Implementation of Undo / Redo for Gridarta.
void endTransaction()
Ends a transaction.
Utility class implementing undo and redo actions.
Interface for MapArchObjects.