Search in sources :

Example 1 with IPointSeriesSettings

use of org.eclipse.swtchart.extensions.core.IPointSeriesSettings 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

Point (org.eclipse.swt.graphics.Point)1 ISeries (org.eclipse.swtchart.ISeries)1 ISeriesSet (org.eclipse.swtchart.ISeriesSet)1 BaseChart (org.eclipse.swtchart.extensions.core.BaseChart)1 IPointSeriesSettings (org.eclipse.swtchart.extensions.core.IPointSeriesSettings)1 ISeriesSettings (org.eclipse.swtchart.extensions.core.ISeriesSettings)1