Package ca.cgjennings.ui
Class LinearHistory<P>
- java.lang.Object
-
- ca.cgjennings.ui.LinearHistory<P>
-
public class LinearHistory<P> extends java.lang.ObjectALinearHistorycaptures a sequence of user actions and allows them to be replayed, as with the forward/back operations in a browsing interface.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description LinearHistory()Creates a new linear history that tracks state objects (URL, location, document, etc.) of typeP.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidback()Go back one step in the history and display the resulting position.booleancanGoBack()Returnstrueif it is possible to go back in the history.booleancanGoForward()Returnstrueif it is possible to go forward in the history.voidclear()Clears the history.voiddisplay(P position)voidforward()Go forward one step in the history and display the resulting position.intgetSize()Returns the number of positions stored in the history.voidgo(P position)Go directly to a new position (without using forward or back) and display the position.
-
-
-
Method Detail
-
clear
public void clear()
Clears the history.
-
go
public void go(P position)
Go directly to a new position (without using forward or back) and display the position. Any positions after the current position in the history are deleted, and the newpositionbecomes the end of the history.- Parameters:
position-
-
back
public void back()
Go back one step in the history and display the resulting position.
-
forward
public void forward()
Go forward one step in the history and display the resulting position.
-
canGoBack
public boolean canGoBack()
Returnstrueif it is possible to go back in the history.- Returns:
trueifback()will have any effect
-
canGoForward
public boolean canGoForward()
Returnstrueif it is possible to go forward in the history.- Returns:
trueifforward()will have any effect
-
display
public void display(P position)
Called when a new position is visited (viago(P),back(), orforward()). The base class does nothing; subclasses may override this to customize behaviour.- Parameters:
position- the new position to display
-
getSize
public int getSize()
Returns the number of positions stored in the history.- Returns:
- the size of the history list
-
-