edu.stanford.hci.r3.events
Class EventEngine

java.lang.Object
  extended by edu.stanford.hci.r3.events.EventEngine

public class EventEngine
extends java.lang.Object

When you ask the PaperToolkit to run a paper Application, there will be exactly one EventEngine handling all pen events for that Application. This EventEngine will process batched pen data, and also handle streaming data. We will tackle streaming first.

This class is responsible for sending data to the event handlers, which will create clicks, drags, etc.

This software is distributed under the BSD License.


Constructor Summary
EventEngine()
          This object handles event dispatch by hooking up pen listeners to local and remote pen servers.
 
Method Summary
 void addEventHandlerForUnmappedEvents(EventHandler handler)
          This can detect and process events when it's outside of any other region...
 EventReplayManager getEventReplayManager()
           
 void handlePenEvent(PenEvent penEvent)
          All pen events go through here.
 void handlePenUpEvent(PenEvent event)
          Send the penUp to the event handlers...
 void register(PenInput pen)
          If you register a pen multiple times, a different pen listener will be attached to the pen.
 void registerPatternMapForEventHandling(PatternLocationToSheetLocationMapping mapping)
          Really, this is the only method we need to do runtime binding.
 void registerPatternMapsForEventHandling(java.util.Collection<PatternLocationToSheetLocationMapping> patternMaps)
          Keep track of the pattern on sheets, so we can dispatch events appropriately.
 void removeEventHandlerForUnmappedEvents(EventHandler handler)
           
 void unregisterAllPatternMaps()
          To reset the event engine at runtime.
 void unregisterPatternMapForEventHandling(PatternLocationToSheetLocationMapping patternMap)
           
 void unregisterPatternMapsForEventHandling(java.util.Collection<PatternLocationToSheetLocationMapping> patternMaps)
          Remove these maps from our runtime list.
 void unregisterPen(PenInput pen)
          Stop watching this pen input device.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventEngine

public EventEngine()
This object handles event dispatch by hooking up pen listeners to local and remote pen servers. It will figure out where to dispatch incoming pen samples... and will activate the correct event handlers.

Method Detail

addEventHandlerForUnmappedEvents

public void addEventHandlerForUnmappedEvents(EventHandler handler)
This can detect and process events when it's outside of any other region...

Parameters:
handler -

getEventReplayManager

public EventReplayManager getEventReplayManager()
Returns:
the replay manager, allowing access to saved event streams.

handlePenEvent

public void handlePenEvent(PenEvent penEvent)
All pen events go through here. We dispatch it to the right handlers in this method. Will this have a ConcurrentModification problem, because we are iterating through the actual patternToSheetMaps list that can be updated at runtime?

TODO: Should this be multithreaded, for performance reasons?

TODO: Should this have synchronized access to patternToSheetMaps, for race conditions?

Parameters:
penEvent -

handlePenUpEvent

public void handlePenUpEvent(PenEvent event)
Send the penUp to the event handlers...

Parameters:
event -

register

public void register(PenInput pen)
If you register a pen multiple times, a different pen listener will be attached to the pen. Only ONE EventEngine listener will be attached to a pen at one time. Otherwise, multiple events would get fired by the same pen. Why would you want to register a single pen multiple times? I dunnno. For some reason I added support for it... but perhaps I'll remove it in the future. :)

Parameters:
pen -

registerPatternMapForEventHandling

public void registerPatternMapForEventHandling(PatternLocationToSheetLocationMapping mapping)
Really, this is the only method we need to do runtime binding. Who cares if the sheet doesn't have the right mapping, anyways?

Parameters:
mapping -

registerPatternMapsForEventHandling

public void registerPatternMapsForEventHandling(java.util.Collection<PatternLocationToSheetLocationMapping> patternMaps)
Keep track of the pattern on sheets, so we can dispatch events appropriately.

Parameters:
patternMaps -

removeEventHandlerForUnmappedEvents

public void removeEventHandlerForUnmappedEvents(EventHandler handler)
Parameters:
strokeHandler -

unregisterAllPatternMaps

public void unregisterAllPatternMaps()
To reset the event engine at runtime.


unregisterPatternMapForEventHandling

public void unregisterPatternMapForEventHandling(PatternLocationToSheetLocationMapping patternMap)
Parameters:
patternMap -

unregisterPatternMapsForEventHandling

public void unregisterPatternMapsForEventHandling(java.util.Collection<PatternLocationToSheetLocationMapping> patternMaps)
Remove these maps from our runtime list.

Parameters:
patternMaps -

unregisterPen

public void unregisterPen(PenInput pen)
Stop watching this pen input device.

Parameters:
pen -

Copyright 2006 Stanford University