public class Animator extends Object
animations
in a CanvasControl
.
For running IAnimation
instances, the methods animate(IAnimation, IEventHandler)
or animateAndWait(IAnimation)
can be used. For simpler cases of custom animations there are also overloads of both methods that take an
IAnimationCallback
.
IAnimation
,
IAnimationCallback
Constructor and Description |
---|
Animator(CanvasControl canvas)
Initializes a new instance of the
Animator class using the given CanvasControl 's Dispatcher to
run the animations. |
Modifier and Type | Method and Description |
---|---|
void |
animate(IAnimation animation)
Animates the given animation instance and triggers the callback upon completion.
|
void |
animate(IAnimationCallback callback,
Duration duration)
Starts animating the given animation for the specified duration.
|
void |
animate(IAnimationCallback callback,
Duration duration,
IEventHandler<IEventArgs> finishedCallback)
Starts animating the given animation for the specified duration.
|
void |
animate(IAnimation animation,
IEventHandler<IEventArgs> finishedCallback)
Animates the given animation instance and triggers the callback upon completion.
|
void |
animateAndWait(IAnimation animation)
Animates the given animation instance.
|
void |
animateAndWait(IAnimationCallback callback,
Duration duration)
Starts to animate the given animation for the specified duration.
|
void |
destroy()
Stops all running animations.
|
CanvasControl |
getControl()
The control the animations are run on.
|
boolean |
isAutoUpdateEnabled()
Gets a value indicating whether to automatically
invalidate the control this
instance has been created for. |
boolean |
isUserInteractionAllowed()
Determines whether user interaction should be allowed during the animation.
|
void |
setAutoUpdateEnabled(boolean value)
Sets a value indicating whether to automatically
invalidate the control this
instance has been created for. |
void |
setUserInteractionAllowed(boolean value)
Determines whether user interaction should be allowed during the animation.
|
protected void |
updateControl()
Invalidates the control if
AutoUpdateEnabled is set to true . |
public Animator(CanvasControl canvas)
Animator
class using the given CanvasControl
's Dispatcher
to
run the animations.
Using this constructor this instance will query an instance of WaitInputMode
from the canvas's context
to automatically set the Waiting
property during animations if UserInteractionAllowed
is set to false
. The animation is not started until animate(IAnimation, IEventHandler)
or animate(IAnimationCallback, Duration, IEventHandler)
is called.
canvas
- The canvas control.public final void animate(IAnimation animation)
The animation will be performed asynchronously during each drawn frame. Thus this method cannot block until the
operation is completed if it is started from the Dispatcher
that is associated with the control this instance
has been created for. It will return before the animation has finished. Upon animation end the finishedCallback
will be triggered.
animation
- The animation to perform.animateAndWait(IAnimation)
public final void animate(IAnimationCallback callback, Duration duration)
The animation will be performed asynchronously during each drawn frame. This method will not block until the operation is completed but might return before the animation has been finished.
callback
- The callback to use for the animation.duration
- The duration in milliseconds that the animation should last.animateAndWait(IAnimationCallback, Duration)
public final void animate(IAnimationCallback callback, Duration duration, IEventHandler<IEventArgs> finishedCallback)
The animation will be performed asynchronously during each drawn frame. This method will not block until the operation is completed but might return before the animation has been finished.
callback
- The callback to use for the animation.duration
- The duration in milliseconds that the animation should last.finishedCallback
- A callback that will be triggered on the Control's Thread once the animation ended.animateAndWait(IAnimationCallback, Duration)
public final void animate(IAnimation animation, IEventHandler<IEventArgs> finishedCallback)
The animation will be performed asynchronously during each drawn frame. Thus this method cannot block until the
operation is completed if it is started from the Dispatcher
that is associated with the control this instance
has been created for. It will return before the animation has finished. Upon animation end the finishedCallback
will be triggered.
animation
- The animation to perform.finishedCallback
- A callback that will be triggered on the Control's Thread once the animation ended. The source of the event will be the
animation
instance.animateAndWait(IAnimation)
public final void animateAndWait(IAnimation animation)
The animation will be performed synchronously. Unless this method is called from the thread associated with the Dispatcher
of the control this instance has been created for, this method will use the draw frame event to process the animation.
Otherwise it will directly execute the animation from within this thread. It will block until the operation is completed
and will return after the animation has been finished.
animation
- The animation to perform.animate(IAnimation, IEventHandler)
public final void animateAndWait(IAnimationCallback callback, Duration duration)
The animation will be performed asynchronously during each drawn frame. This method will block until the operation is completed and will return after the animation has been finished.
callback
- The callback to use for the animation callbacks.duration
- The duration in milliseconds that the animation should last.public void destroy()
public final CanvasControl getControl()
public final boolean isAutoUpdateEnabled()
invalidate the control
this
instance has been created for.
The default is true.
true
if invalidation should happen automatically; false
otherwise.setAutoUpdateEnabled(boolean)
public final boolean isUserInteractionAllowed()
If false
, the WaitInputMode
is queried from the CanvasControl
and Waiting
is enabled during the animation. The default is false
.
setUserInteractionAllowed(boolean)
public final void setAutoUpdateEnabled(boolean value)
invalidate the control
this
instance has been created for.
The default is true.
value
- true
if invalidation should happen automatically; false
otherwise.isAutoUpdateEnabled()
public final void setUserInteractionAllowed(boolean value)
If false
, the WaitInputMode
is queried from the CanvasControl
and Waiting
is enabled during the animation. The default is false
.
value
- The UserInteractionAllowed to set.isUserInteractionAllowed()
protected void updateControl()
AutoUpdateEnabled
is set to true
.
In this implementation the control is invalidated
or
updated directly
, depending on whether the corresponding dispatcher
provides com.yworks.yfiles.view.Dispatcher.checkAccess()
.