Search in sources :

Example 11 with Range

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

the class Axis method zoomOut.

/*
	 * @see IAxis#zoomOut(double)
	 */
public void zoomOut(double coordinate) {
    double lower = min;
    double upper = max;
    if (isValidCategoryAxis()) {
        if ((min + max) / 2d < coordinate && min != 0) {
            lower = min - 1;
        } else if (coordinate < (min + max) / 2d && max != categorySeries.length - 1) {
            upper = max + 1;
        } else {
            lower = min - 1;
            upper = max + 1;
        }
    } else if (isLogScaleEnabled()) {
        double digitMin = Math.log10(min);
        double digitMax = Math.log10(max);
        double digitCoordinate = Math.log10(coordinate);
        lower = Math.pow(10, (digitMin - ZOOM_RATIO * digitCoordinate) / (1 - ZOOM_RATIO));
        upper = Math.pow(10, (digitMax - ZOOM_RATIO * digitCoordinate) / (1 - ZOOM_RATIO));
    } else {
        lower = (min - 2 * ZOOM_RATIO * coordinate) / (1 - 2 * ZOOM_RATIO);
        upper = (max - 2 * ZOOM_RATIO * coordinate) / (1 - 2 * ZOOM_RATIO);
    }
    setRange(new Range(lower, upper));
}
Also used : Range(org.eclipse.swtchart.Range)

Example 12 with Range

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

the class Axis method scrollUp.

/*
	 * @see IAxis#scrollUp()
	 */
public void scrollUp() {
    double lower = min;
    double upper = max;
    if (isValidCategoryAxis()) {
        if (upper < categorySeries.length - 1) {
            lower = min + 1;
            upper = max + 1;
        }
    } else if (isLogScaleEnabled()) {
        double digitMax = Math.log10(upper);
        double digitMin = Math.log10(lower);
        upper = Math.pow(10, digitMax + (digitMax - digitMin) * SCROLL_RATIO);
        lower = Math.pow(10, digitMin + (digitMax - digitMin) * SCROLL_RATIO);
    } else {
        lower = min + (max - min) * SCROLL_RATIO;
        upper = max + (max - min) * SCROLL_RATIO;
    }
    setRange(new Range(lower, upper));
}
Also used : Range(org.eclipse.swtchart.Range)

Example 13 with Range

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

the class Axis method scrollDown.

/*
	 * @see IAxis#scrollDown()
	 */
public void scrollDown() {
    double lower = min;
    double upper = max;
    if (isValidCategoryAxis()) {
        if (lower >= 1) {
            lower = min - 1;
            upper = max - 1;
        }
    } else if (isLogScaleEnabled()) {
        double digitMax = Math.log10(upper);
        double digitMin = Math.log10(lower);
        upper = Math.pow(10, digitMax - (digitMax - digitMin) * SCROLL_RATIO);
        lower = Math.pow(10, digitMin - (digitMax - digitMin) * SCROLL_RATIO);
    } else {
        lower = min - (max - min) * SCROLL_RATIO;
        upper = max - (max - min) * SCROLL_RATIO;
    }
    setRange(new Range(lower, upper));
}
Also used : Range(org.eclipse.swtchart.Range)

Example 14 with Range

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

the class LineSeries method getAdjustedRange.

/*
	 * @see Series#getAdjustedRange(Axis, int)
	 */
@Override
public Range getAdjustedRange(Axis axis, int length) {
    Range range;
    if (axis.getDirection() == Direction.X) {
        range = getXRange();
    } else {
        range = getYRange();
    }
    int lowerPlotMargin = getSymbolSize() + MARGIN_AT_MIN_MAX_PLOT;
    int upperPlotMargin = getSymbolSize() + MARGIN_AT_MIN_MAX_PLOT;
    return getRangeWithMargin(lowerPlotMargin, upperPlotMargin, length, axis, range);
}
Also used : Range(org.eclipse.swtchart.Range)

Example 15 with Range

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

the class Series method getRangeWithMargin.

/**
 * Gets the range with given margin.
 *
 * @param lowerPlotMargin
 *            the lower margin in pixels
 * @param upperPlotMargin
 *            the upper margin in pixels
 * @param length
 *            the axis length in pixels
 * @param axis
 *            the axis
 * @param range
 *            the range
 * @return the range with margin
 */
protected Range getRangeWithMargin(int lowerPlotMargin, int upperPlotMargin, int length, Axis axis, Range range) {
    if (length == 0) {
        return range;
    }
    int lowerPixelCoordinate = axis.getPixelCoordinate(range.lower, range.lower, range.upper) + lowerPlotMargin * (axis.isHorizontalAxis() ? -1 : 1);
    int upperPixelCoordinate = axis.getPixelCoordinate(range.upper, range.lower, range.upper) + upperPlotMargin * (axis.isHorizontalAxis() ? 1 : -1);
    double lower = axis.getDataCoordinate(lowerPixelCoordinate, range.lower, range.upper);
    double upper = axis.getDataCoordinate(upperPixelCoordinate, range.lower, range.upper);
    return new Range(lower, upper);
}
Also used : Range(org.eclipse.swtchart.Range) Point(org.eclipse.swt.graphics.Point)

Aggregations

Range (org.eclipse.swtchart.Range)53 IAxis (org.eclipse.swtchart.IAxis)20 Point (org.eclipse.swt.graphics.Point)13 ISeries (org.eclipse.swtchart.ISeries)9 GridData (org.eclipse.swt.layout.GridData)5 IAxisSet (org.eclipse.swtchart.IAxisSet)5 DecimalFormat (java.text.DecimalFormat)4 StyleRange (org.eclipse.swt.custom.StyleRange)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Event (org.eclipse.swt.widgets.Event)4 MouseEvent (org.eclipse.swt.events.MouseEvent)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Chart (org.eclipse.swtchart.Chart)3 ISeriesSet (org.eclipse.swtchart.ISeriesSet)3 AxisRange (org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange)3 ParseException (java.text.ParseException)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 PaintListener (org.eclipse.swt.events.PaintListener)2 Color (org.eclipse.swt.graphics.Color)2