Package ej.mwt.animation

## Class Animator

- java.lang.Object
- - ej.mwt.animation.Animator

-     public class Animator
      extends Object

  An animator executes animations as fast as possible.

  The animator loops on:

  - retrieve the current time with `Util.platformTimeMillis()`,
  - call the `Animation.tick(long)` of all the registered animations,
  - wait for the end of the flush,
  - start again while at least one animation is running.

  Only one animator can be running at any time.

  In the same way, `Display.callOnFlushCompleted(Runnable)` must not be called when an animator is running

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `Animator.AnimatorListener` | Listener for animator events.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `DEBUG_ANIMATOR_ENABLED_CONSTANT` | `BON boolean constant` to enable/disable the animator debug.
    `static String` | `DEBUG_ANIMATOR_MONITOR_CONSTANT` | `BON Class constant` to set the animator monitor.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Animator()` | Creates an animator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `indicateRenderRequested()` | Indicates to this animator that a render has been requested.
    `void` | `startAnimation​(Animation animation)` | Starts an animation.
    `void` | `stopAllAnimations()` | Stops all the animations.
    `void` | `stopAnimation​(Animation animation)` | Stops an animation.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### DEBUG_ANIMATOR_ENABLED_CONSTANT

          public static final String DEBUG_ANIMATOR_ENABLED_CONSTANT

      `BON boolean constant` to enable/disable the animator debug.

      If enabled, "ej.mwt.debug.animator.monitor" must also be set.

      See Also:
        Constant Field Values

    - #### DEBUG_ANIMATOR_MONITOR_CONSTANT

          public static final String DEBUG_ANIMATOR_MONITOR_CONSTANT

      `BON Class constant` to set the animator monitor.

      Set it to the FQN of an implementation of `Animator.AnimatorListener` to monitor the animator.

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Animator

          public Animator()

      Creates an animator.

      Multiple animators may be created but only one can be running at any time.

  - ### Method Detail

    - #### startAnimation

          public void startAnimation​(Animation animation)

      Starts an animation.

      The animation tick method is then called every period.

      If the animation is already started, nothing is done.

      Parameters:
        `animation` - the animation to start.
      See Also:
        `Animation.tick(long)`

    - #### stopAnimation

          public void stopAnimation​(Animation animation)

      Stops an animation.

      The tick method of the given animation will not be called anymore by this animator.

      This method must be called in the MicroUI thread.

      Parameters:
        `animation` - the animation to stop.
      Throws:
        `IllegalStateException` - if this method is called in an other thread than the MicroUI thread or during an animation tick.

    - #### stopAllAnimations

          public void stopAllAnimations()

      Stops all the animations.

      The tick method of every animation will not be called anymore by this animator.

      This method must be called in the MicroUI thread.

      Throws:
        `IllegalStateException` - if this method is called in an other thread than the MicroUI thread or during an animation tick.

    - #### indicateRenderRequested

          public void indicateRenderRequested()

      Indicates to this animator that a render has been requested.

      Calling this method is only useful if the `DEBUG_ANIMATOR_ENABLED_CONSTANT` constant is enabled.

      This method is called automatically when a render of a widget or of a desktop is requested. This method can be called manually if the animator is used to render something else.