Class InputEventHandler

  extended by java.lang.Thread
      extended by ch.claudio.pen.input.InputEventHandler
All Implemented Interfaces:

public class InputEventHandler
extends java.lang.Thread

Receive data from an EventReader and aggregate them as needed.

The input device delivers separate events for X and Y changes, but adds an EV_SYN after events belonging together. This allows it to combine them.

For this to work an extra thread is necessary, as unfortunately Java does not allow to select on FileChannels.

Claudio Nieder

Copyright (C) 2007-2008 Claudio Nieder <>, CH-8610 Uster

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
Field Summary
Fields inherited from class java.lang.Thread
Constructor Summary
          Create a new input event handler for a component.
Method Summary
 void addListener(InputEventListener listener)
          Add a listener.
static void main(java.lang.String[] args)
          Print license.
 void put(Event e)
          Add a new event to the queue and notify the run method that there are new elements.
 void removeListener(InputEventListener listener)
          Remove a listener.
 void run()
          Fetch input events from the queue and aggregate them.
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public InputEventHandler()
Create a new input event handler for a component.

Method Detail


public void addListener(InputEventListener listener)
Add a listener.

listener -


public void removeListener(InputEventListener listener)
Remove a listener.

listener -


public void put(Event e)
Add a new event to the queue and notify the run method that there are new elements.

e - event


public void run()
Fetch input events from the queue and aggregate them. Then pass them on to the current listener.

Specified by:
run in interface java.lang.Runnable
run in class java.lang.Thread
See Also:


public static void main(java.lang.String[] args)
Print license.

args - ignored