java.lang.Object | |
↳ | sofia.graphics.Shape.Animator<AnimatorType extends sofia.graphics.Shape.Animator<AnimatorType>> |
Known Direct Subclasses
StrokedShape.Animator<AnimatorType extends Animator<AnimatorType>>,
TextShape.Animator<AnimatorType extends Animator<AnimatorType>>
|
Known Indirect Subclasses
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
onAnimationDone
), 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();
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.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Creates a new animator for the specified shape. Users cannot call call this constructor directly; instead, they need to use the Shape#animate(long) method to get an animator object.
duration | the length of one pass of the animation, in milliseconds |
---|
This method is intended for internal use.
Sets the final alpha (opacity) of the shape when the animation ends.
alpha | the final alpha (opacity) of the shape when the animation ends, from 0 (fully transparent) to 255 (fully opaque) |
---|
Sets the final bounds of the shape when the animation ends.
bounds | the final bounds of the shape when the animation ends |
---|
Sets the final color of the shape when the animation ends.
color | the final color of the shape when the animation ends |
---|
Sets the delay, in milliseconds, that the animation will wait after the
play()
method is called until it actually starts.
newDelay | the delay, in milliseconds, before the animation starts |
---|
Gets the delay, in milliseconds, that this animation will wait (or did wait) before starting.
Gets the duration of this animation in milliseconds.
Gets the shape that the receiver is animating.
Gets a value indicating whether the animation is playing backward.
Gets a value indicating whether the animation is playing forward.
Gets a value indicating whether the animation is currently playing, either forward or backward.
Sets the final position of the shape when the animation ends as a relative shift from the shape's position when the animation starts.
dx | the horizontal amount to have shifted the shape when the animation ends |
---|---|
dy | the vertical amount to have shifted the shape when the animation ends |
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.
newName | the name of the animation |
---|
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)
.
Starts the animation.
Sets the final position of the shape when the animation ends.
x | the final x-coordinate of the shape when the animation ends |
---|---|
y | the final y-coordinate of the shape when the animation ends |
Sets the final position of the shape when the animation ends.
point | the final position of the shape when the animation ends |
---|
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 Shape#stopAnimation(). This also means that this method will have no effect if the animation is repeating or oscillating.
Causes the animation to repeat until stopped. This method is
provided as shorthand, equivalent to
repeatMode(RepeatMode.REPEAT)
.
Sets the repeat mode for this animation. See the RepeatMode enumeration for possible values.
mode | the repeat mode for the animation |
---|
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.
rotation | the final rotation, in degrees clockwise (negative values will rotate counter-clockwise) |
---|
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.
newInterpolator | the timing function (interpolator) that determines how the animation behaves during execution |
---|
Sets the final x-coordinate of the shape when the animation ends.
Sets the final y-coordinate of the shape when the animation ends.
y | the final y-coordinate of the shape when the animation ends |
---|
Adds a property transformer to the list of those that will be applied each time the animation advances.
transformer | the property transformer |
---|