Search in sources :

Example 1 with Marker

use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker in project tracecompass by tracecompass.

the class CustomAnnotationProvider method getLabel.

/**
 * Get the label of the marker, may be a format string
 *
 * @return the label of the marker
 */
public Map<String, String> getLabel() {
    Map<String, String> labels = new HashMap<>();
    if (fMarkerSet != null) {
        for (Marker marker : fMarkerSet.getMarkers()) {
            if (marker instanceof PeriodicMarker) {
                PeriodicMarker periodicMarker = (PeriodicMarker) marker;
                labels.put(Objects.requireNonNull(periodicMarker.getName()), Objects.requireNonNull(periodicMarker.getLabel()));
            }
        }
    }
    return labels;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Marker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)

Example 2 with Marker

use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker in project tracecompass by tracecompass.

the class CustomAnnotationProviderTest method testWeightedWithSubmarkers.

/**
 * Test weighted with submarkers
 */
@Test
public void testWeightedWithSubmarkers() {
    List<Annotation> annotationList;
    MarkerSet set = new MarkerSet("name", "id");
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    /*
         * period: 40 ns, offset: 0 ns, range: 0..49, indexRange: 30..31,40
         *
         * requested range: 0 ns-4000 ns
         *
         * expected annotations: 1200 ns[30] 1240 ns[31] 1600 ns[40] 3200 ns[30]
         * 3240 ns[31] 3600 ns[40]
         */
    Marker markerD = new PeriodicMarker("D", "D %d", "d", "ref.d", COLOR_STR, 40.0, "ns", Range.closed(0L, 49L), 0L, ImmutableRangeSet.<Long>builder().add(Range.closed(30L, 31L)).add(Range.singleton(40L)).build());
    set.addMarker(markerD);
    /*
         * period: 40 ns with segment weights {2,1,3}, offset: 0 ns,
         * range:0..49, indexRange:30..31,40
         *
         * requested range: 0 ns-2000 ns
         *
         * expected annotations: 1200 ns[0] 1220[2] 1240 ns[0] 1260[2] 1600 ns[0]
         * 1620 ns[2]
         */
    WeightedMarker markerE = new WeightedMarker("E");
    markerD.addSubMarker(markerE);
    MarkerSegment segmentE1 = new MarkerSegment("E1 %d", "e1", RED_STR, 2);
    markerE.addSegment(segmentE1);
    MarkerSegment segmentE2 = new MarkerSegment("E2 %d", "e2", "", 1);
    markerE.addSegment(segmentE2);
    MarkerSegment segmentE3 = new MarkerSegment("E3 %d", "e3", INVALID_STR, 3);
    markerE.addSegment(segmentE3);
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Arrays.asList("D", "E"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    annotationList = getAnnotationList("E", 0L, 2000L, 1L, new NullProgressMonitor());
    assertEquals(6, annotationList.size());
    int i = 0;
    for (long t = 0L; t < 2000L; t += 40L) {
        int index = (int) (t / 40L) % 50;
        if (index == 30L || index == 31L || index == 40L) {
            validateAnnotation(annotationList.get(i), t, 13L, "E", String.format("E1 %d", 0), RED);
            i++;
            /*
                 * segment 2 does not have visible annotation due to empty color
                 * name
                 */
            validateAnnotation(annotationList.get(i), t + 20L, 20L, "E", String.format("E3 %d", 2), DEFAULT);
            i++;
        }
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Marker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) MarkerSegment(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 3 with Marker

use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker in project tracecompass by tracecompass.

the class MarkerSetTest method testAddMarker.

/**
 * Test the method addMarker
 */
@Test
public void testAddMarker() {
    MarkerSet markerSet = new MarkerSet("name", "id");
    Marker markerA = new PeriodicMarker("A", "A %d", "a", "ref.a", "color1", 1.0, "ms", Range.atLeast(1L), 1L, ImmutableRangeSet.of(Range.atLeast(1L)));
    markerSet.addMarker(markerA);
    Marker markerB = new PeriodicMarker("B", "B %d", "b", "ref.b", "color2", 2.0, "ns", Range.atLeast(2L), 2L, ImmutableRangeSet.of(Range.atLeast(2L)));
    markerSet.addMarker(markerB);
    assertEquals(Arrays.asList(markerA, markerB), markerSet.getMarkers());
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Marker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Test(org.junit.Test)

Example 4 with Marker

use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker in project tracecompass by tracecompass.

the class CustomAnnotationProviderTest method testSimple.

/**
 * Test simple
 */
@Test
public void testSimple() {
    List<Annotation> annotationList;
    MarkerSet set = new MarkerSet("name", "id");
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    /*
         * period: 10 ms, offset: 20 ms, range: 0..4
         *
         * requested range: 100 ms-200 ms
         *
         * expected annotations: 90 ms[2] 100 ms[3] 110 ms[4] 120 ms[0] ... 200
         * ms[3] 210 ms[4]
         */
    Marker markerA = new PeriodicMarker("A", "A %d", "a", "ref.a", COLOR_STR, 10.0, "ms", Range.closed(0L, 4L), 20L, ImmutableRangeSet.of(Range.all()));
    set.addMarker(markerA);
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Arrays.asList("A"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    annotationList = getAnnotationList("A", 100000000L, 200000000L, 1000L, new NullProgressMonitor());
    assertEquals(annotationList.toString(), 13, annotationList.size());
    for (int i = 0; i < annotationList.size(); i++) {
        long t = (i + 9) * 10000000L;
        int index = (i + 9) - 2;
        int labelIndex = index % 5;
        RGBAColor color = index % 2 == 0 ? COLOR : ODD_COLOR;
        validateAnnotation(annotationList.get(i), t, 10000000L, "A", String.format("A %d", labelIndex), color);
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Marker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 5 with Marker

use of org.eclipse.tracecompass.internal.tmf.core.markers.Marker in project tracecompass by tracecompass.

the class CustomAnnotationProviderTest method testOffset.

/**
 * Test offset
 */
@Test
public void testOffset() {
    List<Annotation> annotationList;
    MarkerSet set = new MarkerSet("name", "id");
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    /*
         * period: 10 cycles (40ns), offset: -10 cycles (-40ns), reference:
         * 1000ns[0], range: 0..
         *
         * requested range: 1000 ns-2000 ns
         *
         * expected annotations: 960 ns[0] 1000 ns[1] 1040 ns[2] ... 2000 ns[26]
         * 2040 ns[27]
         */
    Marker markerC = new PeriodicMarker("C", "C %d", "c", "ref.c", COLOR_STR, 10.0, "cycles", Range.atLeast(0L), -10L, ImmutableRangeSet.of(Range.all()));
    set.addMarker(markerC);
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Arrays.asList("C"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    annotationList = getAnnotationList("C", 1000L, 2000L, 1L, new NullProgressMonitor());
    assertEquals(28, annotationList.size());
    for (int i = 0; i < annotationList.size(); i++) {
        long t = (i + 24) * 40L;
        // -25 +1 for offset
        int index = i + 24 - 25 + 1;
        RGBAColor color = index % 2 == 0 ? COLOR : ODD_COLOR;
        validateAnnotation(annotationList.get(i), t, 40L, "C", String.format("C %d", index), color);
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Marker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Aggregations

Marker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker)8 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)8 SubMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker)7 SplitMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)7 WeightedMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker)7 MarkerSet (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet)6 Test (org.junit.Test)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)5 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)4 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 MarkerSegment (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment)1