Class AnimationBuilder


  • public class AnimationBuilder
    extends java.lang.Object
    A builder used to add animations to an element.
    
     Text text = new Text(100, 100, "Hello World");
     text.animate()
         .add(Animation.moveTo(200, 200), 3)      // move to (200, 200) in 3 seconds
         .with(Animation.colorTo(Color.BLUE), 3)  // change color to blue in 3 seconds
         .with(Animation.moveBy(100, 0), 3);      // at the same time, move 100 pixels to the right
     canvas.sleep();                              // wait for the animation to finish
     
    • Field Detail

      • drawable

        protected final Drawable<?> drawable
    • Constructor Detail

      • AnimationBuilder

        public AnimationBuilder​(Drawable<?> drawable)
    • Method Detail

      • add

        public AnimationBuilder add​(Animation animation,
                                    double duration,
                                    TimeUnit unit)
        Add a new animation to the element.
        
         // these animations will run one after the other
         obj.animate()
            .add(Animation.moveTo(100, 100), 100, TimeUnit.Frames)
            .add(Animation.colorTo(Color.BLUE), 100, TimeUnit.Frames);
         
        Parameters:
        animation - The animation type to add
        duration - The amount of time the animation will last
        unit - The unit of time used for duration
        Returns:
        this to allow method chaining
      • add

        public AnimationBuilder add​(Animation animation,
                                    double duration)
        Add a new animation to the element.
        
         // these animations will run one after the other
         obj.animate()
            .add(Animation.moveTo(100, 100), 10)
            .add(Animation.colorTo(Color.BLUE), 10);
         
        Parameters:
        animation - The animation type to add
        duration - The amount of time the animation will last. In seconds.
        Returns:
        this to allow method chaining
      • with

        public AnimationBuilder with​(Animation animation,
                                     double duration,
                                     TimeUnit unit)
        Add the animation alongside / with the previous animation.
        
         // these animations will run at the same time
         obj.animate()
            .add(Animation.moveTo(100, 100), 100, TimeUnit.Frames)
            .add(Animation.colorTo(Color.BLUE), 100, TimeUnit.Frames);
         
        Parameters:
        animation - The animation type to add
        duration - The amount of time the animation will last
        unit - The unit of time used for duration
        Returns:
        this to allow method chaining
      • with

        public AnimationBuilder with​(Animation animation,
                                     double duration)
        Add the animation alongside / with the previous animation.
        
         // these animations will run at the same time
         obj.animate()
            .add(Animation.moveTo(100, 100), 10)
            .with(Animation.colorTo(Color.BLUE), 10);
         
        Parameters:
        animation - The animation type to add
        duration - The amount of time the animation will last
        Returns:
        this to allow method chaining
      • sleep

        public AnimationBuilder sleep​(double seconds)
        Sleep for the specified amount of time. Used to add delays between animations
        Parameters:
        seconds - The amount of time to sleep for
        Returns:
        this to allow method chaining