01: package prefuse.action;
02:
03: import java.util.logging.Logger;
04:
05: import prefuse.Visualization;
06: import prefuse.activity.Activity;
07: import prefuse.util.StringLib;
08:
09: /**
10: * <p>The ActionList represents a chain of Actions that process VisualItems.
11: * ActionList also implements the Action interface, so ActionLists can be placed
12: * within other ActionList or {@link ActionSwitch} instances,
13: * allowing recursive composition of different sets of Actions.</p>
14: *
15: * @author <a href="http://jheer.org">jeffrey heer</a>
16: * @see prefuse.activity.Activity
17: * @see prefuse.action.Action
18: */
19: public class ActionList extends CompositeAction {
20:
21: private static final Logger s_logger = Logger
22: .getLogger(ActionList.class.getName());
23:
24: /**
25: * Creates a new run-once ActionList.
26: */
27: public ActionList() {
28: super (0);
29: }
30:
31: /**
32: * Creates a new run-once ActionList that processes the given
33: * Visualization.
34: * @param vis the {@link prefuse.Visualization} to process.
35: */
36: public ActionList(Visualization vis) {
37: super (vis);
38: }
39:
40: /**
41: * Creates a new ActionList of specified duration and default
42: * step time of 20 milliseconds.
43: * @param duration the duration of this Activity, in milliseconds
44: */
45: public ActionList(long duration) {
46: super (duration, Activity.DEFAULT_STEP_TIME);
47: }
48:
49: /**
50: * Creates a new ActionList which processes the given Visualization
51: * and has the specified duration and a default step time of 20
52: * milliseconds.
53: * @param vis the {@link prefuse.Visualization} to process.
54: * @param duration the duration of this Activity, in milliseconds
55: */
56: public ActionList(Visualization vis, long duration) {
57: super (vis, duration);
58: }
59:
60: /**
61: * Creates a new ActionList of specified duration and step time.
62: * @param duration the duration of this Activity, in milliseconds
63: * @param stepTime the time to wait in milliseconds between executions
64: * of the action list
65: */
66: public ActionList(long duration, long stepTime) {
67: super (duration, stepTime);
68: }
69:
70: /**
71: * @see prefuse.action.Action#run(double)
72: */
73: public void run(double frac) {
74: Object[] actions = m_actions.getArray();
75: for (int i = 0; i < actions.length; ++i) {
76: Action a = (Action) actions[i];
77: try {
78: if (a.isEnabled())
79: a.run(frac);
80: } catch (Exception e) {
81: s_logger.warning(e.getMessage() + '\n'
82: + StringLib.getStackTrace(e));
83: }
84: }
85: }
86:
87: } // end of class ActionList
|