01: package prefuse.action.animate;
02:
03: import java.awt.Font;
04:
05: import prefuse.action.ItemAction;
06: import prefuse.util.FontLib;
07: import prefuse.visual.VisualItem;
08:
09: /**
10: * Animator that interpolates between starting and ending Fonts for VisualItems
11: * during an animation. Font sizes are interpolated linearly. If the
12: * animation fraction is under 0.5, the face and style of the starting
13: * font are used, otherwise the face and style of the second font are
14: * applied.
15: *
16: * @author <a href="http://jheer.org">jeffrey heer</a>
17: */
18: public class FontAnimator extends ItemAction {
19:
20: /**
21: * Create a new FontAnimator that processes all data groups.
22: */
23: public FontAnimator() {
24: super ();
25: }
26:
27: /**
28: * Create a new FontAnimator that processes the specified group.
29: * @param group the data group to process.
30: */
31: public FontAnimator(String group) {
32: super (group);
33: }
34:
35: /**
36: * @see prefuse.action.ItemAction#process(prefuse.visual.VisualItem, double)
37: */
38: public void process(VisualItem item, double frac) {
39: Font f1 = item.getStartFont(), f2 = item.getEndFont();
40: item.setFont(FontLib.getIntermediateFont(f1, f2, frac));
41: }
42:
43: } // end of class FontAnimator
|