JavaView® v2.00.008

jv.anim
Interface PsTimeListenerIf

All Known Implementing Classes:
PsKeyframe, PjProject, PnExplodeElementSet, PnExplodePolytope, MathTimerListener, PgSurfacePair, PgSurface_CatenoidHelicoid

public interface PsTimeListenerIf

Interface required for all objects who want to register itself in an animation manager.

Usage of animations:

  1. Implement the interface PsTimeListenerIf in a class which shall be animated.
  2. Create an instance of PsAnimation and register the above dynamic class.
  3. Show the animationPanel using 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(0.).
	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;
	}
 

Version:
21.02.01, 3.50 revised (kp) New methods added to access supervising animation.
16.09.00, 3.00 revised (kp) Renamed to PsTimeListenerIf from PsDynamicIf.
02.01.00, 2.20 revised (kp) Methods getTimeOfFirst(),... moved into separate interface PsKeyframeIf.
04.10.99, 2.10 revised (ur) getTimeOfFirst/Previous/Next/LastKey methods added.
12.06.99, 2.00 revised (kp) GetName() method added.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PsAnimation, PsKeyframeIf, PjProject, MyProject

Method Summary
 PsAnimation getAnimation()
          Get the animation object 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 object.
 void setAnimation(PsAnimation anAnimation)
          Assign the animation object where this listener is registered.
 boolean setTime(PsTimeEvent timeEvent)
          Animation updates the dynamic object through this method whenever time has changed.
 

Method Detail

getName

public java.lang.String getName()
Get name of listener object. It will e.g. be used as title of the animation panel.

setTime

public boolean setTime(PsTimeEvent timeEvent)
Animation updates the dynamic object through this method whenever time has changed.

getAnimation

public PsAnimation getAnimation()
Get the animation object where this listener is registered. This listener may only have a single animation object which is assigned by the animation object when this listener is registered using setAnimation(PsAnimation).
See Also:
hasAnimation(), setAnimation(PsAnimation)

hasAnimation

public boolean hasAnimation()
Check whether this object is registered as listener of an animation object.
See Also:
getAnimation(), setAnimation(PsAnimation)

setAnimation

public void setAnimation(PsAnimation anAnimation)
Assign the animation object where this listener is registered. This method is invoked by the animation object during registration of this listener, and usually is not required to be called by a user. If this listener has an assigned animation object, then its animation panel may be shown to change the current time of this listener.

Only one animation object may be assigned to this listener. Subsequent assignments will replace the previous assignment.

See Also:
getAnimation(), hasAnimation()

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.