public abstract class EventGenerator extends Object
| Constructor and Description |
|---|
EventGenerator()
Creates a new event generator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addToSystemPool()
Adds the generator in the system pool.
|
static <E extends EventGenerator> |
get(Class<E> clazz)
Gets all generators of the given type from the system pool in an array.
|
static <E extends EventGenerator> |
get(Class<E> clazz,
int fromIndex)
Gets a generator whose class is
clazz from the system pool starting the search from
fromIndex. |
static EventGenerator |
get(int id)
Gets a generator from its identifier.
|
EventHandler |
getEventHandler()
Gets the generator's event handler.
|
abstract int |
getEventType()
Gets the event type associated with the event generator
|
int |
getId()
Gets the generator's unique identifier.
|
void |
removeFromSystemPool()
Removes the generator from the system generators pool.
|
protected void |
sendEvent(int event)
Sends the given event to the current
EventHandler. |
void |
setEventHandler(EventHandler eventHandler)
Sets an event handler to this event generator.
|
public EventGenerator()
public int addToSystemPool()
MicroUIException - if the maximum number of event generators added to the system pool has been reached.public void removeFromSystemPool()
public void setEventHandler(@Nullable EventHandler eventHandler)
It replaces the old one and can be null.
eventHandler - the event handler to add.SecurityException - if a security manager exists and does not allow the caller to handle events from this event
generator.public static EventGenerator get(int id)
id - the generator's identifier.IndexOutOfBoundsException - if the generator does not exist.MicroUIException - if MicroUI is not started@Nullable public static <E extends EventGenerator> E get(Class<E> clazz, int fromIndex)
clazz from the system pool starting the search from
fromIndex. If class clazz is not an EventGenerator or if nothing is found,
returns null.clazz - the EventGenerator's class to returnfromIndex - index from which starting to searchEventGenerator or null.MicroUIException - if MicroUI is not startedpublic static <E extends EventGenerator> EventGenerator[] get(Class<E> clazz)
clazz - the type of the event generators to return.MicroUIException - if MicroUI is not startedpublic final int getId()
EventGenerators can be installed as MicroUI system
event generator.int.@Nullable public EventHandler getEventHandler()
public abstract int getEventType()
protected void sendEvent(int event)
EventHandler. Does nothing if there is no event handler set to this
event generator.event - the event to send