org.tanager.ui
Class CUIStateContext

java.lang.Object
  extended by org.tanager.ui.CUIStateContext
All Implemented Interfaces:
IDownButtonCallback, ILeftButtonCallback, IMenuButtonCallback, IMiddleButtonCallback, IPowerButtonCallback, IRightButtonCallback, IStopButtonCallback, IUIComponentCallback, IUpButtonCallback

public class CUIStateContext
extends java.lang.Object
implements IMiddleButtonCallback, IPowerButtonCallback, IMenuButtonCallback, IStopButtonCallback, IUIComponentCallback, IDownButtonCallback, IUpButtonCallback, ILeftButtonCallback, IRightButtonCallback

This class defines the interface into the button pane's state machine and is the only access allowed to clients.

Version:
$Revision: 1.2.2.5 $
Author:
Bob Lavey
See Also:
the State Design Pattern, GoF page 305., Design Patterns

Field Summary
private  CButtonPane theButtonPane_
           Poseidon-generated association with the CButtonPane.
protected  CUIMenuModeState theMenuModeState_
           Poseidon-generated association with the CUIMenuModeState.
protected  CUIState thePlayModeState_
           Poseidon-generated association with the CUIState.
private  IUIControllerCallback theUIController_
           Poseidon-generated association with the IUIControllerCallback.
 
Constructor Summary
CUIStateContext(CButtonPane buttonPane, IUIControllerCallback uiController)
           This is the only constructor allowed for a CUIStateContext object.
 
Method Summary
 void displayMenu(CMenu menu)
           This method is used to process the displayMenu() event.
This is part of the IUIComponentCallback interface.
 void displayPane(CScrollablePane pane)
           This method is used to process the displayPane() event.
This is part of the IUIComponentCallback interface.
 void downButtonPressed()
           This method is used to process the downButtonPressed() event.
This is part of the IDownButtonCallback interface.
 void exitMenus()
           This method is used to process the exitMenus() event.
This is part of the IUIComponentCallback interface.
 javax.swing.Icon getMiddleButtonIcon()
           This method is used to return the middle button icon that is appropriate for the current state.
protected  CButtonPane getTheButtonPane()
           Poseidon-generated accessor method.
protected  CUIMenuModeState getTheMenuModeState()
           Poseidon-generated acessor method.
protected  CUIState getThePlayModeState()
           Poseidon-generated acessor method.
protected  IUIControllerCallback getTheUIController()
           Poseidon-generated accessor method.
 void idle()
           This method is used to process the idle() event.
This is part of the IUIComponentCallback interface.
 void initialize()
           This method is used to process the initialize() event.
This is part of the IUIComponentCallback interface.
 void leftButtonPressed()
           This method is used to process the leftButtonPressed() event.
This is part of the ILeftButtonCallback interface.
 void menuButtonPressed()
           This method is used to process the menuButtonPressed() event.
This is part of the IMenuButtonCallback interface.
 void middleButtonPressed()
           This method is used to process the middleButtonPressed() event.
This is part of the IMiddleButtonCallback interface.
 void pausedSong(CSong song)
           This method is used to process the pausedSong() event.
This is part of the IUIComponentCallback interface.
 void playingSong(CSong song)
           This method is used to process the playingSong() event.
This is part of the IUIComponentCallback interface.
 void powerButtonPressed()
           This method is used to process the powerButtonPressed() event.
 void previousPane()
           This method is used to process the previousMenu() event.
This is part of the IUIComponentCallback interface.
 void redraw()
           This method is used to tell the IUIComponentCallback objects to redraw themselves.
 void rightButtonPressed()
           This method is used to process the rightButtonPressed() event.
This is part of the IRightButtonCallback interface.
protected  void setTheMenuModeState(CUIMenuModeState newState)
           Poseidon-generated mutator method.
protected  void setThePlayModeState(CUIState newState)
           Poseidon-generated mutator method.
 void stopButtonPressed()
           This method is used to process the stopButtonPressed() event.
This is part of the IStopButtonCallback interface.
 void upButtonPressed()
           This method is used to process the upButtonPressed() event.
This is part of the IUpButtonCallback interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theUIController_

private IUIControllerCallback theUIController_

Poseidon-generated association with the IUIControllerCallback.


theButtonPane_

private CButtonPane theButtonPane_

Poseidon-generated association with the CButtonPane.


thePlayModeState_

protected CUIState thePlayModeState_

Poseidon-generated association with the CUIState.


theMenuModeState_

protected CUIMenuModeState theMenuModeState_

Poseidon-generated association with the CUIMenuModeState.

Constructor Detail

CUIStateContext

public CUIStateContext(CButtonPane buttonPane,
                       IUIControllerCallback uiController)

This is the only constructor allowed for a CUIStateContext object.

Semantics:
  1. initialize the Button Pane association with the given reference
  2. initialize the UI Controller association with the given reference
  3. initialize the Play Mode state to CUIStateNotInitialized
  4. initialize the Menu Mode state to CUIStateNotInMenus

Parameters:
buttonPane - a reference to the Button Pane
uiController - a reference to the UI Controller
Method Detail

getTheButtonPane

protected CButtonPane getTheButtonPane()

Poseidon-generated accessor method.

Returns:
the button pane

getTheUIController

protected IUIControllerCallback getTheUIController()

Poseidon-generated accessor method.

Returns:
the button pane's IUIControllerCallback association

getThePlayModeState

protected CUIState getThePlayModeState()

