Search in sources :

Example 1 with ISeriesData

use of org.eclipse.swtchart.extensions.core.ISeriesData in project swtchart by eclipse.

the class BarSeries_1_1_Part method initialize.

private void initialize() {
    /*
		 * Chart Settings
		 */
    IChartSettings chartSettings = getChartSettings();
    chartSettings.setCreateMenu(true);
    applySettings(chartSettings);
    /*
		 * Additional settings
		 */
    setNumberOfHighestIntensitiesToLabel(5);
    setLabelOption(LabelOption.NOMIMAL);
    setCustomLabels(null);
    /*
		 * Create series.
		 */
    List<IBarSeriesData> barSeriesDataList = new ArrayList<IBarSeriesData>();
    ISeriesData seriesData = SeriesConverter.getSeriesXY(SeriesConverter.BAR_SERIES_1);
    // 
    IBarSeriesData barSeriesData = new BarSeriesData(seriesData);
    barSeriesDataList.add(barSeriesData);
    /*
		 * Set series.
		 */
    addSeriesData(barSeriesDataList);
}
Also used : ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) IBarSeriesData(org.eclipse.swtchart.extensions.barcharts.IBarSeriesData) IBarSeriesData(org.eclipse.swtchart.extensions.barcharts.IBarSeriesData) BarSeriesData(org.eclipse.swtchart.extensions.barcharts.BarSeriesData) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) ArrayList(java.util.ArrayList)

Example 2 with ISeriesData

use of org.eclipse.swtchart.extensions.core.ISeriesData in project swtchart by eclipse.

the class BarSeries_1_3_Part method initialize.

private void initialize() {
    setNumberOfHighestIntensitiesToLabel(5);
    setLabelOption(LabelOption.CUSTOM);
    setCustomLabels(createCustomLabels());
    /*
		 * Create series.
		 */
    List<IBarSeriesData> barSeriesDataList = new ArrayList<IBarSeriesData>();
    ISeriesData seriesData = SeriesConverter.getSeriesXY(SeriesConverter.BAR_SERIES_1);
    // 
    IBarSeriesData barSeriesData = new BarSeriesData(seriesData);
    barSeriesDataList.add(barSeriesData);
    /*
		 * Set series.
		 */
    addSeriesData(barSeriesDataList);
}
Also used : ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) IBarSeriesData(org.eclipse.swtchart.extensions.barcharts.IBarSeriesData) IBarSeriesData(org.eclipse.swtchart.extensions.barcharts.IBarSeriesData) BarSeriesData(org.eclipse.swtchart.extensions.barcharts.BarSeriesData) ArrayList(java.util.ArrayList)

Example 3 with ISeriesData

use of org.eclipse.swtchart.extensions.core.ISeriesData in project swtchart by eclipse.

the class ImageFactory_3_UITest method test1.

