Search in sources :

Example 1 with IAxisSet

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

the class ScrollableChart method addPrimaryAxisY.

private void addPrimaryAxisY(IChartSettings chartSettings) {
    IAxisSet axisSet = baseChart.getAxisSet();
    IAxis yAxisPrimary = axisSet.getYAxis(BaseChart.ID_PRIMARY_Y_AXIS);
    IPrimaryAxisSettings primaryAxisSettings = chartSettings.getPrimaryAxisSettingsY();
    setAxisSettings(yAxisPrimary, primaryAxisSettings);
    baseChart.putYAxisSettings(BaseChart.ID_PRIMARY_Y_AXIS, primaryAxisSettings);
}
Also used : IAxisSet(org.eclipse.swtchart.IAxisSet) IAxis(org.eclipse.swtchart.IAxis)

Example 2 with IAxisSet

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

the class ScrollableChart method addSecondaryAxesY.

private void addSecondaryAxesY(IChartSettings chartSettings) {
    IAxisSet axisSet = baseChart.getAxisSet();
    for (int id : axisSet.getYAxisIds()) {
        if (id != BaseChart.ID_PRIMARY_Y_AXIS) {
            axisSet.deleteYAxis(id);
        }
    }
    /*
		 * Remove all items except the primary axis settings.
		 */
    baseChart.removeYAxisSettings();
    /*
		 * Add the axis settings.
		 */
    for (ISecondaryAxisSettings secondaryAxisSettings : chartSettings.getSecondaryAxisSettingsListY()) {
        int yAxisId = axisSet.createYAxis();
        IAxis yAxisSecondary = axisSet.getYAxis(yAxisId);
        setAxisSettings(yAxisSecondary, secondaryAxisSettings);
        baseChart.putYAxisSettings(yAxisId, secondaryAxisSettings);
    }
}
Also used : IAxisSet(org.eclipse.swtchart.IAxisSet) Point(org.eclipse.swt.graphics.Point) IAxis(org.eclipse.swtchart.IAxis)

Example 3 with IAxisSet

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

the class AbstractExtendedChart method setRange.

@Override
public void setRange(String axis, double start, double stop) {
    IAxisSet axisSet = getAxisSet();
    IAxis selectedAxis = (axis.equals(IExtendedChart.X_AXIS)) ? axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS) : axisSet.getYAxis(BaseChart.ID_PRIMARY_Y_AXIS);
    setRange(selectedAxis, start, stop, true);
}
Also used : IAxisSet(org.eclipse.swtchart.IAxisSet) IAxis(org.eclipse.swtchart.IAxis)

Example 4 with IAxisSet

use of org.eclipse.swtchart.IAxisSet 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 5 with IAxisSet

use of org.eclipse.swtchart.IAxisSet 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)

Aggregations

IAxisSet (org.eclipse.swtchart.IAxisSet)12 IAxis (org.eclipse.swtchart.IAxis)11 Range (org.eclipse.swtchart.Range)5 Point (org.eclipse.swt.graphics.Point)4 Chart (org.eclipse.swtchart.Chart)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 MassifSnapshot (org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Color (org.eclipse.swt.graphics.Color)1 Font (org.eclipse.swt.graphics.Font)1 FontData (org.eclipse.swt.graphics.FontData)1 GC (org.eclipse.swt.graphics.GC)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Control (org.eclipse.swt.widgets.Control)1 IAxisTick (org.eclipse.swtchart.IAxisTick)1 ILineSeries (org.eclipse.swtchart.ILineSeries)1 ITitle (org.eclipse.swtchart.ITitle)1