Poseidon-generated acessor method.

Returns:
the current Play Mode state

setThePlayModeState

protected void setThePlayModeState(CUIState newState)

Poseidon-generated mutator method.

Semantics:
  1. set the state to the given state
  2. if the new state is different than the old state
    1. call the new state's doEntryActions() method

Parameters:
newState - the new Play Mode state

getTheMenuModeState

protected CUIMenuModeState getTheMenuModeState()

Poseidon-generated acessor method.

Returns:
the current Menu Mode state

setTheMenuModeState

protected void setTheMenuModeState(CUIMenuModeState newState)

Poseidon-generated mutator method.

Parameters:
newState - the new Menu Mode state

getMiddleButtonIcon

public javax.swing.Icon getMiddleButtonIcon()

This method is used to return the middle button icon that is appropriate for the current state.

Semantics:
  1. if we are in the menus
    1. get the icon from the menu state
  2. if we are not in the menus
    1. get the icon from the play mode state

Returns:
the middle button icon specified by the current state

initialize

public void initialize()

This method is used to process the initialize() event.
This is part of the IUIComponentCallback interface.

Specified by:
initialize in interface IUIComponentCallback

idle

public void idle()

This method is used to process the idle() event.
This is part of the IUIComponentCallback interface.

Specified by:
idle in interface IUIComponentCallback

playingSong

public void playingSong(CSong song)

This method is used to process the playingSong() event.
This is part of the IUIComponentCallback interface.

Specified by:
playingSong in interface IUIComponentCallback
Parameters:
song - the playing song

pausedSong

public void pausedSong(CSong song)

This method is used to process the pausedSong() event.
This is part of the IUIComponentCallback interface.

Specified by:
pausedSong in interface IUIComponentCallback
Parameters:
song - the paused song

displayMenu

public void displayMenu(CMenu menu)

This method is used to process the displayMenu() event.
This is part of the IUIComponentCallback interface.

Specified by:
displayMenu in interface IUIComponentCallback
Parameters:
menu - the menu we've been asked to display

displayPane

public void displayPane(CScrollablePane pane)

This method is used to process the displayPane() event.
This is part of the IUIComponentCallback interface.

Specified by:
displayPane in interface IUIComponentCallback
Parameters:
pane - the scrollable pane we've been asked to display

exitMenus

public void exitMenus()

This method is used to process the exitMenus() event.
This is part of the IUIComponentCallback interface.

Specified by:
exitMenus in interface IUIComponentCallback

previousPane

public void previousPane()

This method is used to process the previousMenu() event.
This is part of the IUIComponentCallback interface.

Specified by:
previousPane in interface IUIComponentCallback

redraw

public void redraw()

This method is used to tell the IUIComponentCallback objects to redraw themselves.

Specified by:
redraw in interface IUIComponentCallback

upButtonPressed

public void upButtonPressed()

This method is used to process the upButtonPressed() event.
This is part of the IUpButtonCallback interface.

Semantics:
  1. if we are not in the menus
    1. pass the event to the play mode state
  2. if we are in the menus
    1. the menu has registered for notification of this event, so we don't need to do anything

Specified by:
upButtonPressed in interface IUpButtonCallback

downButtonPressed

public void downButtonPressed()

This method is used to process the downButtonPressed() event.
This is part of the IDownButtonCallback interface.

Semantics:
  1. if we are not in the menus
    1. pass the event to the play mode state
  2. if we are in the menus
    1. the menu has registered for notification of this event, so we don't need to do anything

Specified by:
downButtonPressed in interface IDownButtonCallback

leftButtonPressed

public void leftButtonPressed()

This method is used to process the leftButtonPressed() event.
This is part of the ILeftButtonCallback interface.

Semantics:
  1. if we are not in the menus
    1. pass the event to the play mode state
  2. if we are in the menus
    1. the menu has registered for notification of this event, so we don't need to do anything

Specified by:
leftButtonPressed in interface ILeftButtonCallback

rightButtonPressed

public void rightButtonPressed()

This method is used to process the rightButtonPressed() event.
This is part of the IRightButtonCallback interface.

Semantics:
  1. if we are not in the menus
    1. pass the event to the play mode state
  2. if we are in the menus
    1. the menu has registered for notification of this event, so we don't need to do anything

Specified by:
rightButtonPressed in interface IRightButtonCallback

middleButtonPressed

public void middleButtonPressed()

This method is used to process the middleButtonPressed() event.
This is part of the IMiddleButtonCallback interface.

Semantics:
  1. if we are not in the menus
    1. pass the event to the play mode state
  2. if we are in the menus
    1. the menu has registered for notification of this event, so we don't need to do anything

Specified by:
middleButtonPressed in interface IMiddleButtonCallback

menuButtonPressed

public void menuButtonPressed()

This method is used to process the menuButtonPressed() event.
This is part of the IMenuButtonCallback interface.

Specified by:
menuButtonPressed in interface IMenuButtonCallback

stopButtonPressed

public void stopButtonPressed()

This method is used to process the stopButtonPressed() event.
This is part of the IStopButtonCallback interface.

Specified by:
stopButtonPressed in interface IStopButtonCallback

powerButtonPressed

public void powerButtonPressed()

This method is used to process the powerButtonPressed() event. This is part of the IPowerButtonCallback interface.

Semantics:
  1. call the UI Controller's powerOff() method

Specified by:
powerButtonPressed in interface IPowerButtonCallback