LuciadLightspeed provides a simple animation framework which can be used to improve the user experience of the application. Animations can be used to create smooth transitions between viewpoints, fade-in and fade-out effects, and so on.

The animation framework consists of two main components:

  • The animation manager provides global timing and bookkeeping.

  • Animations are implemented by the user and submitted for playback to the animation manager.

The animation manager is implemented by ALcdAnimationManager. This class is a singleton: only one instance can be started per application.

The animation manager uses an internal clock to keep track of time. At every clock tick, the manager tells all currently running animations what the current time is, allowing the animations to take appropriate action. The clock ticks happen at a user-specified frequency: all animations are synchronized to the same frame rate, 60 frames per second for example. If you want, you can change the frame rate. If the animations cannot be updated at the desired rate because they take up too much CPU time, frames will be dropped. Consequently, animations are updated with larger time steps.

When an animation is submitted to the animation manager with the putAnimation() method, it is associated with a particular object. For instance, if an animation is used to slide a toolbar into the view, it could be associated with the Swing component representing that toolbar. This is a convenience mechanism that you can use to prevent simultaneously running animations from interfering with each other. If putAnimation() is called with the same object parameter twice, the animation manager terminates the first animation associated with the object before starting the second one.

Animations that change the camera in a Lightspeed view should use the ALspViewXYZWorldTransformation of the view.

Animations are defined by the interface ILcdAnimation. An animation is essentially a class that gets notified by the manager when the clock has ticked. To notify the animation, the animation’s setTime() method is called. The current time is passed to this method as an argument to determine the elapsed time relative to the time at which the animation was started. What happens in the setTime() method is entirely up to the developer of the animation. Typically, some properties of an object, such as position, color and transparency, are interpolated from an initial state to a target state over the duration of the animation.

An animation can specify its own duration, and can indicate whether it wants to be played back in a repeating loop or not. These properties are taken into account by the animation manager: if an animation has reached the end of its duration, it is detached from its corresponding object and is no longer notified of clock ticks.

The animation manager may contain animations associated with objects relevant to multiple views. Some animations may change the property of a view, causing it to repaint itself, while other animations do not affect the view. Therefore, the animation manager does nothing to invalidate the appropriate views. This is entirely the responsibility of the individual animations. LuciadLightspeed provides the abstract ALcdAnimation which invalidates any views provided to it at construction.

The package contains an example of how the animation framework can be used to smoothly vary the fill color of a domain object. See animated styles for more information.