net.thestump.ghronos.mediate
Class Mediator

java.lang.Object
  extended bynet.thestump.ghronos.mediate.Registrar
      extended bynet.thestump.ghronos.mediate.Mediator
All Implemented Interfaces:
superwaba.ext.xplat.io.Storable

public class Mediator
extends Registrar
implements superwaba.ext.xplat.io.Storable

Mediates communication between the program's various objects. Follows the mediator design pattern. Is a singleton class.

Author:
Christopher C. Stump

Field Summary
 
Fields inherited from class net.thestump.ghronos.mediate.Registrar
bottomClock, hardButton, mainWin, menuBar, stateLabel, timingStyle, topClock
 
Method Summary
 void endGame()
          Adjusts the interface to reflect the end of a game
 boolean gameIsOver()
          Tells if the game is over or not
 byte getID()
           
 superwaba.ext.xplat.io.Storable getInstance()
           
 int getMoves()
          Gets the total number of moves made during a game
static Mediator instance()
          Singleton getter
 boolean isPaused()
          Tells if the game is paused or not
 boolean isTicking(char clock)
          Tells the ticking status of a clock
 void loadState(superwaba.ext.xplat.io.DataStream ds)
           
 void outOfTime(Clock clock)
          Tells the mediator that a clock is out of time
 void replaceClock(Clock toReplace, Clock replacement)
          Replaces a clock on the main interface.
 void replaceState(StateLabel replacement)
          Replaces a state label on the main interface.
 void reset(boolean toStart)
          Resets the interface to game start
 void reversePauseState()
          If the game is currently paused, this unpauses the interface.
 void saveState(superwaba.ext.xplat.io.DataStream ds)
           
 void switchClocks()
          Controls switching the clocks between players
 
Methods inherited from class net.thestump.ghronos.mediate.Registrar
getTimingStyle, registerClocks, registerHardButton, registerMainWindow, registerMenubar, registerState, registerTimingStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static Mediator instance()
Singleton getter

Returns:
the application's mediator

getMoves

public int getMoves()
Gets the total number of moves made during a game

Returns:
The sequential count of a game's moves

gameIsOver

public boolean gameIsOver()
Tells if the game is over or not

Returns:
true if the game is over, false otherwise

isPaused

public boolean isPaused()
Tells if the game is paused or not

Returns:
true if the game is paused, false otherwise

outOfTime

public void outOfTime(Clock clock)
Tells the mediator that a clock is out of time

Parameters:
clock - The clock that is out of time

isTicking

public boolean isTicking(char clock)
Tells the ticking status of a clock

Parameters:
clock - 't' if we want to test the ticking status of the top clock. 'b' if we want to test the ticking status of the bottom clock
Throws:
BadArgumentException - If clock is not 't' or 'b'

replaceState

public void replaceState(StateLabel replacement)
Replaces a state label on the main interface. Useful for timing styles which require special labels.

Parameters:
replacement - The new StateLabel

endGame

public void endGame()
Adjusts the interface to reflect the end of a game


reversePauseState

public void reversePauseState()
If the game is currently paused, this unpauses the interface. Otherwise the game (interface) is paused


replaceClock

public void replaceClock(Clock toReplace,
                         Clock replacement)
Replaces a clock on the main interface. Useful for timing styles which require special clocks.

Parameters:
toReplace - One of the clocks from the MainWindow that we want to replace
replacement - The clock to replace toReplace with

switchClocks

public void switchClocks()
Controls switching the clocks between players


reset

public void reset(boolean toStart)
Resets the interface to game start

Parameters:
toStart - true if we want to reset the game time to the last time set. False to zero out the clocks

getID

public byte getID()
Specified by:
getID in interface superwaba.ext.xplat.io.Storable

getInstance

public superwaba.ext.xplat.io.Storable getInstance()
Specified by:
getInstance in interface superwaba.ext.xplat.io.Storable

saveState

public void saveState(superwaba.ext.xplat.io.DataStream ds)
Specified by:
saveState in interface superwaba.ext.xplat.io.Storable

loadState

public void loadState(superwaba.ext.xplat.io.DataStream ds)
Specified by:
loadState in interface superwaba.ext.xplat.io.Storable


Copyright © 2004 Christopher C. Stump. All Rights Reserved.