Exemplo n.º 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);
 }
Exemplo n.º 2
0
 /**
  *
  * <!-- synchroniseWith -->
  * Synchronise two sequences. They must have the same start time and increment.
  *
  * @param event the sequence to synchronise with
  * @throws ScheduleException
  */
 public void synchroniseWith(SequentialActionGroup event) throws ScheduleException {
   boolean wasTimed = isTimed();
   super.synchroniseWith(event);
   if (!wasTimed && event.isTimed()) {
     this.increment = event.increment;
   } else if (this.increment != event.increment) {
     throw new ScheduleException(
         this,
         "(time "
             + time
             + ", increment"
             + increment
             + ") cannot be synchronised with "
             + event.getURI()
             + " (time "
             + event.time
             + ", increment "
             + event.increment
             + ")");
   }
 }