org.openuat.channel.oob
Class ButtonChannelImpl

java.lang.Object
  extended by org.openuat.channel.oob.ButtonChannelImpl
Direct Known Subclasses:
AWTButtonChannelImpl, J2MEButtonChannelImpl

public abstract class ButtonChannelImpl
extends java.lang.Object

This class defines a broad interface which allows to implement the different button channels. Each platform that supports button channels should derive and implement a platform specific variant of this class.
If a platform can't implement a specific method (e.g. vibrate), it should do nothing (empty method body) and shouldn't be called by an application.
For all graphical operations (displaying a signal or a progress bar etc.) the usage of this class works as follows: All operations just manipulate the internal state and have no immediate effect on the screen. The changes become visible on screen after the next call to the repaint method.

Version:
1.0
Author:
Lukas Huser

Field Summary
protected  IntervalList intervalList
          An IntervalList used to draw the progress bar.
protected  Log logger
          Logger instance.
protected  boolean prepareSignal
          Should a hint to a following signal currently be displayed?
protected  float progress
          Progress of the progress bar in %.
protected  boolean showCount
          Should the signalCount be displayed on screen?
protected  boolean showSignal
          Should the signal currently be displayed?
protected  int signalCount
          Number of already processed (sent or received) signals/button inputs.
protected  int transmissionMode
          transmissionMode is one of the TRANSMIT_* constants defined in this class.
static int TRANSMIT_BAR
          Transmission mode: progress bar.
static int TRANSMIT_PLAIN
          Transmission mode: plain (simply display text).
static int TRANSMIT_SIGNAL
          Transmission mode: signal.
static int TRANSMIT_TRAFFIC_LIGHT
          Transmission mode: traffic light.
static int TRANSMIT_VERT_BARS
          Transmission mode: power bar.
 
Constructor Summary
ButtonChannelImpl()
           
 
Method Summary
abstract  void repaint()
          Repaints the currently displayed gui element.
 void setInterval(IntervalList list)
          Before transmitting in the modes TRANSMIT_BAR or TRANSMIT_VERT_BARS, an IntervalList must be set.
 void setPrepareSignal(boolean enabled)
          Should a hint to a following signal currently be displayed?
 void setProgress(float progress)
          Sets the progress of the progress bar in %.
 void setShowCount(boolean enabled)
          Should the signalCount be displayed on screen?
 void setSignal(boolean enabled)
          Should the signal currently be displayed?
 void setSignalCount(int signalCount)
          Sets the number of already processed signals.
abstract  void showCaptureGui(java.lang.String text, ButtonInputHandler inputHandler)
          Starts the capturing process by launching a gui element that listens to button inputs.
abstract  void showTransmitGui(java.lang.String text, int type)
          Starts the transmitting process.
abstract  void vibrate(int milliseconds)
          Vibrates for milliseconds ms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSMIT_PLAIN

public static final int TRANSMIT_PLAIN
Transmission mode: plain (simply display text).

See Also:
Constant Field Values

TRANSMIT_SIGNAL

public static final int TRANSMIT_SIGNAL
Transmission mode: signal.

See Also:
Constant Field Values

TRANSMIT_TRAFFIC_LIGHT

public static final int TRANSMIT_TRAFFIC_LIGHT
Transmission mode: traffic light.

See Also:
Constant Field Values

TRANSMIT_BAR

public static final int TRANSMIT_BAR
Transmission mode: progress bar.

See Also:
Constant Field Values

TRANSMIT_VERT_BARS

public static final int TRANSMIT_VERT_BARS
Transmission mode: power bar.

See Also:
Constant Field Values

transmissionMode

protected int transmissionMode
transmissionMode is one of the TRANSMIT_* constants defined in this class.


signalCount

protected int signalCount
Number of already processed (sent or received) signals/button inputs.


showCount

protected boolean showCount
Should the signalCount be displayed on screen? It's more convenient for the user, but use with care: it may leak information to an attacker (a secure channel should not display this information on screen).


showSignal

protected boolean showSignal
Should the signal currently be displayed?


prepareSignal

protected boolean prepareSignal
Should a hint to a following signal currently be displayed?


intervalList

protected IntervalList intervalList
An IntervalList used to draw the progress bar.


progress

protected float progress
Progress of the progress bar in %.


logger

protected Log logger
Logger instance. It will be used by this class and its subclasses as well.

Constructor Detail

ButtonChannelImpl

public ButtonChannelImpl()
Method Detail

showCaptureGui

public abstract void showCaptureGui(java.lang.String text,
                                    ButtonInputHandler inputHandler)
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.

Parameters:
text - Is displayed on screen while capturing.
inputHandler - Button inputs are delegated to inputHandler.

showTransmitGui

public abstract void showTransmitGui(java.lang.String text,
                                     int type)
Starts the transmitting process.

Parameters:
text - Is displayed on screen before transmitting starts.
type - Defines the transmission type.

vibrate

public abstract void vibrate(int milliseconds)
Vibrates for milliseconds ms.
This method returns immediately and does not block the caller.

Parameters:
milliseconds - The vibration duration.

repaint

public abstract void repaint()
Repaints the currently displayed gui element.


setSignalCount

public void setSignalCount(int signalCount)
Sets the number of already processed signals.
When transmitting, it represents the number of already sent signals. When capturing, it represents the number of processed button events.
If signalCount is not within the boundaries 0 <= signalCount <= TOTAL_SIGNAL_COUNT its value will be automatically truncated to the respective boundary.

Parameters:
signalCount - The current signal count.

setShowCount

public void setShowCount(boolean enabled)
Should the signalCount be displayed on screen?

Parameters:
enabled - Enable or disable the signal count on screen.

setSignal

public void setSignal(boolean enabled)
Should the signal currently be displayed?
This method only modifies the state of the current object and has no immediate effect. The effect becomes visible after the next call to repaint.

Parameters:
enabled - Enable or disable the signal.

setPrepareSignal

public void setPrepareSignal(boolean enabled)
Should a hint to a following signal currently be displayed?
This method only modifies the state of the current object and has no immediate effect. The effect becomes visible after the next call to repaint.
Note: When in TRANSMIT_SIGNAL mode: To enable the preparatory signal, the 'real' signal must be disabled first (setSignal(false)). If the signal is active, it always has precedence over the preparatory signal.

Parameters:
enabled - Enable or disable the preparatory signal.

setInterval

public void setInterval(IntervalList list)
Before transmitting in the modes TRANSMIT_BAR or TRANSMIT_VERT_BARS, an IntervalList must be set.

Parameters:
list - An IntervalList.

setProgress

public void setProgress(float progress)
Sets the progress of the progress bar in %. Values which are too small (< 0) or too big (> 100) are set to the respective boundary.
This method only modifies the state of the current object and has no immediate effect. The effect becomes visible after the next call to repaint.

Parameters:
progress - Progress of the progress bar in %.


2005-2009, Rene Mayrhofer.