Class Animator


  • public class Animator
    extends java.lang.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.

    • Field Detail

      • DEBUG_ANIMATOR_MONITOR_CONSTANT

        public static final java.lang.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:
        java.lang.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:
        java.lang.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.