Rogue Wave JViews Diagrammer Code Example: Animated Layout (Single-Threaded)


Description

This sample shows how to implement a single-threaded animation with the graphic framework.

A multithreaded version of the sample can be found here

How to Run the Code Example as an Application

This code example can also be run as an application. The installation directory contains an executable JAR file, animation-singlethreaded.jar, that allows you to execute the code example with a double click from a file browser. Note that if you are using Internet Explorer, you can open the installation directory and execute the JAR file from the browser. This technique may not work in other Web browsers.

Alternatively, you can run the code example application from the command line. First check that the Ant utility is properly configured. If not, see the instructions on how to configure Ant for Rogue Wave JViews.

Then, go to the installation directory of the code example and type:

ant run

Topics Covered

Detailed Description

There are various ways to implement animation: If a diagram component (IlvDiagrammer instance) is used, an animation renderer (IlvAnimationRenderer) can be installed. If no diagram component is used, animation can be implemented directly on top of the graphic framework. This sample shows the latter case: how to implement animation directly with the graphic framework. It illustrates how to animate changes to node and link positions from a recorded state to a new state in a single-threaded applet or application. The sample uses various layout algorithms and shows with animation how the node and link positions change as a result of the different layouts. Do not confuse this type of animation with the setAnimate option of some layout algorithms, which animate how the layout algorithm works internally. This sample shows the results of the layout algorithms using animation.

Because the sample is single-threaded, animation runs in the AWT event thead. Animation can help the user preserve a mental map of the graph when the positions of many nodes change at the same time.


Animation works as follows:

  1. Attach an IlvManagerAnimator to the IlvManager.
  2. Call IlvManagerAnimator.recordState() to store the current situation of the manager in the manager animator.
  3. After the (invisible) placement of nodes and links, call IlvManagerAnimator.animate() to animate changes to the manager. This will draw an animated movement of the objects from the positions recorded by recordState to the new object positions.
The animation framework allows you to control the animation rate (the number of steps performed to animate a movement) and the animation delay (the interval between two animation steps). Both parameters affect the animation speed.




Installation Directory

The Animated Layout (Single-Threaded) code example is installed here.

Classes Involved

Source Files

Copyright © Rogue Wave Software, Inc. 1997, 2015. All rights reserved. Legal terms.