Search in sources :

Example 51 with ISeries

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

the class BaseChart method multiplySeries.

/**
 * axisId = IExtendedChart.X_AXIS or IExtendedChart.Y_AXIS.
 *
 * @param selectedSeriesId
 * @param axisId
 * @param factor
 */
public void multiplySeries(String selectedSeriesId, String axisId, double factor) {
    ISeries dataSeries = getSeriesSet().getSeries(selectedSeriesId);
    if (dataSeries != null) {
        // 
        double[] xSeries = dataSeries.getXSeries();
        double[] ySeries = dataSeries.getYSeries();
        // 
        if (IExtendedChart.X_AXIS.equals(axisId)) {
            dataSeries.setXSeries(multiplySeries(xSeries, factor));
        } else if (IExtendedChart.Y_AXIS.equals(axisId)) {
            dataSeries.setYSeries(multiplySeries(ySeries, factor));
        }
        // 
        double seriesMinX = Arrays.stream(xSeries).min().getAsDouble();
        double seriesMaxX = Arrays.stream(xSeries).max().getAsDouble();
        double seriesMinY = Arrays.stream(ySeries).min().getAsDouble();
        double seriesMaxY = Arrays.stream(ySeries).max().getAsDouble();
        // 
        updateCoordinates(seriesMinX, seriesMaxX, seriesMinY, seriesMaxY);
        fireSeriesModificationEvent();
    }
}
Also used : ISeries(org.eclipse.swtchart.ISeries)

Example 52 with ISeries

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

the class BaseChart method selectSeries.

public void selectSeries(String selectedSeriesId, boolean fireUpdate) {
    if (isSeriesContained(selectedSeriesId)) {
        ISeries dataSeries = getSeriesSet().getSeries(selectedSeriesId);
        ISeriesSettings seriesSettings = getSeriesSettings(selectedSeriesId);
        selectedSeriesIds.add(selectedSeriesId);
        applySeriesSettings(dataSeries, seriesSettings.getSeriesSettingsHighlight());
        if (fireUpdate) {
            fireSeriesStatusEvent(selectedSeriesId, ISeriesStatusListener.SELECT);
        }
    }
}
Also used : ISeries(org.eclipse.swtchart.ISeries)

Example 53 with ISeries

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

the class BaseChart method shiftSeries.

public void shiftSeries(String selectedSeriesId, double shiftX, double shiftY) {
    ISeries dataSeries = getSeriesSet().getSeries(selectedSeriesId);
    if (dataSeries != null) {
        // 
        if (shiftX != 0.0d || shiftY != 0.0d) {
            // 
            double seriesMinX = Double.MAX_VALUE;
            double seriesMaxX = Double.MIN_VALUE;
            double seriesMinY = Double.MAX_VALUE;
            double seriesMaxY = Double.MIN_VALUE;
            // 
            if (shiftX != 0.0d) {
                /*
					 * Shift X
					 */
                double[] xSeriesShifted = adjustArray(dataSeries.getXSeries(), shiftX, IExtendedChart.X_AXIS);
                dataSeries.setXSeries(xSeriesShifted);
                seriesMinX = xSeriesShifted[0];
                seriesMaxX = xSeriesShifted[xSeriesShifted.length - 1];
            }
            // 
            if (shiftY != 0.0d) {
                /*
					 * Shift Y
					 */
                double[] ySeriesShifted = adjustArray(dataSeries.getYSeries(), shiftY, IExtendedChart.Y_AXIS);
                dataSeries.setYSeries(ySeriesShifted);
                seriesMinY = ySeriesShifted[0];
                seriesMaxY = ySeriesShifted[ySeriesShifted.length - 1];
            }
            /*
				 * Track the shifts.
				 */
            Range rangeX = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS).getRange();
            Range rangeY = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS).getRange();
            List<double[]> shiftRecord = getShiftRecord(selectedSeriesId);
            shiftRecord.add(new double[] { rangeX.lower, rangeX.upper, shiftX, rangeY.lower, rangeY.upper, shiftY, shiftConstraints });
            // 
            updateCoordinates(seriesMinX, seriesMaxX, seriesMinY, seriesMaxY);
            fireSeriesModificationEvent();
        }
    }
}
Also used : Range(org.eclipse.swtchart.Range) ISeries(org.eclipse.swtchart.ISeries)

Example 54 with ISeries

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

the class BaseChart method resetSeriesSettings.

public void resetSeriesSettings(boolean fireUpdate) {
    ISeries[] series = getSeriesSet().getSeries();
    // 
    for (ISeries dataSeries : series) {
        ISeriesSettings seriesSettings = getSeriesSettings(dataSeries.getId());
        applySeriesSettings(dataSeries, seriesSettings);
    }
    // 
    selectedSeriesIds.clear();
    redraw();
    if (fireUpdate) {
        fireSeriesStatusEvent(SELECTED_SERIES_NONE, ISeriesStatusListener.RESET);
    }
}
Also used : ISeries(org.eclipse.swtchart.ISeries)

Example 55 with ISeries

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

the class SeriesLabelMarker method paintControl.

@Override
public void paintControl(PaintEvent e) {
    if (isDraw()) {
        BaseChart baseChart = getBaseChart();
        ISeriesSet seriesSet = baseChart.getSeriesSet();
        ISeries[] series = seriesSet.getSeries();
        for (ISeries serie : series) {
            String label = serie.getId();
            ISeriesSettings seriesSettings = baseChart.getSeriesSettings(label);
            if (seriesSettings.isVisible()) {
                /*
					 * Only draw is series is visible.
					 */
                int symbolSize = 1;
                if (seriesSettings instanceof IPointSeriesSettings) {
                    symbolSize = ((IPointSeriesSettings) seriesSettings).getSymbolSize();
                }
                /*
					 * Draw the label
					 */
                e.gc.setForeground(getForegroundColor());
                for (int i = 0; i < serie.getXSeries().length; i++) {
                    Point point = serie.getPixelCoordinates(i);
                    Point labelSize = e.gc.textExtent(label);
                    e.gc.drawText(label, (int) (point.x - labelSize.x / 2.0d), (int) (point.y - labelSize.y - symbolSize / 2.0d), true);
                }
            }
        }
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesSet(org.eclipse.swtchart.ISeriesSet) IPointSeriesSettings(org.eclipse.swtchart.extensions.core.IPointSeriesSettings) ISeriesSettings(org.eclipse.swtchart.extensions.core.ISeriesSettings) Point(org.eclipse.swt.graphics.Point) ISeries(org.eclipse.swtchart.ISeries) Point(org.eclipse.swt.graphics.Point)

Aggregations

ISeries (org.eclipse.swtchart.ISeries)60 Point (org.eclipse.swt.graphics.Point)21 ISeriesSet (org.eclipse.swtchart.ISeriesSet)11 Chart (org.eclipse.swtchart.Chart)10 IAxis (org.eclipse.swtchart.IAxis)9 Range (org.eclipse.swtchart.Range)9 BaseChart (org.eclipse.swtchart.extensions.core.BaseChart)8 Color (org.eclipse.swt.graphics.Color)5 IBarSeries (org.eclipse.swtchart.IBarSeries)5 ILineSeries (org.eclipse.swtchart.ILineSeries)5 IAxisSettings (org.eclipse.swtchart.extensions.core.IAxisSettings)5 Rectangle (org.eclipse.swt.graphics.Rectangle)4 MouseEvent (org.eclipse.swt.events.MouseEvent)3 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)3 GC (org.eclipse.swt.graphics.GC)3 Test (org.junit.Test)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 PrintWriter (java.io.PrintWriter)2 ArrayList (java.util.ArrayList)2