guk.im
Class KeyboardMap

java.lang.Object
  |
  +--guk.im.KeyboardMap
All Implemented Interfaces:
Runnable

public class KeyboardMap
extends Object
implements Runnable

A virtual keyboard map. It uses its own thread do udate the display.


Inner Class Summary
 class KeyboardMap.KeyGUI
           
 
Field Summary
(package private)  boolean alt
           
(package private)  boolean capslock
           
(package private)  JPanel contentPane
          The content pane that holds all the KeyGUIs.
(package private)  boolean ctrl
           
(package private)  Map GUIforString
          maps from String(the English lowercase representation of the key) to KeyGUI
(package private)  LocaleHandler handler
          the active locale handler
(package private)  List highlightedKeys
          The keys curently highlighted
(package private)  GateIM im
          The input method.
(package private)  List jobs
          The job list.
(package private)  Map labelForKey
          Maps from Key to JLabel for the keys that have keyCap defined .
(package private)  Thread myThread
          The thread that does the updating.
(package private)  LocaleHandler newHandler
          The new active locale handler.
(package private)  State newState
          The current state of the new current locale handler.
(package private) static Component placeHolder
          Empty component used for the key that are not bound to a Unicode character.
(package private)  boolean shift
           
(package private)  State state
          The current state of the current locale handler.
(package private)  Window window
          The window used for displaying the keyboard map
 
Constructor Summary
KeyboardMap(GateIM im, LocaleHandler handler, State state)
          Builds the keyboard map.
 
Method Summary
 void addJob(Object job)
          Adds a job to the job list of the thread.
protected  void fixShape()
           
protected  KeyboardMap.KeyGUI guiForKey(Key key)
          Gets the gui that corresponds to a Key object.
 void run()
          The run method for the thread responsible for updating the display.
 void setAlt(boolean alt)
          Is the Alt key pressed?
 void setCtrl(boolean ctrl)
          Is the Ctrl key pressed?
 void setShift(boolean shift)
          Is the Shift key pressed?
protected  void update()
          Does th actual update.
 void update(LocaleHandler newHandler, State newState)
          Updates the keyboard map for a new Locale or a new state of the current locale handler.
protected  void updateLabels()
          Updates the virtual keyboard to reflect the current state.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

handler

LocaleHandler handler
the active locale handler

newHandler

LocaleHandler newHandler
The new active locale handler. This member is useful during the period when the active locale handler has changed but the keyboard map is not updated yet. The keyboard map will be updated as soon as the tasks that were added to the job list before the locale change are consumed.

state

State state
The current state of the current locale handler.

newState

State newState
The current state of the new current locale handler.
See Also:
newHandler

window

Window window
The window used for displaying the keyboard map

contentPane

JPanel contentPane
The content pane that holds all the KeyGUIs.
See Also:
KeyboardMap.KeyGUI

highlightedKeys

List highlightedKeys
The keys curently highlighted

shift

boolean shift

ctrl

boolean ctrl

alt

boolean alt

capslock

boolean capslock

GUIforString

Map GUIforString
maps from String(the English lowercase representation of the key) to KeyGUI

labelForKey

Map labelForKey
Maps from Key to JLabel for the keys that have keyCap defined .

im

GateIM im
The input method.

myThread

Thread myThread
The thread that does the updating.

jobs

List jobs
The job list.

placeHolder

static Component placeHolder
Empty component used for the key that are not bound to a Unicode character.
Constructor Detail

KeyboardMap

public KeyboardMap(GateIM im,
                   LocaleHandler handler,
                   State state)
Builds the keyboard map. Uses a window provided by the context of the input method.
Parameters:
im - the input method
handler - the active Locale handler
state - the state of the handler.
Method Detail

run

public void run()
The run method for the thread responsible for updating the display.
Specified by:
run in interface Runnable

addJob

public void addJob(Object job)
Adds a job to the job list of the thread. A job is either a String or an InputEvent The string can be one of The input events refer to pressed keys and are treated accordingly.
Parameters:
job -  

update

public void update(LocaleHandler newHandler,
                   State newState)
Updates the keyboard map for a new Locale or a new state of the current locale handler. Currently the state changes are ignored. This method delegates its job to the thread which will do the actual update.
Parameters:
newHandler -  
newState -  

update

protected void update()
Does th actual update.

updateLabels

protected void updateLabels()
Updates the virtual keyboard to reflect the current state.

fixShape

protected void fixShape()

guiForKey

protected KeyboardMap.KeyGUI guiForKey(Key key)
Gets the gui that corresponds to a Key object.
Parameters:
key -  

setShift

public void setShift(boolean shift)
Is the Shift key pressed?
Parameters:
shift -  

setAlt

public void setAlt(boolean alt)
Is the Alt key pressed?
Parameters:
alt -  

setCtrl

public void setCtrl(boolean ctrl)
Is the Ctrl key pressed?
Parameters:
ctrl -