Search in sources :

Example 6 with ILineSeries

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

the class BaseChart method applySeriesSettings.

private void applySeriesSettings(ISeries dataSeries, ISeriesSettings seriesSettings) {
    if (dataSeries instanceof ILineSeries) {
        ILineSeries lineSeries = (ILineSeries) dataSeries;
        if (seriesSettings instanceof ILineSeriesSettings) {
            /*
				 * Line Series
				 */
            ILineSeriesSettings lineSeriesSettings = (ILineSeriesSettings) seriesSettings;
            applyLineSeriesSettings(lineSeries, lineSeriesSettings);
        } else if (seriesSettings instanceof IScatterSeriesSettings) {
            /*
				 * Scatter Series
				 */
            IScatterSeriesSettings scatterSeriesSettings = (IScatterSeriesSettings) seriesSettings;
            applyScatterSeriesSettings(lineSeries, scatterSeriesSettings);
        }
    } else if (dataSeries instanceof IBarSeries) {
        /*
			 * Bar Series
			 */
        IBarSeries barSeries = (IBarSeries) dataSeries;
        IBarSeriesSettings barSeriesSettings = (IBarSeriesSettings) seriesSettings;
        applyBarSeriesSettings(barSeries, barSeriesSettings);
    }
}
Also used : ILineSeriesSettings(org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings) IBarSeriesSettings(org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings) IScatterSeriesSettings(org.eclipse.swtchart.extensions.scattercharts.IScatterSeriesSettings) IBarSeries(org.eclipse.swtchart.IBarSeries) ILineSeries(org.eclipse.swtchart.ILineSeries)

Example 7 with ILineSeries

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

the class SeriesPage method apply.

/*
	 * @see AbstractPreferencePage#apply()
	 */
@Override
public void apply() {
    for (int i = 0; i < series.length; i++) {
        series[i].setVisible(visibleStates[i]);
        if (series[i] instanceof ILineSeries) {
            Color lineColor = new Color(Display.getDefault(), lineColors[i]);
            ((ILineSeries) series[i]).setLineColor(lineColor);
            final String lineColorKey = SERIES_LINE_COLOR + series[i].getId();
            if (resources.getColor(lineColorKey) == null) {
                series[i].addDisposeListener(new IDisposeListener() {

                    public void disposed(Event e) {
                        resources.removeColor(lineColorKey);
                    }
                });
            }
            resources.put(lineColorKey, lineColor);
            Color symbolColor = new Color(Display.getDefault(), symbolColors[i]);
            ((ILineSeries) series[i]).setSymbolColor(symbolColor);
            final String symbolColorKey = SERIES_SYMBOL_COLOR + series[i].getId();
            if (resources.getColor(symbolColorKey) == null) {
                series[i].addDisposeListener(new IDisposeListener() {

                    public void disposed(Event e) {
                        resources.removeColor(symbolColorKey);
                    }
                });
            }
            resources.put(symbolColorKey, symbolColor);
            ((ILineSeries) series[i]).setLineStyle(lineStyles[i]);
            ((ILineSeries) series[i]).setSymbolType(symbolTypes[i]);
            ((ILineSeries) series[i]).setSymbolSize(symbolSizes[i]);
        } else if (series[i] instanceof IBarSeries) {
            Color barColor = new Color(Display.getDefault(), barColors[i]);
            ((IBarSeries) series[i]).setBarColor(barColor);
            final String barColorKey = SERIES_BAR_COLOR + series[i].getId();
            if (resources.getColor(barColorKey) == null) {
                series[i].addDisposeListener(new IDisposeListener() {

                    public void disposed(Event e) {
                        resources.removeColor(barColorKey);
                    }
                });
            }
            resources.put(barColorKey, barColor);
            ((IBarSeries) series[i]).setBarPadding(paddings[i]);
        }
        try {
            series[i].enableStack(stackedStates[i]);
        } catch (IllegalArgumentException e) {
            stackedStates[i] = false;
            stackedButton.setSelection(false);
        }
        series[i].setXAxisId(xAxisIds[i]);
        series[i].setYAxisId(yAxisIds[i]);
    }
}
Also used : IDisposeListener(org.eclipse.swtchart.IDisposeListener) IBarSeries(org.eclipse.swtchart.IBarSeries) ILineSeries(org.eclipse.swtchart.ILineSeries) Color(org.eclipse.swt.graphics.Color) Event(org.eclipse.swt.widgets.Event) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 8 with ILineSeries

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

the class LineChart method addSeriesData.

/**
 * The data is compressed to the given length.
 * If you're unsure which length to set, then use one of the following variables:
 *
 * HIGH_COMPRESSION
 * MEDIUM_COMPRESSION
 * LOW_COMPRESSION
 * NO_COMPRESSION
 *
 * @param lineSeriesDataList
 * @param compressToLength
 */