public void test1() {
    try {
        /*
			 * Create the factory.
			 */
        ImageFactory<PCAChart> imageFactory = new ImageFactory<PCAChart>(PCAChart.class, 800, 600);
        /*
			 * Modify the chart.
			 */
        PCAChart pcaChart = imageFactory.getChart();
        BaseChart baseChart = pcaChart.getBaseChart();
        pcaChart.setBackground(baseChart.getDisplay().getSystemColor(SWT.COLOR_WHITE));
        List<ISeriesData> scatterSeriesList = SeriesConverter.getSeriesScatter(TestPathHelper.getAbsolutePath(TestPathHelper.TESTFILE_SCATTER_SERIES_1));
        List<IScatterSeriesData> scatterSeriesDataList = new ArrayList<IScatterSeriesData>();
        // 
        for (ISeriesData seriesData : scatterSeriesList) {
            IScatterSeriesData scatterSeriesData = new ScatterSeriesData(seriesData);
            IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
            /*
				 * Set the color and symbol type.
				 */
            double x = seriesData.getXSeries()[0];
            double y = seriesData.getYSeries()[0];
            scatterSeriesSettings.setSymbolSize(SYMBOL_SIZE);
            // 
            if (x > 0 && y > 0) {
                scatterSeriesSettings.setSymbolColor(baseChart.getDisplay().getSystemColor(SWT.COLOR_RED));
                scatterSeriesSettings.setSymbolType(PlotSymbolType.SQUARE);
            } else if (x > 0 && y < 0) {
                scatterSeriesSettings.setSymbolColor(baseChart.getDisplay().getSystemColor(SWT.COLOR_BLUE));
                scatterSeriesSettings.setSymbolType(PlotSymbolType.TRIANGLE);
            } else if (x < 0 && y > 0) {
                scatterSeriesSettings.setSymbolColor(baseChart.getDisplay().getSystemColor(SWT.COLOR_MAGENTA));
                scatterSeriesSettings.setSymbolType(PlotSymbolType.DIAMOND);
            } else if (x < 0 && y < 0) {
                scatterSeriesSettings.setSymbolColor(baseChart.getDisplay().getSystemColor(SWT.COLOR_CYAN));
                scatterSeriesSettings.setSymbolType(PlotSymbolType.INVERTED_TRIANGLE);
            } else {
                scatterSeriesSettings.setSymbolColor(baseChart.getDisplay().getSystemColor(SWT.COLOR_GRAY));
                scatterSeriesSettings.setSymbolType(PlotSymbolType.CIRCLE);
            }
            // 
            scatterSeriesDataList.add(scatterSeriesData);
        }
        pcaChart.addSeriesData(scatterSeriesDataList);
        /*
			 * Export the images.
			 */
        String exportFolder = TestPathHelper.getAbsolutePath(TestPathHelper.TESTFOLDER_EXPORT);
        String prefix = "ScatterSeries1";
        // 
        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 : IScatterSeriesData(org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesData) IScatterSeriesData(org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesData) ScatterSeriesData(org.eclipse.swtchart.extensions.scattercharts.ScatterSeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) IScatterSeriesSettings(org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesSettings) ArrayList(java.util.ArrayList) ImageFactory(org.eclipse.swtchart.extensions.images.ImageFactory) BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) PCAChart(org.eclipse.swtchart.extensions.customcharts.PCAChart) File(java.io.File)

Example 4 with ISeriesData

use of org.eclipse.swtchart.extensions.core.ISeriesData in project swtchart by eclipse.

the class SeriesConverter method getSeriesScatter.

public static List<ISeriesData> getSeriesScatter(String fileName) {
    List<ISeriesData> scatterSeriesList = new ArrayList<ISeriesData>();
    // 
    BufferedReader bufferedReader = null;
    try {
        String line;
        bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
        while ((line = bufferedReader.readLine()) != null) {
            String[] values = line.split("\t");
            String id = values[0].trim();
            double[] xSeries = new double[] { Double.parseDouble(values[1].trim()) };
            double[] ySeries = new double[] { Double.parseDouble(values[2].trim()) };
            ISeriesData seriesData = new SeriesData(xSeries, ySeries, id);
            scatterSeriesList.add(seriesData);
        }
    } catch (Exception e) {
    // 
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (IOException e) {
            // 
            }
        }
    }
    return scatterSeriesList;
}
Also used : ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) SeriesData(org.eclipse.swtchart.extensions.core.SeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

Example 5 with ISeriesData

use of org.eclipse.swtchart.extensions.core.ISeriesData 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);
    }
}
Also used : LineSeriesData(org.eclipse.swtchart.extensions.linecharts.LineSeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) ChromatogramChart(org.eclipse.swtchart.extensions.customcharts.ChromatogramChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ArrayList(java.util.ArrayList) ImageFactory(org.eclipse.swtchart.extensions.images.ImageFactory) ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) File(java.io.File)

Aggregations

ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)44 ArrayList (java.util.ArrayList)37 IChartSettings (org.eclipse.swtchart.extensions.core.IChartSettings)24 ILineSeriesData (org.eclipse.swtchart.extensions.linecharts.ILineSeriesData)20 ILineSeriesSettings (org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings)20 LineSeriesData (org.eclipse.swtchart.extensions.linecharts.LineSeriesData)20 DecimalFormat (java.text.DecimalFormat)10 DecimalFormatSymbols (java.text.DecimalFormatSymbols)10 IPrimaryAxisSettings (org.eclipse.swtchart.extensions.core.IPrimaryAxisSettings)10 BarSeriesData (org.eclipse.swtchart.extensions.barcharts.BarSeriesData)9 IBarSeriesData (org.eclipse.swtchart.extensions.barcharts.IBarSeriesData)9 Color (org.eclipse.swt.graphics.Color)8 SeriesData (org.eclipse.swtchart.extensions.core.SeriesData)8 BufferedReader (java.io.BufferedReader)6 IOException (java.io.IOException)6 InputStreamReader (java.io.InputStreamReader)6 HashMap (java.util.HashMap)6 IScatterSeriesData (org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesData)6 IScatterSeriesSettings (org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesSettings)6 ScatterSeriesData (org.eclipse.swtchart.extensions.scattercharts.ScatterSeriesData)6