public static class Animation.Builder
extends java.lang.Object
Builder in order to construct animations comfortable.
Modifier and Type | Method and Description |
---|---|
Animation |
build()
Builds the animation.
|
Animation.Builder |
ledOff(int index)
Turns the LED or digital output on the Kart at the given index off.
|
Animation.Builder |
ledOn(int index)
Turns the LED or digital output on the Kart at the given index on.
|
Animation.Builder |
perform(java.lang.Runnable action)
Performs a custom action that can be passed as Runnable implementation to the builder method call.
|
Animation.Builder |
until(java.util.concurrent.Callable<java.lang.Boolean> condition)
Tests repeatedly the given condition until the condition returns true, then the animation is continued.
|
Animation.Builder |
until(java.util.concurrent.Callable<java.lang.Boolean> condition,
int pollInterval)
Tests repeatedly the given condition until the condition returns true, then the animation is continued.
|
Animation.Builder |
wait(int milliseconds)
Waits the given amount of milliseconds before the next step of the animation will be executed.
|
public Animation.Builder ledOn(int index)
Turns the LED or digital output on the Kart at the given index on.
index
- Index of the LED/Output to set to on (0..3).java.lang.IndexOutOfBoundsException
- If the LED index is outside the range 0..3.public Animation.Builder ledOff(int index)
Turns the LED or digital output on the Kart at the given index off.
index
- Index of the LED/Output to set to off (0..3).java.lang.IndexOutOfBoundsException
- If the LED index is outside the range 0..3.public Animation.Builder wait(int milliseconds)
Waits the given amount of milliseconds before the next step of the animation will be executed.
milliseconds
- Number of milliseconds to wait before executing the next step.public Animation.Builder perform(java.lang.Runnable action)
Performs a custom action that can be passed as Runnable implementation to the builder method call.
action
- Runnable implementation that will be executed at the given animation step.public Animation.Builder until(java.util.concurrent.Callable<java.lang.Boolean> condition)
Tests repeatedly the given condition until the condition returns true, then the animation is continued. The default poll interval (the interval the condition is tested) is 100ms, thus a frequency of about 10 Hz.
condition
- Callable implementation that will be executed at the given animation step as long as it does not return true.public Animation.Builder until(java.util.concurrent.Callable<java.lang.Boolean> condition, int pollInterval)
Tests repeatedly the given condition until the condition returns true, then the animation is continued. The poll interval can be specified in milliseconds.
condition
- Callable implementation that will be executed at the given animation step as long as it does not return true.pollInterval
- Interval at which's the condition is tested.public Animation build()
Builds the animation. This method will finalize the Animation instance building process and returns a reference to the newly build animation.