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