Package paintingcanvas.animation
Class AnimationBuilder
- java.lang.Object
-
- paintingcanvas.animation.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
-
-
Constructor Summary
Constructors Constructor Description AnimationBuilder(Drawable<?> drawable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnimationBuilder
add(Animation animation, double duration)
Add a new animation to the element.AnimationBuilder
add(Animation animation, double duration, TimeUnit unit)
Add a new animation to the element and wait for it to finish.AnimationBuilder
sleep(double seconds)
Sleep for the specified amount of time.AnimationBuilder
with(Animation animation, double duration)
Add the animation to run at the same time as the previous animation, without waiting for it to finish.AnimationBuilder
with(Animation animation, double duration, TimeUnit unit)
Add the animation to run at the same time as the previous animation, without waiting for it 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 and wait for it to finish.// 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 addduration
- the amount of time the animation will lastunit
- the unit of time used forduration
- 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 addduration
- 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 to run at the same time as the previous animation, without waiting for it to finish.// these animations will run at the same time obj.animate() .with(Animation.moveTo(100, 100), 100, TimeUnit.Frames) .with(Animation.colorTo(Color.BLUE), 100, TimeUnit.Frames);
- Parameters:
animation
- The animation type to addduration
- The amount of time the animation will lastunit
- The unit of time used forduration
- Returns:
this
to allow method chaining
-
with
public AnimationBuilder with(Animation animation, double duration)
Add the animation to run at the same time as the previous animation, without waiting for it to finish.// these animations will run at the same time obj.animate() .with(Animation.moveTo(100, 100), 10) .with(Animation.colorTo(Color.BLUE), 10);
- Parameters:
animation
- The animation type to addduration
- 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
-
-