+ /**
+ * Set the Y axis title and refresh the chart.
+ *
+ * @param label
+ * the label string.
+ * @param units
+ * the units string.
+ */
+ protected void setYTitle(@Nullable String label, @Nullable String units) {
+ innerSetYTitle(label, units);
+ }
+
+ private void innerSetYTitle(@Nullable String label, @Nullable String units) {
+ fYLabel = nullToEmptyString(label);
+ innerSetYUnits(units);
+ refreshDisplayTitles();
+ }
+
+ /**
+ * Set the units on the Y Axis title and refresh the chart.
+ *
+ * @param units
+ * the units string.
+ */
+ protected void setYUnits(@Nullable String units) {
+ innerSetYUnits(units);
+ }
+
+ private void innerSetYUnits(@Nullable String units) {
+ /*
+ * All time durations in the Lami protocol are nanoseconds, on the
+ * charts we use an axis formater that converts back to seconds as a
+ * base unit and then uses prefixes like nano and milli depending on the
+ * range.
+ *
+ * So set the units to seconds in the title to match the base unit of
+ * the formater.
+ */
+ if (NANOSECONDS_SYMBOL.equals(units)) {
+ fYUnits = SECONDS_SYMBOL;
+ } else {
+ fYUnits = units;
+ }
+ refreshDisplayTitles();
+ }
+
+ /**
+ * Get the Y axis title string.
+ *
+ * If the units is non-null, the title will be: "label (units)"
+ *
+ * If the units is null, the title will be: "label"
+ *
+ * @return the title of the Y axis.
+ */
+ protected String getYTitle() {
+ if (fYUnits == null) {
+ return fYLabel;
+ }
+ return fYLabel + " (" + fYUnits + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Set the X axis title and refresh the chart.
+ *
+ * @param label
+ * the label string.
+ * @param units
+ * the units string.
+ */
+ protected void setXTitle(@Nullable String label, @Nullable String units) {
+ innerSetXTitle(label, units);
+ }
+
+ private void innerSetXTitle(@Nullable String label, @Nullable String units) {
+ fXLabel = nullToEmptyString(label);
+ innerSetXUnits(units);
+ refreshDisplayTitles();
+ }
+
+ /**
+ * Set the units on the X Axis title.
+ *
+ * @param units
+ * the units string
+ */
+ protected void setXUnits(@Nullable String units) {
+ innerSetXUnits(units);
+ }
+
+ private void innerSetXUnits(@Nullable String units) {
+ /* The time duration formatter converts ns to s on the axis */
+ if (NANOSECONDS_SYMBOL.equals(units)) {
+ fXUnits = SECONDS_SYMBOL;
+ } else {
+ fXUnits = units;
+ }
+ refreshDisplayTitles();
+ }
+
+ /**
+ * Get the X axis title string.
+ *
+ * If the units is non-null, the title will be: "label (units)"
+ *
+ * If the units is null, the title will be: "label"
+ *
+ * @return the title of the Y axis.
+ */
+ protected String getXTitle() {
+ if (fXUnits == null) {
+ return fXLabel;
+ }
+ return fXLabel + " (" + fXUnits + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+