public interface PsTimeListenerIf
Usage of animations:
anim.getAnimationPanel().setVisible(true)
and start animation from panel, or directly call anim.start()
.The following code describes how to register a dynamic object as animation. After the registration, the animation may be started from code or interactively from the animation manager's info panel. The info panel is available by calling anim#getAnimationPanel()#setVisible(true), or, if the manager is created inside a project, by registering the manager in the project via project#setAnimation(anim) and then pressing F4 or Strg-A.
Somewhere, e.g. in the initialization method of a project:
// The class DynSample is a user defined class to be animated. The
// class must implement the interface PsTimeListenerIf
.
DynSample dyn = new DynSample();
// Create a new animation manager which will supervise the animation.
PsAnimation anim = new PsAnimation();
anim.setName("Sample Animation");
// Register the sample dynamic object within the animation manager
// as a lisener of timer events.
// In return, the animation will itself register as animation in the listener.
// This enables JavaView to display the animation panel of the listener.
anim.addTimeListener(dyn);
// Set initial time of animation. This will result in a call of dyn.setTime(PsTimeEvent time).
anim.setTime(0.);
In DynSample.java:
// DynSample.setTime(PsTimeEvent time) should recompute the dynamic object // according to the new current time. public boolean setTime(PsTimeEvent time) { // recompute dynamic object ... // further, update itself to let the system know about its change. update(this); return true; }
PsAnimation
,
PsKeyframeIf
,
MyProject
Modifier and Type | Method and Description |
---|---|
PsAnimation |
getAnimation()
Get the animation manager where this listener is registered.
|
java.lang.String |
getName()
Get name of listener object.
|
boolean |
hasAnimation()
Check whether this object is registered as listener of an animation manager.
|
void |
setAnimation(PsAnimation anAnimation)
Assign the animation manager where this listener is registered.
|
boolean |
setTime(PsTimeEvent timeEvent)
Animation updates the dynamic object through this method whenever time has changed.
|
java.lang.String getName()
boolean setTime(PsTimeEvent timeEvent)
PsAnimation getAnimation()
setAnimation(PsAnimation)
.hasAnimation()
,
setAnimation(PsAnimation)
boolean hasAnimation()
getAnimation()
,
setAnimation(PsAnimation)
void setAnimation(PsAnimation anAnimation)
Only one animation manager may be assigned to this listener. Subsequent assignments will replace the previous assignment.
getAnimation()
,
hasAnimation()
"