예제 #1
0
 /**
  *
  * <!-- addAction -->
  * Add a sequence to the sequence. A non-timed sequence can always be added to another non-timed
  * sequence. A timed sequence can be added to another timed sequence, so long as they both have
  * the same increment, and the start time of the sequence being added is the same as the time at
  * which the next action in this sequence would occur. A timed sequence can be added to a
  * non-timed sequence, with the assumption that any existing actions on the non-timed sequence
  * occur before the start time of the timed sequence. A non-timed sequence can be added to a timed
  * sequence--all actions in the non-timed sequence then become timed.
  *
  * @param sequence
  * @throws ScheduleException
  */
 public void addAction(SequentialActionGroup sequence) throws ScheduleException {
   if (!isTimed() && sequence.isTimed()) {
     setTime(sequence.time - (actionSequence.size() * sequence.increment));
     increment = sequence.increment;
     int i = 0;
     for (AbstractScheduledAction existingAction : actionSequence) {
       existingAction.setTime(time + (i * increment));
       i++;
     }
   } else if (isTimed() && sequence.isTimed()) {
     if (increment != sequence.increment) {
       throw new ScheduleException(
           this,
           "Cannot add timed sequence "
               + sequence.getURI()
               + " with different increment (respectively, "
               + increment
               + " and "
               + sequence.increment
               + ")");
     }
     sequence.setTime(time + (actionSequence.size() * increment));
   } else if (isTimed() && !sequence.isTimed()) {
     int i = actionSequence.size();
     for (AbstractScheduledAction sequenceAction : sequence.actionSequence) {
       sequenceAction.setTime(time + (i * increment));
       i++;
     }
   }
   actionSequence.addAll(sequence.actionSequence);
 }
예제 #2
0
 /**
  *
  * <!-- addAction -->
  * Add an action to the sequence
  *
  * @param action
  * @throws ScheduleException
  */
 public void addAction(AbstractScheduledAction action) throws ScheduleException {
   if (isTimed()) {
     action.setTime(time + (actionSequence.size() * increment));
   } else if (action.isTimed()) {
     throw new ScheduleException(
         this, "Cannot add timed action " + action.getURI() + " to non-timed sequence");
   }
   actionSequence.addLast(action);
 }