use of org.eclipse.swtchart.ISeriesSet 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);
}
}
}
}
}
use of org.eclipse.swtchart.ISeriesSet in project tracecompass by tracecompass.
the class SWTBotCustomChartUtils method assertSeriesTitle.
/**
* Verify the title of the series. These titles are shown in the legend if
* there is more than one serie
*
* @param customChart
* The chart to verify
* @param titles
* The list of series titles
*/
public static void assertSeriesTitle(Chart customChart, List<String> titles) {
ISeriesSet seriesSet = customChart.getSeriesSet();
assertNotNull(seriesSet);
ISeries<?>[] series = seriesSet.getSeries();
assertEquals(titles.size(), series.length);
for (int i = 0; i < series.length; i++) {
assertEquals("Series title " + i, titles.get(i), series[i].getId());
}
}
Aggregations