uk.ac.ic.doc.automed.p2p.gui
Class ScreenHandler

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by uk.ac.ic.doc.automed.p2p.gui.ScreenHandler
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

public class ScreenHandler
extends java.awt.event.MouseAdapter
implements java.awt.event.MouseMotionListener, java.awt.event.KeyListener


Field Summary
private  java.awt.Point currentPoint
           
private  java.util.Map handlerMap
           
static int INIT
           
static int K_CTRL
           
static int K_DOWN
           
static int K_ENTER
           
static int K_SHIFT
           
static int K_UP
           
private  int kc
           
static int M_DOUBLE_CLICKED
           
static int M_DRAGGED
           
static int M_LEFT_CLICKED
           
static int M_MOVED
           
static int M_RELEASED
           
static int M_RIGHT_CLICKED
           
static int MAX_KEY_STATE
           
static int MIN_MOUSE_STATE
           
private  int state
           
 
Constructor Summary
ScreenHandler()
           
 
Method Summary
 void addKeyListener(java.awt.Component source, java.awt.event.ActionListener handler)
           
 void addMouseListener(java.awt.Component source, java.awt.event.ActionListener handler)
           
 void addMouseMotionListener(java.awt.Component source, java.awt.event.ActionListener handler)
           
 int getKeyCode()
           
 java.awt.Point getMousePoint()
           
 int getState()
           
 boolean isCtrlDown()
           
 boolean isDoubleClicked()
           
 boolean isKeyDown()
           
 boolean isKeyEnter()
           
 boolean isKeyUp()
           
 boolean isLeftClicked()
           
 boolean isRightClicked()
           
 boolean isShiftDown()
           
 boolean isTypingMode()
          Check whether user is in the typing mode.
 void keyPressed(java.awt.event.KeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(java.awt.event.KeyEvent e)
          Invoked when a key has been released.
 void keyTyped(java.awt.event.KeyEvent e)
          Invoked when a key has been typed.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
private  void raiseEvent(java.lang.Object source)
          Invoked when a GUI event occured on a registered GUI component
 void registerHandler(java.lang.Object source, java.awt.event.ActionListener handler)
          Calling GUI components register their handlers via this method
 
Methods inherited from class java.awt.event.MouseAdapter
mouseEntered, mouseExited, mousePressed, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentPoint

private java.awt.Point currentPoint

INIT

public static final int INIT
See Also:
Constant Field Values

K_CTRL

public static final int K_CTRL
See Also:
Constant Field Values

K_SHIFT

public static final int K_SHIFT
See Also:
Constant Field Values

K_UP

public static final int K_UP
See Also:
Constant Field Values

K_DOWN

public static final int K_DOWN
See Also:
Constant Field Values

K_ENTER

public static final int K_ENTER
See Also:
Constant Field Values

MIN_MOUSE_STATE

public static final int MIN_MOUSE_STATE
See Also:
Constant Field Values

MAX_KEY_STATE

public static final int MAX_KEY_STATE
See Also:
Constant Field Values

M_LEFT_CLICKED

public static final int M_LEFT_CLICKED
See Also:
Constant Field Values

M_RIGHT_CLICKED

public static final int M_RIGHT_CLICKED
See Also:
Constant Field Values

M_DOUBLE_CLICKED

public static final int M_DOUBLE_CLICKED
See Also:
Constant Field Values

M_RELEASED

public static final int M_RELEASED
See Also:
Constant Field Values

M_DRAGGED

public static final int M_DRAGGED
See Also:
Constant Field Values

M_MOVED

public static final int M_MOVED
See Also:
Constant Field Values

state

private int state

kc

private int kc

handlerMap

private java.util.Map handlerMap
Constructor Detail

ScreenHandler

public ScreenHandler()
Method Detail

addMouseListener

public void addMouseListener(java.awt.Component source,
                             java.awt.event.ActionListener handler)

addMouseMotionListener

public void addMouseMotionListener(java.awt.Component source,
                                   java.awt.event.ActionListener handler)

addKeyListener

public void addKeyListener(java.awt.Component source,
                           java.awt.event.ActionListener handler)

registerHandler

public void registerHandler(java.lang.Object source,
                            java.awt.event.ActionListener handler)
Calling GUI components register their handlers via this method

Parameters:
source -
handler -

raiseEvent

private void raiseEvent(java.lang.Object source)
Invoked when a GUI event occured on a registered GUI component

Parameters:
source -
eventTag -

isCtrlDown

public boolean isCtrlDown()

isShiftDown

public boolean isShiftDown()

isDoubleClicked

public boolean isDoubleClicked()

isLeftClicked

public boolean isLeftClicked()

isRightClicked

public boolean isRightClicked()

isKeyDown

public boolean isKeyDown()

isKeyUp

public boolean isKeyUp()

isKeyEnter

public boolean isKeyEnter()

isTypingMode

public boolean isTypingMode()
Check whether user is in the typing mode. This is true when the state is less than the first mouse state

Returns:

getState

public int getState()

getKeyCode

public int getKeyCode()

getMousePoint

public java.awt.Point getMousePoint()

mouseClicked

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

mouseReleased

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

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class java.awt.event.MouseAdapter

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class java.awt.event.MouseAdapter

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Invoked when a key has been typed. See the class description for KeyEvent for a definition of a key typed event.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Invoked when a key has been pressed. See the class description for KeyEvent for a definition of a key pressed event.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.

Specified by:
keyReleased in interface java.awt.event.KeyListener