Perforce 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
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 Perforce JViews.
Then, go to the installation directory
of the code example and type:
ant run
Topics Covered
- Grapher
- Graph layout
- Animation (single thread)
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 application 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:
- Attach an
IlvManagerAnimator
to theIlvManager
. - Call
IlvManagerAnimator.recordState()
to store the current situation of the manager in the manager animator. - 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 byrecordState
to the new object positions.
Installation Directory
The Animated Layout (Single-Threaded) code example is installed here.
Classes Involved
- ilog.views.animation.IlvManagerAnimator
- ilog.views.animation.IlvObjectAnimator
- ilog.views.animation.IlvGraphicAnimator
- ilog.views.animation.IlvLinkImageAnimator