Search in sources :

Example 21 with IChartSettings

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

the class ScatterSeries_Edit_Part method createChart.

private void createChart(Composite parent) {
    handledChart = new HandledChart(parent, SWT.BORDER);
    handledChart.setLayoutData(new GridData(GridData.FILL_BOTH));
    // 
    IChartSettings chartSettings = handledChart.getChartSettings();
    chartSettings.setCreateMenu(true);
    chartSettings.setSupportDataShift(true);
    handledChart.applySettings(chartSettings);
    // 
    loadScatterData();
}
Also used : IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) GridData(org.eclipse.swt.layout.GridData)

Example 22 with IChartSettings

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

the class CustomLineChart1 method configureChart.

private void configureChart() {
    try {
        IChartSettings chartSettings = getChartSettings();
        chartSettings.setOrientation(SWT.HORIZONTAL);
        chartSettings.setEnableRangeSelector(enableRangeSelector);
        chartSettings.setHorizontalSliderVisible(enableHorizontalSlider);
        chartSettings.setVerticalSliderVisible(false);
        chartSettings.getRangeRestriction().setZeroX(true);
        chartSettings.getRangeRestriction().setZeroY(true);
        // 
        IPrimaryAxisSettings primaryAxisSettingsX = chartSettings.getPrimaryAxisSettingsX();
        primaryAxisSettingsX.setTitle("Retention Time (milliseconds)");
        primaryAxisSettingsX.setDecimalFormat(new DecimalFormat(("0.0##"), new DecimalFormatSymbols(Locale.ENGLISH)));
        primaryAxisSettingsX.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
        primaryAxisSettingsX.setPosition(Position.Secondary);
        primaryAxisSettingsX.setVisible(false);
        primaryAxisSettingsX.setGridLineStyle(LineStyle.NONE);
        // 
        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));
        primaryAxisSettingsY.setPosition(Position.Primary);
        primaryAxisSettingsY.setVisible(true);
        primaryAxisSettingsY.setGridLineStyle(LineStyle.NONE);
        /*
			 * Secondary X-Axes
			 */
        String axisTitle = (showAxisTitle) ? "Minutes" : "";
        ISecondaryAxisSettings secondaryAxisSettingsX1 = new SecondaryAxisSettings(axisTitle, "Minutes", new MillisecondsToMinuteConverter());
        secondaryAxisSettingsX1.setPosition(Position.Primary);
        secondaryAxisSettingsX1.setDecimalFormat(new DecimalFormat(("0.00"), new DecimalFormatSymbols(Locale.ENGLISH)));
        secondaryAxisSettingsX1.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
        chartSettings.getSecondaryAxisSettingsListX().add(secondaryAxisSettingsX1);
        /*
			 * Secondary Y-Axes
			 */
        ISecondaryAxisSettings secondaryAxisSettingsY1 = new SecondaryAxisSettings("Relative Intensity [%]", new RelativeIntensityConverter(SWT.VERTICAL, true));
        secondaryAxisSettingsY1.setPosition(Position.Secondary);
        secondaryAxisSettingsY1.setDecimalFormat(new DecimalFormat(("0.00"), new DecimalFormatSymbols(Locale.ENGLISH)));
        secondaryAxisSettingsY1.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
        chartSettings.getSecondaryAxisSettingsListY().add(secondaryAxisSettingsY1);
        // 
        applySettings(chartSettings);
    } catch (Exception e) {
        System.out.println(e);
    }
}
Also used : ISecondaryAxisSettings(org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings) RelativeIntensityConverter(org.eclipse.swtchart.extensions.axisconverter.RelativeIntensityConverter) DecimalFormatSymbols(java.text.DecimalFormatSymbols) SecondaryAxisSettings(org.eclipse.swtchart.extensions.core.SecondaryAxisSettings) ISecondaryAxisSettings(org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) DecimalFormat(java.text.DecimalFormat) MillisecondsToMinuteConverter(org.eclipse.swtchart.extensions.axisconverter.MillisecondsToMinuteConverter) IPrimaryAxisSettings(org.eclipse.swtchart.extensions.core.IPrimaryAxisSettings)

