use of org.eclipse.swtchart.extensions.customcharts.ChromatogramChart in project swtchart by eclipse.
the class ImageFactory_1_UITest method test1.
public void test1() {
try {
/*
* Create the factory.
*/
ImageFactory<ChromatogramChart> imageFactory = new ImageFactory<ChromatogramChart>(ChromatogramChart.class, 800, 600);
/*
* Modify the chart.
*/
ChromatogramChart chromatogramChart = imageFactory.getChart();
chromatogramChart.setBackground(chromatogramChart.getBaseChart().getDisplay().getSystemColor(SWT.COLOR_WHITE));
List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
//
ISeriesData seriesData = SeriesConverter.getSeriesXY(TestPathHelper.getAbsolutePath(TestPathHelper.TESTFILE_LINE_SERIES_1));
ILineSeriesData lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSerieSettings = lineSeriesData.getLineSeriesSettings();
lineSerieSettings.setEnableArea(true);
lineSeriesDataList.add(lineSeriesData);
chromatogramChart.addSeriesData(lineSeriesDataList);
/*
* Export the images.
*/
String exportFolder = TestPathHelper.getAbsolutePath(TestPathHelper.TESTFOLDER_EXPORT);
String prefix = "LineSeries1";
//
String png = exportFolder + File.separator + prefix + ".png";
imageFactory.saveImage(png, SWT.IMAGE_PNG);
File filePng = new File(png);
assertTrue(filePng.exists());
filePng.delete();
//
String jpg = exportFolder + File.separator + prefix + ".jpg";
imageFactory.saveImage(jpg, SWT.IMAGE_JPEG);
File fileJpg = new File(jpg);
assertTrue(fileJpg.exists());
fileJpg.delete();
//
String bmp = exportFolder + File.separator + prefix + ".bmp";
imageFactory.saveImage(bmp, SWT.IMAGE_BMP);
File fileBmp = new File(bmp);
assertTrue(fileBmp.exists());
fileBmp.delete();
//
imageFactory.closeShell();
//
} catch (InstantiationException e) {
System.out.println(e);
} catch (IllegalAccessException e) {
System.out.println(e);
}
}
use of org.eclipse.swtchart.extensions.customcharts.ChromatogramChart in project swtchart by eclipse.
the class LineSeries_Edit_Part method createChart.
private void createChart(Composite parent) {
chromatogramChart = new ChromatogramChart(parent, SWT.BORDER);
chromatogramChart.setLayoutData(new GridData(GridData.FILL_BOTH));
//
IChartSettings chartSettings = chromatogramChart.getChartSettings();
chartSettings.setCreateMenu(true);
chartSettings.setSupportDataShift(true);
chromatogramChart.applySettings(chartSettings);
//
loadChromatogramData();
}
use of org.eclipse.swtchart.extensions.customcharts.ChromatogramChart in project swtchart by eclipse.
the class LineSeries_Random_Part method initialize.
private void initialize() throws Exception {
this.setLayout(new GridLayout(1, true));
/*
* Buttons
*/
Composite compositeButtons = new Composite(this, SWT.NONE);
GridData gridDataComposite = new GridData(GridData.FILL_HORIZONTAL);
gridDataComposite.horizontalAlignment = SWT.END;
compositeButtons.setLayoutData(gridDataComposite);
compositeButtons.setLayout(new GridLayout(3, false));
//
buttonStart = new Button(compositeButtons, SWT.PUSH);
buttonStart.setToolTipText("Start Recording");
buttonStart.setText(Activator.getDefault() != null ? "" : "Start");
buttonStart.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_START) : null);
buttonStart.setEnabled(true);
buttonStart.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
acquisition.setRecordData(true);
display.asyncExec(recording);
//
setButtonsEnabled(true);
}
});
//
buttonStop = new Button(compositeButtons, SWT.PUSH);
buttonStop.setToolTipText("Stop Recording");
buttonStop.setText(Activator.getDefault() != null ? "" : "Stop");
buttonStop.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_STOP) : null);
buttonStop.setEnabled(false);
buttonStop.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
acquisition.setRecordData(false);
display.timerExec(-1, recording);
//
setButtonsEnabled(false);
}
});
//
buttonReset = new Button(compositeButtons, SWT.PUSH);
buttonReset.setToolTipText("Reset");
buttonReset.setText(Activator.getDefault() != null ? "" : "Reset");
buttonReset.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_RESET) : null);
buttonReset.setEnabled(true);
buttonReset.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
acquisition.setRecordData(false);
display.timerExec(-1, recording);
//
chromatogramChart.deleteSeries();
x = 0;
//
List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
ISeriesData seriesData = getRandomSeriesData();
ILineSeriesData lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_RED));
lineSeriesSettings.setEnableArea(true);
lineSeriesDataList.add(lineSeriesData);
ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
lineSeriesSettingsHighlight.setLineWidth(2);
chromatogramChart.addSeriesData(lineSeriesDataList);
}
});
/*
* Chart
*/
chromatogramChart = new ChromatogramChart(this, SWT.BORDER);
chromatogramChart.setLayoutData(new GridData(GridData.FILL_BOTH));
//
List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
ISeriesData seriesData = getRandomSeriesData();
ILineSeriesData lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_RED));
lineSeriesSettings.setEnableArea(true);
ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
lineSeriesSettingsHighlight.setLineWidth(2);
lineSeriesDataList.add(lineSeriesData);
chromatogramChart.addSeriesData(lineSeriesDataList);
}
Aggregations