org.jplot2d.env
Class UndoManager<E>
- java.lang.Object
-
- org.jplot2d.env.UndoManager<E>
-
public class UndoManager<E> extends java.lang.ObjectMaintains a queue of undo sets, a current set, and a redo sets.
-
-
Constructor Summary
Constructors Constructor and Description UndoManager()Construct a ChangeHistory with capacity 0.UndoManager(int capacity)Construct a ChangeHistory with the given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(E cs)Add the given change set as current, and push old change set into history.booleancanRedo()Returnstrueif redo is possible.booleancanUndo()Returnstrueif undo is possible.Ecurrent()Return the current change set.intgetCapacity()Returns the capacity of undo stack.intgetCSN()Returns the current CSNintgetUndoSize()Returns the possible undo steps.Eredo()Returns the next change set after the current change set.voidsetCapacity(int capacity)Sets the The capacity of undo stack.Eundo()Move the change set before the current set to current, and return it.
-
-
-
Constructor Detail
-
UndoManager
public UndoManager()
Construct a ChangeHistory with capacity 0.
-
UndoManager
public UndoManager(int capacity) throws java.lang.IllegalArgumentExceptionConstruct a ChangeHistory with the given capacity.- Parameters:
capacity- the capacity of the undo stack.- Throws:
java.lang.IllegalArgumentException- if the specified capacity is negative
-
-
Method Detail
-
getCapacity
public int getCapacity()
Returns the capacity of undo stack.- Returns:
- the capacity of undo stack
-
setCapacity
public void setCapacity(int capacity)
Sets the The capacity of undo stack. The default capacity is 0.- Parameters:
capacity- the capacity of undo stack
-
getUndoSize
public int getUndoSize()
Returns the possible undo steps. The size dose not count the current change set.- Returns:
- the possible undo steps
-
current
public E current()
Return the current change set.- Returns:
- the current change set
-
getCSN
public int getCSN()
Returns the current CSN- Returns:
- the current CSN
-
add
public void add(E cs)
Add the given change set as current, and push old change set into history.- Parameters:
cs- the change set
-
canUndo
public boolean canUndo()
Returnstrueif undo is possible.- Returns:
trueif undo is possible
-
undo
public E undo()
Move the change set before the current set to current, and return it.- Returns:
- the previous change set
-
canRedo
public boolean canRedo()
Returnstrueif redo is possible.- Returns:
trueif redo is possible
-
redo
public E redo()
Returns the next change set after the current change set. Returnsnullif there is no next change set.- Returns:
- the next change set
-
-
DMelt 3.0 © DataMelt by jWork.ORG