Example 23 with IChartSettings

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

the class LineSeries_Preferences_Part method applyChartSettings.

private void applyChartSettings() throws Exception {
    IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
    setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // 
    Color colorHintRangeSelector = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_COLOR_HINT_RANGE_SELECTOR));
    Color colorTitle = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_TITLE_COLOR));
    Color colorBackground = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_BACKGROUND));
    Color colorBackgroundChart = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_BACKGROUND_CHART));
    Color colorBackgroundPlotArea = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_BACKGROUND_PLOT_AREA));
    Color colorPrimaryXAxis = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_COLOR));
    Color colorPrimaryYAxis = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_COLOR));
    Locale localePrimaryXAxis = new Locale(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_DECIMAL_FORMAT_LOCALE));
    Locale localePrimaryYAxis = new Locale(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_DECIMAL_FORMAT_LOCALE));
    Color colorSecondaryXAxis = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_COLOR));
    Color colorSecondaryYAxis = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_COLOR));
    Locale localeSecondaryXAxis = new Locale(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_DECIMAL_FORMAT_LOCALE));
    Locale localeSecondaryYAxis = new Locale(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_DECIMAL_FORMAT_LOCALE));
    Color colorPositionMarker = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_COLOR_POSITION_MARKER));
    Color colorPlotCenterMarker = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_COLOR_PLOT_CENTER_MARKER));
    Color colorLegendMarker = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_COLOR_LEGEND_MARKER));
    Color colorAxisZeroMarker = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_COLOR_AXIS_ZERO_MARKER));
    Color colorSeriesLabelMarker = getColor(PreferenceConverter.getColor(preferenceStore, LineSeriesPreferenceConstants.P_COLOR_SERIES_LABEL_MARKER));
    // 
    IChartSettings chartSettings = lineChart.getChartSettings();
    chartSettings.setEnableRangeSelector(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_ENABLE_RANGE_SELECTOR));
    chartSettings.setShowRangeSelectorInitially(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SHOW_RANGE_SELECTOR_INITIALLY));
    chartSettings.setColorHintRangeSelector(colorHintRangeSelector);
    chartSettings.setRangeSelectorDefaultAxisX(preferenceStore.getInt(LineSeriesPreferenceConstants.P_RANGE_SELECTOR_DEFAULT_AXIS_X));
    chartSettings.setRangeSelectorDefaultAxisY(preferenceStore.getInt(LineSeriesPreferenceConstants.P_RANGE_SELECTOR_DEFAULT_AXIS_Y));
    chartSettings.setVerticalSliderVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_VERTICAL_SLIDER_VISIBLE));
    chartSettings.setHorizontalSliderVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_HORIZONTAL_SLIDER_VISIBLE));
    chartSettings.setTitle(preferenceStore.getString(LineSeriesPreferenceConstants.P_TITLE));
    chartSettings.setTitleVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_TITLE_VISIBLE));
    chartSettings.setTitleColor(colorTitle);
    chartSettings.setLegendPosition(preferenceStore.getInt(LineSeriesPreferenceConstants.P_LEGEND_POSITION));
    chartSettings.setLegendVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_LEGEND_VISIBLE));
    chartSettings.setOrientation(preferenceStore.getInt(LineSeriesPreferenceConstants.P_ORIENTATION));
    chartSettings.setBackground(colorBackground);
    chartSettings.setBackgroundChart(colorBackgroundChart);
    chartSettings.setBackgroundPlotArea(colorBackgroundPlotArea);
    chartSettings.setEnableCompress(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_ENABLE_COMPRESS));
    RangeRestriction rangeRestriction = chartSettings.getRangeRestriction();
    rangeRestriction.setZeroX(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_ZERO_X));
    rangeRestriction.setZeroY(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_ZERO_Y));
    rangeRestriction.setRestrictZoom(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_RESTRICT_ZOOM));
    rangeRestriction.setXZoomOnly(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_X_ZOOM_ONLY));
    rangeRestriction.setYZoomOnly(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_Y_ZOOM_ONLY));
    rangeRestriction.setForceZeroMinY(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_FORCE_ZERO_MIN_Y));
    rangeRestriction.setExtendTypeX(RangeRestriction.ExtendType.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_EXTEND_TYPE_X)));
    rangeRestriction.setExtendMinX(preferenceStore.getDouble(LineSeriesPreferenceConstants.P_EXTEND_MIN_X));
    rangeRestriction.setExtendMaxX(preferenceStore.getDouble(LineSeriesPreferenceConstants.P_EXTEND_MAX_X));
    rangeRestriction.setExtendTypeY(RangeRestriction.ExtendType.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_EXTEND_TYPE_Y)));
    rangeRestriction.setExtendMinY(preferenceStore.getDouble(LineSeriesPreferenceConstants.P_EXTEND_MIN_Y));
    rangeRestriction.setExtendMaxY(preferenceStore.getDouble(LineSeriesPreferenceConstants.P_EXTEND_MAX_Y));
    // 
    chartSettings.setShowPositionMarker(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SHOW_POSITION_MARKER));
    chartSettings.setColorPositionMarker(colorPositionMarker);
    chartSettings.setShowPlotCenterMarker(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SHOW_PLOT_CENTER_MARKER));
    chartSettings.setColorPlotCenterMarker(colorPlotCenterMarker);
    chartSettings.setShowLegendMarker(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SHOW_LEGEND_MARKER));
    chartSettings.setColorLegendMarker(colorLegendMarker);
    chartSettings.setShowAxisZeroMarker(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SHOW_AXIS_ZERO_MARKER));
    chartSettings.setColorLegendMarker(colorAxisZeroMarker);
    chartSettings.setShowSeriesLabelMarker(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SHOW_SERIES_LABEL_MARKER));
    chartSettings.setColorSeriesLabelMarker(colorSeriesLabelMarker);
    // 
    chartSettings.setCreateMenu(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_CREATE_MENU));
    /*
		 * Primary X-Axis
		 */
    IPrimaryAxisSettings primaryAxisSettingsX = chartSettings.getPrimaryAxisSettingsX();
    primaryAxisSettingsX.setTitle(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_TITLE));
    primaryAxisSettingsX.setDescription(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_DESCRIPTION));
    primaryAxisSettingsX.setDecimalFormat(new DecimalFormat((preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_DECIMAL_FORMAT_PATTERN)), new DecimalFormatSymbols(localePrimaryXAxis)));
    primaryAxisSettingsX.setColor(colorPrimaryXAxis);
    primaryAxisSettingsX.setPosition(Position.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_POSITION)));
    primaryAxisSettingsX.setVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_VISIBLE));
    primaryAxisSettingsX.setGridLineStyle(LineStyle.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_GRID_LINE_STYLE)));
    primaryAxisSettingsX.setEnableLogScale(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_ENABLE_LOG_SCALE));
    primaryAxisSettingsX.setExtraSpaceTitle(preferenceStore.getInt(LineSeriesPreferenceConstants.P_PRIMARY_X_AXIS_EXTRA_SPACE_TITLE));
    /*
		 * Primary Y-Axis
		 */
    IPrimaryAxisSettings primaryAxisSettingsY = chartSettings.getPrimaryAxisSettingsY();
    primaryAxisSettingsY.setTitle(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_TITLE));
    primaryAxisSettingsY.setDescription(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_DESCRIPTION));
    primaryAxisSettingsY.setDecimalFormat(new DecimalFormat((preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_DECIMAL_FORMAT_PATTERN)), new DecimalFormatSymbols(localePrimaryYAxis)));
    primaryAxisSettingsY.setColor(colorPrimaryYAxis);
    primaryAxisSettingsY.setPosition(Position.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_POSITION)));
    primaryAxisSettingsY.setVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_VISIBLE));
    primaryAxisSettingsY.setGridLineStyle(LineStyle.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_GRID_LINE_STYLE)));
    primaryAxisSettingsY.setEnableLogScale(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_ENABLE_LOG_SCALE));
    primaryAxisSettingsY.setExtraSpaceTitle(preferenceStore.getInt(LineSeriesPreferenceConstants.P_PRIMARY_Y_AXIS_EXTRA_SPACE_TITLE));
    /*
		 * Secondary X-Axes
		 */
    chartSettings.getSecondaryAxisSettingsListX().clear();
    ISecondaryAxisSettings secondaryAxisSettingsX = new SecondaryAxisSettings(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_TITLE), new MillisecondsToMinuteConverter());
    secondaryAxisSettingsX.setDescription(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_DESCRIPTION));
    secondaryAxisSettingsX.setDecimalFormat(new DecimalFormat((preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_DECIMAL_FORMAT_PATTERN)), new DecimalFormatSymbols(localeSecondaryXAxis)));
    secondaryAxisSettingsX.setColor(colorSecondaryXAxis);
    secondaryAxisSettingsX.setPosition(Position.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_POSITION)));
    secondaryAxisSettingsX.setVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_VISIBLE));
    secondaryAxisSettingsX.setGridLineStyle(LineStyle.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_GRID_LINE_STYLE)));
    secondaryAxisSettingsX.setEnableLogScale(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_ENABLE_LOG_SCALE));
    secondaryAxisSettingsX.setExtraSpaceTitle(preferenceStore.getInt(LineSeriesPreferenceConstants.P_SECONDARY_X_AXIS_EXTRA_SPACE_TITLE));
    chartSettings.getSecondaryAxisSettingsListX().add(secondaryAxisSettingsX);
    /*
		 * Secondary Y-Axes
		 */
    chartSettings.getSecondaryAxisSettingsListY().clear();
    ISecondaryAxisSettings secondaryAxisSettingsY = new SecondaryAxisSettings(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_TITLE), new RelativeIntensityConverter(SWT.VERTICAL, true));
    secondaryAxisSettingsY.setDescription(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_DESCRIPTION));
    secondaryAxisSettingsY.setDecimalFormat(new DecimalFormat((preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_DECIMAL_FORMAT_PATTERN)), new DecimalFormatSymbols(localeSecondaryYAxis)));
    secondaryAxisSettingsY.setColor(colorSecondaryYAxis);
    secondaryAxisSettingsY.setPosition(Position.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_POSITION)));
    secondaryAxisSettingsY.setVisible(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_VISIBLE));
    secondaryAxisSettingsY.setGridLineStyle(LineStyle.valueOf(preferenceStore.getString(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_GRID_LINE_STYLE)));
    secondaryAxisSettingsY.setEnableLogScale(preferenceStore.getBoolean(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_ENABLE_LOG_SCALE));
    secondaryAxisSettingsY.setExtraSpaceTitle(preferenceStore.getInt(LineSeriesPreferenceConstants.P_SECONDARY_Y_AXIS_EXTRA_SPACE_TITLE));
    chartSettings.getSecondaryAxisSettingsListY().add(secondaryAxisSettingsY);
    // 
    lineChart.applySettings(chartSettings);
}
Also used : Locale(java.util.Locale) ISecondaryAxisSettings(org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings) RelativeIntensityConverter(org.eclipse.swtchart.extensions.axisconverter.RelativeIntensityConverter) DecimalFormatSymbols(java.text.DecimalFormatSymbols) ISecondaryAxisSettings(org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings) SecondaryAxisSettings(org.eclipse.swtchart.extensions.core.SecondaryAxisSettings) Color(org.eclipse.swt.graphics.Color) IChartSettings(org.eclipse.swtchart.extensions.core.IChartSettings) DecimalFormat(java.text.DecimalFormat) MillisecondsToMinuteConverter(org.eclipse.swtchart.extensions.axisconverter.MillisecondsToMinuteConverter) RangeRestriction(org.eclipse.swtchart.extensions.core.RangeRestriction) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IPrimaryAxisSettings(org.eclipse.swtchart.extensions.core.IPrimaryAxisSettings)

