if (pointAreaWidth <= 0) {
pointAreaWidth = fSashForm.getBounds().width - curTimeAxisOffset;
}
- // TODO this is just an approximation that assumes that the end will be at the same position but that can change for a different data range/scaling
int endOffset = curTimeAxisOffset + pointAreaWidth;
GridLayout layout = (GridLayout) fXYViewerContainer.getLayout();
int endOffsetWithoutMargin = endOffset + layout.marginRight;
long currentStart = getTimeInNanos(currentRange.getStartTime());
long currentEnd = getTimeInNanos(currentRange.getEndTime());
if (dataInput == null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- clearContent();
- }
- });
+ if (!getDisplay().isDisposed()) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ clearContent();
+ }
+ });
+ }
fDisplayData = NonNullUtils.checkNotNull(Collections.EMPTY_LIST);
} else {
Collection<ISegment> elements = (Collection<ISegment>) dataInput.getIntersectingElements(currentStart, currentEnd);
IAxisTick xTick = xAxis.getTick();
xTick.setFormat(tmfChartTimeStampFormat);
xAxis.setRange(new Range(0.0, end - start));
- xAxis.adjustRange();
if (maxY > 0.0) {
swtChart.getAxisSet().getYAxis(0).setRange(new Range(0.0, maxY));
}
********************************************************************************/
package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency;
+
import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.tmf.ui.views.TmfView;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
+import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer;
+import org.eclipse.tracecompass.tmf.ui.views.TmfChartView;
/**
* Some stuff
*
* @author Matthew Khouzam
*/
-public class LatencyScatterView extends TmfView {
+public class LatencyScatterView extends TmfChartView {
// Attributes
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
@Override
- public void createPartControl(@Nullable Composite parent) {
- SashForm sf = new SashForm(parent, SWT.NONE);
- fScatterViewer = new LatencyScatterGraphViewer(sf, nullToEmptyString(Messages.LatencyScatterView_title), nullToEmptyString(Messages.LatencyScatterView_xAxis), nullToEmptyString(Messages.LatencyScatterView_yAxis));
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public void setFocus() {
- if (fScatterViewer != null) {
- fScatterViewer.getControl().setFocus();
- }
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (fScatterViewer != null) {
- fScatterViewer.dispose();
- }
+ protected TmfXYChartViewer createChartViewer(@Nullable Composite parent) {
+ fScatterViewer = new LatencyScatterGraphViewer(NonNullUtils.checkNotNull(parent), nullToEmptyString(Messages.LatencyScatterView_title), nullToEmptyString(Messages.LatencyScatterView_xAxis),
+ nullToEmptyString(Messages.LatencyScatterView_yAxis));
+ return fScatterViewer;
}
}
@Override
public void mouseUp(MouseEvent e) {
if ((fIsUpdate) && (fStartTime != fEndTime)) {
- // Adjust range to the full range here so that it shows
- // the original range (important for time alignment)
- IAxis xAxis = getChart().getAxisSet().getXAxis(0);
- xAxis.adjustRange();
-
ITmfChartTimeProvider viewer = getChartViewer();
viewer.updateWindow(fStartTime, fEndTime);
}
int pixelCoordinate = 0;
IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes();
- ISeries[] series = fSwtChart.getSeriesSet().getSeries();
- if ((xAxes.length > 0) && (series.length > 0) &&
- (series[0].getXSeries() != null) && (series[0].getXSeries().length > 0)) {
+ if (xAxes.length > 0) {
IAxis axis = xAxes[0];
- // All series have the same X series
- double[] xSeries = series[0].getXSeries();
- double minX = Double.MAX_VALUE;
- for (double x : xSeries) {
- if (minX > x) {
- minX = x;
- }
- }
-
- pixelCoordinate = axis.getPixelCoordinate(minX);
+ pixelCoordinate = axis.getPixelCoordinate(axis.getRange().lower);
}
return getSwtChart().toControl(getSwtChart().getPlotArea().toDisplay(pixelCoordinate, 0)).x;
}
*/
public int getPointAreaWidth() {
IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes();
- ISeries[] series = fSwtChart.getSeriesSet().getSeries();
- if ((xAxes.length > 0) && (series.length > 0) &&
- (series[0].getXSeries() != null) && (series[0].getXSeries().length > 0)) {
+ if (xAxes.length > 0) {
IAxis axis = xAxes[0];
- // All series have the same X series
- double[] xSeries = series[0].getXSeries();
- double maxX = Double.MIN_VALUE;
- for (double x : xSeries) {
- if (maxX < x) {
- maxX = x;
- }
- }
-
int x1 = getPointAreaOffset();
- int x2 = axis.getPixelCoordinate(maxX);
+ int x2 = axis.getPixelCoordinate(axis.getRange().upper);
x2 = getSwtChart().toControl(getSwtChart().getPlotArea().toDisplay(x2, 0)).x;
int width = x2 - x1;
return width;
int lastX = xValues.length - 1;
double end = (start == xValues[lastX]) ? start + 1 : xValues[lastX];
getSwtChart().getAxisSet().getXAxis(0).setRange(new Range(start, end));
- getSwtChart().getAxisSet().getXAxis(0).adjustRange();
if (maxy > miny) {
getSwtChart().getAxisSet().getYAxis(0).setRange(new Range(miny, maxy));
}
if (pointAreaWidth <= 0) {
pointAreaWidth = fSashForm.getBounds().width - curTimeAxisOffset;
}
-
- // TODO this is just an approximation that assumes that the end will be at the same position but that can change for a different data range/scaling
int endOffset = curTimeAxisOffset + pointAreaWidth;
GridLayout layout = (GridLayout) fXYViewerContainer.getLayout();
int endOffsetWithoutMargin = endOffset + layout.marginRight;
if (pointAreaWidth <= 0) {
pointAreaWidth = fSashForm.getBounds().width - curTimeAxisOffset;
}
- // TODO this is just an approximation that assumes that the end will be at the same position but that can change for a different data range/scaling
int endOffset = curTimeAxisOffset + pointAreaWidth;
GridLayout layout = (GridLayout) fTimeRangeComposite.getLayout();
int endOffsetWithoutMargin = endOffset + layout.marginRight;