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;
}