01: package prefuse.action.animate;
02:
03: import prefuse.action.ItemAction;
04: import prefuse.visual.VisualItem;
05:
06: /**
07: * Animator that linearly interpolates between two positions. This
08: * is useful for performing animated transitions.
09: *
10: * @author <a href="http://jheer.org">jeffrey heer</a>
11: */
12: public class LocationAnimator extends ItemAction {
13:
14: /**
15: * Create a new LocationAnimator that processes all data groups.
16: */
17: public LocationAnimator() {
18: super ();
19: }
20:
21: /**
22: * Create a new LocationAnimator that processes the specified group.
23: * @param group the data group to process.
24: */
25: public LocationAnimator(String group) {
26: super (group);
27: }
28:
29: /**
30: * @see prefuse.action.ItemAction#process(prefuse.visual.VisualItem, double)
31: */
32: public void process(VisualItem item, double frac) {
33: double sx = item.getStartX();
34: double sy = item.getStartY();
35: item.setX(sx + frac * (item.getEndX() - sx));
36: item.setY(sy + frac * (item.getEndY() - sy));
37: }
38:
39: } // end of class LocationAnimator
|