vooga.gameEngine.controller
Class HumanController

java.lang.Object
  extended by vooga.gameEngine.game.GameRelatedObject
      extended by vooga.gameEngine.controller.GameRelatedController
          extended by vooga.gameEngine.controller.HumanController
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener

public class HumanController
extends GameRelatedController
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

HumanController is an GameRelatedController which manages GameItem's that are affected by human interaction. As an GameRelatedController, it will store these items in a list. When the user enters in input through some form, this class will update all relevant items of the change.

Author:
Scott Brothers, Geoffrey Lawler, Jacob Harer
See Also:
Serialized Form

Constructor Summary
HumanController()
          Creates a HumanController
 
Method Summary
 void addKeyboardInput(javax.swing.KeyStroke key, java.lang.Class<? extends java.util.EventObject> eventClass)
          Maps a keyboard key to an event so that pressing that key when the Game window has focus will result in the mapped event being fired to its registered listeners.
 void addKeyboardInput(javax.swing.KeyStroke key, java.lang.Class<? extends java.util.EventObject> eventClass, java.util.EventListener listener)
          Maps a keyboard key to an event and a specific listener so that pressing that key when the Game window has focus will result in the mapped event being fired only to that specific listener.
 void addMouseClicked(java.lang.Integer mouseEventID, java.lang.Class<? extends java.util.EventObject> eventClass)
          Maps a MouseEventkey to an event.
 void addMouseInput(java.lang.Integer mouseEventID, java.lang.Class<? extends java.util.EventObject> eventClass)
          Maps a MouseEvent to an event.
 void addMouseInput(java.lang.Integer mouseEventID, java.lang.Class<? extends java.util.EventObject> eventClass, java.util.EventListener listener)
          Maps a MouseEvent to an event and a specific listener so that whenever the MouseEvent is fired, the event it maps to will be fired to the specific listener.
 void addMouseListener(java.awt.event.MouseListener listener)
          adds the specified mouse listener to the list of listeners a mouse event will be fired at the listener every time a mouse event would normally be fired by java the mouse event will be changed to the coordinate system used by the game
 void disableAllInputListening()
          Disables this HumanController from listening to key or mouse input.
 java.util.Map<javax.swing.KeyStroke,java.lang.Class<? extends java.util.EventObject>> getKeyBindings()
          Returns all the key bindings that are currently assigned.
 java.util.List<java.util.EventObject> getUserInput()
          Simple getter method to obtain the events fired by user input.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent arg0)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent arg0)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void pauseInputListening()
          Pauses this HumanController from responding to any input that would result in firing an event that is not a PausableEvent.
 void removeAllKeyboardInput()
          Resets all keyboard input.
 void removeAllKeyboardInput(java.util.Collection<javax.swing.KeyStroke> keys)
          Removes the given KeyStrokes from all relevant Maps.
 void removeKeyboardInput(javax.swing.KeyStroke key)
          Removes the given KeyStroke from all relevant Maps.
 void removeMouseListener(java.awt.event.MouseListener listener)
           
 void resumeInputListening()
          Allows this HumanController to resume responding to all input.
 void setCameraController(CameraController cameraController)
          sets the camera controller for updating the mouse position
 void setComponent(javax.swing.JComponent component)
          Sets the JComponent that this HumanController will listen to for keyboard and mouse input
 
Methods inherited from class vooga.gameEngine.game.GameRelatedObject
addEventListener, clearListeners, equals, fire, fire, fire, getEventListeners, getID, getListenerCount, removeEventListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HumanController

public HumanController()
Creates a HumanController

Method Detail

setComponent

public void setComponent(javax.swing.JComponent component)
Sets the JComponent that this HumanController will listen to for keyboard and mouse input

Parameters:
component - this HumanController will listen to

setCameraController

public void setCameraController(CameraController cameraController)
sets the camera controller for updating the mouse position

Parameters:
cameraController -

addKeyboardInput

public void addKeyboardInput(javax.swing.KeyStroke key,
                             java.lang.Class<? extends java.util.EventObject> eventClass)
Maps a keyboard key to an event so that pressing that key when the Game window has focus will result in the mapped event being fired to its registered listeners.

Parameters:
key - The keyboard key or combination of keys to be mapped
eventClass - The class of the event to be fired when the key parameter is pressed

addKeyboardInput

public void addKeyboardInput(javax.swing.KeyStroke key,
                             java.lang.Class<? extends java.util.EventObject> eventClass,
                             java.util.EventListener listener)
Maps a keyboard key to an event and a specific listener so that pressing that key when the Game window has focus will result in the mapped event being fired only to that specific listener.

Parameters:
key - The keyboard key or combination of keys to be mapped
eventClass - The class of the event to be fired when the key parameter is pressed
listener - The EventListener that should respond to the firing of the event

removeKeyboardInput

public void removeKeyboardInput(javax.swing.KeyStroke key)
Removes the given KeyStroke from all relevant Maps. Thus, if the given KeyStroke is pressed, no action will be taken.

Parameters:
key - the KeyStroke to remove functionality from

removeAllKeyboardInput

public void removeAllKeyboardInput(java.util.Collection<javax.swing.KeyStroke> keys)
Removes the given KeyStrokes from all relevant Maps. Thus, if any of the given KeyStrokes are pressed, no action will be taken.

Parameters:
keys - the KeyStrokes to remove functionality from

removeAllKeyboardInput

public void removeAllKeyboardInput()
Resets all keyboard input.

See Also:
removeAllKeyboardInput(Collection)

addMouseInput

public void addMouseInput(java.lang.Integer mouseEventID,
                          java.lang.Class<? extends java.util.EventObject> eventClass)
Maps a MouseEvent to an event. This map is then used so that whenever the MouseEvent is fired, the event it maps to will be fired to all registered listeners.

Parameters:
mouseButton - The MouseEvent to be mapped
eventClass - The class of the event to be fired when the MouseEvent occurs

addMouseInput

public void addMouseInput(java.lang.Integer mouseEventID,
                          java.lang.Class<? extends java.util.EventObject> eventClass,
                          java.util.EventListener listener)
Maps a MouseEvent to an event and a specific listener so that whenever the MouseEvent is fired, the event it maps to will be fired to the specific listener.

Parameters:
mouseButton - The MouseEvent to be mapped
eventClass - The class of the event to be fired when the MouseEvent occurs
listener - The EventListener that should respond to the firing of the event

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)
adds the specified mouse listener to the list of listeners a mouse event will be fired at the listener every time a mouse event would normally be fired by java the mouse event will be changed to the coordinate system used by the game

Parameters:
listener -

addMouseClicked

public void addMouseClicked(java.lang.Integer mouseEventID,
                            java.lang.Class<? extends java.util.EventObject> eventClass)
Maps a MouseEventkey to an event. This method fires only if the mouse is on an object

Parameters:
mouseInput -
eventClass -

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent arg0)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent arg0)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

getUserInput

public java.util.List<java.util.EventObject> getUserInput()
Simple getter method to obtain the events fired by user input.

Returns:
the List of fired events

pauseInputListening

public void pauseInputListening()
Pauses this HumanController from responding to any input that would result in firing an event that is not a PausableEvent.


resumeInputListening

public void resumeInputListening()
Allows this HumanController to resume responding to all input.


disableAllInputListening

public void disableAllInputListening()
Disables this HumanController from listening to key or mouse input.


getKeyBindings

public java.util.Map<javax.swing.KeyStroke,java.lang.Class<? extends java.util.EventObject>> getKeyBindings()
Returns all the key bindings that are currently assigned.

Returns:
a Map of key bindings