edu.stanford.hci.r3.events
Class EventHandler

java.lang.Object
  extended by edu.stanford.hci.r3.events.EventHandler
Direct Known Subclasses:
ClickHandler, CrossHandler, DragHandler, GestureHandler, HandwritingRecognizer, InkCollector, LocationHandler, StrokeHandler

public abstract class EventHandler
extends java.lang.Object

This is the super interface of all the other event handlers. These are the pen & paper analogues to Java Swing's EventListener architecture. We changed it to an abstract class in ver. 0.5, as now handlers should have access to their parent regions.... Event Handlers can be added to multiple regions (is this unique?)

We have merged Filters into Event Handlers. Filters are both similar to and different from EventHandlers. They are similar in the sense that they can be added to regions. When ink is written on a region, the data will be sent to a filter that is attached to that region.

Filters are different that event handlers because they transform incoming pen data into something qualitatively different, instead of just telling a piece of code that an event has arrived. For example, one could implement a filter that inverts pen samples' y value on a page (dunno why, but it's a fun example). Then, you can add an event handler to this filter. The event handler would then get PenEvents with upside down pen samples.

A more intricate filter would be an ink container. It can collect all ink that passes through the filter, and tell a handler that new ink has arrived. Whenever the handler needs the ink, it can request it from the ink container. Because of the custom nature of filters, it might be that each filter has a custom event handler. For example, an InkContainer might have an InkContainer listener. We can implement these as inner classes.

Filters can change the incoming event stream. For example, it might only care about events that affect certain parts of the region. Events that are not close to these parts will be ignored.

This software is distributed under the BSD License.


Field Summary
protected  java.util.List<Region> parentRegions
          This is used in debugging visualizations, for traversing up the list to figure out where the event handler should be positioned.
 
Constructor Summary
EventHandler()
           
 
Method Summary
 void addParentRegion(Region r)
           
 java.util.List<Region> getParentRegions()
           
abstract  void handleEvent(PenEvent event)
          if this event should be consumed (i.e., lower priority event handlers should not see this event), we should set the event.consumed property to true
 void showMe(java.lang.String message)
           
abstract  java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parentRegions

protected java.util.List<Region> parentRegions
This is used in debugging visualizations, for traversing up the list to figure out where the event handler should be positioned.

Constructor Detail

EventHandler

public EventHandler()
Method Detail

addParentRegion

public void addParentRegion(Region r)

getParentRegions

public java.util.List<Region> getParentRegions()

handleEvent

public abstract void handleEvent(PenEvent event)
if this event should be consumed (i.e., lower priority event handlers should not see this event), we should set the event.consumed property to true


showMe

public void showMe(java.lang.String message)

toString

public abstract java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the Event Handler's Name

Copyright 2006 Stanford University