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