public class States extends EventGenerator
EVENT_TYPE
events
and allows to retrieve for each state its current value. Each instance can manage at most 256
states and
each state can have a value between 0
and 255
.0
and getNumberOfStates()
-1
Modifier and Type | Field and Description |
---|---|
static int |
EVENT_TYPE
The STATE event type returned by
getEventType() . |
Constructor and Description |
---|
States(int[] nbValues,
int[] initialValues)
Creates a states generator.
|
Modifier and Type | Method and Description |
---|---|
int |
buildEvent(int stateId,
int value)
Builds a MicroUI event for the given state identifier on its value.
|
int |
getCurrentValue(int stateId)
Gets the current value of the given state.
|
int |
getEventType()
Gets the event type associated with the event generator.
|
int |
getNumberOfStates()
Gets the number of states managed by this instance.
|
int |
getNumberOfValues(int stateId)
Gets the total number of values for the given state.
|
static int |
getStateId(int event)
Gets the state's identifier held by the state event.
|
static int |
getStateValue(int event)
Gets the state's value held by the state event.
|
void |
send(int stateId,
int value)
Stores the given state value and sends a MicroUI
EVENT_TYPE to the States's listener. |
addToSystemPool, get, get, get, getEventHandler, getId, removeFromSystemPool, sendEvent, setEventHandler
public static final int EVENT_TYPE
getEventType()
.public States(int[] nbValues, int[] initialValues)
nbValues
- number of values for each state.initialValues
- initial value for each state.IllegalArgumentException
- if both arrays don't have the same length.IndexOutOfBoundsException
- if arrays length is greater than 255.IndexOutOfBoundsException
- if nbValues[i] < 0
or nbValues[i] > 255
.IndexOutOfBoundsException
- if initialValues[i] < 0
or initialValues[i] >= nbValues[i]
.public static int getStateId(int event)
event
- the state event to decode.0
and 255
.public static int getStateValue(int event)
event
- the state event to decode.0
and 255
.public int getEventType()
EVENT_TYPE
.getEventType
in class EventGenerator
public int getNumberOfValues(int stateId)
stateId
- the state identifier value.IndexOutOfBoundsException
- when stateId is out of [0,getNumberOfStates()
-1]
.public int getCurrentValue(int stateId)
stateId
- the state identifier value.0
and getNumberOfValues(int)
-1
.IndexOutOfBoundsException
- when stateId is out of [0,getNumberOfStates()
-1]
.public int getNumberOfStates()
public int buildEvent(int stateId, int value)
stateId
- the state identifier value.value
- the new state valuepublic void send(int stateId, int value)
EVENT_TYPE
to the States's listener.stateId
- the state identifier value.value
- the new state valueIndexOutOfBoundsException
- when stateId
is out of [0,getNumberOfStates()
-1]
.IndexOutOfBoundsException
- when value
is out of [0,getNumberOfValues(int)
-1]
.