dasher.applet
Class JDasherApplet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by dasher.applet.JDasherApplet
All Implemented Interfaces:
FontListener, JDasherHost, JDasherMenuBarListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer

public class JDasherApplet
extends javax.swing.JApplet
implements java.awt.event.MouseListener, java.awt.event.KeyListener, JDasherMenuBarListener, JDasherHost, FontListener

Applet containing a JDasherScreen panel, a JDasherEdit TextBox, and a set of menus to set relevant parameters.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 java.lang.String buildDate
          Date of last build; appears in About box
 JDasher Dasher
          Instance of Dasher which does the work
private  JDasherEdit EditBox
          Edit box in which typed text appears
 java.awt.datatransfer.Clipboard m_Clipboard
          Clipboard object
private  JDasherMenuBar MenuBar
          Our menu bar
private  ScreenOverlay ProgressMeter
          Overlay to display when Dasher is locked
private  JDasherScreen Screen
          Our Screen panel
private  java.util.Timer taskScheduler
          Scheduling agent used to cue new frames
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JDasherApplet()
           
 
Method Summary
 javax.swing.JPanel constructGUIPanel(java.awt.Dimension size)
          Sets up a Panel containing the entire Applet's GUI, and returns the Panel.
 JDasherMenuBar constructMenus()
          Produces our menu bar (a JDasherMenuBar) and returns it.
 java.lang.String getCurrentEditBoxText()
          Retrieves the current EditBox text.
private  int getMessageType(int type)
          Converts Dasher's message dialog types into JOptionPane's constants with the same meaning.
 void handleEvent(CEvent event)
          The Applet responds to the following parameter events:
 void init()
          Instantiates Dasher, gets a handle to the system clipboard if possible, calls constructGUIPanel to produce our GUI, and informs Dasher of the Screen Panel created by this method using the ChangeScreen method.
 boolean isDataFlavorAvailable(java.awt.datatransfer.DataFlavor flavour)
          Checks with the clipboard whether a given data flavour is enabled.
 void keyPressed(java.awt.event.KeyEvent e)
          We respond to the following key presses:
 void keyReleased(java.awt.event.KeyEvent e)
          Upon releasing the space bar, we signal Dasher a KeyDown event with a key of zero.
 void keyTyped(java.awt.event.KeyEvent arg0)
          Ignored
 void menuCopy()
          Copies the current edit box selection to the clipboard if possible.
 void menuCut()
          Cuts the current edit box selection to the clipboard if possible.
 void menuExit()
          Quits Dasher
 void menuHelpAbout()
          Displays an About dialog showing the compilation date.
 void menuNew()
          Blanks the EditBox and invalidates our current context.
 void menuPaste()
          Attempts to paste from the clipboard, overwriting our current EditBox selection if there is one.
 void menuSelFont()
          Opens the Select Font dialog in order to choose a new EditBox font
 void menuSetAlph(java.lang.String newalph)
          Sets the currently selected alphabet
 void menuSetColours(java.lang.String newcolours)
          Sets the currently selected colourscheme
 void menuSetDasherSpeed(int speed)
          Sets Dasher's LP_MAX_BITRATE parameter to a given value
 void menuSetFontSize(int size)
          Sets the Dasher font size (LP_DASHER_FONTSIZE) to a given value.
 void menuSetInputFilter(java.lang.String filter)
          Sets the input filter (SP_INPUT_FILTER) to a given String.
 void menuSetLMID(int LMID)
          Sets the currently selected language model to a given ID.
 void menuSetLMLearn(boolean enabled)
          Sets BP_LM_ADAPTIVE
 void menuSetMouseLine(boolean enabled)
          Sets BP_DRAW_MOUSE_LINE
 void menuSetSpeedAuto(boolean enabled)
          Sets BP_AUTO_SPEEDCONTROL
 void menuSetStartMouse(boolean enabled)
          Sets BP_START_MOUSE
 void menuSetStartSpace(boolean enabled)
          Sets BP_START_SPACE
 void mouseClicked(java.awt.event.MouseEvent e)
          MouseClicks are responded to by feeding Dasher a KeyDown event.
 void mouseEntered(java.awt.event.MouseEvent arg0)
          Ignored
 void mouseExited(java.awt.event.MouseEvent arg0)
          Ignored
 void mousePressed(java.awt.event.MouseEvent arg0)
          Ignored
 void mouseReleased(java.awt.event.MouseEvent arg0)
          Ignored
 void Redraw()
          Calls the applet's repaint method to trigger a redraw of Dasher.
 void regMouseMotionListener(java.awt.event.MouseMotionListener e)
          Adds a MouseMotionListener; requested by Dasher in order to hook its JMouseInput object up to hear mouse events.
 void setNewFont(java.awt.Font f)
          Sets our edit box font
 void stop()
          Cancels our new frame scheduler, and calls Dasher's DestroyInterface method to give it an opportunity to clean up if necessary.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Dasher

