use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class SystemCallLatencyScatterChartViewTest method testWithTrace.
/**
* Test to check the System Call Scatter view. When trace opens, there are a few
* syscalls present, then we move to the zone without system calls, the tree
* should be empty.
*
* TODO: Test the data
*/
@Test
public void testWithTrace() {
// Wait for analysis to finish.
WaitUtils.waitForJobs();
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof SystemCallLatencyScatterView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
SWTBotUtils.waitUntil(bot -> bot.tree().visibleRowCount() >= 25, getSWTBotView().bot(), "Missing rows, expected 25, was " + getSWTBotView().bot().tree().visibleRowCount());
SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
for (SWTBotTreeItem item : items) {
item.check();
}
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 24, chart, "No data available");
/* Test type, style and color of series */
verifyChartStyle();
// Update the time range to a range where there is no data
long noDataStart = 1412670961274443542L;
long noDataEnd = 1412670961298823940L;
TmfTimeRange windowRange = new TmfTimeRange(TmfTimestamp.fromNanos(noDataStart), TmfTimestamp.fromNanos(noDataEnd));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, windowRange));
fBot.waitUntil(ConditionHelpers.windowRange(windowRange));
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
// Only the root item should be present
items = getSWTBotView().bot().tree().getAllItems();
assertEquals(1, items.length);
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class AbstractSegmentStoreDensityViewer method clearContent.
/**
* Clears the view content.
*/
private void clearContent() {
final Chart chart = fChart;
if (!chart.isDisposed()) {
ISeriesSet set = chart.getSeriesSet();
ISeries<?>[] series = set.getSeries();
for (int i = 0; i < series.length; i++) {
set.deleteSeries(series[i].getId());
}
for (IAxis axis : chart.getAxisSet().getAxes()) {
axis.setRange(new Range(0, 1));
}
chart.redraw();
}
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class MemoryUsageViewTest method testMemoryUsage.
/**
* Test Memory Usage data model
*/
@Test
public void testMemoryUsage() {
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof UstMemoryUsageView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
checkAllEntries();
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 3, chart, "No data available");
chartViewer.setNbPoints(50);
/* Test data model*/
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, FIRST_SERIES_NAME, SECOND_SERIES_NAME, THIRD_SERIES_NAME, FOURTH_SERIES_NAME), "resources/memory-res50.json", "Chart data is not valid");
/* Test type, style and color of series */
verifyChartStyle();
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class MemoryUsageViewTest method testOpenMemoryUsage.
/**
* Test if Memory Usage is populated
*/
@Test
public void testOpenMemoryUsage() {
SWTBotView viewBot = fBot.viewById(UstMemoryUsageView.ID);
viewBot.setFocus();
// Do some basic validation
Matcher<Chart> matcher = WidgetOfType.widgetOfType(Chart.class);
Chart chart = viewBot.bot().widget(matcher);
checkAllEntries();
// Verify that the chart has 4 series
fBot.waitUntil(ConditionHelpers.numberOfSeries(chart, EXPECTED_NUM_SERIES));
ISeriesSet seriesSet = chart.getSeriesSet();
ISeries<?>[] series = seriesSet.getSeries();
// Verify that each series is a ILineSeries
for (ISeries<?> serie : series) {
assertTrue(serie instanceof ILineSeries);
}
}
use of org.eclipse.swtchart.Chart in project olca-app by GreenDelta.
the class ContributionChart method create.
public static ContributionChart create(Composite parent, FormToolkit tk) {
Composite comp = UI.formComposite(parent, tk);
UI.gridLayout(comp, 2);
UI.gridData(comp, true, true);
// create and configure the chart
Chart chart = new Chart(comp, SWT.NONE);
GridData gdata = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gdata.heightHint = 300;
gdata.widthHint = 700;
chart.setLayoutData(gdata);
chart.setOrientation(SWT.HORIZONTAL);
chart.getLegend().setVisible(false);
// we set a white title just to fix the problem
// that the y-axis is cut sometimes
chart.getTitle().setText(".");
chart.getTitle().setFont(UI.defaultFont());
chart.getTitle().setForeground(Colors.white());
chart.getTitle().setVisible(true);
// configure the x-axis with one category
IAxis x = chart.getAxisSet().getXAxis(0);
x.getTitle().setVisible(false);
x.getTick().setForeground(Colors.darkGray());
x.enableCategory(true);
x.setCategorySeries(new String[] { "" });
// configure the y-axis
IAxis y = chart.getAxisSet().getYAxis(0);
y.getTitle().setVisible(false);
y.getTick().setForeground(Colors.darkGray());
y.getGrid().setStyle(LineStyle.NONE);
y.getTick().setFormat(new DecimalFormat("0.0E0#", new DecimalFormatSymbols(Locale.US)));
y.getTick().setTickMarkStepHint(10);
return new ContributionChart(chart, new ChartLegend(comp));
}
Aggregations