use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.
the class TmfChartView method coupleSelectViewer.
/**
* Method to couple {@link AbstractSelectTreeViewer2} and
* {@link TmfFilteredXYChartViewer} so that they use the same legend and that
* the chart listens to selected items in the tree
*/
private void coupleSelectViewer() {
TmfViewer tree = getLeftChildViewer();
TmfXYChartViewer chart = getChartViewer();
if (tree instanceof AbstractSelectTreeViewer2 && chart instanceof TmfFilteredXYChartViewer) {
ILegendImageProvider2 legendImageProvider = new XYChartLegendImageProvider((TmfCommonXAxisChartViewer) chart);
AbstractSelectTreeViewer2 selectTree = (AbstractSelectTreeViewer2) tree;
selectTree.addTreeListener((TmfFilteredXYChartViewer) chart);
selectTree.setLegendImageProvider(legendImageProvider);
TriStateFilteredCheckboxTree checkboxTree = selectTree.getTriStateFilteredCheckboxTree();
checkboxTree.addPreCheckStateListener(new ManyEntriesSelectedDialogPreCheckedListener(checkboxTree));
}
}
use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.
the class TmfChartView method getZoomOutAction.
private Action getZoomOutAction() {
Action zoomOutAction = fZoomOutAction;
if (zoomOutAction == null) {
zoomOutAction = new Action() {
@Override
public void run() {
TmfXYChartViewer viewer = getChartViewer();
if (viewer == null) {
return;
}
Chart chart = viewer.getSwtChart();
if (chart == null) {
return;
}
TmfXyUiUtils.zoom(viewer, XYAxis.create(chart.getAxisSet().getXAxis(0)), false);
}
};
zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);
zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);
zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));
}
return zoomOutAction;
}
use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer 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.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.
the class TmfChartView method createPartControl.
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
fClampAction = createClampAction();
menuManager.add(new Separator());
menuManager.add(fClampAction);
fSashForm = new SashForm(parent, SWT.NONE);
fTmfViewer = createLeftChildViewer(fSashForm);
fXYViewerContainer = new Composite(fSashForm, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
fXYViewerContainer.setLayout(layout);
fChartViewer = createChartViewer(fXYViewerContainer);
fChartViewer.setSendTimeAlignSignals(true);
fChartViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
fChartViewer.getSwtChart().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
super.mouseDoubleClick(e);
resetStartFinishTime();
}
});
fChartViewer.getControl().addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
// drag listener here
if (fSashDragListener == null) {
for (Control control : fSashForm.getChildren()) {
if (control instanceof Sash) {
fSashDragListener = event -> TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(fSashForm, getTimeViewAlignmentInfo()));
control.removePaintListener(this);
control.addListener(SWT.Selection, fSashDragListener);
// There should be only one sash
break;
}
}
}
}
});
fSashForm.setWeights(DEFAULT_WEIGHTS);
fZoomInAction = getZoomInAction();
fZoomOutAction = getZoomOutAction();
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fResetScaleAction);
toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fZoomInAction);
toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fZoomOutAction);
ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
if (trace != null) {
loadTrace();
}
IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
fChartViewer.setStatusLineManager(statusLineManager);
fOriginalTabLabel = getPartName();
coupleSelectViewer();
IWorkbenchPartSite site = getSite();
fContextService = site.getWorkbenchWindow().getService(IContextService.class);
TmfXYChartViewer chartViewer = getChartViewer();
if (chartViewer != null) {
chartViewer.getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
deactivateContextService();
}
@Override
public void focusGained(FocusEvent e) {
activateContextService();
}
});
}
}
use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.
the class TmfChartView method getZoomInAction.
private Action getZoomInAction() {
Action zoomInAction = fZoomInAction;
if (zoomInAction == null) {
zoomInAction = new Action() {
@Override
public void run() {
TmfXYChartViewer viewer = getChartViewer();
if (viewer == null) {
return;
}
Chart chart = viewer.getSwtChart();
if (chart == null) {
return;
}
TmfXyUiUtils.zoom(viewer, XYAxis.create(chart.getAxisSet().getXAxis(0)), true);
}
};
zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);
zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);
zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));
}
return zoomInAction;
}
Aggregations