org.openuat.channel.oob
Class AWTButtonChannelImpl

java.lang.Object
  extended by org.openuat.channel.oob.ButtonChannelImpl
      extended by org.openuat.channel.oob.AWTButtonChannelImpl

public class AWTButtonChannelImpl
extends ButtonChannelImpl

This is an AWT specific implementation of the ButtonChannelImpl class.
Special care must be taken to handle fake key events from the OS when a key is held down. Key press (and release) events MAY be fired by the OS at the systems (variable) keyboard repeat rate.

User: Key press Hold the key Key release
Windows: Key press event Key press events at systems keyboard repeat rate Key release event
Linux: Key press event Key release/key press event pairs (in that order, with identical timestamps) at systems keyboard repeat rate Key release event
Linux (modifier keys): Key press event No events Key release event
Presumably, the key repeat functionality is activated on most systems. However, it could be deactivated by the user as well (which is the same behavior as with the modifier keys like CTRL, SHIFT, ALT on linux).
This class has been tested under Linux (Ubuntu 8.10) and quickly on Windows XP.

Version:
1.0
Author:
Lukas Huser

Field Summary
protected  javax.swing.JButton abortButton
          A button that allows the user to abort the current processing (capture or transmit).
protected  int buttonKey
          The keyboard key which is used as the button for user input.
protected  java.lang.String currentText
          Text content which will be displayed in the textComponent gui element.
protected  java.awt.Font defaultFont
          Default font when displaying text.
protected  java.awt.Component paintableComponent
          A gui component that paints to the screen.
protected  java.awt.Container parent
          The parent gui component.
protected  javax.swing.JTextPane textComponent
          A gui component that displays text.
 
Fields inherited from class org.openuat.channel.oob.ButtonChannelImpl
intervalList, logger, prepareSignal, progress, showCount, showSignal, signalCount, transmissionMode, TRANSMIT_BAR, TRANSMIT_PLAIN, TRANSMIT_SIGNAL, TRANSMIT_TRAFFIC_LIGHT, TRANSMIT_VERT_BARS
 
Constructor Summary
AWTButtonChannelImpl(java.awt.Container parentComponent, java.awt.event.ActionListener abortHandler)
          Creates a new instance.
 
Method Summary
 void repaint()
          Repaints the currently displayed gui element.
 void showCaptureGui(java.lang.String text, ButtonInputHandler inputHandler)
          Starts the capturing process by launching a gui element that listens to button inputs.
 void showTransmitGui(java.lang.String text, int type)
          Starts the transmitting process.
 void vibrate(int milliseconds)
          Vibrates for milliseconds ms.
 
Methods inherited from class org.openuat.channel.oob.ButtonChannelImpl
setInterval, setPrepareSignal, setProgress, setShowCount, setSignal, setSignalCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected java.awt.Container parent
The parent gui component. It serves as a container for gui elements created by this class.


paintableComponent

protected java.awt.Component paintableComponent
A gui component that paints to the screen. If it is set, it can be updated through the repaint method.


textComponent

protected javax.swing.JTextPane textComponent
A gui component that displays text. It it is set and the repaint method is called, its content will be updated with the current signalCount


currentText

protected java.lang.String currentText
Text content which will be displayed in the textComponent gui element.


abortButton

protected javax.swing.JButton abortButton
A button that allows the user to abort the current processing (capture or transmit).


defaultFont

protected java.awt.Font defaultFont
Default font when displaying text.


buttonKey

protected int buttonKey
The keyboard key which is used as the button for user input.
It is the space bar on J2SE.

Constructor Detail

AWTButtonChannelImpl

public AWTButtonChannelImpl(java.awt.Container parentComponent,
                            java.awt.event.ActionListener abortHandler)
Creates a new instance.

Parameters:
parentComponent - The parent gui element which will hold gui elements created by this class.
abortHandler - An action listener which will be called when the user aborts the current transmission or capture process.
Method Detail

repaint

public void repaint()
Description copied from class: ButtonChannelImpl
Repaints the currently displayed gui element.

Specified by:
repaint in class ButtonChannelImpl

showCaptureGui

public void showCaptureGui(java.lang.String text,
                           ButtonInputHandler inputHandler)
Description copied from class: ButtonChannelImpl
Starts the capturing process by launching a gui element that listens to button inputs. text should be an instructive and/or informative text that helps the user to perform his task.

Specified by:
showCaptureGui in class ButtonChannelImpl
Parameters:
text - Is displayed on screen while capturing.
inputHandler - Button inputs are delegated to inputHandler.

showTransmitGui

public void showTransmitGui(java.lang.String text,
                            int type)
Description copied from class: ButtonChannelImpl
Starts the transmitting process.

Specified by:
showTransmitGui in class ButtonChannelImpl
Parameters:
text - Is displayed on screen before transmitting starts.
type - Defines the transmission type.

vibrate

public void vibrate(int milliseconds)
Description copied from class: ButtonChannelImpl
Vibrates for milliseconds ms.
This method returns immediately and does not block the caller.

Specified by:
vibrate in class ButtonChannelImpl
Parameters:
milliseconds - The vibration duration.


2005-2009, Rene Mayrhofer.