in assets/scripts/api.simile-widgets.org/timeline/2.3.1/scripts/compact-painter.js [58:169]
Timeline.CompactEventPainter.prototype.paint = function() {
var eventSource = this._band.getEventSource();
if (eventSource == null) {
return;
}
this._eventIdToElmt = {};
this._prepareForPainting();
var theme = this._params.theme;
var eventTheme = theme.event;
var metrics = {
trackOffset: "trackOffset" in this._params ? this._params.trackOffset : 10,
trackHeight: "trackHeight" in this._params ? this._params.trackHeight : 10,
tapeHeight: theme.event.tape.height,
tapeBottomMargin: "tapeBottomMargin" in this._params ? this._params.tapeBottomMargin : 2,
labelBottomMargin: "labelBottomMargin" in this._params ? this._params.labelBottomMargin : 5,
labelRightMargin: "labelRightMargin" in this._params ? this._params.labelRightMargin : 5,
defaultIcon: eventTheme.instant.icon,
defaultIconWidth: eventTheme.instant.iconWidth,
defaultIconHeight: eventTheme.instant.iconHeight,
customIconWidth: "iconWidth" in this._params ? this._params.iconWidth : eventTheme.instant.iconWidth,
customIconHeight: "iconHeight" in this._params ? this._params.iconHeight : eventTheme.instant.iconHeight,
iconLabelGap: "iconLabelGap" in this._params ? this._params.iconLabelGap : 2,
iconBottomMargin: "iconBottomMargin" in this._params ? this._params.iconBottomMargin : 2
};
if ("compositeIcon" in this._params) {
metrics.compositeIcon = this._params.compositeIcon;
metrics.compositeIconWidth = this._params.compositeIconWidth || metrics.customIconWidth;
metrics.compositeIconHeight = this._params.compositeIconHeight || metrics.customIconHeight;
} else {
metrics.compositeIcon = metrics.defaultIcon;
metrics.compositeIconWidth = metrics.defaultIconWidth;
metrics.compositeIconHeight = metrics.defaultIconHeight;
}
metrics.defaultStackIcon = "icon" in this._params.stackConcurrentPreciseInstantEvents ?
this._params.stackConcurrentPreciseInstantEvents.icon : metrics.defaultIcon;
metrics.defaultStackIconWidth = "iconWidth" in this._params.stackConcurrentPreciseInstantEvents ?
this._params.stackConcurrentPreciseInstantEvents.iconWidth : metrics.defaultIconWidth;
metrics.defaultStackIconHeight = "iconHeight" in this._params.stackConcurrentPreciseInstantEvents ?
this._params.stackConcurrentPreciseInstantEvents.iconHeight : metrics.defaultIconHeight;
var minDate = this._band.getMinDate();
var maxDate = this._band.getMaxDate();
var filterMatcher = (this._filterMatcher != null) ?
this._filterMatcher :
function(evt) { return true; };
var highlightMatcher = (this._highlightMatcher != null) ?
this._highlightMatcher :
function(evt) { return -1; };
var iterator = eventSource.getEventIterator(minDate, maxDate);
var stackConcurrentPreciseInstantEvents = "stackConcurrentPreciseInstantEvents" in this._params && typeof this._params.stackConcurrentPreciseInstantEvents == "object";
var collapseConcurrentPreciseInstantEvents = "collapseConcurrentPreciseInstantEvents" in this._params && this._params.collapseConcurrentPreciseInstantEvents;
if (collapseConcurrentPreciseInstantEvents || stackConcurrentPreciseInstantEvents) {
var bufferedEvents = [];
var previousInstantEvent = null;
while (iterator.hasNext()) {
var evt = iterator.next();
if (filterMatcher(evt)) {
if (!evt.isInstant() || evt.isImprecise()) {
this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
} else if (previousInstantEvent != null &&
previousInstantEvent.getStart().getTime() == evt.getStart().getTime()) {
bufferedEvents[bufferedEvents.length - 1].push(evt);
} else {
bufferedEvents.push([ evt ]);
previousInstantEvent = evt;
}
}
}
for (var i = 0; i < bufferedEvents.length; i++) {
var compositeEvents = bufferedEvents[i];
if (compositeEvents.length == 1) {
this.paintEvent(compositeEvents[0], metrics, this._params.theme, highlightMatcher(evt));
} else {
var match = -1;
for (var j = 0; match < 0 && j < compositeEvents.length; j++) {
match = highlightMatcher(compositeEvents[j]);
}
if (stackConcurrentPreciseInstantEvents) {
this.paintStackedPreciseInstantEvents(compositeEvents, metrics, this._params.theme, match);
} else {
this.paintCompositePreciseInstantEvents(compositeEvents, metrics, this._params.theme, match);
}
}
}
} else {
while (iterator.hasNext()) {
var evt = iterator.next();
if (filterMatcher(evt)) {
this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
}
}
}
this._highlightLayer.style.display = "block";
this._lineLayer.style.display = "block";
this._eventLayer.style.display = "block";
};