jfreerails.client.view
Class ServerControlModel

java.lang.Object
  extended by jfreerails.client.view.ServerControlModel
All Implemented Interfaces:
ModelRootListener

public class ServerControlModel
extends java.lang.Object
implements ModelRootListener

Exposes the ServerControlInterface to client UI implementations.

Author:
rob, Luke, MystiqueAgent

Nested Class Summary
private  class ServerControlModel.LoadGameAction
           
private  class ServerControlModel.NewGameAction
           
private  class ServerControlModel.SaveGameAction
           
private  class ServerControlModel.SetTargetTicksPerSecondAction
           
 
Field Summary
private  DialogueBoxController dbc
           
private  javax.swing.Action loadGameAction
           
private  ModelRootImpl modelRoot
           
private  javax.swing.Action newGameAction
           
private  javax.swing.Action saveGameAction
           
private  ActionAdapter selectMapActions
           
private  ServerControlModel.SetTargetTicksPerSecondAction[] speedActions
           
private  ActionAdapter targetTicksPerSecondActions
           
 
Constructor Summary
ServerControlModel(ModelRootImpl mr)
           
 
Method Summary
 java.lang.String getGameSpeedDesc(int tickPerSecond)
          Returns human readable string description of tickPerSecond number.
 javax.swing.Action getLoadGameAction()
           
 ActionAdapter getMapNames()
           
 javax.swing.Action getNewGameAction()
          When calling this action, set the action command string to the desired map name, or call the appropriate selectMapAction.
 javax.swing.Action getSaveGameAction()
           
 ActionAdapter getSetTargetTickPerSecondActions()
           
 int getTargetTicksPerSecond()
           
 void propertyChange(ModelRoot.Property p, java.lang.Object oldValue, java.lang.Object newValue)
           
 void setServerControlInterface()
           
 void setup(ModelRootImpl modelRoot, DialogueBoxController dbc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadGameAction

private final javax.swing.Action loadGameAction

modelRoot

private ModelRootImpl modelRoot

newGameAction

private final javax.swing.Action newGameAction

saveGameAction

private final javax.swing.Action saveGameAction

selectMapActions

private ActionAdapter selectMapActions

speedActions

private final ServerControlModel.SetTargetTicksPerSecondAction[] speedActions

targetTicksPerSecondActions

private final ActionAdapter targetTicksPerSecondActions

dbc

private DialogueBoxController dbc
Constructor Detail

ServerControlModel

public ServerControlModel(ModelRootImpl mr)
Method Detail

getGameSpeedDesc

public java.lang.String getGameSpeedDesc(int tickPerSecond)
Returns human readable string description of tickPerSecond number. Looks for tickPerSecond in targetTicksPerSecondActions. If appropriate action is not found returns first greater value or the greatest value.

Parameters:
tickPerSecond - int
Returns:
String human readable description

getLoadGameAction

public javax.swing.Action getLoadGameAction()
Returns:
an action to load a game.

getMapNames

public ActionAdapter getMapNames()
Returns:
an ActionAdapter representing a list of actions representing valid map names.

getNewGameAction

public javax.swing.Action getNewGameAction()
When calling this action, set the action command string to the desired map name, or call the appropriate selectMapAction.

Returns:
an action to start a new game

getSaveGameAction

public javax.swing.Action getSaveGameAction()
Returns:
an action to save a game TODO The action produces a file selector dialog to save the game

getSetTargetTickPerSecondActions

public ActionAdapter getSetTargetTickPerSecondActions()
Returns:
an action adapter to set the target ticks per second

getTargetTicksPerSecond

public int getTargetTicksPerSecond()

propertyChange

public void propertyChange(ModelRoot.Property p,
                           java.lang.Object oldValue,
                           java.lang.Object newValue)
Specified by:
propertyChange in interface ModelRootListener

setup

public void setup(ModelRootImpl modelRoot,
                  DialogueBoxController dbc)

setServerControlInterface

public void setServerControlInterface()