Search in sources :

Example 1 with ChromatogramChart

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);
    }
}
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)

Example 2 with ChromatogramChart

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();
}
Also used : ChromatogramChart(org.eclipse.swtchart.extensions.customcharts.ChromatogramChart) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) GridData(org.eclipse.swt.layout.GridData)

Example 3 with ChromatogramChart

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);
}
Also used : LineSeriesData(org.eclipse.swtchart.extensions.linecharts.LineSeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ChromatogramChart(org.eclipse.swtchart.extensions.customcharts.ChromatogramChart) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ChromatogramChart (org.eclipse.swtchart.extensions.customcharts.ChromatogramChart)3 ArrayList (java.util.ArrayList)2 GridData (org.eclipse.swt.layout.GridData)2 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)2 ILineSeriesData (org.eclipse.swtchart.extensions.linecharts.ILineSeriesData)2 ILineSeriesSettings (org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings)2 LineSeriesData (org.eclipse.swtchart.extensions.linecharts.LineSeriesData)2 File (java.io.File)1 List (java.util.List)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 IChartSettings (org.eclipse.swtchart.extensions.core.IChartSettings)1 ImageFactory (org.eclipse.swtchart.extensions.images.ImageFactory)1