Search in sources :

Example 6 with ILineSeriesSettings

use of org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings in project swtchart by eclipse.

the class LineSeries_4_Part method initialize.

private void initialize() throws Exception {
    /*
		 * Chart Settings
		 */
    IChartSettings chartSettings = getChartSettings();
    chartSettings.setCreateMenu(true);
    applySettings(chartSettings);
    /*
		 * Create series.
		 */
    Map<Integer, Color> colors = new HashMap<Integer, Color>();
    colors.put(1, getDisplay().getSystemColor(SWT.COLOR_RED));
    colors.put(2, getDisplay().getSystemColor(SWT.COLOR_BLACK));
    colors.put(3, getDisplay().getSystemColor(SWT.COLOR_GRAY));
    colors.put(4, getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    colors.put(5, getDisplay().getSystemColor(SWT.COLOR_GRAY));
    // 
    List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
    for (int i = 1; i <= 5; i++) {
        ISeriesData seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES + "4_" + i);
        ILineSeriesData lineSeriesData = new LineSeriesData(seriesData);
        ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
        lineSeriesSettings.setLineColor(colors.get(i));
        lineSeriesSettings.setEnableArea(false);
        ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
        lineSeriesSettingsHighlight.setLineWidth(2);
        lineSeriesDataList.add(lineSeriesData);
    }
    // 
    addSeriesData(lineSeriesDataList, LineChart.MEDIUM_COMPRESSION);
}
Also used : ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) LineSeriesData(org.eclipse.swtchart.extensions.linecharts.LineSeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) HashMap(java.util.HashMap) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList)

Example 7 with ILineSeriesSettings

use of org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings in project swtchart by eclipse.

the class LineSeries_5_Part method initialize.

private void initialize() throws Exception {
    IChartSettings chartSettings = getChartSettings();
    chartSettings.getRangeRestriction().setZeroY(false);
    applySettings(chartSettings);
    // 
    List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
    // 
    ISeriesData seriesData;
    ILineSeriesData lineSeriesData;
    ILineSeriesSettings lineSeriesSettings;
    /*
		 * Positive
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_5_POSITIVE);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setLineColor(getBaseChart().getDisplay().getSystemColor(SWT.COLOR_RED));
    lineSeriesSettings.setEnableArea(false);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Negative
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_5_NEGATIVE);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
    lineSeriesSettings.setEnableArea(false);
    ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Set series.
		 */
    addSeriesData(lineSeriesDataList);
}
Also used : ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) LineSeriesData(org.eclipse.swtchart.extensions.linecharts.LineSeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) ArrayList(java.util.ArrayList)

Example 8 with ILineSeriesSettings

use of org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings in project swtchart by eclipse.

the class LineSeries_6_Part method initialize.

private void initialize() throws Exception {
    /*
		 * Chart Settings
		 */
    IChartSettings chartSettings = getChartSettings();
    chartSettings.setOrientation(SWT.HORIZONTAL);
    chartSettings.setHorizontalSliderVisible(true);
    chartSettings.setVerticalSliderVisible(false);
    chartSettings.getRangeRestriction().setZeroX(false);
    chartSettings.getRangeRestriction().setZeroY(true);
    chartSettings.getRangeRestriction().setRestrictZoom(false);
    chartSettings.setCreateMenu(true);
    /*
		 * Primary X-Axis
		 */
    IPrimaryAxisSettings primaryAxisSettingsX = chartSettings.getPrimaryAxisSettingsX();
    primaryAxisSettingsX.setTitle("f1 (ppm)");
    primaryAxisSettingsX.setDecimalFormat(new DecimalFormat(("0.0##"), new DecimalFormatSymbols(Locale.ENGLISH)));
    primaryAxisSettingsX.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
    primaryAxisSettingsX.setPosition(Position.Primary);
    /*
		 * Primary Y-Axis
		 */
    IPrimaryAxisSettings primaryAxisSettingsY = chartSettings.getPrimaryAxisSettingsY();
    primaryAxisSettingsY.setTitle("Intensity");
    primaryAxisSettingsY.setDecimalFormat(new DecimalFormat(("0.0#E0"), new DecimalFormatSymbols(Locale.ENGLISH)));
    primaryAxisSettingsY.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
    // 
    applySettings(chartSettings);
    /*
		 * Create series.
		 */
    List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
    ISeriesData seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_6);
    // 
    ILineSeriesData lineSeriesData = new LineSeriesData(seriesData);
    ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(false);
    ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Set series.
		 */
    addSeriesData(lineSeriesDataList);
}
Also used : ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) LineSeriesData(org.eclipse.swtchart.extensions.linecharts.LineSeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) DecimalFormatSymbols(java.text.DecimalFormatSymbols) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) IPrimaryAxisSettings(org.eclipse.swtchart.extensions.core.IPrimaryAxisSettings)

