com.realtime.crossfire.jxclient.window
Class KeyHandler

java.lang.Object
  extended by com.realtime.crossfire.jxclient.window.KeyHandler

public class KeyHandler
extends java.lang.Object

Handles keyboard input processing.


Field Summary
private  CommandQueue commandQueue
          The CommandQueue to use.
private  java.io.Writer debugKeyboard
          The Writer for logging keyboard debug output.
private static int KEY_SHIFT_ALT
           
private static int KEY_SHIFT_ALT_GR
           
private static int KEY_SHIFT_CTRL
           
private static int KEY_SHIFT_SHIFT
           
private  KeyBindings keyBindings
           
private  KeybindingsManager keybindingsManager
          The KeybindingsManager to use.
private  KeyHandlerListener keyHandlerListener
          The KeyHandlerListener to notify.
private  boolean[] keyShift
           
private  java.text.DateFormat simpleDateFormat
          A formatter for timestamps.
private  JXCWindowRenderer windowRenderer
          The JXCWindowRenderer to use.
 
Constructor Summary
KeyHandler(java.io.Writer debugKeyboard, KeybindingsManager keybindingsManager, CommandQueue commandQueue, JXCWindowRenderer windowRenderer, KeyHandlerListener keyHandlerListener)
          Creates a new instance.
 
Method Summary
private  void debugKeyboardWrite(java.lang.CharSequence message)
          Writes a message to the keyboard debug.
private  void debugKeyboardWrite(java.lang.String type, java.awt.event.KeyEvent e)
          Writes a KeyEvent to the keyboard debug.
private  boolean getKeyShift(int keyId)
           
private  void handleKeyPress(java.awt.event.KeyEvent e)
           
private  void handleKeyRelease(java.awt.event.KeyEvent e)
           
private  void handleKeyType(java.awt.event.KeyEvent e)
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void reset()
           
 void setKeyBindings(KeyBindings keyBindings)
           
private  void setKeyShift(int keyId, boolean state)
           
private  void updateModifiers(java.awt.event.InputEvent keyEvent)
          Update the saved modifier state from a key event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandQueue

@NotNull
private final CommandQueue commandQueue
The CommandQueue to use.


debugKeyboard

@Nullable
private final java.io.Writer debugKeyboard
The Writer for logging keyboard debug output. Log nothing if null.


KEY_SHIFT_ALT

private static final int KEY_SHIFT_ALT
See Also:
Constant Field Values

KEY_SHIFT_ALT_GR

private static final int KEY_SHIFT_ALT_GR
See Also:
Constant Field Values

KEY_SHIFT_CTRL

private static final int KEY_SHIFT_CTRL
See Also:
Constant Field Values

KEY_SHIFT_SHIFT

private static final int KEY_SHIFT_SHIFT
See Also:
Constant Field Values

keyBindings

@Nullable
private KeyBindings keyBindings

keybindingsManager

@NotNull
private final KeybindingsManager keybindingsManager
The KeybindingsManager to use.


keyHandlerListener

@NotNull
private final KeyHandlerListener keyHandlerListener
The KeyHandlerListener to notify.


keyShift

@NotNull
private final boolean[] keyShift

simpleDateFormat

@NotNull
private final java.text.DateFormat simpleDateFormat
A formatter for timestamps.


windowRenderer

@NotNull
private final JXCWindowRenderer windowRenderer
The JXCWindowRenderer to use.

Constructor Detail

KeyHandler

public KeyHandler(@Nullable
                  java.io.Writer debugKeyboard,
                  @NotNull
                  KeybindingsManager keybindingsManager,
                  @NotNull
                  CommandQueue commandQueue,
                  @NotNull
                  JXCWindowRenderer windowRenderer,
                  @NotNull
                  KeyHandlerListener keyHandlerListener)
Creates a new instance.

Parameters:
debugKeyboard - the writer for logging keyboard debug output; may
keybindingsManager - the keybindings manager to use
commandQueue - the command queue to use
windowRenderer - the window renderer to use
keyHandlerListener - the key handler listener to notify
Method Detail

debugKeyboardWrite

private void debugKeyboardWrite(@NotNull
                                java.lang.CharSequence message)
Writes a message to the keyboard debug.

Parameters:
message - the message to write

debugKeyboardWrite

private void debugKeyboardWrite(@NotNull
                                java.lang.String type,
                                @NotNull
                                java.awt.event.KeyEvent e)
Writes a KeyEvent to the keyboard debug.

Parameters:
type - the event type
e - the key event to write

getKeyShift

private boolean getKeyShift(int keyId)

handleKeyPress

private void handleKeyPress(@NotNull
                            java.awt.event.KeyEvent e)

handleKeyRelease

private void handleKeyRelease(@NotNull
                              java.awt.event.KeyEvent e)

handleKeyType

private void handleKeyType(@NotNull
                           java.awt.event.KeyEvent e)

keyPressed

public void keyPressed(@NotNull
                       java.awt.event.KeyEvent e)

keyReleased

public void keyReleased(@NotNull
                        java.awt.event.KeyEvent e)

keyTyped

public void keyTyped(@NotNull
                     java.awt.event.KeyEvent e)

reset

public void reset()

setKeyBindings

public void setKeyBindings(@NotNull
                           KeyBindings keyBindings)

setKeyShift

private void setKeyShift(int keyId,
                         boolean state)

updateModifiers

private void updateModifiers(@NotNull
                             java.awt.event.InputEvent keyEvent)
Update the saved modifier state from a key event.

Parameters:
keyEvent - The key event to process.