Package ca.cgjennings.ui
Class LinearHistory<P>
- java.lang.Object
-
- ca.cgjennings.ui.LinearHistory<P>
-
public class LinearHistory<P> extends java.lang.Object
ALinearHistory
captures 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 void
back()
Go back one step in the history and display the resulting position.boolean
canGoBack()
Returnstrue
if it is possible to go back in the history.boolean
canGoForward()
Returnstrue
if it is possible to go forward in the history.void
clear()
Clears the history.void
display(P position)
void
forward()
Go forward one step in the history and display the resulting position.int
getSize()
Returns the number of positions stored in the history.void
go(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 newposition
becomes 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()
Returnstrue
if it is possible to go back in the history.- Returns:
true
ifback()
will have any effect
-
canGoForward
public boolean canGoForward()
Returnstrue
if it is possible to go forward in the history.- Returns:
true
ifforward()
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
-
-