dualroids
Class InputHandler

java.lang.Object
  |
  +--java.awt.event.WindowAdapter
        |
        +--dualroids.InputHandler
All Implemented Interfaces:
EventListener, KeyListener, WindowListener

public final class InputHandler
extends WindowAdapter
implements KeyListener

Class for handling keyboard input and windowClosing window event.


Field Summary
(package private)  ClientModelConnector connector
          The associated ClientModelConnector.
(package private)  SpaceShip ship
          The ship that is controlled by this InputHandler.
 
Constructor Summary
InputHandler(ClientModelConnector connector)
          Contructs a new InputHandler.
 
Method Summary
 void keyPressed(KeyEvent ke)
          Handles key pressed events.
 void keyReleased(KeyEvent ke)
          Handles key released events.
 void keyTyped(KeyEvent ke)
          Dummy handler for key typed events.
 void registerShip(SpaceShip ship)
          Registers a SpaceShip for contrilling through this InputHandler.
 void windowClosing(WindowEvent event)
          Clean up the window and initiate a network close procedure when the window close event is made.
 
Methods inherited from class java.awt.event.WindowAdapter
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ship

SpaceShip ship
The ship that is controlled by this InputHandler.

connector

ClientModelConnector connector
The associated ClientModelConnector.
Constructor Detail

InputHandler

public InputHandler(ClientModelConnector connector)
Contructs a new InputHandler.
Parameters:
connector - the ClientModelConnector to be associated with this InputHandler
Method Detail

registerShip

public void registerShip(SpaceShip ship)
Registers a SpaceShip for contrilling through this InputHandler.
Parameters:
ship - the ship to be controlled

keyPressed

public void keyPressed(KeyEvent ke)
Handles key pressed events.
Specified by:
keyPressed in interface KeyListener
Parameters:
ke - the event

keyReleased

public void keyReleased(KeyEvent ke)
Handles key released events.
Specified by:
keyReleased in interface KeyListener
Parameters:
ke - the event

keyTyped

public void keyTyped(KeyEvent ke)
Dummy handler for key typed events.
Specified by:
keyTyped in interface KeyListener
Parameters:
ke - the event

windowClosing

public void windowClosing(WindowEvent event)
Clean up the window and initiate a network close procedure when the window close event is made. The network close will eventually cause an exit() to be called when everything is safely closed.
Overrides:
windowClosing in class WindowAdapter
Parameters:
event - the window event


Dualroids was written by Oskar Ojala, Yrjö Kari-Koskinen and Henri Sivonen