Search in sources :

Example 1 with ChartData

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);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ChartData(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData) ChartSelectionUpdateSignal(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.signal.ChartSelectionUpdateSignal) ChartModel(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartModel) ChartMakerDialog(org.eclipse.tracecompass.internal.provisional.tmf.chart.ui.dialog.ChartMakerDialog)

Example 2 with ChartData

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));
}
Also used : IDataChartDescriptor(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.descriptor.IDataChartDescriptor) ChartData(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData) ArrayList(java.util.ArrayList) ChartSeries(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartSeries) StubObject(org.eclipse.tracecompass.tmf.chart.core.tests.stubs.StubObject) Test(org.junit.Test)

Example 3 with ChartData

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());
}
Also used : IDataChartDescriptor(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.descriptor.IDataChartDescriptor) ChartData(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData) ArrayList(java.util.ArrayList) ChartSeries(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartSeries) StubObject(org.eclipse.tracecompass.tmf.chart.core.tests.stubs.StubObject) Test(org.junit.Test)

Example 4 with ChartData

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();
}
Also used : ChartData(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData) ChartType(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartType) ChartModel(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartModel)

Aggregations

ChartData (org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartData)4 ArrayList (java.util.ArrayList)2 ChartModel (org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartModel)2 ChartSeries (org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartSeries)2 IDataChartDescriptor (org.eclipse.tracecompass.internal.provisional.tmf.chart.core.descriptor.IDataChartDescriptor)2 StubObject (org.eclipse.tracecompass.tmf.chart.core.tests.stubs.StubObject)2 Test (org.junit.Test)2 Shell (org.eclipse.swt.widgets.Shell)1 ChartType (org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart.ChartType)1 ChartSelectionUpdateSignal (org.eclipse.tracecompass.internal.provisional.tmf.chart.core.signal.ChartSelectionUpdateSignal)1 ChartMakerDialog (org.eclipse.tracecompass.internal.provisional.tmf.chart.ui.dialog.ChartMakerDialog)1