Example 24 with IChartSettings

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

the class LineSeries_10_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("[1]");
    labels.add("[2]");
    labels.add("[3]");
    labels.add("[4]");
    labels.add("[5]");
    labels.add("[6]");
    labels.add("[7]");
    labels.add("[8]");
    labels.add("[9]");
    labels.add("[10]");
    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 25 with IChartSettings

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

the class LineSeries_1_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;
    ILineSeriesSettings lineSeriesSettingsHighlight;
    /*
		 * Chromatogram [0]
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Baseline [1]
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_BASELINE);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    lineSeriesSettings.setSymbolType(PlotSymbolType.NONE);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Selected Scans [2]
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_SELECTED_SCANS);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setLineStyle(LineStyle.NONE);
    lineSeriesSettings.setSymbolType(PlotSymbolType.CROSS);
    lineSeriesSettings.setSymbolSize(5);
    lineSeriesSettings.setSymbolColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Active Peaks [3]
		 */
    indexSeries = 3;
    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));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Inactive Peaks
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_INACTIVE_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));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Peak 1
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_SELECTED_PEAK_1);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    lineSeriesSettings.setSymbolType(PlotSymbolType.CIRCLE);
    lineSeriesSettings.setSymbolColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettings.setSymbolSize(2);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Background 1
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_SELECTED_PEAK_1_BACKGROUND);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    lineSeriesSettings.setSymbolType(PlotSymbolType.NONE);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Peak 2
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_SELECTED_PEAK_2);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    lineSeriesSettings.setSymbolType(PlotSymbolType.CIRCLE);
    lineSeriesSettings.setSymbolColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettings.setSymbolSize(2);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Background 2
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_SELECTED_PEAK_2_BACKGROUND);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setEnableArea(true);
    lineSeriesSettings.setSymbolType(PlotSymbolType.NONE);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Identified Scans
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_IDENTIFIED_SCANS);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setLineStyle(LineStyle.NONE);
    lineSeriesSettings.setSymbolType(PlotSymbolType.CIRCLE);
    lineSeriesSettings.setSymbolSize(3);
    lineSeriesSettings.setLineColor(getDisplay().getSystemColor(SWT.COLOR_GRAY));
    lineSeriesSettings.setSymbolColor(getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Identified Scans Selected.
		 */
    seriesData = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_1_IDENTIFIED_SCANS_SELECTED);
    lineSeriesData = new LineSeriesData(seriesData);
    lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
    lineSeriesSettings.setLineStyle(LineStyle.NONE);
    lineSeriesSettings.setSymbolType(PlotSymbolType.CIRCLE);
    lineSeriesSettings.setSymbolSize(5);
    lineSeriesSettings.setSymbolColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
    lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
    lineSeriesSettingsHighlight.setLineWidth(2);
    lineSeriesDataList.add(lineSeriesData);
    /*
		 * Set series.
		 */
    addSeriesData(lineSeriesDataList);
    /*
		 * Set the labels.
		 */
    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.VERTICAL);
    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)

