dasher
Class CDefaultFilter

java.lang.Object
  extended by dasher.CDasherComponent
      extended by dasher.CDasherModule
          extended by dasher.CInputFilter
              extended by dasher.CDefaultFilter

public class CDefaultFilter
extends CInputFilter

Dasher's current default input filter, otherwise known as Normal Control. This causes Dasher, when unpaused, to zoom towards the mouse position with the goal that the spot the mouse hovers over at time X should be under the crosshair at some later time.

The filter also includes support for a number of Start Handlers, and is responsible for instantiating and managing them if the parameters relating to them are set appropriately.

It does not respond to key presses except to start and stop on key 100.

Automatic Speed Control is also featured with the Default Filter, using an instance of AutoSpeedControl for this purpose.

See Also:
CAutoSpeedControl

Field Summary
protected  CAutoSpeedControl m_AutoSpeedControl
          Our Automatic Speed Control helper class
protected  CStartHandler m_StartHandler
          The currently enabled start handler, if any
 
Fields inherited from class dasher.CInputFilter
m_Interface
 
Fields inherited from class dasher.CDasherComponent
m_EventHandler, m_SettingsStore
 
Constructor Summary
CDefaultFilter(CEventHandler EventHandler, CSettingsStore SettingsStore, CDasherInterfaceBase Interface, CDasherModel m_DasherModel, long iID, java.lang.String szName)
          Sole constructor.
 
Method Summary
 void CreateStartHandler()
          Creates a start handler.
 boolean DecorateView(CDasherView View)
          Draws the mouse square and mouse line to the specified View in the case that BP_DRAW_MOUSE and BP_DRAW_MOUSE_LINE are enabled respectively, and calls m_StartHandler's DecorateView method to draw the start handler, if applicable.
 void DrawMouse(CDasherView View)
          Draws a small box at the current mouse position.
 void DrawMouseLine(CDasherView View)
          Draws a line from the origin (LP_OX, LP_OY) to the current mouse position.
 void HandleEvent(CEvent Event)
          Called by the event handler when dispatching events.
 void KeyDown(long iTime, int iId, CDasherModel Model)
          Called by the InterfaceBase when a key is pressed.
 boolean Timer(long Time, CDasherView m_DasherView, CDasherModel m_DasherModel)
          See CInputFilter for an description of the method's purpose.
 
Methods inherited from class dasher.CInputFilter
Activate, Deactivate, KeyUp
 
Methods inherited from class dasher.CDasherModule
GetID, GetName, GetType, Ref, Unref
 
Methods inherited from class dasher.CDasherComponent
GetBoolParameter, GetLongParameter, GetParameterName, GetParameterType, GetStringParameter, InsertEvent, SetBoolParameter, SetLongParameter, SetStringParameter, UnregisterComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_AutoSpeedControl

protected CAutoSpeedControl m_AutoSpeedControl
Our Automatic Speed Control helper class


m_StartHandler

protected CStartHandler m_StartHandler
The currently enabled start handler, if any

Constructor Detail

CDefaultFilter

public CDefaultFilter(CEventHandler EventHandler,
                      CSettingsStore SettingsStore,
                      CDasherInterfaceBase Interface,
                      CDasherModel m_DasherModel,
                      long iID,
                      java.lang.String szName)
Sole constructor. Constructs a DefaultFilter with an AutoSpeedControl helper class and runs CreateStartHandler to produce a start handler if this is necessary.

Parameters:
EventHandler - Event handler with which to register ourselves
SettingsStore - Setting repository to use
Interface - Interface with which this Module should register itself
m_DasherModel - Model which will yield a FrameRate for creation of CAutoSpeedControl
iID - Unique ID for this module
szName - Friendly name for this module
Method Detail

DecorateView

public boolean DecorateView(CDasherView View)
Draws the mouse square and mouse line to the specified View in the case that BP_DRAW_MOUSE and BP_DRAW_MOUSE_LINE are enabled respectively, and calls m_StartHandler's DecorateView method to draw the start handler, if applicable.

Overrides:
DecorateView in class CInputFilter
Parameters:
View - View to which we should draw decorations
Returns:
True if this method drew anything, false if not.

Timer

public boolean Timer(long Time,
                     CDasherView m_DasherView,
                     CDasherModel m_DasherModel)
See CInputFilter for an description of the method's purpose.

This filter simply asks the View for our mouse co-ordinates in Dasher space, and feeds them to the Model's Tap_on_display method which causes the model to move in this direction.

The coordinates are then fed to our AutoSpeedControl helper to fine tune the dashing speed, and our start handler is passed the View and Model pointers in case it too has action to take.

Overrides:
Timer in class CInputFilter
Parameters:
Time - System time at which this event was called, as a UNIX timestamp
m_DasherView - View to query for input co-ordinates
m_DasherModel - Model to alter using these co-ordinates
Returns:
True if the model has been changed, false if not.

KeyDown

public void KeyDown(long iTime,
                    int iId,
                    CDasherModel Model)
Called by the InterfaceBase when a key is pressed. This filter responds to space and mouse by starting and stopping Dasher if BP_START_SPACE and BP_START_MOUSE are set respectively.

For a complete listing of key IDs, see the documentation for DasherInterfaceBase.KeyDown.

Overrides:
KeyDown in class CInputFilter
Parameters:
iTime - System time when this key was pressed, as a UNIX timestamp
iId - Key identifier
Model - Ignored by this filter

HandleEvent

public void HandleEvent(CEvent Event)
Called by the event handler when dispatching events.

This class responds to the following parameter changes:

BP_CIRCLE_START and BP_MOUSEPOS_MODE: Recalls CreateStartHandler() in case we need to change our set start handler.

Overrides:
HandleEvent in class CInputFilter
Parameters:
Event - Event to handle

CreateStartHandler

public void CreateStartHandler()
Creates a start handler. At present, this method will create a CircleStartHandler in response to BP_CIRCLE_START only. If CTwoBoxStartHandler is ported to Java in the future, there is commented code in the source which would instantiate this in response to BP_MOUSEPOS_MODE also.


DrawMouse

public void DrawMouse(CDasherView View)
Draws a small box at the current mouse position.

Parameters:
View - View to which we should draw

DrawMouseLine

public void DrawMouseLine(CDasherView View)
Draws a line from the origin (LP_OX, LP_OY) to the current mouse position.

Parameters:
View - View to which this line should be drawn.