public JDasher Dasher
Instance of Dasher which does the work


Screen

private JDasherScreen Screen
Our Screen panel


MenuBar

private JDasherMenuBar MenuBar
Our menu bar


ProgressMeter

private ScreenOverlay ProgressMeter
Overlay to display when Dasher is locked


EditBox

private JDasherEdit EditBox
Edit box in which typed text appears


m_Clipboard

public java.awt.datatransfer.Clipboard m_Clipboard
Clipboard object


taskScheduler

private java.util.Timer taskScheduler
Scheduling agent used to cue new frames


buildDate

public final java.lang.String buildDate
Date of last build; appears in About box

See Also:
Constant Field Values
Constructor Detail

JDasherApplet

public JDasherApplet()
Method Detail

init

public void init()
Instantiates Dasher, gets a handle to the system clipboard if possible, calls constructGUIPanel to produce our GUI, and informs Dasher of the Screen Panel created by this method using the ChangeScreen method.

Finally, we call constructMenus to produce our menu bar.

Overrides:
init in class java.applet.Applet

constructGUIPanel

public javax.swing.JPanel constructGUIPanel(java.awt.Dimension size)
Sets up a Panel containing the entire Applet's GUI, and returns the Panel.

The Panel contains a JDasherScreen (which is stored in the Screen variable) and a JDasherEdit (stored in EditBox).

Parameters:
size - Size of the panel to be created
Returns:
Created Panel

constructMenus

public JDasherMenuBar constructMenus()
Produces our menu bar (a JDasherMenuBar) and returns it.

After instantiating, its options are set from Dasher's current settings. For example, we cause the current Alphabet to be set as 'selected' in the menu bar.

Returns:
MenuBar to be added to our Applet

handleEvent

public void handleEvent(CEvent event)
The Applet responds to the following parameter events:

BP_DASHER_PAUSED: We start/stop requesting frames at a regular interval depending on whether Dasher is currently paused.

LP_LANGUAGE_MODEL_ID: Updates our MenuBar's currently selected language model to reflect that which has been chosen.

SP_COLOUR_ID: Updates our MenuBar's currently selected colour scheme to reflect that which has been chosen. Usually this occurs in response to an alphabet specifying its own colour scheme.

The Applet also responds to LockEvents by showing our ScreenOverlay when locked and updating its progress bar, and MessageEvents by showing a message dialog.

Finally we pass the event on to the EditBox, in case some handling is required there as well.

Specified by:
handleEvent in interface JDasherHost
Parameters:
event - Event being passed

getMessageType

private int getMessageType(int type)
Converts Dasher's message dialog types into JOptionPane's constants with the same meaning. For example, type 0 becomes JOptionPane.INFORMATION_MESSAGE.

If asked to convert an invalid message type, -1 is returned.

Parameters:
type - Type to convert.
Returns:
JOptionPane equivalent constant

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
MouseClicks are responded to by feeding Dasher a KeyDown event. See CDasherInterfaceBase.KeyDown.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent arg0)
Ignored

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent arg0)
Ignored

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent arg0)
Ignored

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent arg0)
Ignored

Specified by:
mouseReleased in interface java.awt.event.MouseListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
We respond to the following key presses:

CTRL: Set speed boost factor to 175
SHIFT: Set speed boost factor to 25.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Upon releasing the space bar, we signal Dasher a KeyDown event with a key of zero.

If either CTRL or SHIFT are released, the speed boost constant is reset to 100, 175 or 25, dependent on which keys are still down.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent arg0)
Ignored

Specified by:
keyTyped in interface java.awt.event.KeyListener

stop

public void stop()
Cancels our new frame scheduler, and calls Dasher's DestroyInterface method to give it an opportunity to clean up if necessary.

Ultimately any neglected cleaning is likely not to cause a problem, as we are about to stop the application.

Overrides:
stop in class java.applet.Applet

Redraw

public void Redraw()
Calls the applet's repaint method to trigger a redraw of Dasher.

This method is called by Dasher when it wishes to be redrawn; the process has to be started from the top because it is tied in with Swing's painting architecture.

Specified by:
Redraw in interface JDasherHost

regMouseMotionListener

public void regMouseMotionListener(java.awt.event.MouseMotionListener e)
Adds a MouseMotionListener; requested by Dasher in order to hook its JMouseInput object up to hear mouse events.

Specified by:
regMouseMotionListener in interface JDasherHost
Parameters:
e - Listener to add

setNewFont

public void setNewFont(java.awt.Font f)
Sets our edit box font

