Search in sources :

Example 6 with BaseChart

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

the class LineChart method addSeriesData.

/**
 * The data is compressed to the given length.
 * If you're unsure which length to set, then use one of the following variables:
 *
 * HIGH_COMPRESSION
 * MEDIUM_COMPRESSION
 * LOW_COMPRESSION
 * NO_COMPRESSION
 *
 * @param lineSeriesDataList
 * @param compressToLength
 */
public void addSeriesData(List<ILineSeriesData> lineSeriesDataList, int compressToLength) {
    /*
		 * Suspend the update when adding new data to improve the performance.
		 */
    if (lineSeriesDataList != null && lineSeriesDataList.size() > 0) {
        BaseChart baseChart = getBaseChart();
        baseChart.suspendUpdate(true);
        for (ILineSeriesData lineSeriesData : lineSeriesDataList) {
            /*
				 * Get the series data and apply the settings.
				 */
            try {
                ISeriesData seriesData = lineSeriesData.getSeriesData();
                ISeriesData optimizedSeriesData = calculateSeries(seriesData, compressToLength);
                ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
                // Initialize
                lineSeriesSettings.getSeriesSettingsHighlight();
                ILineSeries lineSeries = (ILineSeries) createSeries(optimizedSeriesData, lineSeriesSettings);
                baseChart.applyLineSeriesSettings(lineSeries, lineSeriesSettings);
            } catch (SeriesException e) {
            // 
            }
        }
        baseChart.suspendUpdate(false);
        adjustRange(true);
        baseChart.redraw();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeries(org.eclipse.swtchart.ILineSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Example 7 with BaseChart

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

the class ScatterChart method addSeriesData.

public void addSeriesData(List<IScatterSeriesData> scatterSeriesDataList) {
    /*
		 * Suspend the update when adding new data to improve the performance.
		 */
    if (scatterSeriesDataList != null && scatterSeriesDataList.size() > 0) {
        /*
			 * Set the data.
			 */
        BaseChart baseChart = getBaseChart();
        baseChart.suspendUpdate(true);
        for (IScatterSeriesData scatterSeriesData : scatterSeriesDataList) {
            /*
				 * Get the series data and apply the settings.
				 */
            try {
                ISeriesData seriesData = scatterSeriesData.getSeriesData();
                ISeriesData optimizedSeriesData = calculateSeries(seriesData, ScrollableChart.NO_COMPRESS_TO_LENGTH);
                IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
                // Initialize
                scatterSeriesSettings.getSeriesSettingsHighlight();
                ILineSeries scatterSeries = (ILineSeries) createSeries(optimizedSeriesData, scatterSeriesSettings);
                baseChart.applyScatterSeriesSettings(scatterSeries, scatterSeriesSettings);
            } catch (SeriesException e) {
            // 
            }
        }
        baseChart.suspendUpdate(false);
        adjustRange(true);
        baseChart.redraw();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeries(org.eclipse.swtchart.ILineSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Example 8 with BaseChart

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

the class ScatterSeries_Edit_Part method initialize.

private void initialize() {
    this.setLayout(new GridLayout(1, true));
    tabFolder = new TabFolder(this, SWT.BOTTOM);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    tabFolder.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    tabFolder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int index = tabFolder.getSelectionIndex();
            if (index == 1) {
                table.removeAll();
                BaseChart baseChart = handledChart.getBaseChart();
                for (String selectedSeriesId : baseChart.getSelectedSeriesIds()) {
                    addTableRow(table, selectedSeriesId);
                }
            }
        }
    });
    createChartTabItem();
    createTableTabItems();
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 9 with BaseChart

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

the class LineSeries_Edit_Part method createButtonRight.

private void createButtonRight(Composite parent) {
    Button button = new Button(parent, SWT.PUSH);
    button.setToolTipText("Move Right");
    button.setText(Activator.getDefault() != null ? "" : "Move Right");
    button.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_RIGHT) : null);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            BaseChart baseChart = chromatogramChart.getBaseChart();
            double shiftX = getShift(IExtendedChart.X_AXIS);
            String selectedSeriesId = comboSelectSeries.getText().trim();
            baseChart.shiftSeries(selectedSeriesId, shiftX, 0.0d);
            baseChart.redraw();
        }
    });
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 10 with BaseChart

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

the class LineSeries_Edit_Part method getShift.

private double getShift(String axis) {
    double shiftValue = 0.0d;
    try {
        /*
			 * Try to calculate the primary unit.
			 */
        BaseChart baseChart = chromatogramChart.getBaseChart();
        DecimalFormat decimalFormat;
        int selectedAxis;
        // 
        if (axis.equals(IExtendedChart.X_AXIS)) {
            selectedAxis = comboScaleX.getSelectionIndex();
            decimalFormat = baseChart.getDecimalFormat(IExtendedChart.X_AXIS, selectedAxis);
        } else {
            selectedAxis = comboScaleY.getSelectionIndex();
            decimalFormat = baseChart.getDecimalFormat(IExtendedChart.Y_AXIS, selectedAxis);
        }
        // 
        double secondaryValue;
        if (axis.equals(IExtendedChart.X_AXIS)) {
            secondaryValue = decimalFormat.parse(textShiftX.getText().trim()).doubleValue();
        } else {
            secondaryValue = decimalFormat.parse(textShiftY.getText().trim()).doubleValue();
        }
        /*
			 * Convert the range on demand.
			 */
        if (selectedAxis == 0) {
            shiftValue = secondaryValue;
        } else {
            IAxisScaleConverter axisScaleConverter = baseChart.getAxisScaleConverter(axis, selectedAxis);
            shiftValue = axisScaleConverter.convertToPrimaryUnit(secondaryValue);
        }
    } catch (ParseException e) {
        System.out.println(e);
    }
    // 
    return shiftValue;
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) DecimalFormat(java.text.DecimalFormat) IAxisScaleConverter(org.eclipse.swtchart.extensions.core.IAxisScaleConverter) ParseException(java.text.ParseException)

Aggregations

BaseChart (org.eclipse.swtchart.extensions.core.BaseChart)28 Point (org.eclipse.swt.graphics.Point)8 ISeries (org.eclipse.swtchart.ISeries)8 IAxisSettings (org.eclipse.swtchart.extensions.core.IAxisSettings)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 IAxisScaleConverter (org.eclipse.swtchart.extensions.core.IAxisScaleConverter)6 Button (org.eclipse.swt.widgets.Button)5 File (java.io.File)4 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)4 FileNotFoundException (java.io.FileNotFoundException)3 PrintWriter (java.io.PrintWriter)3 FileDialog (org.eclipse.swt.widgets.FileDialog)3 ISecondaryAxisSettings (org.eclipse.swtchart.extensions.core.ISecondaryAxisSettings)3 SeriesException (org.eclipse.swtchart.extensions.exceptions.SeriesException)3 DecimalFormat (java.text.DecimalFormat)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 ILineSeries (org.eclipse.swtchart.ILineSeries)2