IntervalTimeInstancepublic final class IntervalTimeInstance extends TimeInstance This specialized TimeInstance is created by
SyncBaseCondition time conditions.
IntervalTimeInstance instances can be notified
of updates by the TimeCondition which created it.
This update can result on a Time update on the
instance depending on context.
|
Fields Summary |
---|
long | offsetOffset from the interval sync base. | TimeInterval | timeIntervalAssociated interval. | boolean | isBeginSyncControls whether the instance synchronizes on begin or end | TimedElementSupport | syncBaseAssociated syncBase |
Constructors Summary |
---|
IntervalTimeInstance(TimedElementSupport timedElement, TimedElementSupport syncBase, long offset, boolean clearOnReset, boolean isBegin, boolean isBeginSync)Builds an instance time for the input TimedElementSupport
and time. The constructor will insert the instance
automatically into the TimeInterval 's corresponding
dependent list
super(timedElement,
getTime(syncBase.currentInterval,
isBeginSync,
offset,
timedElement,
syncBase),
clearOnReset,
isBegin);
this.offset = offset;
this.syncBase = syncBase;
this.timeInterval = syncBase.currentInterval;
this.isBeginSync = isBeginSync;
timeInterval.addDependent(this);
|
Methods Summary |
---|
void | dispose()Invoke when this instance is no longer in a begin or end instance list,
i.e., when it is removed from one of these lists.
timeInterval.removeDependent(this);
| private static Time | getTime(TimeInterval interval, boolean isBeginSync, long offset, TimedElementSupport timedElement, TimedElementSupport syncBase)Implementation helpers.
if (isBeginSync && !interval.begin.isResolved()) {
// 'unresolved' and 'indefinite' times are not
// legal begin time for intervals. This is an illegal
// state, so we throw an exception.
throw new IllegalStateException();
}
Time t = interval.begin;
if (!isBeginSync) {
t = interval.end;
}
if (!t.isResolved()) {
return t;
} else {
// Convert the time value from the syncBase's time space
// to the timedElement time space.
Time time = new Time(t.value + offset);
return timedElement.toContainerSimpleTime
(syncBase.toRootContainerSimpleTime(time));
}
| void | onIntervalUpdate()Must be called by the TimeInterval 's begin
or end time this instance depends on changes.
This method update this time instance with a new
time, accounting for the offset from the sync base.
setTime(getTime(timeInterval, isBeginSync, offset, timedElement,
syncBase));
| void | syncTime()Used to synchronize this instance's time with its syncBase time. This is
used when resetting timed elements.
setTime(getTime(timeInterval, isBeginSync, offset, timedElement,
syncBase));
|
|