lttng: Add time alignment work to scatter chart
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 14 Oct 2015 01:56:39 +0000 (21:56 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 16 Oct 2015 00:00:15 +0000 (20:00 -0400)
Removes adjustRange() on the X-axis because it can change the desired
range when no data point exists at the range bounds.

Changes TmfCommonXLineChartViewer to use X-axis range for time alignment
instead of first and last data points.

Change-Id: Ia15eff9a258da0b20d0204c25f003768adc6b5e0
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/57011
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/LatencyScatterGraphViewer.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/LatencyScatterView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfMouseDragProvider.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfXYChartViewer.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java

index a2b899a0f98f2f6244aba2ba77d2ae66218c64d9..ac6ac327094ca348b66c8a9a9e5b05df47016c35 100644 (file)
@@ -187,7 +187,6 @@ public class CpuUsageView extends TmfView implements ITmfTimeAligned {
         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;
index 12477b20c52e187e97e6d169c80d4403fb915f7a..e7819c811793466d4c635b469f19813f7a555886 100644 (file)
@@ -274,12 +274,14 @@ public class LatencyScatterGraphViewer extends TmfCommonXLineChartViewer {
         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);
@@ -348,7 +350,6 @@ public class LatencyScatterGraphViewer extends TmfCommonXLineChartViewer {
         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));
         }
index 0fff37e3f09ee3359b21eed2610dc50a6bb8ee7b..e1c23836fe26d19a272d2f2ea6733dd2e7b28c5a 100644 (file)
@@ -8,20 +8,21 @@
  ********************************************************************************/
 
 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
     // ------------------------------------------------------------------------
 
@@ -46,28 +47,10 @@ public class LatencyScatterView extends TmfView {
     // ------------------------------------------------------------------------
 
     @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;
     }
 
 }
index 996657c3f9520829b3a7a0545a2c600b8ec9d154..ca624fbe443cdc2d6c5650a8eed424d6b2d0b350 100644 (file)
@@ -91,11 +91,6 @@ public class TmfMouseDragProvider extends TmfBaseProvider implements MouseListen
     @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);
         }
index f658ee7ed1b31c352e94a2e87c6a19ed13e82549..ee224645e53a666dc18e2da82ca0b3972caf53d4 100644 (file)
@@ -393,20 +393,9 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar
 
         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;
     }
@@ -424,21 +413,10 @@ public abstract class TmfXYChartViewer extends TmfTimeViewer implements ITmfChar
      */
     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;
index f2cd2171294876d53654795c789311b93c7f46f8..ee5a1c0e70879bc40c7d9bb64375992e58717564 100644 (file)
@@ -363,7 +363,6 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
                     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));
                     }
index 97c561a91e3dc695a958e4645ac302b6c413c292..21c48829b9736bd0a5a0f4896b66f1b9cbf4c099 100644 (file)
@@ -208,8 +208,6 @@ public abstract class TmfChartView extends TmfView implements ITmfTimeAligned {
         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;
index 0d9e9d402dc07a1d0019b6e82f41932570075056..84922b4c63cae086b5deac855502dcb187e0c74a 100644 (file)
@@ -423,7 +423,6 @@ public class HistogramView extends TmfView implements ITmfTimeAligned {
         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;
This page took 0.029867 seconds and 5 git commands to generate.