use of org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData in project tracecompass by tracecompass.
the class LamiReportViewTabPage method createNewCustomChart.
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/**
* This method is used for creating a chart from the result table of the
* analyse. It uses the custom charts plugin to configure and create the
* chart.
*/
public void createNewCustomChart() {
Shell shell = this.getControl().getShell();
if (shell == null) {
return;
}
/* Open the chart maker dialog */
ChartMakerDialog dialog = new ChartMakerDialog(shell, fResultTable);
if (dialog.open() != Window.OK) {
return;
}
/* Make sure the data for making a chart was generated */
ChartData data = dialog.getDataSeries();
ChartModel model = dialog.getChartModel();
if (data == null || model == null) {
return;
}
/* Make a chart with the factory constructor */
LamiViewerControl viewerControl = new LamiViewerControl(fControl, data, model);
fCustomGraphViewerControls.add(viewerControl);
viewerControl.getToggleAction().run();
/* Signal the current selection to the newly created graph */
ChartSelectionUpdateSignal signal = new ChartSelectionUpdateSignal(LamiReportViewTabPage.this, fResultTable, fSelection);
TmfSignalManager.dispatchSignal(signal);
}
use of org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData in project tracecompass by tracecompass.
the class ChartDataTest method testGetDescriptors.
/**
* Test getting the descriptors for x and y series of a chart data
*/
@Test
public void testGetDescriptors() {
// Create chart data with the string descriptor as x axis and a series
// for every other y axis
Collection<@NonNull IDataChartDescriptor<StubObject, ?>> dataDescriptors = fProvider.getDataDescriptors();
IDataChartDescriptor<StubObject, ?> xDesc = null;
for (IDataChartDescriptor<StubObject, ?> desc : dataDescriptors) {
if (desc.getName().equals(StubChartProvider.STRING_DESCRIPTOR)) {
xDesc = desc;
break;
}
}
assertNotNull(xDesc);
List<@NonNull ChartSeries> list = new ArrayList<>();
for (IDataChartDescriptor<StubObject, ?> desc : dataDescriptors) {
if (!desc.getName().equals(StubChartProvider.STRING_DESCRIPTOR)) {
list.add(new ChartSeries(xDesc, desc));
}
}
assertEquals(3, list.size());
ChartData data = new ChartData(fProvider, list);
// Verify that the series correspond to what has been added
Collection<@NonNull ChartSeries> chartSeries = data.getChartSeries();
assertEquals(3, chartSeries.size());
assertEquals(xDesc, data.getX(0));
assertEquals(xDesc, data.getX(1));
assertEquals(xDesc, data.getX(2));
assertEquals(list.get(0).getY(), data.getY(0));
assertEquals(list.get(1).getY(), data.getY(1));
assertEquals(list.get(2).getY(), data.getY(2));
}
use of org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData in project tracecompass by tracecompass.
the class ChartDataTest method testImmutableSeries.
/**
* Test that the series cannot be modified outside the class
*/
@Test
public void testImmutableSeries() {
// Create chart data with only one series
Iterator<@NonNull IDataChartDescriptor<StubObject, ?>> dataDescriptors = fProvider.getDataDescriptors().iterator();
IDataChartDescriptor<StubObject, ?> x = dataDescriptors.next();
IDataChartDescriptor<StubObject, ?> y = dataDescriptors.next();
List<@NonNull ChartSeries> list = new ArrayList<>();
list.add(new ChartSeries(x, y));
ChartData data = new ChartData(fProvider, list);
assertEquals(1, data.getChartSeries().size());
// Add a new series to the list and make sure it is not in the data
// (which should be immutable)
y = dataDescriptors.next();
list.add(new ChartSeries(x, y));
assertEquals(1, data.getChartSeries().size());
}
use of org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData in project tracecompass by tracecompass.
the class ChartMakerDialog method okPressed.
@Override
public void okPressed() {
/* Create the data series */
fDataSeries = new ChartData(fDataProvider, fSelectedSeries);
/* Create the data model */
ChartType type = checkNotNull(checkNotNull(fType).getType());
String title = fDataProvider.getName();
boolean xlog = fXLogscaleButton.getSelection();
boolean ylog = fYLogscaleButton.getSelection();
fChartModel = new ChartModel(type, title, xlog, ylog);
super.okPressed();
}
Aggregations