KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > action > animate > FontAnimator


1 package prefuse.action.animate;
2
3 import java.awt.Font JavaDoc;
4
5 import prefuse.action.ItemAction;
6 import prefuse.util.FontLib;
7 import prefuse.visual.VisualItem;
8
9
10 /**
11  * Animator that interpolates between starting and ending Fonts for VisualItems
12  * during an animation. Font sizes are interpolated linearly. If the
13  * animation fraction is under 0.5, the face and style of the starting
14  * font are used, otherwise the face and style of the second font are
15  * applied.
16  *
17  * @author <a HREF="http://jheer.org">jeffrey heer</a>
18  */

19 public class FontAnimator extends ItemAction {
20
21     /**
22      * Create a new FontAnimator that processes all data groups.
23      */

24     public FontAnimator() {
25         super();
26     }
27
28     /**
29      * Create a new FontAnimator that processes the specified group.
30      * @param group the data group to process.
31      */

32     public FontAnimator(String JavaDoc group) {
33         super(group);
34     }
35
36     /**
37      * @see prefuse.action.ItemAction#process(prefuse.visual.VisualItem, double)
38      */

39     public void process(VisualItem item, double frac) {
40         Font JavaDoc f1 = item.getStartFont(), f2 = item.getEndFont();
41         item.setFont(FontLib.getIntermediateFont(f1,f2,frac));
42     }
43
44 } // end of class FontAnimator
45
Popular Tags