Search in sources :

Example 16 with RGBAColor

use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor 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)

Example 17 with RGBAColor

use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.

the class CustomAnnotationProviderTest method testIrregular.

/**
 * Test irregular
 */
@Test
public void testIrregular() {
    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);
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Arrays.asList("D"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    annotationList = getAnnotationList("D", 0L, 4000L, 1L, new NullProgressMonitor());
    assertEquals(6, annotationList.size());
    int i = 0;
    for (long t = 0L; t < 4000L; t += 40L) {
        int index = (int) (t / 40L) % 50;
        if (index == 30L || index == 31L || index == 40L) {
            Annotation annotation = annotationList.get(i++);
            RGBAColor color = index % 2 == 0 ? COLOR : ODD_COLOR;
            validateAnnotation(annotation, t, 40L, "D", String.format("D %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)

Example 18 with RGBAColor

use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor 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 19 with RGBAColor

use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.

the class TmfPieChart method addPieSlice.

/**
 * Add a slice to the model
 *
 * @param label
 *            Label
 * @param value
 *            Value (numerical)
 * @param id
 *            the unique ID
 */
public void addPieSlice(String label, double value, String id) {
    PieSlice pieSlice = new PieSlice(label, value, id);
    IBarSeries<?> bs = (IBarSeries<?>) getSeriesSet().createSeries(SeriesType.BAR, id);
    Color sliceColor = REGISTRY.get(id);
    if (sliceColor == null) {
        fCurrentColor += 3;
        RGBAColor rgba = PALETTE.get().get(fCurrentColor % NUM_COLORS);
        REGISTRY.put(id, new RGB(rgba.getRed(), rgba.getGreen(), rgba.getBlue()));
        sliceColor = REGISTRY.get(id);
    }
    bs.setBarColor(sliceColor);
    fSlices.add(pieSlice);
}
Also used : IBarSeries(org.eclipse.swtchart.IBarSeries) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) Color(org.eclipse.swt.graphics.Color) RGB(org.eclipse.swt.graphics.RGB)

Example 20 with RGBAColor

use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.

the class CustomAnnotationProvider method getColor.

private RGBAColor getColor(Marker marker) {
    RGBAColor color = fColors.get(marker);
    if (color == null) {
        color = parseColor(marker.getColor());
        fColors.put(marker, color);
    }
    return color;
}
Also used : RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)

Aggregations

RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)25 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)12 Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 NonNull (org.eclipse.jdt.annotation.NonNull)5 Color (org.eclipse.swt.graphics.Color)5 Point (org.eclipse.swt.graphics.Point)5 RGB (org.eclipse.swt.graphics.RGB)5 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)5 SubMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker)5 StateItem (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 Marker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker)4 MarkerSet (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet)4 SplitMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)4 WeightedMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker)4 LongPoint (org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.LongPoint)4 StyleManager (org.eclipse.tracecompass.tmf.ui.model.StyleManager)4 Test (org.junit.Test)4