# Class TouchEvent

java.lang.Object
com.sparshui.common.messages.events.TouchEvent

All Implemented Interfaces:
  `Event, Serializable`

public class TouchEvent extends Object implements Event

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`TouchEvent()`
`TouchEvent(byte[] data)`
Constructs a new TouchEvent from a serialized version - 4 bytes : id - 4 bytes : x - 4 bytes : y - 4 bytes : state - 8 bytes : time - 24 bytes total
`TouchEvent(int id, float x, float y, int state)`
`TouchEvent(TouchPoint tp)`

## Method Summary

Modifier and Type
Method
Description
`int`
`getEventType()`
Returns the integer value of this event type.
`int`
`getState()`
`long`
`getTime()`
`int`
`getTouchID()`
`float`
`getX()`
`float`
`getY()`
`byte[]`
`serialize()`
Constructs the data packet with this event data.
`void`
`setX(float x)`
`void`
`setY(float y)`
`String`
`toString()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### TouchEvent

public TouchEvent()

### TouchEvent

public TouchEvent(int id, float x, float y, int state)

Parameters:
  `id` -
  `x` -
  `y` -
  `state` -

### TouchEvent

public TouchEvent(TouchPoint tp)

### TouchEvent

public TouchEvent(byte[] data)
Constructs a new TouchEvent from a serialized version - 4 bytes : id - 4 bytes : x - 4 bytes : y - 4 bytes : state - 8 bytes : time - 24 bytes total

Parameters:
  `data` - the serialized version of touchEvent

## Method Details

### getTouchID

public int getTouchID()

### getTime

public long getTime()

### getX

public float getX()

### getY

public float getY()

### setX

public void setX(float x)

### setY

public void setY(float y)

### getState

public int getState()

### getEventType

public int getEventType()
Description copied from interface: `Event`
Returns the integer value of this event type. Event type values are defined in the enumeration com.sparshui.common.messages.events.EventType.java

Specified by:
  `getEventType` in interface `Event`
Returns:
  The event type

### serialize

public byte[] serialize()
Constructs the data packet with this event data. Message format for this event: - 4 bytes : event type - 4 bytes : id - 4 bytes : x - 4 bytes : y - 4 bytes : state - 8 bytes : time - 28 bytes total

Specified by:
  `serialize` in interface `Event`
Returns:
  serialized data

### toString

public String toString()

Overrides:
  `toString` in class `Object`