Search in sources :

Example 1 with ISeriesSet

use of org.eclipse.swtchart.ISeriesSet in project swtchart by eclipse.

the class AbstractExtendedChart method createSeries.

@Override
public ISeries createSeries(ISeriesData seriesData, ISeriesSettings seriesSettings) throws SeriesException {
    SeriesType seriesType = getSeriesType(seriesSettings);
    double[] xSeries = seriesData.getXSeries();
    double[] ySeries = seriesData.getYSeries();
    // 
    if (xSeries.length == ySeries.length) {
        /*
			 * Put the settings to the map.
			 */
        String id = seriesData.getId();
        seriesSettingsMap.put(id, seriesSettings);
        // 
        ISeriesSet seriesSet = getSeriesSet();
        ISeries series = seriesSet.createSeries(seriesType, id);
        series.setXSeries(xSeries);
        series.setYSeries(ySeries);
        calculateCoordinates(series);
        return series;
    } else {
        throw new SeriesException("The length of x and y series differs.");
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) SeriesType(org.eclipse.swtchart.ISeries.SeriesType) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException) ISeries(org.eclipse.swtchart.ISeries)

Example 2 with ISeriesSet

use of org.eclipse.swtchart.ISeriesSet in project swtchart by eclipse.

the class AbstractExtendedChart method appendSeries.

@Override
public void appendSeries(ISeriesData seriesData) {
    if (seriesData != null) {
        ISeriesSet seriesSet = getSeriesSet();
        ISeries series = seriesSet.getSeries(seriesData.getId());
        if (series != null) {
            /*
				 * Append the data.
				 */
            double[] xSeriesNew = concatenateSeries(series.getXSeries(), seriesData.getXSeries());
            series.setXSeries(xSeriesNew);
            double[] ySeriesNew = concatenateSeries(series.getYSeries(), seriesData.getYSeries());
            series.setYSeries(ySeriesNew);
            // 
            calculateCoordinates(series);
        }
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) ISeries(org.eclipse.swtchart.ISeries)

Example 3 with ISeriesSet

use of org.eclipse.swtchart.ISeriesSet in project tracecompass by tracecompass.

the class PatternDensityViewTest method testWithTrace.

/**
 * Test the pattern density view and its viewers data
 *
 * @throws SecurityException
 *             If a security manager is present and any the wrong class is
 *             loaded or the class loader is not the same as its ancestor's
 *             loader.
 *
 * @throws NoSuchFieldException
 *             Field not available
 * @throws IllegalAccessException
 *             Field is inaccessible
 * @throws IllegalArgumentException
 *             the object is not the correct class type
 */
@Test
public void testWithTrace() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    setDensityViewer();
    WaitUtils.waitForJobs();
    // Test the table content
    SWTBotTable tableBot = new SWTBotTable(fDensityViewer.getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
    tableBot.header(COLUMN_HEADER).click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
    tableBot.header(COLUMN_HEADER).click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
    // Test the chart content
    final Chart densityChart = fDensityChart;
    assertNotNull(densityChart);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(densityChart, 1));
    SWTBotChart chartBot = new SWTBotChart(densityChart);
    assertVisible(chartBot);
    ISeriesSet seriesSet = fDensityChart.getSeriesSet();
    assertNotNull(seriesSet);
    ISeries<?>[] series = seriesSet.getSeries();
    assertNotNull(series);
    // Verify that the chart has 1 series
    assertEquals(1, series.length);
    // Verify that the series has data
    assertTrue(((IndexedSeriesModel<?>) series[0].getDataModel()).size() > 0);
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) IndexedSeriesModel(org.eclipse.swtchart.model.IndexedSeriesModel) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) ISeries(org.eclipse.swtchart.ISeries) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Example 4 with ISeriesSet

use of org.eclipse.swtchart.ISeriesSet in project tracecompass by tracecompass.

the class PatternScatterChartViewTest method testWithTrace.

/**
 * Test the pattern latency scatter graph. This method test if the chart has one
 * series and the series has data
 */
@Test
public void testWithTrace() {
    // Get the chart viewer and wait for the view to be ready
    WaitUtils.waitForJobs();
    TmfXYChartViewer chartViewer = getChartViewer();
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    // Check all the items in the tree
    final Chart chart = fScatterChart;
    assertNotNull(chart);
    SWTBotView viewBot = fBot.viewById(VIEW_ID);
    SWTBotTreeItem[] items = viewBot.bot().tree().getAllItems();
    for (SWTBotTreeItem item : items) {
        item.check();
    }
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
    // Look at the presence of data in the chart
    SWTBotChart chartBot = new SWTBotChart(chart);
    assertVisible(chartBot);
    final Range range = chart.getAxisSet().getXAxes()[0].getRange();
    assertEquals(100000000, range.upper - range.lower, 0);
    ISeriesSet seriesSet = fScatterChart.getSeriesSet();
    assertNotNull(seriesSet);
    ISeries<?>[] series = seriesSet.getSeries();
    assertNotNull(series);
    // Verify that the chart has more than 1 series
    assertTrue(series.length > 1);
    // Verify that each series has data
    for (int i = 0; i < series.length; i++) {
        assertTrue("Verifying series " + i, ((IndexedSeriesModel<?>) series[i].getDataModel()).size() > 0);
    }
}
Also used : TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) ISeriesSet(org.eclipse.swtchart.ISeriesSet) IndexedSeriesModel(org.eclipse.swtchart.model.IndexedSeriesModel) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Range(org.eclipse.swtchart.Range) ISeries(org.eclipse.swtchart.ISeries) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Example 5 with ISeriesSet

use of org.eclipse.swtchart.ISeriesSet in project tracecompass by tracecompass.

the class TmfXYChartViewer method clearContent.

// ------------------------------------------------------------------------
// Helper Methods
// ------------------------------------------------------------------------
/**
 * Clears the view content.
 */
protected void clearContent() {
    if (!fSwtChart.isDisposed()) {
        ISeriesSet set = fSwtChart.getSeriesSet();
        ISeries<?>[] series = set.getSeries();
        for (int i = 0; i < series.length; i++) {
            set.deleteSeries(series[i].getId());
        }
        for (IAxis axis : fSwtChart.getAxisSet().getAxes()) {
            axis.setRange(new Range(0, 1));
        }
        fSwtChart.redraw();
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) Range(org.eclipse.swtchart.Range) ISeries(org.eclipse.swtchart.ISeries) Point(org.eclipse.swt.graphics.Point) IAxis(org.eclipse.swtchart.IAxis)

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