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());
}
}
}
}
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()));
}
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);
}
}
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());
}
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()));
}
Aggregations