de.enough.polish.util
Class ScreenHistory

java.lang.Object
  extended by de.enough.polish.util.ScreenHistory

public class ScreenHistory
extends java.lang.Object

Manages a history of screens in a stack, when a previous screen is shown all following screens are removed from the history.

ScreenHistory is thread safe.

Copyright Enough Software 2007 - 2008

 history
        Jan 14, 2007 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Constructor Summary
ScreenHistory()
          Creates a new ScreenStack with no limitations on the number of possible screens between a former and a new screen.
ScreenHistory(int maxStep)
          Creates a new ScreenStack
 
Method Summary
 void clearHistory()
          Clears the history.
 javax.microedition.lcdui.Displayable getCurrent()
          Retrieves the current screen when there is any.
 int getHistorySize()
          Retrieves the size of the history managed by this stack.
 javax.microedition.lcdui.Displayable getPrevious()
          Retrieves the previous screen when there is any.
 boolean hasPrevious()
          Determines whether there is a previous screen in this ScreenStack.
 void popHistory()
          Removes the last history entry, if there is one
 void show(javax.microedition.lcdui.Displayable screen, javax.microedition.lcdui.Display display)
          Shows the screen When the screen has been shown previously, any screens that followed the screen are removed from the history.
 boolean showPrevious(javax.microedition.lcdui.Display display)
          Shows the previous screen when there is any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenHistory

public ScreenHistory()
Creates a new ScreenStack with no limitations on the number of possible screens between a former and a new screen.

See Also:
ScreenHistory(int)

ScreenHistory

public ScreenHistory(int maxStep)
Creates a new ScreenStack

Parameters:
maxStep - the maximum number of screens that is checked if a new screen has been previously shown, -1 when all screens should be checked
Method Detail

show

public void show(javax.microedition.lcdui.Displayable screen,
                 javax.microedition.lcdui.Display display)
Shows the screen When the screen has been shown previously, any screens that followed the screen are removed from the history.

Parameters:
screen - the screen that should be shown next
display - the display used for showing the screen

hasPrevious

public boolean hasPrevious()
Determines whether there is a previous screen in this ScreenStack.

Returns:
true when there is a previous screen
See Also:
getPrevious(), showPrevious(Display)

showPrevious

public boolean showPrevious(javax.microedition.lcdui.Display display)
Shows the previous screen when there is any.

Parameters:
display - the display used for showing the screen
Returns:
true when there is a previous screen
See Also:
hasPrevious(), getPrevious()

getPrevious

public javax.microedition.lcdui.Displayable getPrevious()
Retrieves the previous screen when there is any. The history is not changed by this operation.

Returns:
the previous screen or null when there is no previous screen
See Also:
hasPrevious(), showPrevious(Display), getCurrent()

getCurrent

public javax.microedition.lcdui.Displayable getCurrent()
Retrieves the current screen when there is any. The history is not changed by this operation.

Returns:
the current screen or null when there is no current screen

getHistorySize

public int getHistorySize()
Retrieves the size of the history managed by this stack.

Returns:
the size of the history, 0 when there no screens

clearHistory

public void clearHistory()
Clears the history.


popHistory

public void popHistory()
Removes the last history entry, if there is one