dasher
Class CInputFilter

java.lang.Object
  extended by dasher.CDasherComponent
      extended by dasher.CDasherModule
          extended by dasher.CInputFilter
Direct Known Subclasses:
CClickFilter, CDefaultFilter

public class CInputFilter
extends CDasherModule

Input filters are a key part of the Dasher infrastructure.

They are responsible for taking raw input co-ordinates and modifying the DasherModel in some way if appropriate.

They are also notified of all key presses and are given a chance to apply graphical decorations towards the end of the drawing cycle.

The most important method is Timer, which will be fired at the beginning of each new frame. This is responsible for obtaining input co-ordinates from the View, typically using the GetCoordinates method, and interacting with the model in some way, typically by calling Tap_on_display.

Timer will always be called every frame, regardless of the filter in use, except for when Dasher is paused or locked.

Being Modules, InputFilters have an Activate and Deactivate method which is intended to allow the allocation and deallocation of temporary helper objects, helper threads, network connections and so forth.

It is very important that the Timer method should return as near instantaneously as possible, as this will be called tens of times per second.

Input filters may also interact with the main Dasher interface, typically to start and stop Dasher in response to key presses.


Field Summary
protected  CDasherInterfaceBase m_Interface
          Interface which this InputFilter may control
 
Fields inherited from class dasher.CDasherComponent
m_EventHandler, m_SettingsStore
 
Constructor Summary
CInputFilter(CEventHandler EventHandler, CSettingsStore SettingsStore, CDasherInterfaceBase Interface, long iID, int iType, java.lang.String szName)
          Creates a new filter.
 
Method Summary
 void Activate()
          Activates this filter; now is the time to start helper threads, allocate resources, and so forth.
 void Deactivate()
          Deactivates this filter; threads should be stopped and resources which can be freed should be.
 boolean DecorateView(CDasherView View)
          Should draw any decorations applicable to this filter.
 void HandleEvent(CEvent Event)
          Ignores all events; to be overridden by subclasses if desired.
 void KeyDown(long Time, int iId, CDasherModel Model)
          Notifies the filter of a key-down event at a given time, and allows it to make changes to the Model but not the View in response to this change.
 void KeyUp(long Time, int iId, CDasherModel Model)
          Notifies the filter of a key-up event at a given time, and allows it to make changes to the Model but not the View in response to this change.
 boolean Timer(long Time, CDasherView m_DasherView, CDasherModel m_DasherModel)
          Requests that the input filter should modify the indicated Model.
 
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_Interface

protected CDasherInterfaceBase m_Interface
Interface which this InputFilter may control

Constructor Detail

CInputFilter

public CInputFilter(CEventHandler EventHandler,
                    CSettingsStore SettingsStore,
                    CDasherInterfaceBase Interface,
                    long iID,
                    int iType,
                    java.lang.String szName)
Creates a new filter. See DasherModule for information on registering this with the Interface as a usable module.

Parameters:
EventHandler - Event handler with which we should register ourselves
SettingsStore - Settings repository to use
Interface - Interface which this filter may control
iID - Unique identifier for this Module
iType - Module type (see DasherModule for a list)
szName - Friendly name (ideally unique)
See Also:
CDasherModule
Method Detail

HandleEvent

public void HandleEvent(CEvent Event)
Ignores all events; to be overridden by subclasses if desired.

Overrides:
HandleEvent in class CDasherComponent
Parameters:
Event - Event received.

DecorateView

public boolean DecorateView(CDasherView View)
Should draw any decorations applicable to this filter.

For example, DefaultFilter might draw a line indicating the mouse position at this stage.

If we wish to allow any helper classes to do their own decorating, we should pass the View to them at this stage.

Parameters:
View - View to which we should draw our decorations.
Returns:
True if anything has been drawn, false otherwise.

KeyDown

public void KeyDown(long Time,
                    int iId,
                    CDasherModel Model)
Notifies the filter of a key-down event at a given time, and allows it to make changes to the Model but not the View in response to this change. If we wish to display things in response to a key event, we must store state in the meantime and wait for the next frame.

Parameters:
Time - System time at which the key event took place, as a unix timestamp.
iId - ID of the key pressed (see DasherInterfaceBase.KeyDown for a list)
Model - DasherModel which may be modified in response to this keypress

KeyUp

public void KeyUp(long Time,
                  int iId,
                  CDasherModel Model)
Notifies the filter of a key-up event at a given time, and allows it to make changes to the Model but not the View in response to this change. If we wish to display things in response to a key event, we must store state in the meantime and wait for the next frame.

Parameters:
Time - System time at which the key event took place, as a unix timestamp.
iId - ID of the key pressed (see DasherInterfaceBase.KeyDown for a list)
Model - DasherModel which may be modified in response to this keypress

Timer

public boolean Timer(long Time,
                     CDasherView m_DasherView,
                     CDasherModel m_DasherModel)
Requests that the input filter should modify the indicated Model. The View is passed so that input co-ordinates can be resolved to Dasher co-ordinates prior to interacting with the Model.

Nothing should be drawn at this stage in spite of the availability of the View; drawing should take place during the call to DecorateView.

See DefaultFilter for a typical example of a Timer method.

Parameters:
Time - System time as a unix timestamp
m_DasherView - View against which co-ordinates should be resolved
m_DasherModel - Model which we may manipulate in response to this event
Returns:
True if the model was changed, false otherwise.

Activate

public void Activate()
Activates this filter; now is the time to start helper threads, allocate resources, and so forth.


Deactivate

public void Deactivate()
Deactivates this filter; threads should be stopped and resources which can be freed should be.