Search in sources :

Example 1 with PlotSymbolType

use of org.eclipse.swtchart.ILineSeries.PlotSymbolType in project swtchart by eclipse.

the class ScatterSeries_Preferences_Part method applySeriesSettings.

private void applySeriesSettings() {
    IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
    int symbolSize = preferenceStore.getInt(ScatterSeriesPreferenceConstants.P_SYMBOL_SIZE_SERIES);
    // 
    Color symbolColorSeriesLeftTop = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_LEFT_TOP));
    Color symbolColorSeriesRightTop = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_RIGHT_TOP));
    Color symbolColorSeriesLeftBottom = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_LEFT_BOTTOM));
    Color symbolColorSeriesRightBottom = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_RIGHT_BOTTOM));
    PlotSymbolType plotSymbolTypeLeftTop = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_LEFT_TOP));
    boolean isVisibleLeftTop = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_LEFT_TOP);
    PlotSymbolType plotSymbolTypeRightTop = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_RIGHT_TOP));
    boolean isVisibleRightTop = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_RIGHT_TOP);
    PlotSymbolType plotSymbolTypeLeftBottom = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_LEFT_BOTTOM));
    boolean isVisibleLeftBottom = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_LEFT_BOTTOM);
    PlotSymbolType plotSymbolTypeRightBottom = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_RIGHT_BOTTOM));
    boolean isVisibleRightBottom = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_RIGHT_BOTTOM);
    // 
    Color symbolColorSeriesLeftTopHighlight = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_HIGHLIGHT_LEFT_TOP));
    Color symbolColorSeriesRightTopHighlight = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_HIGHLIGHT_RIGHT_TOP));
    Color symbolColorSeriesLeftBottomHighlight = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_HIGHLIGHT_LEFT_BOTTOM));
    Color symbolColorSeriesRightBottomHighlight = getColor(PreferenceConverter.getColor(preferenceStore, ScatterSeriesPreferenceConstants.P_SYMBOL_COLOR_SERIES_HIGHLIGHT_RIGHT_BOTTOM));
    PlotSymbolType plotSymbolTypeLeftTopHighlight = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_HIGHLIGHT_LEFT_TOP));
    boolean isVisibleLeftTopHighlight = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_HIGHLIGHT_LEFT_TOP);
    PlotSymbolType plotSymbolTypeRightTopHighlight = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_HIGHLIGHT_RIGHT_TOP));
    boolean isVisibleRightTopHighlight = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_HIGHLIGHT_RIGHT_TOP);
    PlotSymbolType plotSymbolTypeLeftBottomHighlight = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_HIGHLIGHT_LEFT_BOTTOM));
    boolean isVisibleLeftBottomHighlight = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_HIGHLIGHT_LEFT_BOTTOM);
    PlotSymbolType plotSymbolTypeRightBottomHighlight = PlotSymbolType.valueOf(preferenceStore.getString(ScatterSeriesPreferenceConstants.P_SYMBOL_TYPE_SERIES_HIGHLIGHT_RIGHT_BOTTOM));
    boolean isVisibleRightBottomHighlight = preferenceStore.getBoolean(ScatterSeriesPreferenceConstants.P_VISIBLE_SERIES_HIGHLIGHT_RIGHT_BOTTOM);
    // 
    scatterChart.deleteSeries();
    /*
		 * Data
		 */
    List<ISeriesData> scatterSeriesList = SeriesConverter.getSeriesScatter(SeriesConverter.SCATTER_SERIES_1);
    List<IScatterSeriesData> scatterSeriesDataList = new ArrayList<IScatterSeriesData>();
    // 
    for (ISeriesData seriesData : scatterSeriesList) {
        IScatterSeriesData scatterSeriesData = new ScatterSeriesData(seriesData);
        IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
        IScatterSeriesSettings scatterSeriesSettingsHighlight = (IScatterSeriesSettings) scatterSeriesSettings.getSeriesSettingsHighlight();
        /*
			 * Set the color and symbol type.
			 */
        double x = seriesData.getXSeries()[0];
        double y = seriesData.getYSeries()[0];
        scatterSeriesSettings.setSymbolSize(symbolSize);
        scatterSeriesSettingsHighlight.setSymbolSize(symbolSize);
        // 
        if (x > 0 && y > 0) {
            scatterSeriesSettings.setSymbolColor(symbolColorSeriesRightTop);
            scatterSeriesSettings.setSymbolType(plotSymbolTypeRightTop);
            scatterSeriesSettings.setVisible(isVisibleRightTop);
            scatterSeriesSettingsHighlight.setSymbolColor(symbolColorSeriesRightTopHighlight);
            scatterSeriesSettingsHighlight.setSymbolType(plotSymbolTypeRightTopHighlight);
            scatterSeriesSettingsHighlight.setVisible(isVisibleRightTopHighlight);
        } else if (x > 0 && y < 0) {
            scatterSeriesSettings.setSymbolColor(symbolColorSeriesRightBottom);
            scatterSeriesSettings.setSymbolType(plotSymbolTypeRightBottom);
            scatterSeriesSettings.setVisible(isVisibleRightBottom);
            scatterSeriesSettingsHighlight.setSymbolColor(symbolColorSeriesRightBottomHighlight);
            scatterSeriesSettingsHighlight.setSymbolType(plotSymbolTypeRightBottomHighlight);
            scatterSeriesSettingsHighlight.setVisible(isVisibleRightBottomHighlight);
        } else if (x < 0 && y > 0) {
            scatterSeriesSettings.setSymbolColor(symbolColorSeriesLeftTop);
            scatterSeriesSettings.setSymbolType(plotSymbolTypeLeftTop);
            scatterSeriesSettings.setVisible(isVisibleLeftTop);
            scatterSeriesSettingsHighlight.setSymbolColor(symbolColorSeriesLeftTopHighlight);
            scatterSeriesSettingsHighlight.setSymbolType(plotSymbolTypeLeftTopHighlight);
            scatterSeriesSettingsHighlight.setVisible(isVisibleLeftTopHighlight);
        } else if (x < 0 && y < 0) {
            scatterSeriesSettings.setSymbolColor(symbolColorSeriesLeftBottom);
            scatterSeriesSettings.setSymbolType(plotSymbolTypeLeftBottom);
            scatterSeriesSettings.setVisible(isVisibleLeftBottom);
            scatterSeriesSettingsHighlight.setSymbolColor(symbolColorSeriesLeftBottomHighlight);
            scatterSeriesSettingsHighlight.setSymbolType(plotSymbolTypeLeftBottomHighlight);
            scatterSeriesSettingsHighlight.setVisible(isVisibleLeftBottomHighlight);
        }
        // 
        scatterSeriesDataList.add(scatterSeriesData);
    }
    // 
    scatterChart.addSeriesData(scatterSeriesDataList);
}
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) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) PlotSymbolType(org.eclipse.swtchart.ILineSeries.PlotSymbolType)

