ballwar.model
Interface IViewCtrlAdapter


public interface IViewCtrlAdapter

The adapter interface the model uses to communicate to the view.


Method Summary
 void addKeyCmd(String keyName, ILambda cmd)
          Asks the GUI to associate the given key with the given behavior.
 Component getCanvas()
           
 int getCanvasHeight()
          Gets the height of the GUI component upon which the balls are painted.
 int getCanvasWidth()
          Gets the width of the GUI component upon which the balls are painted.
 IPlayer getSelectedPlayer()
          Returns the currently selected player on the GUI.
 void update()
          Method that is called when the model wishes the view to update.
 

Method Detail

update

void update()
Method that is called when the model wishes the view to update. Periodicaly called by the model's timer. The view will then turn around and call the model's paint method when it needs the model to update and paint.


getCanvas

Component getCanvas()

getCanvasWidth

int getCanvasWidth()
Gets the width of the GUI component upon which the balls are painted.

Returns:
The width of the ball's display area in pixels.

getCanvasHeight

int getCanvasHeight()
Gets the height of the GUI component upon which the balls are painted.

Returns:
The height of the ball's display area in pixels.

addKeyCmd

void addKeyCmd(String keyName,
               ILambda cmd)
Asks the GUI to associate the given key with the given behavior.

Parameters:
keyName - The name of the virtual key, less the leading "VK_". See the Java documentation for "KeyEvent"
cmd - The behavior to be associated with the key. The ILambda's apply() method will be called with the key's name when that key is pressed.

getSelectedPlayer

IPlayer getSelectedPlayer()
Returns the currently selected player on the GUI.

Returns:
The currently selected player.