Repository navigation
SliderSegment
Up | Previous | Next | Русский
Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not kept in the working file SliderSegment.java: the production code stays clean, and the explanations live in the wiki.
package com.velitask.plugin.official;
import com.velitask.sdk.SourceType;
/* One segment of the slider map over the track time interval [start, end). Immutable. */
final class SliderSegment {
/* Kind: a source is shown, or empty. */
final SliderSegmentKind kind;
final long start;
final long end;
/* The fields below are filled only for SOURCE; for EMPTY they are zeros and null. */
final SourceType sourceType;
final long sourceId;
/* The track time at which the nested indicator finds the source: the start of the source in the project. */
final long contentBase;
/* The track moment that corresponds to the start of showing the content: the start of the source or the start of the shifted slot. */
final long anchor;
/* Length of the source: needed so as not to go past the last frame. */
final long sourceDuration;
/* Time multiplier by mode: PARENT = 1, FROZEN = 0, REAL = 1 / player speed. */
final double coef;
/* The constructor is closed: segments are created only by the factories. */
private SliderSegment(SliderSegmentKind kind, long start, long end, SourceType sourceType,
long sourceId, long contentBase, long anchor, long sourceDuration, double coef) {
this.kind = kind;
this.start = start;
this.end = end;
this.sourceType = sourceType;
this.sourceId = sourceId;
this.contentBase = contentBase;
this.anchor = anchor;
this.sourceDuration = sourceDuration;
this.coef = coef;
}
/* Factory for a segment with a source. */
static SliderSegment source(long start, long end, SourceType sourceType, long sourceId,
long contentBase, long anchor, long sourceDuration, double coef) {
return new SliderSegment(SliderSegmentKind.SOURCE, start, end, sourceType, sourceId,
contentBase, anchor, sourceDuration, coef);
}
/* Factory for an empty segment: boundaries only. */
static SliderSegment empty(long start, long end) {
return new SliderSegment(SliderSegmentKind.EMPTY, start, end, null, 0, 0, 0, 0, 0);
}
}SliderSegment is an immutable record of one segment of the SliderTimelineMap map. It stores the boundaries in track time and everything SliderIndicator needs to recalculate the time for nested indicators.
Data.
| Field | Meaning |
|---|---|
kind |
SOURCE or EMPTY. |
start, end
|
Segment boundaries in track time, ms: [start, end). |
sourceType |
Source type (VIDEO or IMAGE); null for EMPTY. |
sourceId |
Source identifier; 0 for EMPTY. Needed for merging adjacent segments. |
contentBase |
The time at which the nested indicator finds the source (the start of the source in the project). |
anchor |
The track moment from which the time inside the slide is counted. |
sourceDuration |
Source length, ms. |
coef |
Time multiplier by the time mode. |
Settings. There are no direct settings: the values are filled in by SliderTimelineMap.build(...) from the slider settings.
Drawing. The class draws nothing. SliderIndicator calculates the time of nested indicators like this:
raw = contentBase + coef * (t - anchor)
tPrime = clamp(raw, contentBase, contentBase + max(0, sourceDuration - 1))
Clamping at the edges means that after the end of a short video its last frame is shown, and before the start, its first frame.
- The constructor is closed; instances are created by the
source(...)andempty(...)factories. -
anchorequals the start of the source if the slide started on time; if the slot was shifted because of the previous slide or a pause,anchorequals the start of the shifted slot, and the content is shown from the very beginning. - The class is package-private.