ch.claudio.pen.input
Class Event

java.lang.Object
  extended by ch.claudio.pen.input.Event

public final class Event
extends java.lang.Object

Hold the data for an event.

Version:
$Id:$
Author:
Claudio Nieder

Copyright (C) 2007-2008 Claudio Nieder <private@claudio.ch>, 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


Field Summary
 short code
          Code (ABS_X etc.) as supplied by the event device
 PenState penState
          Pen state
 long timestamp
          Time stamp as supplied by the event device.
 short type
          Type (EV_ABS etc.) as supplied by the event device
 int value
          value as supplied by the event device
 int x
          Absolute x coordinate
 int y
          Absolute
 
Constructor Summary
Event(int lastX, int lastY, PenState lastState)
          Create a new event and initialise it with the given last coordinate values.
Event(long time, short typeArg, short codeArg, int valueArg)
          Creates an Event object out of an input handler event
 
Method Summary
 Event clone()
           
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 boolean isSync()
          Return true if this event is a snc event EV_SYN indicating that all preceding invents since the lasy sync belong together.
 long javaTime()
          Return a time stamp conforming to java time.
static void main(java.lang.String[] args)
          Print license.
 java.lang.String toString()
           
 void update(Event other)
          Updates this event considering the values found in the other event.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

timestamp

public long timestamp
Time stamp as supplied by the event device. Currently this is the time since Unix epoch measured in microseconds. One should not rely on that, but simply be happy to know that it is increasing monotonically.


type

public short type
Type (EV_ABS etc.) as supplied by the event device


code

public short code
Code (ABS_X etc.) as supplied by the event device


value

public int value
value as supplied by the event device


x

public int x
Absolute x coordinate


y

public int y
Absolute

penState

public PenState penState
Pen state

Constructor Detail

Event

public Event(long time,
             short typeArg,
             short codeArg,
             int valueArg)
Creates an Event object out of an input handler event

Parameters:
time - time stamp
typeArg - event type (e.g. EV_ABS)
codeArg - event code (e.g. ABS_X)
valueArg - event value

Event

public Event(int lastX,
             int lastY,
             PenState lastState)
Create a new event and initialise it with the given last coordinate values.

Parameters:
lastX -
lastY -
lastState -
Method Detail

update

public void update(Event other)
Updates this event considering the values found in the other event.

Parameters:
other - event

isSync

public boolean isSync()
Return true if this event is a snc event EV_SYN indicating that all preceding invents since the lasy sync belong together. This is needed because changes in different axis and buttons are reported separatly, yet should later be treated as one event. Also input events are "optimized" thus one might receive more or less events between two sync events depending on which values changes.

Returns:
true id this is a sync event.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

javaTime

public long javaTime()
Return a time stamp conforming to java time.

Returns:
time in milliseconds

clone

public Event clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

main

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

Parameters:
args - ignored