Search in sources :

Example 11 with IAxis

use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.

the class BaseChart method setSelectionXY.

private void setSelectionXY(int xStart, int xStop, int yStart, int yStop) {
    IAxis xAxis = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS);
    IAxis yAxis = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS);
    // 
    if ((getOrientation() == SWT.HORIZONTAL)) {
        setHorizontalRange(xAxis, yAxis, xStart, xStop, yStart, yStop);
    } else {
        setVerticalRange(xAxis, yAxis, xStart, xStop, yStart, yStop);
    }
}
Also used : IAxis(org.eclipse.swtchart.IAxis)

Example 12 with IAxis

use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.

the class RangeSelector method adjustRanges.

public void adjustRanges(boolean redraw) {
    BaseChart baseChart = scrollableChart.getBaseChart();
    // 
    int indexX = (comboScaleX.getSelectionIndex() >= 0) ? comboScaleX.getSelectionIndex() : BaseChart.ID_PRIMARY_X_AXIS;
    int indexY = (comboScaleY.getSelectionIndex() >= 0) ? comboScaleY.getSelectionIndex() : BaseChart.ID_PRIMARY_Y_AXIS;
    IAxis xAxis = baseChart.getAxisSet().getXAxis(indexX);
    IAxis yAxis = baseChart.getAxisSet().getYAxis(indexY);
    Range rangeX = xAxis.getRange();
    Range rangeY = yAxis.getRange();
    // 
    DecimalFormat decimalFormatX = baseChart.getDecimalFormat(IExtendedChart.X_AXIS, indexX);
    DecimalFormat decimalFormatY = baseChart.getDecimalFormat(IExtendedChart.Y_AXIS, indexY);
    // 
    if (rangeX != null && rangeY != null) {
        /*
			 * Update the text boxes.
			 */
        textStartX.setText(decimalFormatX.format(rangeX.lower));
        textStopX.setText(decimalFormatX.format(rangeX.upper));
        textStartY.setText(decimalFormatY.format(rangeY.lower));
        textStopY.setText(decimalFormatY.format(rangeY.upper));
        /*
			 * Redraw the base chart.
			 */
        if (redraw) {
            baseChart.redraw();
        }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis)

Example 13 with IAxis

use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.

the class ZoomEvent method handleEvent.

@Override
public void handleEvent(BaseChart baseChart, Event event) {
    IAxisSet axisSet = baseChart.getAxisSet();
    IAxis xAxis = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
    IAxis yAxis = axisSet.getYAxis(BaseChart.ID_PRIMARY_Y_AXIS);
    // 
    RangeRestriction rangeRestriction = baseChart.getRangeRestriction();
    if (baseChart.isZoomXAndY(rangeRestriction)) {
        /*
			 * X and Y zoom.
			 */
        baseChart.zoomX(xAxis, event);
        baseChart.zoomY(yAxis, event);
    } else {
        /*
			 * X or Y zoom.
			 */
        if (rangeRestriction.isXZoomOnly()) {
            baseChart.zoomX(xAxis, event);
        } else if (rangeRestriction.isYZoomOnly()) {
            baseChart.zoomY(yAxis, event);
        }
    }
    /*
		 * Adjust the range if it shall not exceed the initial
		 * min and max values.
		 */
    if (rangeRestriction.isRestrictZoom()) {
        /*
			 * Adjust the primary axes.
			 * The secondary axes are adjusted by setting the range.
			 */
        Range rangeX = xAxis.getRange();
        Range rangeY = yAxis.getRange();
        baseChart.setRange(xAxis, rangeX.lower, rangeX.upper, true);
        baseChart.setRange(yAxis, rangeY.lower, rangeY.upper, true);
    } else {
        /*
			 * Update the secondary axes.
			 */
        baseChart.adjustSecondaryXAxes();
        baseChart.adjustSecondaryYAxes();
    }
    // 
    baseChart.fireUpdateCustomRangeSelectionHandlers(event);
    baseChart.redraw();
}
Also used : IAxisSet(org.eclipse.swtchart.IAxisSet) RangeRestriction(org.eclipse.swtchart.extensions.core.RangeRestriction) Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis)

Example 14 with IAxis

use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.

the class Series method setXAxisId.

/*
	 * @see ISeries#setXAxisId(int)
	 */
public void setXAxisId(int id) {
    if (xAxisId == id) {
        return;
    }
    IAxis axis = chart.getAxisSet().getXAxis(xAxisId);
    if (minX <= 0 && axis != null && axis.isLogScaleEnabled()) {
        chart.getAxisSet().getXAxis(xAxisId).enableLogScale(false);
    }
    xAxisId = id;
    ((SeriesSet) chart.getSeriesSet()).updateStackAndRiserData();
}
Also used : IAxis(org.eclipse.swtchart.IAxis)

Example 15 with IAxis

use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.

the class Series method setXSeries.

/*
	 * @see ISeries#setXSeries(double[])
	 */
public void setXSeries(double[] series) {
    if (series == null) {
        SWT.error(SWT.ERROR_NULL_ARGUMENT);
        // to suppress warning...
        return;
    }
    xSeries = new double[series.length];
    System.arraycopy(series, 0, xSeries, 0, series.length);
    isDateSeries = false;
    if (xSeries.length == 0) {
        return;
    }
    // find the min and max value of x series
    minX = xSeries[0];
    maxX = xSeries[0];
    for (int i = 1; i < xSeries.length; i++) {
        if (minX > xSeries[i]) {
            minX = xSeries[i];
        }
        if (maxX < xSeries[i]) {
            maxX = xSeries[i];
        }
        if (xSeries[i - 1] > xSeries[i]) {
            isXMonotoneIncreasing = false;
        }
    }
    setCompressor();
    compressor.setXSeries(xSeries);
    compressor.setYSeries(ySeries);
    if (minX <= 0) {
        IAxis axis = chart.getAxisSet().getXAxis(xAxisId);
        if (axis != null) {
            axis.enableLogScale(false);
        }
    }
}
Also used : Point(org.eclipse.swt.graphics.Point) IAxis(org.eclipse.swtchart.IAxis)

Aggregations

IAxis (org.eclipse.swtchart.IAxis)64 Point (org.eclipse.swt.graphics.Point)27 Range (org.eclipse.swtchart.Range)19 IAxisSet (org.eclipse.swtchart.IAxisSet)10 Chart (org.eclipse.swtchart.Chart)7 ISeries (org.eclipse.swtchart.ISeries)7 MouseEvent (org.eclipse.swt.events.MouseEvent)5 ILineSeries (org.eclipse.swtchart.ILineSeries)5 Color (org.eclipse.swt.graphics.Color)4 GridData (org.eclipse.swt.layout.GridData)4 DecimalFormat (java.text.DecimalFormat)3 PaintEvent (org.eclipse.swt.events.PaintEvent)3 PaintListener (org.eclipse.swt.events.PaintListener)3 GC (org.eclipse.swt.graphics.GC)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Composite (org.eclipse.swt.widgets.Composite)3 IBarSeries (org.eclipse.swtchart.IBarSeries)3 ITitle (org.eclipse.swtchart.ITitle)3 Axis (org.eclipse.swtchart.internal.axis.Axis)3 StyleRange (org.eclipse.swt.custom.StyleRange)2