Search in sources :

Example 1 with LineSeries

use of org.eclipse.swtchart.internal.series.LineSeries 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

Color (org.eclipse.swt.graphics.Color)1 IBarSeries (org.eclipse.swtchart.IBarSeries)1 ILineSeries (org.eclipse.swtchart.ILineSeries)1 LineSeries (org.eclipse.swtchart.internal.series.LineSeries)1