public void addSeriesData(List<ILineSeriesData> lineSeriesDataList, int compressToLength) {
    /*
		 * Suspend the update when adding new data to improve the performance.
		 */
    if (lineSeriesDataList != null && lineSeriesDataList.size() > 0) {
        BaseChart baseChart = getBaseChart();
        baseChart.suspendUpdate(true);
        for (ILineSeriesData lineSeriesData : lineSeriesDataList) {
            /*
				 * Get the series data and apply the settings.
				 */
            try {
                ISeriesData seriesData = lineSeriesData.getSeriesData();
                ISeriesData optimizedSeriesData = calculateSeries(seriesData, compressToLength);
                ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
                // Initialize
                lineSeriesSettings.getSeriesSettingsHighlight();
                ILineSeries lineSeries = (ILineSeries) createSeries(optimizedSeriesData, lineSeriesSettings);
                baseChart.applyLineSeriesSettings(lineSeries, lineSeriesSettings);
            } catch (SeriesException e) {
            // 
            }
        }
        baseChart.suspendUpdate(false);
        adjustRange(true);
        baseChart.redraw();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeries(org.eclipse.swtchart.ILineSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Example 9 with ILineSeries

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

the class ScatterChart method addSeriesData.

public void addSeriesData(List<IScatterSeriesData> scatterSeriesDataList) {
    /*
		 * Suspend the update when adding new data to improve the performance.
		 */
    if (scatterSeriesDataList != null && scatterSeriesDataList.size() > 0) {
        /*
			 * Set the data.
			 */
        BaseChart baseChart = getBaseChart();
        baseChart.suspendUpdate(true);
        for (IScatterSeriesData scatterSeriesData : scatterSeriesDataList) {
            /*
				 * Get the series data and apply the settings.
				 */
            try {
                ISeriesData seriesData = scatterSeriesData.getSeriesData();
                ISeriesData optimizedSeriesData = calculateSeries(seriesData, ScrollableChart.NO_COMPRESS_TO_LENGTH);
                IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
                // Initialize
                scatterSeriesSettings.getSeriesSettingsHighlight();
                ILineSeries scatterSeries = (ILineSeries) createSeries(optimizedSeriesData, scatterSeriesSettings);
                baseChart.applyScatterSeriesSettings(scatterSeries, scatterSeriesSettings);
            } catch (SeriesException e) {
            // 
            }
        }
        baseChart.suspendUpdate(false);
        adjustRange(true);
        baseChart.redraw();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeries(org.eclipse.swtchart.ILineSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Example 10 with ILineSeries

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

the class Legend method drawSymbol.

/**
 * Draws the symbol of series.
 *
 * @param gc
 *            the graphics context
 * @param series
 *            the series
 * @param r
 *            the rectangle to draw the symbol of series
 */
protected void drawSymbol(GC gc, Series series, Rectangle r) {
    if (!visible) {
        return;
    }
    if (series instanceof ILineSeries) {
        // draw plot line
        gc.setForeground(((ILineSeries) series).getLineColor());
        gc.setLineWidth(LINE_WIDTH);
        int lineStyle = Util.getIndexDefinedInSWT(((ILineSeries) series).getLineStyle());
        int x = r.x;
        int y = r.y + r.height / 2;
        if (lineStyle != SWT.NONE) {
            gc.setLineStyle(lineStyle);
            gc.drawLine(x, y, x + SYMBOL_WIDTH, y);
        }
        // draw series symbol
        Color color = ((ILineSeries) series).getSymbolColor();
        Color[] colors = ((ILineSeries) series).getSymbolColors();
        if (colors != null && colors.length > 0) {
            color = colors[0];
        }
        ((LineSeries) series).drawSeriesSymbol(gc, x + SYMBOL_WIDTH / 2, y, color);
    } else if (series instanceof IBarSeries) {
        // draw riser
        gc.setBackground(((IBarSeries) series).getBarColor());
        int size = SYMBOL_WIDTH / 2;
        int x = r.x + size / 2;
        int y = (int) (r.y - size / 2d + r.height / 2d);
        gc.fillRectangle(x, y, size, size);
    }
}
Also used : IBarSeries(org.eclipse.swtchart.IBarSeries) ILineSeries(org.eclipse.swtchart.ILineSeries) Color(org.eclipse.swt.graphics.Color) ILineSeries(org.eclipse.swtchart.ILineSeries) LineSeries(org.eclipse.swtchart.internal.series.LineSeries)

Aggregations

ILineSeries (org.eclipse.swtchart.ILineSeries)29 Chart (org.eclipse.swtchart.Chart)13 Color (org.eclipse.swt.graphics.Color)7 Point (org.eclipse.swt.graphics.Point)5 IAxis (org.eclipse.swtchart.IAxis)5 IBarSeries (org.eclipse.swtchart.IBarSeries)5 ISeries (org.eclipse.swtchart.ISeries)5 MouseEvent (org.eclipse.swt.events.MouseEvent)3 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)2 ISeriesSet (org.eclipse.swtchart.ISeriesSet)2 InteractiveChart (org.eclipse.swtchart.extensions.charts.InteractiveChart)2 BaseChart (org.eclipse.swtchart.extensions.core.BaseChart)2 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)2 SeriesException (org.eclipse.swtchart.extensions.exceptions.SeriesException)2 Test (org.junit.Test)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 IAction (org.eclipse.jface.action.IAction)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1