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);
}
}
Aggregations