java.lang.Object
sofia.graphics.Shape.Animator<AnimatorType extends sofia.graphics.Shape.Animator<AnimatorType>>
![]()
StrokedShape.Animator<AnimatorType extends Animator<AnimatorType>>,
TextShape.Animator<AnimatorType extends Animator<AnimatorType>>
|
![]()
FillableShape.Animator<AnimatorType extends Animator<AnimatorType>>
|
Provides animation support for shapes. Most uses of this class will not need to reference it directly; for example, an animation can be constructed and played by chaining method calls directly:
shape.animate(500).color(Color.blue).alpha(128).play();In situations where the type of the class must be referenced directly (for example, when one is passed to an event handler like an animation began/ended callback), referring to the name of that type can be somewhat awkward due to the use of some Java generics tricks to ensure that the methods chain properly. In nearly all cases, it is reasonable to use a "?" wildcard in place of the generic parameter:
Shape.Animator<?> anim = shape.animate(500).color(Color.blue); anim.play();or,
public void bounceAnimationEnded(Animator> animator) { ... }
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Shape.Animator(long duration)
Creates a new animator for the specified shape.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean
|
advanceTo(long time)
This method is intended for internal use.
| ||||||||||
AnimatorType
|
alpha(int alpha)
Sets the final alpha (opacity) of the shape when the animation ends.
| ||||||||||
AnimatorType
|
bounds(RectF bounds)
Sets the final bounds of the shape when the animation ends.
| ||||||||||
AnimatorType
|
color(Color color)
Sets the final color of the shape when the animation ends.
| ||||||||||
AnimatorType
|
delay(long newDelay)
Sets the delay, in milliseconds, that the animation will wait after the
play() method is called until it actually starts. | ||||||||||
long
|
getDelay()
Gets the delay, in milliseconds, that this animation will wait (or
did wait) before starting.
| ||||||||||
long
|
getDuration()
Gets the duration of this animation in milliseconds.
| ||||||||||
Shape
|
getShape()
Gets the shape that the receiver is animating.
| ||||||||||
boolean
|
isBackward()
Gets a value indicating whether the animation is playing backward.
| ||||||||||
boolean
|
isForward()
Gets a value indicating whether the animation is playing forward.
| ||||||||||
boolean
|
isPlaying()
Gets a value indicating whether the animation is currently playing,
either forward or backward.
| ||||||||||
AnimatorType
|
moveBy(float dx, float dy)
Sets the final position of the shape when the animation ends as a
relative shift from the shape's position when the animation starts.
| ||||||||||
AnimatorType
|
moveBy(MotionStep motionStep)
| ||||||||||
AnimatorType
|
moveBy(float dx, float dy, float ax, float ay)
| ||||||||||
AnimatorType
|
name(String newName)
Sets the name of this animation. | ||||||||||
AnimatorType
|
oscillate()
Causes the animation to oscillate (from start to end and back to
start) until stopped.
| ||||||||||
void
|
play()
Starts the animation.
| ||||||||||
AnimatorType
|
position(float x, float y)
Sets the final position of the shape when the animation ends.
| ||||||||||
AnimatorType
|
position(PointF point)
Sets the final position of the shape when the animation ends.
| ||||||||||
AnimatorType
|
removeWhenComplete()
Causes the shape to be automatically removed from its view when the animation completes. | ||||||||||
AnimatorType
|
repeat()
Causes the animation to repeat until stopped.
| ||||||||||
AnimatorType
|
repeatMode(RepeatMode mode)
Sets the repeat mode for this animation.
| ||||||||||
AnimatorType
|
rotation(float rotation)
Sets the final rotation, in degrees clockwise, of the shape when the animation ends. | ||||||||||
void
|
stop()
Stops the animation.
| ||||||||||
AnimatorType
|
timing(Interpolator newInterpolator)
Sets the timing function (interpolator) that determines how the
animation behaves during execution.
| ||||||||||
AnimatorType
|
x(float x)
Sets the final x-coordinate of the shape when the animation ends.
| ||||||||||
AnimatorType
|
y(float y)
Sets the final y-coordinate of the shape when the animation ends.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void
|
addTransformer(PropertyTransformer transformer)
Adds a property transformer to the list of those that will be applied
each time the animation advances.
|
Methods inherited from
class
java.lang.Object
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Object
|
clone()
| ||||||||||
boolean
|
equals(Object arg0)
| ||||||||||
void
|
finalize()
| ||||||||||
final
Class<?>
|
getClass()
| ||||||||||
int
|
hashCode()
| ||||||||||
final
void
|
notify()
| ||||||||||
final
void
|
notifyAll()
| ||||||||||
String
|
toString()
| ||||||||||
final
void
|
wait()
| ||||||||||
final
void
|
wait(long arg0, int arg1)
| ||||||||||
final
void
|
wait(long arg0)
|
Creates a new animator for the specified shape. Users cannot call
call this constructor directly; instead, they need to use the
animate(long)
method to get an animator object.
This method is intended for internal use.
Sets the final alpha (opacity) of the shape when the animation ends.
this animator, for method chaining
Sets the final bounds of the shape when the animation ends.
this animator, for method chaining
Sets the final color of the shape when the animation ends.
this animator, for method chaining
Sets the delay, in milliseconds, that the animation will wait after the
play()
method is called until it actually starts.
this animator, for method chaining
Gets the delay, in milliseconds, that this animation will wait (or did wait) before starting.
the delay, in milliseconds, that this animation will (or did) wait before starting
Gets the duration of this animation in milliseconds.
the duration of this animation in milliseconds
Gets the shape that the receiver is animating.
the shape that the receiver is animating
Gets a value indicating whether the animation is playing backward.
true if the animation is playing backward, otherwise false
Gets a value indicating whether the animation is playing forward.
true if the animation is playing forward, otherwise false
Gets a value indicating whether the animation is currently playing, either forward or backward.
true if the animation is playing, otherwise false
Sets the final position of the shape when the animation ends as a relative shift from the shape's position when the animation starts.
this animator, for method chaining
Sets the name of this animation. You should set the name of an animation if you wish to be notified about events related to that animation. This name is used to determine the name of the handler method to call on the shape or the controller when animation begins, repeats, or ends.
For example, if the animation has the name "bounce", then the following notifications will be sent to the shape and the controller, if those methods exist:
bounceAnimationStarted(Shape.Animator<?>)
bounceAnimationStarted()
bounceAnimationRepeated(Shape.Animator<?>)
bounceAnimationStarted()
bounceAnimationEnded(Shape.Animator<?>)
bounceAnimationEnded()
Therefore, the name of an animation should be a valid Java identifier, preferably starting with a lowercase letter.
The name of the animation must be set in order to receive notifications about it. If you are not interested in receiving those notifications, you do not have to provide a name.
this animator, for method chaining
Causes the animation to oscillate (from start to end and back to
start) until stopped. This method is provided as shorthand,
equivalent to repeatMode(RepeatMode.OSCILLATE)
.
this animator, for chaining method calls
Starts the animation.
Sets the final position of the shape when the animation ends.
this animator, for method chaining
Sets the final position of the shape when the animation ends.
this animator, for method chaining
Causes the shape to be automatically removed from its view when the animation completes. This is useful for animations that cause a shape to fade out, where you want it to disappear for good when done.
Note that the shape will only be removed if the animation ends on its
own when its time expires; it will not be removed if you end the
animation prematurely by calling stopAnimation()
. This
also means that this method will have no effect if the animation is
repeating or oscillating.
this animator, for chaining method calls
Causes the animation to repeat until stopped. This method is
provided as shorthand, equivalent to
repeatMode(RepeatMode.REPEAT)
.
this animator, for chaining method calls
Sets the repeat mode for this animation. See the RepeatMode
enumeration for possible values.
this animator, for chaining method calls
Sets the final rotation, in degrees clockwise, of the shape when the animation ends. Negative values will create a counter-clockwise rotation.
A shape can be made to rotate completely multiple times by providing values higher than 360 to this method. For example, passing 360 would cause the shape to make one full rotation over the duration of the animation, passing 720 would cause it to make two full rotations, and so forth.
this animator, for method chaining
Stops the animation.
Sets the timing function (interpolator) that determines how the
animation behaves during execution. A number of pre-written timing
functions can be found as static methods in the Timings
class.
this animator, for method chaining
Sets the final x-coordinate of the shape when the animation ends.
this animator, for method chaining
Sets the final y-coordinate of the shape when the animation ends.
this animator, for method chaining
Adds a property transformer to the list of those that will be applied each time the animation advances.