Search in sources :

Example 1 with ITimeReferenceProvider

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");
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAdaptable(org.eclipse.core.runtime.IAdaptable) ITimeReference(org.eclipse.tracecompass.tmf.core.markers.ITimeReference) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) TimeReference(org.eclipse.tracecompass.tmf.core.markers.TimeReference) ITimeReference(org.eclipse.tracecompass.tmf.core.markers.ITimeReference) ITimeReferenceProvider(org.eclipse.tracecompass.tmf.core.markers.ITimeReferenceProvider)

Aggregations

IAdaptable (org.eclipse.core.runtime.IAdaptable)1 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)1 ITimeReference (org.eclipse.tracecompass.tmf.core.markers.ITimeReference)1 ITimeReferenceProvider (org.eclipse.tracecompass.tmf.core.markers.ITimeReferenceProvider)1 TimeReference (org.eclipse.tracecompass.tmf.core.markers.TimeReference)1 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1