use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class LargeSeriesExample 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("Large Series");
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(getSeries());
lineSeries.setSymbolType(PlotSymbolType.NONE);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class ChartLayout method parseControls.
/**
* Parses the controls on given composite.
*
* @param composite
* the composite
* @return true if all children found
*/
private boolean parseControls(Composite composite) {
for (Control child : composite.getChildren()) {
if (child instanceof Legend) {
legend = (Legend) child;
} else if (child instanceof PlotArea) {
plot = (PlotArea) child;
}
}
if (composite instanceof Chart) {
IAxisSet axisSet = ((Chart) composite).getAxisSet();
if (axisSet != null) {
axes = (Axis[]) axisSet.getAxes();
if (((Chart) composite).getOrientation() == SWT.HORIZONTAL) {
horizontalAxes = (Axis[]) axisSet.getXAxes();
verticalAxes = (Axis[]) axisSet.getYAxes();
} else {
verticalAxes = (Axis[]) axisSet.getXAxes();
horizontalAxes = (Axis[]) axisSet.getYAxes();
}
}
title = (ChartTitle) ((Chart) composite).getTitle();
}
if (title == null || legend == null || plot == null || axes == null) {
// the initialization of chart is not completed yet
return false;
}
return true;
}
use of org.eclipse.swtchart.Chart in project org.eclipse.linuxtools by eclipse-linuxtools.
the class ChartTests method testChartCallback.
@Test
public void testChartCallback() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testChartCallback");
IAction chartAction = getChartAction();
assertNotNull(chartAction);
chartAction.run();
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
assertTrue(part instanceof ChartEditor);
Chart control = ((ChartEditor) part).getControl();
ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().getSeries(// $NON-NLS-1$
Messages.getString("HeapChart.Total_Heap"));
Point p1 = lsTotal.getPixelCoordinates(4);
HeapChart heapChart = ((ChartEditorInput) ((ChartEditor) part).getEditorInput()).getChart();
int x = control.getAxisSet().getXAxis(0).getPixelCoordinate(heapChart.time[4]);
int y = control.getAxisSet().getYAxis(0).getPixelCoordinate(heapChart.dataTotal[4]);
assertEquals(x, p1.x);
assertEquals(y, p1.y);
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class TmfChartView method getZoomOutAction.
private Action getZoomOutAction() {
Action zoomOutAction = fZoomOutAction;
if (zoomOutAction == null) {
zoomOutAction = 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)), false);
}
};
zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);
zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);
zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));
}
return zoomOutAction;
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class DisksIOViewTest method testDiskView.
/**
* Test to check the Disks IO Activity view. First, when trace opened, there
* should not be any activity. Then, we move to a time range where there are
* write activity. Afterward, we test the zoom
*/
@Test
public void testDiskView() {
// Wait for analysis to finish.
WaitUtils.waitForJobs();
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof DiskIOActivityView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
for (SWTBotTreeItem item : items) {
item.check();
}
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
chartViewer.setNbPoints(NUMBER_OF_POINT);
/* Initially, no disk activity */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk0-res50.json", "Chart data is not valid");
/* Change time range where there is disks activity */
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, new TmfTimeRange(ZOOM_START_TIME, ZOOM_END_TIME)));
fBot.waitUntil(ConditionHelpers.windowRange(new TmfTimeRange(ZOOM_START_TIME, ZOOM_END_TIME)));
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test type, style and color of series */
verifyChartStyle();
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk1-res50.json", "Chart data is not valid");
/* Change Zoom and number of points */
chartViewer.setNbPoints(MORE_POINTS);
/* Test type, style and color of series */
verifyChartStyle();
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk2-res100.json", "Chart data is not valid");
}
Aggregations