Add process and syscall labels to Control Flow and Resources views
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / TimeGraphControl.java
index df90b6f5c4b7a758573116661d614cc005a0b062..ede0e83314391fd5fc02914f2c87017cbc11c816 100644 (file)
@@ -903,7 +903,36 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         return idx >= 0 ? _data._expandedItems[idx]._trace : null;
     }
 
-    long getTimeAtX(int x) {
+    /**
+     * Return the x coordinate corresponding to a time
+     *
+     * @param time the time
+     * @return the x coordinate corresponding to the time
+     *
+     * @since 2.0
+     */
+    public int getXForTime(long time) {
+        if (null == _timeProvider) {
+            return -1;
+        }
+        long time0 = _timeProvider.getTime0();
+        long time1 = _timeProvider.getTime1();
+        int width = getCtrlSize().x;
+        int nameSpace = _timeProvider.getNameSpace();
+        double pixelsPerNanoSec = (width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (width - nameSpace - RIGHT_MARGIN) / (time1 - time0);
+        int x = getBounds().x + nameSpace + (int) ((time - time0) * pixelsPerNanoSec);
+        return x;
+    }
+
+    /**
+     * Return the time corresponding to an x coordinate
+     *
+     * @param x the x coordinate
+     * @return the time corresponding to the x coordinate
+     *
+     * @since 2.0
+     */
+    public long getTimeAtX(int x) {
         if (null == _timeProvider) {
             return -1;
         }
This page took 0.026222 seconds and 5 git commands to generate.