Search in sources :

Example 36 with Chart

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

the class LineChartExample method createChart.

/**
 * create the chart.
 *
 * @param parent
 *            The parent composite
 * @return The created chart
 */
public static Chart createChart(Composite parent) {
    // create a chart
    Chart chart = new Chart(parent, SWT.NONE);
    // set titles
    chart.getTitle().setText("Line Chart");
    chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");
    chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");
    // create line series
    ILineSeries lineSeries = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
    lineSeries.setYSeries(ySeries);
    // adjust the axis range
    chart.getAxisSet().adjustRange();
    return chart;
}
Also used : ILineSeries(org.eclipse.swtchart.ILineSeries) Chart(org.eclipse.swtchart.Chart)

Example 37 with Chart

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

the class KernelMemoryUsageViewTest method testKernelMemoryView.

/**
 * Simple test to check the Kernel Memory Usage view data model
 */
@Test
public void testKernelMemoryView() {
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof KernelMemoryUsageView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    final Chart chart = getChart();
    assertNotNull(chart);
    chartViewer.setNbPoints(NUMBER_OF_POINT);
    SWTBotTree treeBot = getSWTBotView().bot().tree();
    SWTBotTreeItem totalNode = treeBot.getTreeItem(fTraceName);
    SWTBotUtils.waitUntil(root -> root.getItems().length >= 5, totalNode, "Did not finish loading");
    /*
         * Select the total entry, which should be the first entry with an empty pid
         * column.
         */
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 1, chart, "No data available");
    /* Test type, style and color of series */
    verifySeriesStyle(TOTAL_PID, ISeries.SeriesType.LINE, BLUE, LineStyle.SOLID, false);
    /* Test data model*/
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json), "resources/kernelmemory/kernel-memory-res50.json", "Chart data is not valid");
    /*
         * Select a thread
         */
    SWTBotTreeItem sessiondEntry = totalNode.getNode("lttng-sessiond");
    sessiondEntry.check();
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
    /* Test type, style and color of series */
    verifySeriesStyle(SESSIOND_PID, ISeries.SeriesType.LINE, RED, LineStyle.SOLID, false);
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, SESSIOND_PID), "resources/kernelmemory/kernel-memory-res50Selected.json", "Chart data is not valid");
    /*
         * Select an another thread and change zoom
         */
    SWTBotTreeItem consumerdEntry = totalNode.getNode("lttng-consumerd");
    consumerdEntry.check();
    chartViewer.setNbPoints(MORE_POINTS);
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 3, chart, "Only total and sessiond available");
    /* Test type, style and color of series */
    verifySeriesStyle(CONSUMERD_PID, ISeries.SeriesType.LINE, GREEN, LineStyle.SOLID, false);
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, CONSUMERD_PID), "resources/kernelmemory/kernel-memory-res100Selected.json", "Chart data is not valid");
}
Also used : IViewPart(org.eclipse.ui.IViewPart) KernelMemoryUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.kernelmemoryusage.KernelMemoryUsageView) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) 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 38 with Chart

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

the class ResourcesAndCpuViewTest method getChartTitle.

private String getChartTitle() {
    getSWTBotView().setFocus();
    // Do some basic validation
    Matcher<Chart> matcher = WidgetOfType.widgetOfType(Chart.class);
    Chart chart = getSWTBotView().bot().widget(matcher);
    return chart.getTitle().getText();
}
Also used : Chart(org.eclipse.swtchart.Chart)

Example 39 with Chart

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

the class XYDataProviderBaseTest method setup.

/**
 * Set up
 */
@Before
public void setup() {
    SWTBotUtils.openView(getViewID());
    fViewBot = fBot.viewById(getViewID());
    fViewBot.show();
    Matcher<Chart> widgetOfType = WidgetOfType.widgetOfType(Chart.class);
    fChart = fViewBot.bot().widget(widgetOfType);
    ITmfTrace trace = getTestTrace();
    File file = new File(trace.getPath());
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, file.getAbsolutePath(), trace.getTraceTypeId());
    SWTBotUtils.activateEditor(fBot, trace.getName());
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) File(java.io.File) Chart(org.eclipse.swtchart.Chart) Before(org.junit.Before)

Example 40 with Chart

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

the class TmfChartView method getZoomInAction.

private Action getZoomInAction() {
    Action zoomInAction = fZoomInAction;
    if (zoomInAction == null) {
        zoomInAction = new Action() {

            @Override
            public void run() {
                TmfXYChartViewer viewer = getChartViewer();
                if (viewer == null) {
                    return;
                }
                Chart chart = viewer.getSwtChart();
                if (chart == null) {
                    return;
                }
                TmfXyUiUtils.zoom(viewer, XYAxis.create(chart.getAxisSet().getXAxis(0)), true);
            }
        };
        zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);
        zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);
        zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));
    }
    return zoomInAction;
}
Also used : TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) Chart(org.eclipse.swtchart.Chart)

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