Search in sources :

Example 16 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testRollover.

/**
 * Test a periodic annotation provider with roll-over.
 */
@Test
public void testRollover() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 4, COLOR, null);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-100L, 0L, -1, "3", COLOR_STYLE), new Annotation(0L, 0L, -1, "0", COLOR_STYLE), new Annotation(100L, 0L, -1, "1", COLOR_STYLE), new Annotation(200L, 0L, -1, "2", COLOR_STYLE), new Annotation(300L, 0L, -1, "3", COLOR_STYLE), new Annotation(400L, 0L, -1, "0", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 300L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 17 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testResolution.

/**
 * Test a query with a resolution.
 */
@Test
public void testResolution() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 10L, 0, EVEN_COLOR, ODD_COLOR);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-20L, 10L, -1, "-2", EVEN_COLOR_STYLE), new Annotation(0L, 10L, -1, "0", EVEN_COLOR_STYLE), new Annotation(30L, 10L, -1, "3", ODD_COLOR_STYLE), new Annotation(50L, 10L, -1, "5", ODD_COLOR_STYLE), new Annotation(80L, 10L, -1, "8", EVEN_COLOR_STYLE), new Annotation(100L, 10L, -1, "10", EVEN_COLOR_STYLE), new Annotation(130L, 10L, -1, "13", ODD_COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 100L, 25));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 18 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testReference.

/**
 * Test a periodic annotation provider with non-zero reference.
 */
@Test
public void testReference() {
    ITimeReference reference = new TimeReference(250L, 10);
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, reference, 100L, 0, COLOR, null);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-50L, 0L, -1, "7", COLOR_STYLE), new Annotation(50L, 0L, -1, "8", COLOR_STYLE), new Annotation(150L, 0L, -1, "9", COLOR_STYLE), new Annotation(250L, 0L, -1, "10", COLOR_STYLE), new Annotation(350L, 0L, -1, "11", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 300L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) ITimeReference(org.eclipse.tracecompass.tmf.core.markers.ITimeReference) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) TimeReference(org.eclipse.tracecompass.tmf.core.markers.TimeReference) ITimeReference(org.eclipse.tracecompass.tmf.core.markers.ITimeReference) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 19 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testLineAnnotationSource.

/**
 * Test a periodic annotation provider with lines at every period.
 */
@Test
public void testLineAnnotationSource() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, COLOR, null);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(0L, 0L, -1, "0", COLOR_STYLE), new Annotation(100L, 0L, -1, "1", COLOR_STYLE), new Annotation(200L, 0L, -1, "2", COLOR_STYLE), new Annotation(300L, 0L, -1, "3", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(50L, 250L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 20 with Annotation

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.

the class CustomAnnotationProvider method getSubMarkerList.

private void getSubMarkerList(SplitMarker splitMarker, Annotation markerEvent, Map<String, Collection<@NonNull Annotation>> annotationMap, long startTime, long endTime, long minDuration, Long[] times) {
    if (markerEvent.getTime() > endTime || markerEvent.getTime() + markerEvent.getDuration() < startTime) {
        return;
    }
    long lower = splitMarker.getRange().lowerEndpoint();
    long upper = splitMarker.getRange().upperEndpoint();
    long segments = upper - lower + 1;
    long start = markerEvent.getTime();
    List<@NonNull Annotation> annotationList = new ArrayList<>();
    for (int i = 0; i < segments; i++) {
        long end = markerEvent.getTime() + Math.round((double) (i + 1) / segments * markerEvent.getDuration());
        long duration = end - start;
        long labelIndex = lower + i;
        if (end >= startTime && duration > minDuration && splitMarker.getIndexRange().contains(labelIndex)) {
            RGBAColor color = (labelIndex & 1) == 0 ? getColor(splitMarker) : getOddColor(getColor(splitMarker));
            OutputElementStyle outputStyle = getOutputStyle(color);
            Annotation subAnnotation = new Annotation(start, end - start, -1, String.format(splitMarker.getLabel(), labelIndex), outputStyle);
            for (SubMarker subMarker : splitMarker.getSubMarkers()) {
                getSubMarkerList(Objects.requireNonNull(subMarker), subAnnotation, annotationMap, startTime, endTime, minDuration, times);
            }
            annotationList.add(subAnnotation);
        }
        if (start >= endTime) {
            break;
        }
        start = end;
    }
    populateMap(annotationMap, annotationList, Objects.requireNonNull(splitMarker.getName()));
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) ArrayList(java.util.ArrayList) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)

Aggregations

Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)22 ArrayList (java.util.ArrayList)17 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 Test (org.junit.Test)15 List (java.util.List)10 IOutputAnnotationProvider (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider)10 PeriodicAnnotationProvider (org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider)9 SubMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker)8 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)7 AnnotationModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel)6 Marker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker)5 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)5 MarkerSet (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet)5 SplitMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)5 WeightedMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 Collection (java.util.Collection)3 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)3 HashMap (java.util.HashMap)2 Nullable (org.eclipse.jdt.annotation.Nullable)2