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