Search in sources :

Example 11 with ISeriesSet

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

Example 12 with ISeriesSet

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());
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) ISeries(org.eclipse.swtchart.ISeries)

Aggregations

ISeriesSet (org.eclipse.swtchart.ISeriesSet)12 ISeries (org.eclipse.swtchart.ISeries)11 Chart (org.eclipse.swtchart.Chart)4 Range (org.eclipse.swtchart.Range)3 Test (org.junit.Test)3 Point (org.eclipse.swt.graphics.Point)2 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)2 IAxis (org.eclipse.swtchart.IAxis)2 ILineSeries (org.eclipse.swtchart.ILineSeries)2 IndexedSeriesModel (org.eclipse.swtchart.model.IndexedSeriesModel)2 Color (org.eclipse.swt.graphics.Color)1 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 SeriesType (org.eclipse.swtchart.ISeries.SeriesType)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 SeriesException (org.eclipse.swtchart.extensions.exceptions.SeriesException)1 SegmentStoreWithRange (org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider.SegmentStoreWithRange)1 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)1