Class Animation.Builder

java.lang.Object
ch.hevs.kart.utils.Animation.Builder
Enclosing class:
Animation

public static class Animation.Builder extends Object

Builder in order to construct animations comfortable.

  • Method Details

    • ledOn

      public Animation.Builder ledOn(int index)

      Turns the LED or digital output on the Kart at the given index on.

      Parameters:
      index - Index of the LED/Output to set to on (0..3).
      Returns:
      Reference to the builder in order to chain the method calls.
      Throws:
      IndexOutOfBoundsException - If the LED index is outside the range 0..3.
    • ledOff

      public Animation.Builder ledOff(int index)

      Turns the LED or digital output on the Kart at the given index off.

      Parameters:
      index - Index of the LED/Output to set to off (0..3).
      Returns:
      Reference to the builder in order to chain the method calls.
      Throws:
      IndexOutOfBoundsException - If the LED index is outside the range 0..3.
    • wait

      public Animation.Builder wait(int milliseconds)

      Waits the given amount of milliseconds before the next step of the animation will be executed.

      Parameters:
      milliseconds - Number of milliseconds to wait before executing the next step.
      Returns:
      Reference to the builder in order to chain the method calls.
    • perform

      public Animation.Builder perform(Runnable action)

      Performs a custom action that can be passed as Runnable implementation to the builder method call.

      Parameters:
      action - Runnable implementation that will be executed at the given animation step.
      Returns:
      Reference to the builder in order to chain the method calls.
    • until

      public Animation.Builder until(Callable<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.

      Parameters:
      condition - Callable implementation that will be executed at the given animation step as long as it does not return true.
      Returns:
      Reference to the builder in order to chain the method calls.
    • until

      public Animation.Builder until(Callable<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.

      Parameters:
      condition - Callable implementation that will be executed at the given animation step as long as it does not return true.
      pollInterval - Interval at which the condition is tested.
      Returns:
      Reference to the builder in order to chain the method calls.
    • build

      public Animation build()

      Builds the animation. This method will finalize the Animation instance building process and returns a reference to the newly build animation.

      Returns:
      Animation that was created using the builder.