tmf.ui: add second unit to timegraph scale
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 27 Jul 2016 19:15:47 +0000 (15:15 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 29 Jul 2016 17:21:14 +0000 (13:21 -0400)
This adds seconds in the time units to make it clear what unit
the time is in.

Change-Id: Ide467c2e1738c6e2f8aadbe7e06e64a15d2ae71b
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/78016
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java

index bcb6c1d9572b465af8b795d8657e2ac2dfeb5a9b..f9a1b7560cd584b56dd19a29e3fdbab707ab969a 100644 (file)
@@ -507,8 +507,9 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
     private int calculateDigits(long time0, long time1) {
         int numDigits = 5;
         long timeRange = time1 - time0;
+        TimeFormat timeFormat = fTimeProvider.getTimeFormat();
 
-        if (fTimeProvider.getTimeFormat() == TimeFormat.CALENDAR) {
+        if (timeFormat == TimeFormat.CALENDAR) {
             // Calculate the number of digits to represent the minutes provided
             // 11:222
             // HH:mm:ss
@@ -526,8 +527,10 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
             int thousandGroups = (numDigits - 1) / 3;
             numDigits += thousandGroups;
             numDigits += 12; // .000 000 000
-            if (fTimeProvider.getTimeFormat() == TimeFormat.CYCLES) {
+            if (timeFormat == TimeFormat.CYCLES) {
                 numDigits += Messages.Utils_ClockCyclesUnit.length();
+            } else if (fTimeProvider.getTimeFormat() == TimeFormat.RELATIVE) {
+                numDigits += 2; // " s"
             }
         }
 
@@ -734,7 +737,7 @@ class TimeDrawSec extends TimeDraw {
     @Override
     public int draw(GC gc, long nanosec, Rectangle rect) {
         long sec = nanosec / SEC_IN_NS;
-        return Utils.drawText(gc, sep(sec), rect, true);
+        return Utils.drawText(gc, sep(sec) + " s", rect, true); //$NON-NLS-1$
     }
 }
 
@@ -744,7 +747,7 @@ class TimeDrawMillisec extends TimeDraw {
         long millisec = nanosec / MILLISEC_IN_NS;
         long ms = millisec % PAD_1000;
         long sec = millisec / SEC_IN_MS;
-        return Utils.drawText(gc, sep(sec) + "." + pad(ms), rect, true); //$NON-NLS-1$
+        return Utils.drawText(gc, sep(sec) + "." + pad(ms) + " s", rect, true); //$NON-NLS-1$ //$NON-NLS-2$
     }
 }
 
@@ -756,7 +759,7 @@ class TimeDrawMicrosec extends TimeDraw {
         long millisec = microsec / MILLISEC_IN_US;
         long ms = millisec % PAD_1000;
         long sec = millisec / SEC_IN_MS;
-        return Utils.drawText(gc, sep(sec) + "." + pad(ms) + " " + pad(us), rect, true); //$NON-NLS-1$ //$NON-NLS-2$
+        return Utils.drawText(gc, sep(sec) + "." + pad(ms) + " " + pad(us) + " s", rect, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 }
 
@@ -769,7 +772,7 @@ class TimeDrawNanosec extends TimeDraw {
         long millisec = microsec / MILLISEC_IN_US;
         long ms = millisec % PAD_1000;
         long sec = millisec / SEC_IN_MS;
-        return Utils.drawText(gc, sep(sec) + "." + pad(ms) + " " + pad(us) + " " + pad(ns), rect, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        return Utils.drawText(gc, sep(sec) + "." + pad(ms) + " " + pad(us) + " " + pad(ns) + " s", rect, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 }
 
This page took 0.027554 seconds and 5 git commands to generate.