Search in sources :

Example 1 with MassSpectrumChart

use of org.eclipse.swtchart.extensions.customcharts.MassSpectrumChart in project swtchart by eclipse.

the class ImageFactory_2_UITest method test1.

public void test1() {
    try {
        /*
			 * Create the factory.
			 */
        ImageFactory<MassSpectrumChart> imageFactory = new ImageFactory<MassSpectrumChart>(MassSpectrumChart.class, 800, 600);
        /*
			 * Modify the chart.
			 */
        MassSpectrumChart massSpectrumChart = imageFactory.getChart();
        massSpectrumChart.setBackground(massSpectrumChart.getBaseChart().getDisplay().getSystemColor(SWT.COLOR_WHITE));
        List<IBarSeriesData> barSeriesDataList = new ArrayList<IBarSeriesData>();
        ISeriesData seriesData = SeriesConverter.getSeriesXY(TestPathHelper.getAbsolutePath(TestPathHelper.TESTFILE_BAR_SERIES_1));
        // 
        IBarSeriesData barSeriesData = new BarSeriesData(seriesData);
        IBarSeriesSettings barSeriesSettings = barSeriesData.getBarSeriesSettings();
        barSeriesSettings.setDescription("");
        barSeriesDataList.add(barSeriesData);
        massSpectrumChart.addSeriesData(barSeriesDataList);
        /*
			 * Export the images.
			 */
        String exportFolder = TestPathHelper.getAbsolutePath(TestPathHelper.TESTFOLDER_EXPORT);
        String prefix = "BarSeries1";
        // 
        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);
    }
}
Also used : ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ArrayList(java.util.ArrayList) ImageFactory(org.eclipse.swtchart.extensions.images.ImageFactory) IBarSeriesSettings(org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings) IBarSeriesData(org.eclipse.swtchart.extensions.barcharts.IBarSeriesData) IBarSeriesData(org.eclipse.swtchart.extensions.barcharts.IBarSeriesData) BarSeriesData(org.eclipse.swtchart.extensions.barcharts.BarSeriesData) File(java.io.File) MassSpectrumChart(org.eclipse.swtchart.extensions.customcharts.MassSpectrumChart)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 BarSeriesData (org.eclipse.swtchart.extensions.barcharts.BarSeriesData)1 IBarSeriesData (org.eclipse.swtchart.extensions.barcharts.IBarSeriesData)1 IBarSeriesSettings (org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings)1 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)1 MassSpectrumChart (org.eclipse.swtchart.extensions.customcharts.MassSpectrumChart)1 ImageFactory (org.eclipse.swtchart.extensions.images.ImageFactory)1