edu.umd.cfar.lamp.apploader
Class HotkeyProcessor

java.lang.Object
  extended byedu.umd.cfar.lamp.apploader.HotkeyProcessor
All Implemented Interfaces:
java.awt.KeyEventDispatcher, java.awt.KeyEventPostProcessor

public class HotkeyProcessor
extends java.lang.Object
implements java.awt.KeyEventPostProcessor, java.awt.KeyEventDispatcher

Author:
davidm

Constructor Summary
HotkeyProcessor()
          Creates a new, empty hotkey processor.
 
Method Summary
 void addActionator(edu.umd.cfar.lamp.apploader.Actionator ax, java.awt.Component bean, int type, javax.swing.KeyStroke key, com.hp.hpl.jena.rdf.model.Resource when, java.lang.String description)
          Adds a new hotkey (or replaces the binding) to the given bean with the given type.
 void addActionator(com.hp.hpl.jena.rdf.model.Statement binding)
          Creates a hotkey for the given inputAction statement [ a lal:Bean] hotkeys:inputAction [a hotkeys:HotkeyBinding] .
 boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
           
static java.lang.String event2stroke(java.awt.event.KeyEvent e)
          Converts the key event into its corresponding key stroke object.
 AppLoader getCore()
           
static java.lang.String getKeyText(int keyCode)
          Get the text representation of the given key code.
static java.lang.String keyStroke2String(javax.swing.KeyStroke key)
          Converts a keystroke into a format parsable by the KeyStroke constructor.
static javax.swing.KeyStroke parseKeyTyped(java.lang.String s)
          Converts the given string into the corresponding keystroke.
 boolean postProcessKeyEvent(java.awt.event.KeyEvent e)
          Use the key as a hotkey, if possible.
 void setCore(AppLoader core)
          Sets the core.
 java.lang.String toHtml()
          Gets an html listing of all the bindings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HotkeyProcessor

public HotkeyProcessor()
Creates a new, empty hotkey processor.

Method Detail

getKeyText

public static java.lang.String getKeyText(int keyCode)
Get the text representation of the given key code.

Parameters:
keyCode - the key code
Returns:
the text representation of the key code, e.g. '9' or 'COMMA'

keyStroke2String

public static java.lang.String keyStroke2String(javax.swing.KeyStroke key)
Converts a keystroke into a format parsable by the KeyStroke constructor. This was as described in the Java Almanac

Parameters:
key - the stroke to output as a String
Returns:
the String description of the given stroke

event2stroke

public static java.lang.String event2stroke(java.awt.event.KeyEvent e)
Converts the key event into its corresponding key stroke object.

Parameters:
e - the event
Returns:
the corresponding stroke

postProcessKeyEvent

public boolean postProcessKeyEvent(java.awt.event.KeyEvent e)
Use the key as a hotkey, if possible. Currently doesn't do ancestorInputAction properly, only works for bubbling upwards. I'm not sure if I understand the spec on how to do it.

Specified by:
postProcessKeyEvent in interface java.awt.KeyEventPostProcessor
Parameters:
e - the event to process
Returns:
true, if the bean is consumed

dispatchKeyEvent

public boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
Specified by:
dispatchKeyEvent in interface java.awt.KeyEventDispatcher
See Also:
KeyEventDispatcher.dispatchKeyEvent(java.awt.event.KeyEvent)

addActionator

public void addActionator(edu.umd.cfar.lamp.apploader.Actionator ax,
                          java.awt.Component bean,
                          int type,
                          javax.swing.KeyStroke key,
                          com.hp.hpl.jena.rdf.model.Resource when,
                          java.lang.String description)
Adds a new hotkey (or replaces the binding) to the given bean with the given type.

Parameters:
ax - The action to invoke when the hotkey is pressed (in the context defined by the bean and type).
bean - The Component with the key binding
type - The type, e.g. input map type (window, has focus, contains focus)
key - The key press
when - indicates if the key should be processed in the pre-stage or the post-stage
description - text description of the action the binding performs

addActionator

public void addActionator(com.hp.hpl.jena.rdf.model.Statement binding)
Creates a hotkey for the given inputAction statement [ a lal:Bean] hotkeys:inputAction [a hotkeys:HotkeyBinding] .

Parameters:
binding - adds the given binding to the list of hotkey bindings

getCore

public AppLoader getCore()
Returns:
AppLoader

setCore

public void setCore(AppLoader core)
Sets the core.

Parameters:
core - The core to set

parseKeyTyped

public static javax.swing.KeyStroke parseKeyTyped(java.lang.String s)
Converts the given string into the corresponding keystroke. This format is more homogenous and cross-platform than the standard java way of doing things.

Parameters:
s - a keystroke string
Returns:
the keystroke

toHtml

public java.lang.String toHtml()
Gets an html listing of all the bindings. This is just an html fragment; it doesn't include html or body tags.

Returns:
an html fragment describing the bindings