Search in sources :

Example 21 with BaseChart

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

the class LineSeries_Selection_Part method initialize.

private void initialize() throws Exception {
    this.setLayout(new GridLayout(1, true));
    this.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // 
    Composite compositeInfo = new Composite(this, SWT.NONE);
    GridData gridDataComposite = new GridData(GridData.FILL_HORIZONTAL);
    gridDataComposite.horizontalAlignment = SWT.BEGINNING;
    compositeInfo.setLayoutData(gridDataComposite);
    compositeInfo.setLayout(new GridLayout(13, false));
    // 
    createLabel(compositeInfo, "X-Start:");
    textRangeXStart = createText(compositeInfo);
    createLabel(compositeInfo, "X-Stop:");
    textRangeXStop = createText(compositeInfo);
    createLabel(compositeInfo, "Y-Start:");
    textRangeYStart = createText(compositeInfo);
    createLabel(compositeInfo, "Y-Stop:");
    textRangeYStop = createText(compositeInfo);
    createLabel(compositeInfo, "X:");
    textX = createText(compositeInfo);
    createLabel(compositeInfo, "Y:");
    textY = createText(compositeInfo);
    createButtonReset(compositeInfo);
    // 
    lineChart = new LineChart(this, SWT.NONE);
    lineChart.setLayoutData(new GridData(GridData.FILL_BOTH));
    lineChart.getBaseChart().addCustomRangeSelectionHandler(new ICustomSelectionHandler() {

        @Override
        public void handleUserSelection(Event event) {
            BaseChart baseChart = lineChart.getBaseChart();
            Range rangeX = baseChart.getAxisSet().getXAxis(BaseChart.ID_PRIMARY_X_AXIS).getRange();
            Range rangeY = baseChart.getAxisSet().getYAxis(BaseChart.ID_PRIMARY_Y_AXIS).getRange();
            DecimalFormat decimalFormatX = baseChart.getDecimalFormat(IExtendedChart.X_AXIS, BaseChart.ID_PRIMARY_X_AXIS);
            DecimalFormat decimalFormatY = baseChart.getDecimalFormat(IExtendedChart.Y_AXIS, BaseChart.ID_PRIMARY_Y_AXIS);
            textRangeXStart.setText(decimalFormatX.format(rangeX.lower));
            textRangeXStop.setText(decimalFormatX.format(rangeX.upper));
            textRangeYStart.setText(decimalFormatY.format(rangeY.lower));
            textRangeYStop.setText(decimalFormatY.format(rangeY.upper));
        }
    });
    lineChart.getBaseChart().addCustomPointSelectionHandler(new ICustomSelectionHandler() {

        @Override
        public void handleUserSelection(Event event) {
            BaseChart baseChart = lineChart.getBaseChart();
            double x = baseChart.getSelectedPrimaryAxisValue(event.x, IExtendedChart.X_AXIS);
            double y = baseChart.getSelectedPrimaryAxisValue(event.y, IExtendedChart.Y_AXIS);
            // 
            DecimalFormat decimalFormatX = baseChart.getDecimalFormat(IExtendedChart.X_AXIS, BaseChart.ID_PRIMARY_X_AXIS);
            DecimalFormat decimalFormatY = baseChart.getDecimalFormat(IExtendedChart.Y_AXIS, BaseChart.ID_PRIMARY_Y_AXIS);
            textX.setText(decimalFormatX.format(x));
            textY.setText(decimalFormatY.format(y));
            // 
            try {
                ISeries series = baseChart.getSeriesSet().getSeries(DATA_POINT_SERIES);
                double xSelected = xValues.floor(x);
                double ySelected = yValues.get(xSelected);
                double[] xSeries = new double[] { xSelected };
                double[] ySeries = new double[] { ySelected };
                series.setXSeries(xSeries);
                series.setYSeries(ySeries);
                baseChart.redraw();
            } catch (Exception e) {
            // 
            }
        }
    });
    applyChartSettings();
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ICustomSelectionHandler(org.eclipse.swtchart.extensions.core.ICustomSelectionHandler) DecimalFormat(java.text.DecimalFormat) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Range(org.eclipse.swtchart.Range) ISeries(org.eclipse.swtchart.ISeries) LineChart(org.eclipse.swtchart.extensions.linecharts.LineChart)

Example 22 with BaseChart

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

the class LineSeries_Edit_Part method setComboAxisItems.

public void setComboAxisItems() {
    /*
		 * X Axes
		 */
    BaseChart baseChart = chromatogramChart.getBaseChart();
    String[] axisLabelsX = baseChart.getAxisLabels(IExtendedChart.X_AXIS);
    comboScaleX.setItems(axisLabelsX);
    if (axisLabelsX.length > 0) {
        // "Minutes"
        int selectedIndex = 1;
        if (selectedIndex >= 0 && selectedIndex < axisLabelsX.length) {
            comboScaleX.select(selectedIndex);
            textShiftX.setText("0.5");
        } else {
            // Milliseconds
            comboScaleX.select(0);
            textShiftX.setText("10000");
        }
    }
    /*
		 * Y Axes
		 */
    String[] axisLabelsY = baseChart.getAxisLabels(IExtendedChart.Y_AXIS);
    comboScaleY.setItems(axisLabelsY);
    if (axisLabelsY.length > 0) {
        // "Relative Intensity [%]"
        int selectedIndex = 1;
        if (selectedIndex >= 0 && selectedIndex < axisLabelsY.length) {
            comboScaleY.select(selectedIndex);
            textShiftY.setText("1.2");
        } else {
            // Intensity
            comboScaleY.select(0);
            textShiftY.setText("100000");
        }
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart)

Example 23 with BaseChart

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

the class LineSeries_Edit_Part method selectSeries.

private void selectSeries() {
    BaseChart baseChart = chromatogramChart.getBaseChart();
    String selectedSeriesId = comboSelectSeries.getText().trim();
    baseChart.resetSeriesSettings();
    baseChart.selectSeries(selectedSeriesId);
    baseChart.redraw();
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart)

Example 24 with BaseChart

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

the class LineSeries_Edit_Part method setShiftConstraints.

private void setShiftConstraints() {
    // int shiftConstraints = shiftConstraintSelection | shiftConstraintDeleteX | shiftConstraintDeleteY | shiftConstraintClinchX | shiftConstraintStretchX | shiftConstraintBroadenX | shiftConstraintNarrowX;
    int shiftConstraints = shiftConstraintDeleteX | shiftConstraintDeleteY;
    BaseChart baseChart = chromatogramChart.getBaseChart();
    baseChart.setShiftConstraints(shiftConstraints);
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart)

Example 25 with BaseChart

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

the class LineSeries_Edit_Part method createButtonUp.

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            BaseChart baseChart = chromatogramChart.getBaseChart();
            double shiftY = getShift(IExtendedChart.Y_AXIS);
            String selectedSeriesId = comboSelectSeries.getText().trim();
            baseChart.shiftSeries(selectedSeriesId, 0.0d, shiftY);
            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)

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