See: Description
Package | Description |
---|---|
com.surelogic |
Provides the annotations necessary to express models of programmer design
intent in Java code.
|
org.jdesktop.core.animation.i18n |
Provides internationalized messages, in particular error messages, to
the Timing Framework.
|
org.jdesktop.core.animation.rendering |
Core classes of a rendering framework that can support
both passive and active rendering approaches.
|
org.jdesktop.core.animation.timing |
Core classes of the Timing Framework; these classes provide the base
functionality that all animations will use.
|
org.jdesktop.core.animation.timing.evaluators |
Evaluator implementations for the standard Java numeric types.
|
org.jdesktop.core.animation.timing.interpolators |
Several useful interpolator implementations for animations.
|
org.jdesktop.core.animation.timing.sources |
Several useful timing source implementations for animations.
|
org.jdesktop.core.animation.timing.triggers |
A simple mechanism for starting animations when specific events occur.
|
org.jdesktop.swing.animation.rendering |
A flexible implementation of rendering on a Swing component that supports
both passive and active rendering approaches.
|
org.jdesktop.swing.animation.timing.evaluators |
Evaluator implementations for the several useful Swing and Java2D types.
|
org.jdesktop.swing.animation.timing.sources |
Timing source implementation for the Swing timer.
|
org.jdesktop.swing.animation.timing.triggers |
A simple mechanism for starting animations when specific Swing events occur.
|
The Timing Framework is a set of utility classes that enables you to create powerful animations in your Java applications.
_______ _ /_ __(_)____ ___ (_)____ ____ _ / / / // __ `__ \/ // __ \/ __ `/ / / / // / / / / / // / / / /_/ / /_/ /_//_/ /_/ /_/_//_/ /_/\__, / /____/ ______ __ / ____/_________ _____ ___ ___ _ ______ _____/ /__ / /_ / ___/ __ `/ __ `__ \/ _ \ | /| / / __ \/ ___/ //_/ / __/ / / / /_/ / / / / / / __/ |/ |/ / /_/ / / / ,< /_/ /_/ \__,_/_/ /_/ /_/\___/|__/|__/\____/_/ /_/|_|
The Timing Framework was implemented by Chet Haase and introduced in the book Filthy Rich Clients (Haase and Guy, Addison-Wesley, 2008).
Improvements to Haase's release were implemented by Tim Halloran beginning in 2011. These improvements include
Animator animator = new Animator.Builder().setDuration(5, TimeUnit.SECONDS) .setRepeatCount(4) .addTarget(myTarget) .build(); animator.start();
TimingSource source = new SwingTimerTimingSource(15, TimeUnit.MILLISECONDS); Animator.setDefaultTimingSource(source); // shared timing source source.init(); // starts the timer ... // create, use, and dispose lots of Animator instances ... source.dispose(); // stops the timer
final KeyFrames<Integer> keyFrames = new KeyFrames.Builder<Integer>().addFrames(2, 6, 3, 5, 4) .setInterpolator(DiscreteInterpolator.getInstance()) .build(); out("Constructed Key Frames"); out("----------------------"); int i = 0; for (KeyFrames.Frame<Integer> keyFrame : keyFrames) { final String s = keyFrame.getInterpolator() == null ? "null" : keyFrame.getInterpolator().getClass().getSimpleName(); out(String.format("Frame %d: value=%d timeFraction=%f interpolator=%s", i++, keyFrame.getValue(), keyFrame.getTimeFraction(), s)); }Alternatively, the key frames could have been constructed frame by frame, even including specific timing fractions for the key frame value, as shown below.
final KeyFrames<Integer> keyFrames = new KeyFrames.Builder<Integer>() .addFrame(2, DiscreteInterpolator.getInstance()) .addFrame(6, DiscreteInterpolator.getInstance()) .addFrame(3, 0.5, DiscreteInterpolator.getInstance()) .addFrame(5, DiscreteInterpolator.getInstance()) .addFrame(4, DiscreteInterpolator.getInstance()) .build();Regardless of how the key frames are constructed, the output of this snippet is listed below. Notice that the interpolator for the first frame is null. This is because the interpolator for a time duration is stored with the end time.
Constructed Key Frames ---------------------- Frame 0: value=2 timeFraction=0.000000 interpolator=null Frame 1: value=6 timeFraction=0.250000 interpolator=DiscreteInterpolator Frame 2: value=3 timeFraction=0.500000 interpolator=DiscreteInterpolator Frame 3: value=5 timeFraction=0.750000 interpolator=DiscreteInterpolator Frame 4: value=4 timeFraction=1.000000 interpolator=DiscreteInterpolator
The Swing and SWT releases contain several demonstration programs that can be run from the release Jar file or built from source code. Many of these demonstration programs are updated versions of the programs presented in Filthy Rich Clients. Their description in the book is referenced in the list below.
The Swing demonstrations are:
To run one of the demonstrations from the release Jar file use:
java -cp "timingframework-swing-demos-7.1.jar;timingframework-swing-7.1.jar" classname
The Swing TooManyBalls demonstration can be changed from passive rendering to game-like active rendering (see the JActiveRenderer class) by defining the org.jdesktop.renderer.active property. For example, use:
java -cp "timingframework-swing-demos-7.1.jar;timingframework-swing-7.1.jar" -Dorg.jdesktop.renderer.active=true org.jdesktop.swing.animation.demos.TooManyBalls
On some computers active rendering looks smoother, but has the cost of using two processors and lots of memory. It is perhaps more appropriate for a game than a desktop application. It is, however, straightforward to write programs that can change from passive to active rendering, like TooManyBalls does, by implementing JRendererTarget.
The Swing distribution also includes org.jdesktop.swing.animation.demos.splineeditor.SplineEditor (from Chapter 14) which can be used to design and preview a particular spline interpolation.
The SWT demonstrations are:
To run one of the SWT demonstrations from the release Jar file use:
java -cp "timingframework-swt-demos-7.1.jar;timingframework-swt-7.1.jar;swt.jar" classname
In the example above I copied the swt.jar for my platform into the same directory, but you can reference it within another directory (the command above worked on Windows under Cygwin).
Neither the spline editor nor active rendering are currently implemented under SWT.
The original Timing Framework implementation was released under following terms:
Copyright (c) 2007, Sun Microsystems, Inc All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Timing Framework project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The enhancements to the original implementation are released under the Apache License, Version 2.0.