Search in sources :

Example 21 with Chart

use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.

the class SystemCallLatencyScatterChartViewTest method testWithTrace.

/**
 * Test to check the System Call Scatter view. When trace opens, there are a few
 * syscalls present, then we move to the zone without system calls, the tree
 * should be empty.
 *
 * TODO: Test the data
 */
@Test
public void testWithTrace() {
    // Wait for analysis to finish.
    WaitUtils.waitForJobs();
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof SystemCallLatencyScatterView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    final Chart chart = getChart();
    assertNotNull(chart);
    SWTBotUtils.waitUntil(bot -> bot.tree().visibleRowCount() >= 25, getSWTBotView().bot(), "Missing rows, expected 25, was " + getSWTBotView().bot().tree().visibleRowCount());
    SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
    for (SWTBotTreeItem item : items) {
        item.check();
    }
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 24, chart, "No data available");
    /* Test type, style and color of series */
    verifyChartStyle();
    // Update the time range to a range where there is no data
    long noDataStart = 1412670961274443542L;
    long noDataEnd = 1412670961298823940L;
    TmfTimeRange windowRange = new TmfTimeRange(TmfTimestamp.fromNanos(noDataStart), TmfTimestamp.fromNanos(noDataEnd));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, windowRange));
    fBot.waitUntil(ConditionHelpers.windowRange(windowRange));
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    // Only the root item should be present
    items = getSWTBotView().bot().tree().getAllItems();
    assertEquals(1, items.length);
}
Also used : IViewPart(org.eclipse.ui.IViewPart) SystemCallLatencyScatterView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.SystemCallLatencyScatterView) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 22 with Chart

use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.

the class AbstractSegmentStoreDensityViewer method clearContent.

/**
 * Clears the view content.
 */
private void clearContent() {
    final Chart chart = fChart;
    if (!chart.isDisposed()) {
        ISeriesSet set = chart.getSeriesSet();
        ISeries<?>[] series = set.getSeries();
        for (int i = 0; i < series.length; i++) {
            set.deleteSeries(series[i].getId());
        }
        for (IAxis axis : chart.getAxisSet().getAxes()) {
            axis.setRange(new Range(0, 1));
        }
        chart.redraw();
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) Range(org.eclipse.swtchart.Range) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) SegmentStoreWithRange(org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider.SegmentStoreWithRange) AxisRange(org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange) ISeries(org.eclipse.swtchart.ISeries) Chart(org.eclipse.swtchart.Chart) IAxis(org.eclipse.swtchart.IAxis)

Example 23 with Chart

use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.

the class MemoryUsageViewTest method testMemoryUsage.

/**
 * Test Memory Usage data model
 */
@Test
public void testMemoryUsage() {
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof UstMemoryUsageView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    final Chart chart = getChart();
    assertNotNull(chart);
    checkAllEntries();
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 3, chart, "No data available");
    chartViewer.setNbPoints(50);
    /* Test data model*/
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, FIRST_SERIES_NAME, SECOND_SERIES_NAME, THIRD_SERIES_NAME, FOURTH_SERIES_NAME), "resources/memory-res50.json", "Chart data is not valid");
    /* Test type, style and color of series */
    verifyChartStyle();
}
Also used : IViewPart(org.eclipse.ui.IViewPart) UstMemoryUsageView(org.eclipse.tracecompass.internal.lttng2.ust.ui.views.memusage.UstMemoryUsageView) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 24 with Chart

use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.

the class MemoryUsageViewTest method testOpenMemoryUsage.

/**
 * Test if Memory Usage is populated
 */
@Test
public void testOpenMemoryUsage() {
    SWTBotView viewBot = fBot.viewById(UstMemoryUsageView.ID);
    viewBot.setFocus();
    // Do some basic validation
    Matcher<Chart> matcher = WidgetOfType.widgetOfType(Chart.class);
    Chart chart = viewBot.bot().widget(matcher);
    checkAllEntries();
    // Verify that the chart has 4 series
    fBot.waitUntil(ConditionHelpers.numberOfSeries(chart, EXPECTED_NUM_SERIES));
    ISeriesSet seriesSet = chart.getSeriesSet();
    ISeries<?>[] series = seriesSet.getSeries();
    // Verify that each series is a ILineSeries
    for (ISeries<?> serie : series) {
        assertTrue(serie instanceof ILineSeries);
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) ILineSeries(org.eclipse.swtchart.ILineSeries) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) ISeries(org.eclipse.swtchart.ISeries) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 25 with Chart

use of org.eclipse.swtchart.Chart in project olca-app by GreenDelta.

the class ContributionChart method create.

public static ContributionChart create(Composite parent, FormToolkit tk) {
    Composite comp = UI.formComposite(parent, tk);
    UI.gridLayout(comp, 2);
    UI.gridData(comp, true, true);
    // create and configure the chart
    Chart chart = new Chart(comp, SWT.NONE);
    GridData gdata = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gdata.heightHint = 300;
    gdata.widthHint = 700;
    chart.setLayoutData(gdata);
    chart.setOrientation(SWT.HORIZONTAL);
    chart.getLegend().setVisible(false);
    // we set a white title just to fix the problem
    // that the y-axis is cut sometimes
    chart.getTitle().setText(".");
    chart.getTitle().setFont(UI.defaultFont());
    chart.getTitle().setForeground(Colors.white());
    chart.getTitle().setVisible(true);
    // configure the x-axis with one category
    IAxis x = chart.getAxisSet().getXAxis(0);
    x.getTitle().setVisible(false);
    x.getTick().setForeground(Colors.darkGray());
    x.enableCategory(true);
    x.setCategorySeries(new String[] { "" });
    // configure the y-axis
    IAxis y = chart.getAxisSet().getYAxis(0);
    y.getTitle().setVisible(false);
    y.getTick().setForeground(Colors.darkGray());
    y.getGrid().setStyle(LineStyle.NONE);
    y.getTick().setFormat(new DecimalFormat("0.0E0#", new DecimalFormatSymbols(Locale.US)));
    y.getTick().setTickMarkStepHint(10);
    return new ContributionChart(chart, new ChartLegend(comp));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) GridData(org.eclipse.swt.layout.GridData) Chart(org.eclipse.swtchart.Chart) IAxis(org.eclipse.swtchart.IAxis)

Aggregations

Chart (org.eclipse.swtchart.Chart)45 Test (org.junit.Test)14 ILineSeries (org.eclipse.swtchart.ILineSeries)13 ISeries (org.eclipse.swtchart.ISeries)11 IAxis (org.eclipse.swtchart.IAxis)8 XYDataProviderBaseTest (org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)8 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)7 IBarSeries (org.eclipse.swtchart.IBarSeries)7 TmfCommonXAxisChartViewer (org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer)6 IViewPart (org.eclipse.ui.IViewPart)6 MouseEvent (org.eclipse.swt.events.MouseEvent)5 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)5 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)5 ISeriesSet (org.eclipse.swtchart.ISeriesSet)4 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)4 Nullable (org.eclipse.jdt.annotation.Nullable)3 IAction (org.eclipse.jface.action.IAction)3 Point (org.eclipse.swt.graphics.Point)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)3