Bug 378401: Implementation of time graph widget.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / TimeGraphControl.java
index ec7a8bc3a4a3fcaecb4a1000d0e3599c9f24539a..d6328ac26a86a1af46d7c0975591643975e44f5a 100644 (file)
@@ -723,14 +723,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         long time1 = _timeProvider.getTime1();\r
         int nameWidth = _timeProvider.getNameSpace();\r
         x -= nameWidth;\r
+        int timeWidth = size.x - nameWidth - RIGHT_MARGIN;\r
         if (x >= 0 && size.x >= nameWidth) {\r
-            if (time1 - time0 > size.x - nameWidth - RIGHT_MARGIN) {\r
+            if (time1 - time0 > timeWidth) {\r
                 // get the last possible time represented by the pixel position\r
-                // by taking the time of the next pixel position minus 1\r
-                // nanosecond\r
-                hitTime = time0 + (long) ((time1 - time0) * ((double) (x + 1) / (size.x - nameWidth - RIGHT_MARGIN))) - 1;\r
+                // by taking the time of the next pixel position minus 1 nanosecond\r
+                hitTime = time0 + (long) ((time1 - time0) * ((double) (x + 1) / timeWidth)) - 1;\r
             } else {\r
-                hitTime = time0 + (long) ((time1 - time0) * ((double) (x) / (size.x - nameWidth - RIGHT_MARGIN)));\r
+                hitTime = time0 + Math.round((time1 - time0) * ((double) x / timeWidth));\r
             }\r
         }\r
         return hitTime;\r
This page took 0.024367 seconds and 5 git commands to generate.