Example 2 with PlotSymbolType

use of org.eclipse.swtchart.ILineSeries.PlotSymbolType in project swtchart by eclipse.

the class SeriesPage method addLineSeriesGroup.

/**
 * Adds the line series group.
 *
 * @param parent
 *            the parent to add the line series group
 */
private void addLineSeriesGroup(Composite parent) {
    lineSeriesGroup = createGroupControl(parent, "Line series:", true);
    stackLayout.topControl = lineSeriesGroup;
    createLabelControl(lineSeriesGroup, "Line color:");
    lineColorButton = createColorButtonControl(lineSeriesGroup);
    lineColorButton.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            lineColors[selectedIndex] = lineColorButton.getColorValue();
        }
    });
    createLabelControl(lineSeriesGroup, "Line style:");
    LineStyle[] styles = LineStyle.values();
    String[] labels = new String[styles.length];
    for (int i = 0; i < styles.length; i++) {
        labels[i] = styles[i].label;
    }
    lineStyleCombo = createComboControl(lineSeriesGroup, labels);
    lineStyleCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String value = lineStyleCombo.getText();
            LineStyle selectedStyle = LineStyle.NONE;
            for (LineStyle style : LineStyle.values()) {
                if (style.label.equals(value)) {
                    selectedStyle = style;
                }
            }
            lineStyles[selectedIndex] = selectedStyle;
        }
    });
    createLabelControl(lineSeriesGroup, "Symbol color:");
    symbolColorButton = createColorButtonControl(lineSeriesGroup);
    symbolColorButton.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            symbolColors[selectedIndex] = symbolColorButton.getColorValue();
        }
    });
    createLabelControl(lineSeriesGroup, "Symbol type:");
    PlotSymbolType[] types = PlotSymbolType.values();
    labels = new String[types.length];
    for (int i = 0; i < types.length; i++) {
        labels[i] = types[i].label;
    }
    symbolTypeCombo = createComboControl(lineSeriesGroup, labels);
    symbolTypeCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String value = symbolTypeCombo.getText();
            PlotSymbolType selectedType = PlotSymbolType.CIRCLE;
            for (PlotSymbolType type : PlotSymbolType.values()) {
                if (type.label.equals(value)) {
                    selectedType = type;
                }
            }
            symbolTypes[selectedIndex] = selectedType;
        }
    });
    createLabelControl(lineSeriesGroup, "Symbol size:");
    symbolSizeSpinner = createSpinnerControl(lineSeriesGroup, 1, 10);
    symbolSizeSpinner.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            symbolSizes[selectedIndex] = symbolSizeSpinner.getSelection();
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) LineStyle(org.eclipse.swtchart.LineStyle) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PlotSymbolType(org.eclipse.swtchart.ILineSeries.PlotSymbolType)

Aggregations

PlotSymbolType (org.eclipse.swtchart.ILineSeries.PlotSymbolType)2 ArrayList (java.util.ArrayList)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Color (org.eclipse.swt.graphics.Color)1 LineStyle (org.eclipse.swtchart.LineStyle)1 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)1 IScatterSeriesData (org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesData)1 IScatterSeriesSettings (org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesSettings)1 ScatterSeriesData (org.eclipse.swtchart.extensions.scattercharts.ScatterSeriesData)1