use of org.eclipse.tracecompass.tmf.core.markers.ITimeReferenceProvider in project tracecompass by tracecompass.
the class CustomAnnotationProvider method configure.
private CustomPeriodicAnnotationProvider configure(Marker marker) {
if (marker instanceof PeriodicMarker) {
PeriodicMarker periodicMarker = (PeriodicMarker) marker;
long rollover = periodicMarker.getRange().hasUpperBound() ? (periodicMarker.getRange().upperEndpoint() - periodicMarker.getRange().lowerEndpoint() + 1) : 0;
RGBAColor evenColor = getColor(marker);
RGBAColor oddColor = getOddColor(evenColor);
ITmfTrace trace = fTrace;
double period = IMarkerConstants.convertToNanos(periodicMarker.getPeriod(), periodicMarker.getUnit(), trace);
String referenceId = periodicMarker.getReferenceId();
ITimeReference baseReference = null;
if (trace instanceof IAdaptable && !referenceId.isEmpty()) {
ITimeReferenceProvider adapter = ((IAdaptable) trace).getAdapter(ITimeReferenceProvider.class);
if (adapter != null) {
baseReference = adapter.apply(referenceId);
}
}
if (baseReference == null) {
baseReference = ITimeReference.ZERO;
}
ITimeReference reference = new TimeReference(baseReference.getTime() + Math.round(IMarkerConstants.convertToNanos(periodicMarker.getOffset(), periodicMarker.getUnit(), trace)), baseReference.getIndex());
return new CustomPeriodicAnnotationProvider(periodicMarker, reference, period, rollover, evenColor, oddColor);
}
// $NON-NLS-1$
throw new IllegalArgumentException("Marker must be of type PeriodicMarker or SubMarker");
}
Aggregations