JMC-5359: Ugly values on Y axis when no events

Ken Dobson kdobson at redhat.com
Tue Sep 18 21:17:22 UTC 2018


Hi all,

This is another simple UI fix for JMC-5359, which also appears to be a
duplicate of JMC-5045 as well. If someone could have a look at it that'd be
great.
Jira: https://bugs.openjdk.java.net/projects/JMC/issues/JMC-5359
https://bugs.openjdk.java.net/projects/JMC/issues/JMC-5045

diff -r 9ebfa2888b8f
application/org.openjdk.jmc.ui/src/main/java/org/openjdk/jmc/ui/charts/XYDataRenderer.java
---
a/application/org.openjdk.jmc.ui/src/main/java/org/openjdk/jmc/ui/charts/XYDataRenderer.java
Fri Sep 14 01:21:16 2018 +0200
+++
b/application/org.openjdk.jmc.ui/src/main/java/org/openjdk/jmc/ui/charts/XYDataRenderer.java
Tue Sep 18 17:11:03 2018 -0400
@@ -44,6 +44,7 @@

 import org.openjdk.jmc.common.IDisplayable;
 import org.openjdk.jmc.common.unit.IQuantity;
+import org.openjdk.jmc.common.unit.UnitLookup;
 import org.openjdk.jmc.common.util.ColorToolkit;
 import org.openjdk.jmc.ui.charts.AWTChartToolkit.IColorProvider;
 import org.openjdk.jmc.ui.charts.IChartInfoVisitor.IBucket;
@@ -200,9 +201,11 @@

         if (yAxisMin != null && yAxisMax != null) {
             FontMetrics fm = context.getFontMetrics();
-            // If min=max, expand range to be [min, min+1]
+            /* If min=max, expand range to be [min, min+1], or [min,
min+1024] in the case of
+            a graph measured in bytes*/
             if (yAxisMin.compareTo(yAxisMax) == 0) {
-                yAxisMax =
yAxisMin.getUnit().quantity(yAxisMin.doubleValue() + 1);
+                int offset = yAxisMin.getUnit() == UnitLookup.BYTE ? 1024
: 1;
+                yAxisMax =
yAxisMin.getUnit().quantity(yAxisMin.doubleValue() + offset);
             } else {
                 // Add sufficient padding to ensure that labels for ticks
<= yAxisMax fit,
                 // and constant value graphs are discernible.

Thanks,

Ken


More information about the jmc-dev mailing list