Range r = vap.getDataRange(this);
if (r == null) {
if (this.timeline instanceof SegmentedTimeline) {
// Timeline hasn't method getStartTime()
r = new DateRange(
((SegmentedTimeline) this.timeline).getStartTime(),
((SegmentedTimeline) this.timeline).getStartTime() + 1);
} else {
r = new DateRange();
}
}
long upper = this.timeline
.toTimelineValue((long) r.getUpperBound());
long lower;
final long fixedAutoRange = (long) this.getFixedAutoRange();
if (fixedAutoRange > 0.0) {
lower = upper - fixedAutoRange;
} else {
lower = this.timeline.toTimelineValue((long) r.getLowerBound());
final double range = upper - lower;
final long minRange = (long) this.getAutoRangeMinimumSize();
if (range < minRange) {
final long expand = (long) (minRange - range) / 2;
upper = upper + expand;
lower = lower - expand;
}
upper = upper + (long) (range * this.getUpperMargin());
lower = lower - (long) (range * this.getLowerMargin());
}
upper = this.timeline.toMillisecond(upper);
lower = this.timeline.toMillisecond(lower);
final DateRange dr = new DateRange(new Date(lower), new Date(upper));
this.setRange(dr, false, false);
}
}