Search in sources :

Example 1 with Range

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

the class AbstractExtendedChart method adjustMinMaxRange.

@Override
public void adjustMinMaxRange(IAxis axis) {
    if (axis != null && !isUpdateSuspended()) {
        Range range = axis.getRange();
        if (axis.getDirection().equals(Direction.X)) {
            /*
				 * X-AXIS
				 */
            if (rangeRestriction.isZeroX()) {
                range.lower = (range.lower < 0) ? 0 : range.lower;
            } else {
                range.lower = (range.lower < minX) ? minX : range.lower;
            }
            extendRange(IExtendedChart.X_AXIS, range, extendedMinX, extendedMaxX, rangeRestriction.getExtendMinX(), rangeRestriction.getExtendMaxX());
        } else {
            /*
				 * Y-AXIS
				 */
            if (rangeRestriction.isForceZeroMinY()) {
                range.lower = 0.0d;
            } else {
                if (rangeRestriction.isZeroY()) {
                    range.lower = (range.lower < 0) ? 0 : range.lower;
                } else {
                    range.lower = (range.lower < minY) ? minY : range.lower;
                }
            }
            // 
            extendRange(IExtendedChart.Y_AXIS, range, extendedMinY, extendedMaxY, rangeRestriction.getExtendMinY(), rangeRestriction.getExtendMaxY());
        }
        /*
			 * Adjust the range.
			 */
        axis.setRange(range);
    }
}
Also used : Range(org.eclipse.swtchart.Range)

Example 2 with Range

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

the class AbstractExtendedChart method adjustSecondaryXAxes.

@Override
public void adjustSecondaryXAxes() {
    IAxisSet axisSet = getAxisSet();
    IAxis xAxis = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
    Range range = xAxis.getRange();
    for (int id : axisSet.getXAxisIds()) {
        if (id != BaseChart.ID_PRIMARY_X_AXIS) {
            IAxis axis = axisSet.getXAxis(id);
            IAxisSettings axisSettings = xAxisSettingsMap.get(id);
            if (axis != null && axisSettings instanceof ISecondaryAxisSettings) {
                IAxisScaleConverter axisScaleConverter = ((ISecondaryAxisSettings) axisSettings).getAxisScaleConverter();
                axisScaleConverter.setChartDataCoordinates(this);
                double start = axisScaleConverter.convertToSecondaryUnit(range.lower);
                double end = axisScaleConverter.convertToSecondaryUnit(range.upper);
                if (end > start) {
                    Range adjustedRange = new Range(start, end);
                    axis.setRange(adjustedRange);
                } else {
                    System.out.println("Can't set secondary x axes range: " + start + "\t" + end);
                }
            }
        }
    }
}
Also used : IAxisSet(org.eclipse.swtchart.IAxisSet) Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis)

Example 3 with Range

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

the class BaseChart method trackUndoSelection.

private void trackUndoSelection() {
    Range xRange = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS).getRange();
    Range yRange = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS).getRange();
    handledSelectionEvents.push(new double[] { xRange.lower, xRange.upper, yRange.lower, yRange.upper });
}
Also used : Range(org.eclipse.swtchart.Range)

Example 4 with Range

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

the class InteractiveChart method setRange.

/**
 * Sets the axis range.
 *
 * @param range
 *            the axis range in pixels
 * @param axis
 *            the axis to set range
 */
private void setRange(Point range, IAxis axis) {
    if (range == null) {
        return;
    }
    double min = axis.getDataCoordinate(range.x);
    double max = axis.getDataCoordinate(range.y);
    axis.setRange(new Range(min, max));
}
Also used : Range(org.eclipse.swtchart.Range)

Example 5 with Range

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

the class BaseChart method trackRedoSelection.

private void trackRedoSelection() {
    Range xRange = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS).getRange();
    Range yRange = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS).getRange();
    redoSelection = new double[] { xRange.lower, xRange.upper, yRange.lower, yRange.upper };
}
Also used : Range(org.eclipse.swtchart.Range)

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