tmf.ui : Only update populated chart
authorFrance Lapointe Nguyen <francelap@gmail.com>
Wed, 10 Jun 2015 13:56:34 +0000 (09:56 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Thu, 18 Jun 2015 13:53:55 +0000 (09:53 -0400)
Check that there is at least one point in a chart to avoid AOOB

Change-Id: Id56153b4548a5ef713b1b0caf89976f3b0e348d6
Signed-off-by: France Lapointe Nguyen <francelap@gmail.com>
Reviewed-on: https://git.eclipse.org/r/49924
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java

index 63008452e23fb785cb338e3b2dc8225add016605..d8751fa55df4b25a377f0fa7d73f7796cdf26c62 100644 (file)
@@ -323,6 +323,10 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
             @Override
             public void run() {
                 if (!getSwtChart().isDisposed()) {
+                    double[] xValues = fXValues;
+                    if (xValues.length < 1) {
+                        return;
+                    }
                     double maxy = DEFAULT_MAXY;
                     double miny = DEFAULT_MINY;
                     for (Entry<String, double[]> entry : fSeriesValues.entrySet()) {
@@ -330,7 +334,7 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
                         if (series == null) {
                             series = addSeries(entry.getKey());
                         }
-                        series.setXSeries(fXValues);
+                        series.setXSeries(xValues);
                         /* Find the minimal and maximum values in this series */
                         for (double value : entry.getValue()) {
                             maxy = Math.max(maxy, value);
@@ -345,9 +349,9 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
                     IAxisTick xTick = getSwtChart().getAxisSet().getXAxis(0).getTick();
                     xTick.setFormat(tmfChartTimeStampFormat);
 
-                    final double start = fXValues[0];
-                    int lastX = fXValues.length - 1;
-                    double end = (start == fXValues[lastX]) ? start + 1 : fXValues[lastX];
+                    final double start = xValues[0];
+                    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) {
This page took 0.029422 seconds and 5 git commands to generate.