From: Jonathan Rajotte Date: Wed, 4 May 2016 21:50:19 +0000 (-0400) Subject: analysis.lami: Correctly set axis name if it is defined by one aspect X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=8d9b1c04e098fd5e621660b753bb2026c323d93f analysis.lami: Correctly set axis name if it is defined by one aspect Bug: 493941 Change-Id: Idc91ef8ff923b1e569ff7e4823ef84c1f94f38b1 Signed-off-by: Jonathan Rajotte Reviewed-on: https://git.eclipse.org/r/72246 Reviewed-by: Hudson CI Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse Reviewed-by: Alexandre Montplaisir --- diff --git a/analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/viewers/LamiXYChartViewer.java b/analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/viewers/LamiXYChartViewer.java index eb4f839dca..874e3b5a35 100644 --- a/analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/viewers/LamiXYChartViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/viewers/LamiXYChartViewer.java @@ -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 */