Search in sources :

Example 1 with SubMarker

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

the class CustomAnnotationProvider method getSubMarkerCategories.

private void getSubMarkerCategories(Set<String> categories, List<SubMarker> subMarkers) {
    for (SubMarker subMarker : subMarkers) {
        categories.add(subMarker.getName());
        getSubMarkerCategories(categories, subMarker.getSubMarkers());
        if (subMarker instanceof WeightedMarker) {
            for (MarkerSegment segment : ((WeightedMarker) subMarker).getSegments()) {
                getSubMarkerCategories(categories, segment.getSubMarkers());
            }
        }
    }
}
Also used : WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) MarkerSegment(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment)

Example 2 with SubMarker

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

the class CustomAnnotationProvider method getSubMarkerList.

private void getSubMarkerList(WeightedMarker weightedMarker, 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 start = markerEvent.getTime();
    long length = 0;
    List<@NonNull Annotation> annotationsList = new ArrayList<>();
    for (int i = 0; i < weightedMarker.getSegments().size(); i++) {
        MarkerSegment segment = weightedMarker.getSegments().get(i);
        length += segment.getLength();
        long end = markerEvent.getTime() + Math.round((length / (double) weightedMarker.getTotalLength()) * markerEvent.getDuration());
        long duration = end - start;
        if (end >= startTime && duration > minDuration && !segment.getColor().isEmpty()) {
            RGBAColor color = getColor(segment);
            Annotation subAnnotation = new Annotation(start, end - start, -1, String.format(segment.getLabel(), i), getOutputStyle(color));
            for (SubMarker subMarker : segment.getSubMarkers()) {
                getSubMarkerList(Objects.requireNonNull(subMarker), subAnnotation, annotationMap, startTime, endTime, minDuration, times);
            }
            for (SubMarker subMarker : weightedMarker.getSubMarkers()) {
                getSubMarkerList(Objects.requireNonNull(subMarker), subAnnotation, annotationMap, startTime, endTime, minDuration, times);
            }
            annotationsList.add(subAnnotation);
        }
        if (start >= endTime) {
            break;
        }
        start = end;
    }
    populateMap(annotationMap, annotationsList, Objects.requireNonNull(weightedMarker.getName()));
}
Also used : RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) ArrayList(java.util.ArrayList) MarkerSegment(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)

Example 3 with SubMarker

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

the class CustomAnnotationProviderTest method testSubmarkers.

/**
 * Test submarkers
 */
@Test
public void testSubmarkers() {
    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);
    /*
         * period: 10 us, offset: 20 ms, range: 1..1000
         *
         * requested range: 100 ms-200 ms
         *
         * expected annotations: 99.99 ms[1000] 100.00 ms[1] 100.01 ms[2] 100.02
         * ms[2] ... 200.00 ms[1]
         */
    SubMarker markerB = new SplitMarker("B", "B %d", "b", COLOR_STR, Range.closed(1L, 1000L), ImmutableRangeSet.of(Range.all()));
    markerA.addSubMarker(markerB);
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Arrays.asList("A", "B"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    annotationList = getAnnotationList("B", 100000000L, 200000000L, 10000L, new NullProgressMonitor());
    assertEquals(0, annotationList.size());
    annotationList = getAnnotationList("B", 100000000L, 200000000L, 1000L, new NullProgressMonitor());
    assertEquals(10002, annotationList.size());
    for (int i = 0; i < annotationList.size(); i++) {
        long t = (i + 9999) * 10000L;
        int index = (i + 9999) - 2000;
        int labelIndex = 1 + index % 1000;
        RGBAColor color = labelIndex % 2 == 0 ? COLOR : ODD_COLOR;
        validateAnnotation(annotationList.get(i), t, 10000L, "B", String.format("B %d", labelIndex), color);
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) 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 4 with SubMarker

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

the class MarkerTest method testAddSubMarker.

/**
 * Test the SplitMarker and WeightedMarker constructors and method addMarker
 */
@Test
public void testAddSubMarker() {
    PeriodicMarker marker = new PeriodicMarker("name", "label", "id", "referenceid", "color", 1.0, "ms", Range.atLeast(0L), 0L, ImmutableRangeSet.of(Range.all()));
    SubMarker subMarkerA = new SplitMarker("A", "a", "a", "color", Range.atLeast(0L), ImmutableRangeSet.of(Range.all()));
    marker.addSubMarker(subMarkerA);
    SubMarker subMarkerB = new WeightedMarker("B");
    marker.addSubMarker(subMarkerB);
    assertEquals(Arrays.asList(subMarkerA, subMarkerB), marker.getSubMarkers());
}
Also used : WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) Test(org.junit.Test)

Example 5 with SubMarker

use of org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker 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

SubMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker)6 Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)4 ArrayList (java.util.ArrayList)3 WeightedMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker)3 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)3 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)2 MarkerSegment (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment)2 SplitMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)2 Test (org.junit.Test)2 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 AnnotationModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel)1 Marker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker)1 MarkerSet (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet)1 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)1