Specified by:
setNewFont in interface FontListener
Parameters:
f - New font

menuCopy

public void menuCopy()
Copies the current edit box selection to the clipboard if possible.

Specified by:
menuCopy in interface JDasherMenuBarListener

menuCut

public void menuCut()
Cuts the current edit box selection to the clipboard if possible.

Specified by:
menuCut in interface JDasherMenuBarListener

menuExit

public void menuExit()
Quits Dasher

Specified by:
menuExit in interface JDasherMenuBarListener

menuHelpAbout

public void menuHelpAbout()
Displays an About dialog showing the compilation date.

Specified by:
menuHelpAbout in interface JDasherMenuBarListener

menuNew

public void menuNew()
Blanks the EditBox and invalidates our current context.

Specified by:
menuNew in interface JDasherMenuBarListener

menuPaste

public void menuPaste()
Attempts to paste from the clipboard, overwriting our current EditBox selection if there is one.

Specified by:
menuPaste in interface JDasherMenuBarListener

menuSelFont

public void menuSelFont()
Opens the Select Font dialog in order to choose a new EditBox font

Specified by:
menuSelFont in interface JDasherMenuBarListener

menuSetDasherSpeed

public void menuSetDasherSpeed(int speed)
Sets Dasher's LP_MAX_BITRATE parameter to a given value

Specified by:
menuSetDasherSpeed in interface JDasherMenuBarListener
Parameters:
speed - New LP_MAX_BITRATE

menuSetFontSize

public void menuSetFontSize(int size)
Sets the Dasher font size (LP_DASHER_FONTSIZE) to a given value.

Specified by:
menuSetFontSize in interface JDasherMenuBarListener
Parameters:
size - New size; either 1, 2 or 4.

menuSetInputFilter

public void menuSetInputFilter(java.lang.String filter)
Sets the input filter (SP_INPUT_FILTER) to a given String.

Specified by:
menuSetInputFilter in interface JDasherMenuBarListener
Parameters:
filter - Name of new input filter

menuSetLMID

public void menuSetLMID(int LMID)
Sets the currently selected language model to a given ID.

If an ID of 5 (corresponding to the RemotePPM language model) is selected, we first prompt the user to name a host and set the SP_LM_HOST parameter to their chosen value.

In any case, we end up setting LP_LANGUAGE_MODEL_ID.

Specified by:
menuSetLMID in interface JDasherMenuBarListener
Parameters:
LMID - New LM ID

menuSetLMLearn

public void menuSetLMLearn(boolean enabled)
Sets BP_LM_ADAPTIVE

Specified by:
menuSetLMLearn in interface JDasherMenuBarListener
Parameters:
enabled - New value

menuSetMouseLine

public void menuSetMouseLine(boolean enabled)
Sets BP_DRAW_MOUSE_LINE

Specified by:
menuSetMouseLine in interface JDasherMenuBarListener
Parameters:
enabled - New value

menuSetSpeedAuto

public void menuSetSpeedAuto(boolean enabled)
Sets BP_AUTO_SPEEDCONTROL

Specified by:
menuSetSpeedAuto in interface JDasherMenuBarListener
Parameters:
enabled - New value

menuSetStartMouse

public void menuSetStartMouse(boolean enabled)
Sets BP_START_MOUSE

Specified by:
menuSetStartMouse in interface JDasherMenuBarListener
Parameters:
enabled - New value

menuSetStartSpace

public void menuSetStartSpace(boolean enabled)
Sets BP_START_SPACE

Specified by:
menuSetStartSpace in interface JDasherMenuBarListener
Parameters:
enabled - New value

menuSetAlph

public void menuSetAlph(java.lang.String newalph)
Sets the currently selected alphabet

Specified by:
menuSetAlph in interface JDasherMenuBarListener
Parameters:
newalph - Alphabet to select

menuSetColours

public void menuSetColours(java.lang.String newcolours)
Sets the currently selected colourscheme

Specified by:
menuSetColours in interface JDasherMenuBarListener
Parameters:
newcolours - Colour scheme to select

isDataFlavorAvailable

public boolean isDataFlavorAvailable(java.awt.datatransfer.DataFlavor flavour)
Checks with the clipboard whether a given data flavour is enabled.

Typically this is used to check whether it is sensible to attempt Paste at the moment.

Specified by:
isDataFlavorAvailable in interface JDasherMenuBarListener
Parameters:
flavour - Flavour to check availability
Returns:
True if available at present, false otherwise.

getCurrentEditBoxText

public java.lang.String getCurrentEditBoxText()
Retrieves the current EditBox text. This method exists for the purposes of JavaScript calling in to invoke unsafe functions.

Thankfully, this doesn't work on FireFox.

Returns:
Current EditBox contents