Example 9 with ILineSeriesSettings

use of org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings in project swtchart by eclipse.

the class LineSeries_9_Part method initialize.

private void initialize() throws Exception {
    /*
		 * Chart Settings
		 */
    IChartSettings chartSettings = getChartSettings();
    chartSettings.setCreateMenu(true);
    applySettings(chartSettings);
    /*
		 * Create series.
		 */
    List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
    // 
    ISeriesData seriesData;
    ILineSeriesData lineSeriesData;
    ILineSeriesSettings lineSeriesSettings;
    /*
		 * Chromatogram [0]
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Active Peaks [1]
		 */
    indexSeries = 1;
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_ACTIVE_PEAKS);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(false);
    lineSeriesSettings.setLineStyle(LineStyle.NONE);
    lineSeriesSettings.setSymbolType(PlotSymbolType.INVERTED_TRIANGLE);
    lineSeriesSettings.setSymbolSize(5);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_GRAY));
    lineSeriesSettings.setSymbolColor(getDisplay().getSystemColor(SWT.COLOR_GRAY));
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Set series.
		 */
    addSeriesData(lineSeriesDataList);
    /*
		 * Add the label marker.
		 */
    IPlotArea plotArea = (IPlotArea) getBaseChart().getPlotArea();
    LabelMarker labelMarker = new LabelMarker(getBaseChart());
    List<String> labels = new ArrayList<String>();
    labels.add("2-Methoxy-4-vinylphenol");
    labels.add("Ethanone, 1-(2-hydroxy-5-methylphenyl)-");
    labels.add("4-Hydroxy-2-methylacetophenone");
    labels.add("Ethanone, 1-(2-hydroxy-5-methylphenyl)-");
    labels.add("4-Hydroxy-3-methylacetophenone");
    labels.add("3-Methoxyacetophenone");
    labels.add("3-Methyl-4-isopropylphenol");
    labels.add("Phenol, 3,4-dimethoxy-");
    labels.add("2,4-Dimethoxyphenol");
    labels.add("3-Amino-2,6-dimethoxypyridine");
    labelMarker.setLabels(labels, indexSeries, SWT.HORIZONTAL);
    plotArea.addCustomPaintListener(labelMarker);
}
Also used : ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) LineSeriesData(org.eclipse.swtchart.extensions.linecharts.LineSeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeriesData(org.eclipse.swtchart.extensions.linecharts.ILineSeriesData) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) ArrayList(java.util.ArrayList) IPlotArea(org.eclipse.swtchart.IPlotArea) LabelMarker(org.eclipse.swtchart.extensions.marker.LabelMarker)

Example 10 with ILineSeriesSettings

use of org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings 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

ILineSeriesSettings (org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings)21 ArrayList (java.util.ArrayList)20 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)20 ILineSeriesData (org.eclipse.swtchart.extensions.linecharts.ILineSeriesData)20 LineSeriesData (org.eclipse.swtchart.extensions.linecharts.LineSeriesData)20 IChartSettings (org.eclipse.swtchart.extensions.core.IChartSettings)15 DecimalFormat (java.text.DecimalFormat)7 DecimalFormatSymbols (java.text.DecimalFormatSymbols)7 IPrimaryAxisSettings (org.eclipse.swtchart.extensions.core.IPrimaryAxisSettings)7 Color (org.eclipse.swt.graphics.Color)4 IPlotArea (org.eclipse.swtchart.IPlotArea)4 LabelMarker (org.eclipse.swtchart.extensions.marker.LabelMarker)4 HashMap (java.util.HashMap)3 ISecondaryAxisSettings (org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings)3 SecondaryAxisSettings (org.eclipse.swtchart.extensions.core.SecondaryAxisSettings)3 RelativeIntensityConverter (org.eclipse.swtchart.extensions.axisconverter.RelativeIntensityConverter)2 ChromatogramChart (org.eclipse.swtchart.extensions.customcharts.ChromatogramChart)2 File (java.io.File)1 List (java.util.List)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1