analysis.lami: Correctly set axis name if it is defined by one aspect
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 4 May 2016 21:50:19 +0000 (17:50 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Thu, 19 May 2016 22:42:11 +0000 (18:42 -0400)
Bug: 493941

Change-Id: Idc91ef8ff923b1e569ff7e4823ef84c1f94f38b1
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Reviewed-on: https://git.eclipse.org/r/72246
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Alexandre Montplaisir <alexmonthy@efficios.com>
analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/viewers/LamiXYChartViewer.java

index eb4f839dca7fda4ea79160ecc589d77ae2b51ceb..874e3b5a35b675a7cea993638e75f410e60e1118 100644 (file)
@@ -214,23 +214,33 @@ public abstract class LamiXYChartViewer extends TmfViewer implements ILamiViewer
              * There are multiple series in the chart, if they all share the same
              * units, display that.
              */
-            long nbDiffAspects = getXAxisAspects().stream()
+            long nbDiffAspectsUnits = getXAxisAspects().stream()
                 .map(aspect -> aspect.getUnits())
                 .distinct()
                 .count();
 
+            long nbDiffAspectName = getXAxisAspects().stream()
+                    .map(aspect -> aspect.getName())
+                    .distinct()
+                    .count();
+
+            String xBaseTitle = Messages.LamiViewer_DefaultValueName;
+            if (nbDiffAspectName == 1) {
+                xBaseTitle = getXAxisAspects().get(0).getName();
+            }
+
             String units = getXAxisAspects().get(0).getUnits();
-            if (nbDiffAspects == 1 && units != null) {
+            if (nbDiffAspectsUnits == 1 && units != null) {
                 /* All aspects use the same unit type */
 
                 // The time duration formatter converts ns to s on the axis
                 if (NANOSECONDS_SYMBOL.equals(units)) {
                     units = SECONDS_SYMBOL;
                 }
-                fXTitle = Messages.LamiViewer_DefaultValueName + " (" + units + ')'; //$NON-NLS-1$
+                fXTitle = xBaseTitle + " (" + units + ')'; //$NON-NLS-1$
             } else {
                 /* Various unit types, just say "Value" */
-                fXTitle = nullToEmptyString(Messages.LamiViewer_DefaultValueName);
+                fXTitle = nullToEmptyString(xBaseTitle);
             }
         }
 
@@ -252,23 +262,33 @@ public abstract class LamiXYChartViewer extends TmfViewer implements ILamiViewer
              * There are multiple series in the chart, if they all share the same
              * units, display that.
              */
-            long nbDiffAspects = getYAxisAspects().stream()
+            long nbDiffAspectsUnits = getYAxisAspects().stream()
                 .map(aspect -> aspect.getUnits())
                 .distinct()
                 .count();
 
+            long nbDiffAspectName = getYAxisAspects().stream()
+                    .map(aspect -> aspect.getName())
+                    .distinct()
+                    .count();
+
+            String yBaseTitle = Messages.LamiViewer_DefaultValueName;
+            if (nbDiffAspectName == 1) {
+                yBaseTitle = getYAxisAspects().get(0).getName();
+            }
+
             String units = getYAxisAspects().get(0).getUnits();
-            if (nbDiffAspects == 1 && units != null) {
+            if (nbDiffAspectsUnits == 1 && units != null) {
                 /* All aspects use the same unit type */
 
                 // The time duration formatter converts ns to s on the axis
                 if (NANOSECONDS_SYMBOL.equals(units)) {
                     units = SECONDS_SYMBOL;
                 }
-                fYTitle = Messages.LamiViewer_DefaultValueName + " (" + units + ')'; //$NON-NLS-1$
+                fYTitle = yBaseTitle + " (" + units + ')'; //$NON-NLS-1$
             } else {
-                /* Various unit types, just say "Value" */
-                fYTitle = nullToEmptyString(Messages.LamiViewer_DefaultValueName);
+                /* Various unit types, don't display any units */
+                fYTitle = nullToEmptyString(yBaseTitle);
             }
 
             /* Put legend at the bottom */
This page took 0.026231 seconds and 5 git commands to generate.