1 package prefuse.action; 2 3 10 public class ActionSwitch extends CompositeAction { 11 12 private int m_switchVal; 13 14 17 public ActionSwitch() { 18 m_switchVal = 0; 19 } 20 21 26 public ActionSwitch(Action[] acts, int switchVal) { 27 for ( int i=0; i<acts.length; i++ ) 28 m_actions.add(acts[i]); 29 setSwitchValue(switchVal); 30 } 31 32 35 public void run(double frac) { 36 if ( m_actions.size() > 0 ) { 37 get(getSwitchValue()).run(frac); 38 } 39 } 40 41 46 public int getSwitchValue() { 47 return m_switchVal; 48 } 49 50 55 public void setSwitchValue(int s) { 56 if ( s < 0 || s >= size() ) 57 throw new IllegalArgumentException ( 58 "Switch value out of legal range"); 59 m_switchVal = s; 60 } 61 62 } | Popular Tags |