dasher.applet
Class JDasher

java.lang.Object
  extended by dasher.CDasherInterfaceBase
      extended by dasher.applet.JDasher

public class JDasher
extends CDasherInterfaceBase

Simple implementation of CDasherInterfaceBase providing minimal facilities to support an Applet version of Dasher.


Field Summary
private  JDasherHost m_Host
          Host to notify of events and request redraws.
private  JMouseInput m_MouseInput
          Our mouse input
 
Fields inherited from class dasher.CDasherInterfaceBase
g_Logger, m_Alphabet, m_AlphIO, m_bConnectLock, m_bGlobalLock, m_bShutdownLock, m_ColourIO, m_Colours, m_DasherModel, m_DasherScreen, m_DasherView, m_EventHandler, m_Input, m_InputFilter, m_oModuleManager, m_SettingsStore, m_UserLog, strCurrentContext, strTrainfileBuffer
 
Constructor Summary
JDasher(JDasherHost host)
          Creates a new JDasher.
 
Method Summary
 void CreateSettingsStore()
          Attempts to create a JSettings object; if a StoreUnavailableException is produced in the course of this, we fall back and produce a standard CSettingsStore.
 void ExternalEventHandler(CEvent Event)
          External event handler; simply passes the event to our host, typically a JDasherApplet.
 int GetFileSize(java.lang.String strFileName)
          Attempts to retrieve a ResourceStream for a given file by retrieving it from our JAR file, and returns its available property which should indicate the file size.
 java.io.InputStream getResourceStream(java.lang.String filename)
          Attempts to retrieve a resource stream representing a given file by using the getResourceAsStream method.
 void Redraw(boolean bChanged)
          Orders our host to redraw.
 void ScanAlphabetFiles(java.util.Collection<java.lang.String> vFileList)
          Populates a given Collection with a list of available alphabet files.
 void ScanColourFiles(java.util.Collection<java.lang.String> vFileList)
          Populates a given Collection with a list of available colour files.
 void SetupPaths()
          Sets our system path to "system.rc/".
 void SetupUI()
          Stub
 int TrainFile(java.lang.String Filename, int iTotalBytes, int iOffset)
          Attempts to retrieve a stream pointing to a given file in this Applet's JAR file and recalls TrainStream on this stream.
 
Methods inherited from class dasher.CDasherInterfaceBase
ChangeAlphabet, ChangeColours, ChangeScreen, ChangeView, ConnectNode, CreateDasherModel, CreateFactories, CreateInput, CreateInputFilter, DeleteAlphabet, DestroyInterface, DisconnectNode, doAlphIO, doColourIO, Draw, GetAlphabet, GetAlphabets, GetAutoOffset, GetBoolParameter, GetColours, GetCurCPM, GetCurFPS, GetEventHandler, GetFontSizes, GetInfo, GetLongParameter, GetModule, GetModuleByName, GetNats, GetStringParameter, GetUserLogPtr, Halt, InterfaceEventHandler, InvalidateContext, KeyDown, KeyUp, NewFrame, PauseAt, PreSetNotify, Realize, RegisterFactory, RegisterNode, ResetNats, ResetParameter, SetBoolParameter, SetInfo, SetLongParameter, SetStringParameter, Start, StartShutdown, TrainStream, Unpause, WriteTrainFile, WriteTrainFileFull, WriteTrainFilePartial
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_MouseInput

private JMouseInput m_MouseInput
Our mouse input


m_Host

private JDasherHost m_Host
Host to notify of events and request redraws.

Constructor Detail

JDasher

public JDasher(JDasherHost host)
Creates a new JDasher. We call CreateSettingsStore immediately after our super-constructor, create, wrap and register a new JMouseInput, run CreateInput and register our newly created input device wiht our host to hook it up to mouse events.

Parameters:
host - Host to report events and request mouse events and redraws.
Method Detail

ExternalEventHandler

public void ExternalEventHandler(CEvent Event)
External event handler; simply passes the event to our host, typically a JDasherApplet.

Overrides:
ExternalEventHandler in class CDasherInterfaceBase
Parameters:
Event - Event to handle

CreateSettingsStore

public void CreateSettingsStore()
Attempts to create a JSettings object; if a StoreUnavailableException is produced in the course of this, we fall back and produce a standard CSettingsStore.

If a SettingsStore already exists, we ignore the call.

Specified by:
CreateSettingsStore in class CDasherInterfaceBase

TrainFile

public int TrainFile(java.lang.String Filename,
                     int iTotalBytes,
                     int iOffset)
Attempts to retrieve a stream pointing to a given file in this Applet's JAR file and recalls TrainStream on this stream.

If we can't retrieve said stream for some reason, 0 is returned.

Overrides:
TrainFile in class CDasherInterfaceBase
Parameters:
Filename - File to retrieve
iTotalBytes - Bytes to read
iOffset - Offset to start reading
Returns:
Number of bytes successfully read

GetFileSize

public int GetFileSize(java.lang.String strFileName)
Attempts to retrieve a ResourceStream for a given file by retrieving it from our JAR file, and returns its available property which should indicate the file size.

In the event of failure of any sort, we return zero.

Specified by:
GetFileSize in class CDasherInterfaceBase
Parameters:
strFileName - File whose size we wish to retrieve
Returns:
File size, or 0 on error.

ScanAlphabetFiles

public void ScanAlphabetFiles(java.util.Collection<java.lang.String> vFileList)
Populates a given Collection with a list of available alphabet files.

Due to the difficulty in enumerating the contents of a JAR file, at present this is hard coded to report a certain set.

Ideally this should be upgraded to report the true list of available files, potentially by reading some master XML file.

Specified by:
ScanAlphabetFiles in class CDasherInterfaceBase
Parameters:
vFileList - Collection to fill with a list of available alphabet files.

ScanColourFiles

public void ScanColourFiles(java.util.Collection<java.lang.String> vFileList)
Populates a given Collection with a list of available colour files.

Due to the difficulty in enumerating the contents of a JAR file, at present this is hard coded to report a certain set.

Ideally this should be upgraded to report the true list of available files, potentially by reading some master XML file.

Specified by:
ScanColourFiles in class CDasherInterfaceBase
Parameters:
vFileList - Collection to fill with a list of available colour files.

getResourceStream

public java.io.InputStream getResourceStream(java.lang.String filename)
Attempts to retrieve a resource stream representing a given file by using the getResourceAsStream method.

Overrides:
getResourceStream in class CDasherInterfaceBase
Parameters:
filename - File to be opened
Returns:
InputStream pointing to the relevant file if possible, or null if not.

SetupPaths

public void SetupPaths()
Sets our system path to "system.rc/".

Specified by:
SetupPaths in class CDasherInterfaceBase

SetupUI

public void SetupUI()
Stub

Specified by:
SetupUI in class CDasherInterfaceBase

Redraw

public void Redraw(boolean bChanged)
Orders our host to redraw.

Specified by:
Redraw in class CDasherInterfaceBase
Parameters:
bChanged - ignored