Aggregations

IChartSettings (org.eclipse.swtchart.extensions.core.IChartSettings)35 ArrayList (java.util.ArrayList)24 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)24 ILineSeriesData (org.eclipse.swtchart.extensions.linecharts.ILineSeriesData)15 ILineSeriesSettings (org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings)15 LineSeriesData (org.eclipse.swtchart.extensions.linecharts.LineSeriesData)15 DecimalFormat (java.text.DecimalFormat)14 DecimalFormatSymbols (java.text.DecimalFormatSymbols)14 IPrimaryAxisSettings (org.eclipse.swtchart.extensions.core.IPrimaryAxisSettings)14 RangeRestriction (org.eclipse.swtchart.extensions.core.RangeRestriction)8 Color (org.eclipse.swt.graphics.Color)7 ISecondaryAxisSettings (org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings)7 SecondaryAxisSettings (org.eclipse.swtchart.extensions.core.SecondaryAxisSettings)6 HashMap (java.util.HashMap)5 IPlotArea (org.eclipse.swtchart.IPlotArea)5 RelativeIntensityConverter (org.eclipse.swtchart.extensions.axisconverter.RelativeIntensityConverter)5 BarSeriesData (org.eclipse.swtchart.extensions.barcharts.BarSeriesData)5 IBarSeriesData (org.eclipse.swtchart.extensions.barcharts.IBarSeriesData)5 LabelMarker (org.eclipse.swtchart.extensions.marker.LabelMarker)5 IScatterSeriesData (org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesData)4