/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
+ * Copyright (c) 2009, 2010 Ericsson\r
* \r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
*/\r
public void waitCursor(boolean waitInd);\r
\r
+ public void setFocus();\r
+\r
}
\ No newline at end of file
/********************************************************************** \r
- * Copyright (c) 2005, 2008, 2009 IBM Corporation, Intel Corporation, Ericsson\r
+ * Copyright (c) 2005, 2008, 2009, 2010 IBM Corporation, Intel Corporation, Ericsson\r
* \r
* All rights reserved. This program and the accompanying materials \r
* are made available under the terms of the Eclipse Public License v1.0 \r
public static String _TRACE_CLASS_NAME;\r
public static String _TRACE_GROUP_NAME;\r
public static String _TRACE_START_TIME;\r
+ public static String _TRACE_EVENT_TIME;\r
public static String _TRACE_DATE;\r
public static String _TRACE_STOP_TIME;\r
public static String _TRACE_STATE;\r
public static String _TRACE_FILTER_DESC;\r
// misc\r
public static String _Timescale;\r
- public static String _DURATION;\r
+ public static String _DURATION;\r
public static String _UNDEFINED_GROUP;\r
public static String _TRACE_GROUP_LABEL;\r
public static String _EDIT_PROFILING_OPTIONS;\r
/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
+ * Copyright (c) 2009, 2010 Ericsson\r
* \r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
import java.util.List;\r
import java.util.Map;\r
\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
import org.eclipse.swt.graphics.GC;\r
import org.eclipse.swt.graphics.Image;\r
import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.ui.plugin.AbstractUIPlugin;\r
\r
public abstract class TmfTimeAnalysisProvider {\r
\r
}\r
}\r
\r
- static private String _externalPath[] = {\r
- "icons/full/obj16/thread_obj.gif", // running thread\r
- "icons/full/obj16/threads_obj.gif", // suspended\r
- "icons/full/obj16/threadt_obj.gif", // stopped\r
- "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
- "icons/full/obj16/stckframe_obj.gif", // stack frame\r
- };\r
-\r
- static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
- "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
- "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
-\r
- static private Image getImage(int idx) {\r
- if (idx < 0 || idx >= IMG_NUM)\r
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
- String key = "trace.img." + idx;\r
- Image img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
- if (null == img) {\r
- ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
- _externalPlugin[idx], _externalPath[idx]);\r
- TmfUiPlugin.getDefault().getImageRegistry().put(key, desc);\r
- img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
- }\r
- return img;\r
- }\r
+ // static private String _externalPath[] = {\r
+ // "icons/full/obj16/thread_obj.gif", // running thread\r
+ // "icons/full/obj16/threads_obj.gif", // suspended\r
+ // "icons/full/obj16/threadt_obj.gif", // stopped\r
+ // "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
+ // "icons/full/obj16/stckframe_obj.gif", // stack frame\r
+ // };\r
+ //\r
+ // static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
+ // "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
+ // "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
+ //\r
+ // static private Image getImage(int idx) {\r
+ // if (idx < 0 || idx >= IMG_NUM)\r
+ // SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
+ // String key = "trace.img." + idx;\r
+ // Image img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
+ // if (null == img) {\r
+ // ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
+ // _externalPlugin[idx], _externalPath[idx]);\r
+ // TmfUiPlugin.getDefault().getImageRegistry().put(key, desc);\r
+ // img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
+ // }\r
+ // return img;\r
+ // }\r
\r
public void drawState(TraceColorScheme colors, ITimeEvent event,\r
Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
* @return\r
*/\r
public Image getItemImage(Object obj) {\r
+ /*\r
if (obj instanceof ITmfTimeAnalysisEntry) {\r
List<TimeEvent> list = ((ITmfTimeAnalysisEntry) obj).getTraceEvents();\r
if (null != list && list.size() > 0)\r
if (obj instanceof TimeEvent) {\r
return getImage(IMG_THREAD_RUNNING);\r
}\r
+ */\r
return null;\r
}\r
\r
/*****************************************************************************\r
- * Copyright (c) 2007, 2008, 2009 Intel Corporation, Ericsson\r
+ * Copyright (c) 2007, 2008, 2009, 2010 Intel Corporation, Ericsson\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
* which accompanies this distribution, and is available at\r
import org.eclipse.swt.events.SelectionEvent;\r
import org.eclipse.swt.events.SelectionListener;\r
import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridLayout;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Control;\r
\r
// Calender Time format, using Epoch reference or Relative time\r
// format(default\r
private boolean calendarTimeFormat = false;\r
- private int timeScaleBoderWidth = 4;\r
+ private int borderWidth = 4;\r
private int timeScaleHeight = 22;\r
\r
/** ctor */\r
_colors = new TraceColorScheme();\r
_dataViewer = new Composite(parent, SWT.NULL);\r
_dataViewer.setLayoutData(GridUtil.createFill());\r
+ GridLayout gl = new GridLayout();\r
+ gl.marginHeight = borderWidth;\r
+ gl.marginWidth = 0;\r
+ gl.verticalSpacing = 0;\r
+ gl.horizontalSpacing = 0;\r
+ _dataViewer.setLayout(gl);\r
\r
_timeScaleCtrl = new TimeScaleCtrl(_dataViewer, _colors);\r
_timeScaleCtrl.setTimeProvider(this);\r
- _timeScaleCtrl.setLayoutData(GridUtil.createFill());\r
+ _timeScaleCtrl.setLayoutData(GridUtil.createHorizontalFill());\r
+ _timeScaleCtrl.setHeight(timeScaleHeight);\r
\r
_stateCtrl = new TmfTimeStatesCtrl(_dataViewer, _colors, _utilImplm);\r
\r
if (r.isEmpty())\r
return;\r
\r
- // System.out.println("Client Area:" + r);\r
- // timeScaleBoderWidth = 8;\r
- // timeScaleHeight = 22;\r
- _timeScaleCtrl.setBounds(r.x, r.y + timeScaleBoderWidth, r.width,\r
- timeScaleHeight);\r
- _stateCtrl.setBounds(r.x, r.y + timeScaleBoderWidth + timeScaleHeight,\r
- r.width, r.height - timeScaleBoderWidth - timeScaleHeight);\r
int width = r.width;\r
if (_nameWidth > width - _minNameWidth)\r
_nameWidth = width - _minNameWidth;\r
_nameWidth = _minNameWidth;\r
}\r
\r
- /** Tries to set most convinient time range for display. */\r
+ /** Tries to set most convenient time range for display. */\r
void setTimeRange(Object traces[]) {\r
_endTime = 0;\r
_beginTime = -1;\r
ITimeEvent event;\r
for (int i = 0; i < traces.length; i++) {\r
- ITmfTimeAnalysisEntry thread = (ITmfTimeAnalysisEntry) traces[i];\r
- long lastEventTime = thread.getStopTime();\r
- if (lastEventTime > thread.getStartTime()) {\r
- if (lastEventTime > _endTime)\r
- _endTime = lastEventTime;\r
+ ITmfTimeAnalysisEntry entry = (ITmfTimeAnalysisEntry) traces[i];\r
+ if (entry.getStopTime() >= entry.getStartTime() && entry.getStopTime() > 0) {\r
+ if (_beginTime < 0 || entry.getStartTime() < _beginTime) {\r
+ _beginTime = entry.getStartTime();\r
+ }\r
+ if (entry.getStopTime() > _endTime) {\r
+ _endTime = entry.getStopTime();\r
+ }\r
}\r
- List<TimeEvent> list = thread.getTraceEvents();\r
+ List<TimeEvent> list = entry.getTraceEvents();\r
int len = list.size();\r
if (len > 0) {\r
+ event = (ITimeEvent) list.get(0);\r
+ if (_beginTime < 0 || event.getTime() < _beginTime) {\r
+ _beginTime = event.getTime();\r
+ }\r
event = (ITimeEvent) list.get(list.size() - 1);\r
- lastEventTime = event.getTime();\r
- if (lastEventTime > _endTime) {\r
- _endTime = lastEventTime;\r
- long duration = event.getDuration();\r
- _endTime += duration > 0 ? duration : 1000000;\r
+ long eventEndTime = event.getTime() + (event.getDuration() > 0 ? event.getDuration() : 0);\r
+ if (eventEndTime > _endTime) {\r
+ _endTime = eventEndTime;\r
}\r
- event = (ITimeEvent) list.get(0);\r
- if (_beginTime < 0 || _beginTime > event.getTime())\r
- _beginTime = event.getTime();\r
}\r
}\r
\r
}\r
\r
void setTimeBounds() {\r
- _time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
+ //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
+ _time0_ = _beginTime;\r
if (_time0_ < 0)\r
_time0_ = 0;\r
// _time1_ = _time0_ + (_endTime - _time0_) * 1.05;\r
void updateInternalData(ITmfTimeAnalysisEntry[] traces, long start, long end) {\r
if (null == traces)\r
traces = new ITmfTimeAnalysisEntry[0];\r
- if (end < 1 || start < 1) {\r
- // End or start time are unspecified and need to be determined from\r
+ if ((start == 0 && end == 0) || start < 0 || end < 0) {\r
+ // Start and end time are unspecified and need to be determined from\r
// individual processes\r
setTimeRange(traces);\r
} else {\r
*/\r
private void refreshAllData(ITmfTimeAnalysisEntry[] traces) {\r
setTimeBounds();\r
- if (_selectedTime < 0 || _selectedTime > _endTime)\r
- _selectedTime = _endTime;\r
+ if (_selectedTime < _beginTime) {\r
+ _selectedTime = _beginTime;\r
+ } else if (_selectedTime > _endTime) {\r
+ _selectedTime = _endTime;\r
+ }\r
_stateCtrl.refreshData(traces);\r
filterOutNotification();\r
}\r
return _time0_;\r
}\r
\r
- /*\r
- * (non-Javadoc)\r
- * \r
- * @see\r
- * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
- * #mouseUp()\r
- */\r
- public void mouseUp() {\r
- // refresh listeners with the new selected time if changed\r
- notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
- }\r
-\r
/*\r
* (non-Javadoc)\r
* \r
_time0 += dt;\r
_time1 += dt;\r
}\r
- if (_time0 < 0) {\r
- _time1 -= _time0;\r
- _time0 = 0;\r
+ if (_time0 < _time0_) {\r
+ _time1 += _time0_ - _time0;\r
+ _time0 = _time0_;\r
} else if (_time1 > _time1_) {\r
_time0 -= _time1 - _time1_;\r
_time1 = _time1_;\r
}\r
\r
public int getBorderWidth() {\r
- return timeScaleBoderWidth;\r
+ return borderWidth;\r
}\r
\r
public void setBorderWidth(int borderWidth) {\r
if (borderWidth > -1) {\r
- this.timeScaleBoderWidth = borderWidth;\r
+ this.borderWidth = borderWidth;\r
+ GridLayout gl = (GridLayout)_dataViewer.getLayout();\r
+ gl.marginHeight = borderWidth;\r
}\r
}\r
\r
public void setHeaderHeight(int headerHeight) {\r
if (headerHeight > -1) {\r
this.timeScaleHeight = headerHeight;\r
+ _timeScaleCtrl.setHeight(headerHeight);\r
}\r
}\r
\r
#*******************************************************************************\r
-# Copyright (c) 2009 Ericsson\r
+# Copyright (c) 2009, 2010 Ericsson\r
# \r
# All rights reserved. This program and the accompanying materials are\r
# made available under the terms of the Eclipse Public License v1.0 which\r
_TRACE_CLASS_NAME = Class Name\r
_TRACE_GROUP_NAME = Group Name\r
_TRACE_START_TIME = Start Time\r
+_TRACE_EVENT_TIME = Event Time\r
_TRACE_STOP_TIME = Stop Time\r
_DURATION = Duration\r
_TRACE_STATE = State\r
/*****************************************************************************\r
- * Copyright (c) 2007, Intel Corporation.\r
+ * Copyright (c) 2007, 2010 Intel Corporation.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
* which accompanies this distribution, and is available at\r
* Contributors:\r
* Intel Corporation - Initial API and implementation\r
* Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- * Alvaro Sanchex-Leon - Udpated for TMF\r
+ * Alvaro Sanchex-Leon - Updated for TMF\r
*\r
* $Id: ITimeDataProvider.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
*****************************************************************************/\r
\r
long getMinTimeInterval();\r
\r
- /**\r
- * Receive Notification when any of the buttons of the mouse switch back to\r
- * up position, this method may trigger time update notification to\r
- * listeners\r
- */\r
- void mouseUp();\r
-\r
/**\r
* Updates the time range and notify registered listeners\r
* \r
/*****************************************************************************\r
- * Copyright (c) 2007, 2008 Intel Corporation and others.\r
+ * Copyright (c) 2007, 2008, 2010 Intel Corporation and others.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
* which accompanies this distribution, and is available at\r
package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
\r
import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
import java.util.Date;\r
+import java.util.GregorianCalendar;\r
+import java.util.TimeZone;\r
\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.Messages;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.Utils.Resolution;\r
addMouseMoveListener(this);\r
}\r
\r
+ private static final long SEC_IN_NS = 1000000000;\r
+ private static final long MIN_IN_NS = 60 * SEC_IN_NS;\r
+ private static final long HOUR_IN_NS = 60 * MIN_IN_NS;\r
+ private static final long DAY_IN_NS = 24 * HOUR_IN_NS;\r
+ private static final long MONTH_IN_NS = 31 * DAY_IN_NS; // upper limit\r
+ private static final long YEAR_IN_NS = 366 * DAY_IN_NS; // upper limit\r
+ \r
+ private static final double LOG10_1 = Math.log10(1);\r
+ private static final double LOG10_2 = Math.log10(2);\r
+ private static final double LOG10_3 = Math.log10(3);\r
+ private static final double LOG10_5 = Math.log10(5);\r
+ \r
+ private static final Calendar GREGORIAN_CALENDAR = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));\r
+ \r
private ITimeDataProvider _timeProvider;\r
private int _dragState = 0;\r
private int _dragX0 = 0;\r
private long _time1bak;\r
private boolean _isInUpdate;\r
private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
+ private int _height;\r
\r
public void setTimeProvider(ITimeDataProvider timeProvider) {\r
_timeProvider = timeProvider;\r
}\r
\r
- private double _timeDeltaD;\r
private long _timeDelta;\r
\r
- private void calcTimeDelta(int width, double K) {\r
- long D[] = { 1, 2, 5, };\r
- long pow = 1;\r
- double powD = 1;\r
- long td = pow;\r
- double tdD = powD;\r
- double dx = tdD * K;\r
- int i = 0;\r
- while (dx < width) {\r
- td = D[i] * pow;\r
- tdD = D[i] * powD;\r
- dx = tdD * K;\r
- i++;\r
- if (i == 3) {\r
- i = 0;\r
- pow *= 10;\r
- powD *= 10;\r
- }\r
- }\r
- _timeDeltaD = tdD;\r
- _timeDelta = td;\r
-// Trace.debug("Width: " + width + " K: " + K + " Time Delta: "\r
-// + _timeDelta);\r
- }\r
-\r
- static private TimeDraw _tds[] = new TimeDraw[] { new TimeDrawSec(),\r
- new TimeDrawMillisec(), new TimeDrawMicrosec(),\r
- new TimeDrawNanosec(), new TimeDrawAbsSec(),\r
- new TimeDrawAbsMillisec(), new TimeDrawAbsMicroSec(),\r
- new TimeDrawAbsNanoSec() };\r
+ @Override\r
+ public Point computeSize(int wHint, int hHint, boolean changed) {\r
+ return super.computeSize(wHint, _height, changed);\r
+ }\r
+\r
+ public void setHeight(int height) {\r
+ this._height = height;\r
+ }\r
+ \r
+ private void calcTimeDelta(int width, double pixelsPerNanoSec) {\r
+ double minDelta = (double) ((pixelsPerNanoSec ==0) ? YEAR_IN_NS : width / pixelsPerNanoSec);\r
+ long unit = 1;\r
+ if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+ if (minDelta > 6 * MONTH_IN_NS) {\r
+ unit = YEAR_IN_NS;\r
+ } else if (minDelta > 3 * MONTH_IN_NS) {\r
+ unit = 6 * MONTH_IN_NS;\r
+ } else if (minDelta > 10 * DAY_IN_NS) {\r
+ unit = MONTH_IN_NS;\r
+ } else if (minDelta > 12 * HOUR_IN_NS) {\r
+ unit = DAY_IN_NS;\r
+ } else if (minDelta > 3 * HOUR_IN_NS) {\r
+ unit = 6 * HOUR_IN_NS;\r
+ } else if (minDelta > 30 * MIN_IN_NS) {\r
+ unit = HOUR_IN_NS;\r
+ } else if (minDelta > 10 * MIN_IN_NS) {\r
+ unit = 15 * MIN_IN_NS;\r
+ } else if (minDelta > 30 * SEC_IN_NS) {\r
+ unit = MIN_IN_NS;\r
+ } else if (minDelta > 20 * SEC_IN_NS) {\r
+ unit = 30 * SEC_IN_NS;\r
+ }\r
+ }\r
+ double log = Math.log10((double) minDelta / unit);\r
+ long pow10 = (long) log;\r
+ double remainder = log - pow10;\r
+ if (remainder < LOG10_1) {\r
+ _timeDelta = (long) Math.pow(10, pow10) * unit;\r
+ } else if (remainder < LOG10_2) {\r
+ _timeDelta = 2 * (long) Math.pow(10, pow10) * unit;\r
+ } else if (remainder < LOG10_3 && unit >= HOUR_IN_NS && unit < YEAR_IN_NS) {\r
+ _timeDelta = 3 * (long) Math.pow(10, pow10) * unit;\r
+ } else if (remainder < LOG10_5) {\r
+ _timeDelta = 5 * (long) Math.pow(10, pow10) * unit;\r
+ } else {\r
+ _timeDelta = 10 * (long) Math.pow(10, pow10) * unit;\r
+ }\r
+ }\r
+\r
+ private static TimeDraw TIMEDRAW_NANOSEC = new TimeDrawNanosec();\r
+ private static TimeDraw TIMEDRAW_MICROSEC = new TimeDrawMicrosec();\r
+ private static TimeDraw TIMEDRAW_MILLISEC = new TimeDrawMillisec();\r
+ private static TimeDraw TIMEDRAW_SEC = new TimeDrawSec();\r
+ private static TimeDraw TIMEDRAW_ABS_NANOSEC = new TimeDrawAbsNanoSec();\r
+ private static TimeDraw TIMEDRAW_ABS_MICROSEC = new TimeDrawAbsMicroSec();\r
+ private static TimeDraw TIMEDRAW_ABS_MILLISEC = new TimeDrawAbsMillisec();\r
+ private static TimeDraw TIMEDRAW_ABS_SEC = new TimeDrawAbsSec();\r
+ private static TimeDraw TIMEDRAW_ABS_MIN = new TimeDrawAbsMin();\r
+ private static TimeDraw TIMEDRAW_ABS_HRS = new TimeDrawAbsHrs();\r
+ private static TimeDraw TIMEDRAW_ABS_DAY = new TimeDrawAbsDay();\r
+ private static TimeDraw TIMEDRAW_ABS_MONTH = new TimeDrawAbsMonth();\r
+ private static TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();\r
\r
TimeDraw getTimeDraw(long timeDelta) {\r
TimeDraw timeDraw;\r
- if (_timeProvider != null) {\r
- if (_timeProvider.isCalendarFormat()) {\r
- if (timeDelta >= 1000000000)\r
- timeDraw = _tds[4];\r
- else if (timeDelta >= 1000000)\r
- timeDraw = _tds[5];\r
- else if (timeDelta >= 1000)\r
- timeDraw = _tds[6];\r
- else\r
- timeDraw = _tds[7];\r
- return timeDraw;\r
- }\r
+ if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+ if (timeDelta >= YEAR_IN_NS)\r
+ timeDraw = TIMEDRAW_ABS_YEAR;\r
+ else if (timeDelta >= MONTH_IN_NS)\r
+ timeDraw = TIMEDRAW_ABS_MONTH;\r
+ else if (timeDelta >= DAY_IN_NS)\r
+ timeDraw = TIMEDRAW_ABS_DAY;\r
+ else if (timeDelta >= HOUR_IN_NS)\r
+ timeDraw = TIMEDRAW_ABS_HRS;\r
+ else if (timeDelta >= MIN_IN_NS)\r
+ timeDraw = TIMEDRAW_ABS_MIN;\r
+ else if (timeDelta >= SEC_IN_NS)\r
+ timeDraw = TIMEDRAW_ABS_SEC;\r
+ else if (timeDelta >= 1000000)\r
+ timeDraw = TIMEDRAW_ABS_MILLISEC;\r
+ else if (timeDelta >= 1000)\r
+ timeDraw = TIMEDRAW_ABS_MICROSEC;\r
+ else\r
+ timeDraw = TIMEDRAW_ABS_NANOSEC;\r
+ return timeDraw;\r
}\r
if (timeDelta >= 1000000000)\r
- timeDraw = _tds[0];\r
+ timeDraw = TIMEDRAW_SEC;\r
else if (timeDelta >= 1000000)\r
- timeDraw = _tds[1];\r
+ timeDraw = TIMEDRAW_MILLISEC;\r
else if (timeDelta >= 1000)\r
- timeDraw = _tds[2];\r
+ timeDraw = TIMEDRAW_MICROSEC;\r
else\r
- timeDraw = _tds[3];\r
+ timeDraw = TIMEDRAW_NANOSEC;\r
return timeDraw;\r
}\r
\r
return;\r
\r
GC gc = e.gc;\r
+ gc.fillRectangle(rect);\r
+ \r
if (null == _timeProvider) {\r
- gc.fillRectangle(rect);\r
return;\r
}\r
\r
- gc.setBackground(_colors.getColor(TraceColorScheme.TOOL_BACKGROUND));\r
- gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND));\r
long time0 = _timeProvider.getTime0();\r
long time1 = _timeProvider.getTime1();\r
long selectedTime = _timeProvider.getSelectedTime();\r
int leftSpace = _timeProvider.getNameSpace();\r
int timeSpace = _timeProvider.getTimeSpace();\r
-\r
- if (time1 <= time0 || timeSpace < 2) {\r
- gc.fillRectangle(rect);\r
- return;\r
- }\r
-\r
- int numDigits = calculateDigits(time0, time1);\r
-\r
+ \r
+ gc.setBackground(_colors.getColor(TraceColorScheme.TOOL_BACKGROUND));\r
+ gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND));\r
Utils.init(_rect0, rect);\r
- int labelWidth = gc.getCharWidth('0') * numDigits;\r
- double K = 1;\r
- if (rect.width - leftSpace > 0) {\r
- K = (double) timeSpace / (time1 - time0);\r
- calcTimeDelta(labelWidth, K);\r
- }\r
\r
- TimeDraw timeDraw = getTimeDraw(_timeDelta);\r
-\r
// draw top left area\r
_rect0.width = leftSpace;\r
- gc.fillRectangle(_rect0);\r
_rect0.x += 4;\r
_rect0.width -= 4;\r
if (_rect0.width > 0) {\r
-// TODO: Check if we really need that piece of code... \r
-// if (false && rect.width - leftSpace > 0)\r
-// Utils.drawText(gc, Messages._Timescale + ": "\r
-// + timeDraw.hint(), _rect0, true);\r
-// else\r
- Utils.drawText(gc, Messages._Timescale + ":", _rect0, true);\r
+ Utils.drawText(gc, Messages._Timescale + ":", _rect0, true);\r
}\r
+ int messageWidth = gc.stringExtent(Messages._Timescale + ":").x + 4;\r
+ Rectangle absHeaderRect = new Rectangle(_rect0.x + messageWidth, _rect0.y, _rect0.width - messageWidth, _rect0.height);\r
_rect0.x -= 4;\r
_rect0.width += 4;\r
-\r
+ \r
// prepare and draw right rect of the timescale\r
_rect0.x += leftSpace;\r
_rect0.width = rect.width - leftSpace;\r
-\r
+ \r
// draw bottom border and erase all other area\r
gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1,\r
- rect.y + rect.height - 1);\r
+ rect.y + rect.height - 1);\r
_rect0.height--;\r
gc.fillRectangle(_rect0);\r
+ \r
+ if (time1 <= time0 || timeSpace < 2) {\r
+ return;\r
+ }\r
+ \r
+ int numDigits = calculateDigits(time0, time1);\r
+ \r
+ int labelWidth = gc.getCharWidth('0') * numDigits;\r
+ double pixelsPerNanoSec = (timeSpace <= 2) ? 0 :\r
+ (double) (timeSpace - 2) / (time1 - time0); // 2 pixels less to make sure end time is visible\r
+ calcTimeDelta(labelWidth, pixelsPerNanoSec);\r
+ \r
+ TimeDraw timeDraw = getTimeDraw(_timeDelta);\r
+\r
+ // draw zoom rectangle\r
+ if (3 == _dragState && null != _timeProvider) {\r
+ if (_dragX0 < _dragX) {\r
+ gc.drawRectangle(leftSpace + _dragX0, rect.y, _dragX - _dragX0 - 1, rect.height - 8);\r
+ } else if (_dragX0 > _dragX) {\r
+ gc.drawRectangle(leftSpace + _dragX, rect.y, _dragX0 - _dragX - 1, rect.height - 8);\r
+ }\r
+ }\r
\r
if (_rect0.isEmpty())\r
return;\r
\r
// draw selected time\r
- int x = _rect0.x + (int) ((selectedTime - time0) * K);\r
+ int x = _rect0.x + (int) ((double)(selectedTime - time0) * pixelsPerNanoSec);\r
if (x >= _rect0.x && x < _rect0.x + _rect0.width) {\r
gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y\r
_rect0.y = rect.y;\r
_rect0.height = rect.height - 4;\r
_rect0.width = labelWidth;\r
- long time = (long) (Math.floor(time0 / _timeDeltaD) * _timeDeltaD);\r
+ \r
+ long time;\r
+ if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+ time = floorToCalendar(time0, _timeDelta);\r
+ } else {\r
+ time = (long) (Math.ceil((double) time0 / _timeDelta) * _timeDelta);\r
+ }\r
+ \r
// long t = (long) (time * 1000000000);\r
- long t = time;\r
int y = _rect0.y + _rect0.height;\r
+\r
+ if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+ timeDraw.drawAbsHeader(gc, time, absHeaderRect);\r
+ }\r
+ \r
while (true) {\r
- x = rect.x + leftSpace + (int) ((time - time0) * K);\r
+ x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));\r
if (x >= rect.x + leftSpace + rect.width - _rect0.width) {\r
break;\r
}\r
gc.drawLine(x, y, x, y + 4);\r
_rect0.x = x;\r
if (x + _rect0.width <= rect.x + rect.width)\r
- timeDraw.draw(gc, t, _rect0);\r
+ timeDraw.draw(gc, time, _rect0);\r
+ }\r
+ if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - _timeDelta) {\r
+ break;\r
}\r
- time += _timeDeltaD;\r
- t += _timeDelta;\r
+ time += _timeDelta;\r
+ if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+ if (_timeDelta >= YEAR_IN_NS) {\r
+ GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+ GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
+ GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
+ time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+ } else if (_timeDelta >= MONTH_IN_NS) {\r
+ GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+ GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
+ time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+ }\r
+ }\r
}\r
}\r
\r
+ private long floorToCalendar(long time, long timeDelta) {\r
+ if (_timeDelta >= YEAR_IN_NS) {\r
+ GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+ int year = GREGORIAN_CALENDAR.get(Calendar.YEAR);\r
+ int yearDelta = (int) (timeDelta / YEAR_IN_NS);\r
+ year = (year / yearDelta) * yearDelta;\r
+ GREGORIAN_CALENDAR.set(Calendar.YEAR, year);\r
+ GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
+ GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
+ GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
+ GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
+ GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
+ GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
+ time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+ } else if (_timeDelta >= MONTH_IN_NS) {\r
+ GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+ int month = GREGORIAN_CALENDAR.get(Calendar.MONTH);\r
+ int monthDelta = (int) (timeDelta / MONTH_IN_NS);\r
+ month = (month / monthDelta) * monthDelta;\r
+ GREGORIAN_CALENDAR.set(Calendar.MONTH, month);\r
+ GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
+ GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
+ GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
+ GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
+ GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
+ time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+ } else {\r
+ time = (time / timeDelta) * timeDelta;\r
+ }\r
+ return time;\r
+ }\r
+ \r
private int calculateDigits(long time0, long time1) {\r
int numDigits = 5;\r
long timeRange = time1 - time0;\r
// Calculate the number of digits to represent the minutes provided\r
// 11:222\r
// HH:mm:ss\r
- numDigits += 5;\r
+ numDigits += 8;\r
if (timeRange < 10000) {\r
// HH:11:222:333:444__\r
numDigits += 10;\r
}\r
\r
public void mouseDown(MouseEvent e) {\r
- if (1 == e.button && null != _timeProvider) {\r
- setCapture(true);\r
- _dragState = 1;\r
- }\r
- // Window adjustment allowed using mouse button three.\r
- _dragX = _dragX0 = e.x - _timeProvider.getNameSpace();\r
- _time0bak = _timeProvider.getTime0();\r
- _time1bak = _timeProvider.getTime1();\r
+ if (_dragState == 0 && null != _timeProvider) {\r
+ if (1 == e.button) {\r
+ setCapture(true);\r
+ _dragState = 1;\r
+ } else if (3 == e.button) {\r
+ _dragState = 3;\r
+ }\r
+ int x = e.x - _timeProvider.getNameSpace();\r
+ if (x < 0) {\r
+ x = 0;\r
+ } else if (x > getSize().x - _timeProvider.getNameSpace()) {\r
+ x = getSize().x - _timeProvider.getNameSpace();\r
+ }\r
+ _dragX = _dragX0 = x;\r
+ _time0bak = _timeProvider.getTime0();\r
+ _time1bak = _timeProvider.getTime1();\r
+ }\r
}\r
\r
public void mouseUp(MouseEvent e) {\r
- if (1 == _dragState) {\r
+ if (e.button == 1 && _dragState == 1) {\r
setCapture(false);\r
_dragState = 0;\r
- }\r
-\r
- if (3 == e.button && null != _timeProvider) {\r
- if (_dragX0 < 0) {\r
+ } else if (e.button == 3 && _dragState == 3 && null != _timeProvider) {\r
+ _dragState = 0;\r
+ if (_dragX0 == _dragX) {\r
return;\r
}\r
- Point size = getSize();\r
-\r
+ int timeSpace = _timeProvider.getTimeSpace();\r
int leftSpace = _timeProvider.getNameSpace();\r
int x = e.x - leftSpace;\r
- if (x > 0 && size.x > leftSpace && _dragX != x) {\r
+ if (timeSpace > 0) {\r
_dragX = x;\r
- long time0 = _time0bak + ((_time1bak - _time0bak) * _dragX0)\r
- / (size.x - leftSpace);\r
- long time1 = _time0bak + ((_time1bak - _time0bak) * _dragX)\r
- / (size.x - leftSpace);\r
+ if (_dragX0 > _dragX) { // drag right to left\r
+ _dragX = _dragX0;\r
+ _dragX0 = x;\r
+ }\r
+ long time0 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / timeSpace));\r
+ long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX / timeSpace));\r
\r
_timeProvider.setStartFinishTime(time0, time1);\r
+ _time0bak = _timeProvider.getTime0();\r
+ _time1bak = _timeProvider.getTime1();\r
}\r
}\r
\r
// Notify time provider to check the need for listener notification\r
- _timeProvider.mouseUp();\r
+ _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
}\r
\r
public void mouseMove(MouseEvent e) {\r
- if (_dragX0 < 0) {\r
+ if (_dragX0 < 0 || _dragState == 0) {\r
return;\r
}\r
Point size = getSize();\r
+ int leftSpace = _timeProvider.getNameSpace();\r
+ int timeSpace = _timeProvider.getTimeSpace();\r
+ int x = e.x - leftSpace;\r
if (1 == _dragState && null != _timeProvider) {\r
- int leftSpace = _timeProvider.getNameSpace();\r
- int x = e.x - leftSpace;\r
if (x > 0 && size.x > leftSpace && _dragX != x) {\r
_dragX = x;\r
- long time1 = _time0bak + ((_time1bak - _time0bak) * _dragX0)\r
- / _dragX;\r
+ long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / _dragX));\r
_timeProvider.setStartFinishTime(_time0bak, time1);\r
}\r
+ } else if (3 == _dragState && null != _timeProvider) {\r
+ if (x < 0) {\r
+ _dragX = 0;\r
+ } else if (x > timeSpace) {\r
+ _dragX = timeSpace;\r
+ } else {\r
+ _dragX = x;\r
+ }\r
+ redraw();\r
}\r
}\r
\r
public void mouseDoubleClick(MouseEvent e) {\r
if (null != _timeProvider) {\r
_timeProvider.resetStartFinishTime();\r
+ _time0bak = _timeProvider.getTime0();\r
+ _time1bak = _timeProvider.getTime1();\r
}\r
}\r
}\r
static String S = ":";\r
static String S0 = ":0";\r
static String S00 = ":00";\r
- protected SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");\r
+ protected static final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");\r
+ protected static final SimpleDateFormat stimeformatheader = new SimpleDateFormat("yyyy MMM dd");\r
+ protected static final SimpleDateFormat sminformat = new SimpleDateFormat("HH:mm");\r
+ protected static final SimpleDateFormat sminformatheader = new SimpleDateFormat("yyyy MMM dd");\r
+ protected static final SimpleDateFormat shrsformat = new SimpleDateFormat("MMM dd HH:mm");\r
+ protected static final SimpleDateFormat shrsformatheader = new SimpleDateFormat("yyyy");\r
+ protected static final SimpleDateFormat sdayformat = new SimpleDateFormat("MMM dd");\r
+ protected static final SimpleDateFormat sdayformatheader = new SimpleDateFormat("yyyy");\r
+ protected static final SimpleDateFormat smonthformat = new SimpleDateFormat("yyyy MMM");\r
+ protected static final SimpleDateFormat syearformat = new SimpleDateFormat("yyyy");\r
+ static {\r
+ stimeformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ stimeformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ sminformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ sminformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ shrsformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ shrsformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ sdayformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ sdayformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ smonthformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ syearformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ }\r
\r
static String pad(long n) {\r
String s = S;\r
return s + n;\r
}\r
\r
- public abstract void draw(GC gc, long time, Rectangle rect);\r
+ public abstract void draw(GC gc, long time, Rectangle rect);\r
\r
+ public void drawAbsHeader(GC gc, long time, Rectangle absHeaderRect) {\r
+ // Override to draw absolute time header\r
+ // This is for the time information not shown in the draw of each tick\r
+ }\r
+ \r
public abstract String hint();\r
}\r
\r
}\r
}\r
\r
-class TimeDrawAbsSec extends TimeDraw {\r
- static String _hint = "HH:mm:ss";\r
+class TimeDrawAbsYear extends TimeDraw {\r
+ static String _hint = "YYYY";\r
\r
- @Override\r
- public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
- Utils.drawText(gc, stime, rect, true);\r
- }\r
+ @Override\r
+ public void draw(GC gc, long time, Rectangle rect) {\r
+ String stime = syearformat.format(new Date((long) (time / 1000000)));\r
+ Utils.drawText(gc, stime, rect, true);\r
+ }\r
\r
- @Override\r
- public String hint() {\r
- return _hint;\r
- }\r
+ @Override\r
+ public String hint() {\r
+ return _hint;\r
+ }\r
+}\r
+\r
+class TimeDrawAbsMonth extends TimeDraw {\r
+ static String _hint = "YYYY Mmm";\r
+\r
+ @Override\r
+ public void draw(GC gc, long time, Rectangle rect) {\r
+ String stime = smonthformat.format(new Date((long) (time / 1000000)));\r
+ Utils.drawText(gc, stime, rect, true);\r
+ }\r
+\r
+ @Override\r
+ public String hint() {\r
+ return _hint;\r
+ }\r
+}\r
+\r
+class TimeDrawAbsDay extends TimeDraw {\r
+ static String _hint = "Mmm dd";\r
+\r
+ @Override\r
+ public void draw(GC gc, long time, Rectangle rect) {\r
+ String stime = sdayformat.format(new Date((long) (time / 1000000)));\r
+ Utils.drawText(gc, stime, rect, true);\r
+ }\r
+\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = sdayformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public String hint() {\r
+ return _hint;\r
+ }\r
+}\r
+\r
+class TimeDrawAbsHrs extends TimeDraw {\r
+ static String _hint = "Mmm dd HH:mm";\r
+\r
+ @Override\r
+ public void draw(GC gc, long time, Rectangle rect) {\r
+ String stime = shrsformat.format(new Date((long) (time / 1000000)));\r
+ Utils.drawText(gc, stime, rect, true);\r
+ }\r
+\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = shrsformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public String hint() {\r
+ return _hint;\r
+ }\r
+}\r
+\r
+class TimeDrawAbsMin extends TimeDraw {\r
+ static String _hint = "HH:mm";\r
+\r
+ @Override\r
+ public void draw(GC gc, long time, Rectangle rect) {\r
+ String stime = sminformat.format(new Date((long) (time / 1000000)));\r
+ Utils.drawText(gc, stime, rect, true);\r
+ }\r
+\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = sminformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public String hint() {\r
+ return _hint;\r
+ }\r
+}\r
+\r
+class TimeDrawAbsSec extends TimeDraw {\r
+ static String _hint = "HH:mm:ss";\r
+\r
+ @Override\r
+ public void draw(GC gc, long time, Rectangle rect) {\r
+ String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+ Utils.drawText(gc, stime, rect, true);\r
+ }\r
+\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public String hint() {\r
+ return _hint;\r
+ }\r
}\r
\r
class TimeDrawAbsMillisec extends TimeDraw {\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
+ String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
String ns = Utils.formatNs(time, Resolution.MILLISEC);\r
\r
Utils.drawText(gc, stime + " " + ns, rect, true);\r
}\r
\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
@Override\r
public String hint() {\r
return _hint;\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
+ String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
String micr = Utils.formatNs(time, Resolution.MICROSEC);\r
Utils.drawText(gc, stime + " " + micr, rect, true);\r
}\r
\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
@Override\r
public String hint() {\r
return _hint;\r
\r
@Override\r
public void draw(GC gc, long time, Rectangle rect) {\r
- String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
+ String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
String ns = Utils.formatNs(time, Resolution.NANOSEC);\r
Utils.drawText(gc, stime + " " + ns, rect, true);\r
}\r
\r
+ @Override\r
+ public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+ String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+ int headerwidth = gc.stringExtent(header).x + 4;\r
+ if (headerwidth <= rect.width) {\r
+ rect.x += (rect.width - headerwidth);\r
+ Utils.drawText(gc, header, rect, true);\r
+ }\r
+ }\r
+ \r
@Override\r
public String hint() {\r
return _hint;\r
import org.eclipse.swt.graphics.Point;\r
import org.eclipse.swt.graphics.Rectangle;\r
import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
import org.eclipse.swt.widgets.ScrollBar;\r
\r
/**\r
public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;\r
public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;\r
public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;\r
- public static final Integer H_SCROLLBAR_MAX = Integer.MAX_VALUE;\r
+ public static int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;\r
\r
private final double zoomCoeff = 1.5;\r
\r
private boolean _isDragCursor3 = false;\r
private boolean _isWaitCursor = true;\r
private boolean _mouseHover = false;\r
- private int _itemHeightDefault = 18;\r
+ private int _itemHeightDefault = 19;\r
private int _itemHeight = _itemHeightDefault;\r
private int _topItem = 0;\r
private int _dragState = 0;\r
private int _dragX0 = 0;\r
private int _dragX = 0;\r
private int _idealNameWidth = 0;\r
- // TODO: 050409\r
- // private double _timeStep = 0.001;\r
// private double _timeStep = 10000000;\r
private long _time0bak;\r
private long _time1bak;\r
private int _borderWidth = 0;\r
private int _headerHeight = 0;\r
\r
+ private Listener mouseScrollFilterListener;\r
+\r
public TmfTimeStatesCtrl(Composite parent, TraceColorScheme colors,\r
TmfTimeAnalysisProvider rutilImp) {\r
\r
if (scrollHor != null) {\r
scrollHor.addSelectionListener(this);\r
}\r
+ mouseScrollFilterListener = new Listener() {\r
+ // This filter is used to prevent scrolling of the view when the\r
+ // mouse wheel is used to zoom\r
+ public void handleEvent(Event event) {\r
+ event.doit = false;\r
+ }\r
+ };\r
\r
_dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);\r
_WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);\r
long delta = timeMax - timeMin;\r
\r
int timePos = 0;\r
- int thumb = 0;\r
+ int thumb = H_SCROLLBAR_MAX;\r
\r
if (delta != 0) {\r
// Thumb size (page size)\r
- thumb = Math\r
- .max(\r
- 1,\r
- (int) (H_SCROLLBAR_MAX * ((double) (time1 - time0) / delta)));\r
+ thumb = Math.max(1, (int) (H_SCROLLBAR_MAX * ((double) (time1 - time0) / delta)));\r
// At the beginning of visible window\r
timePos = (int) (H_SCROLLBAR_MAX * ((double) (time0 - timeMin) / delta));\r
}\r
if (null == _timeProvider)\r
return;\r
ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
- if (trace == _timeProvider)\r
+ if (trace == _timeProvider || trace == null)\r
return;\r
long selectedTime = _timeProvider.getSelectedTime();\r
long endTime = _timeProvider.getEndTime();\r
ITimeEvent nextEvent;\r
- if (-1 == n && selectedTime >= endTime)\r
+ if (-1 == n && selectedTime > endTime)\r
nextEvent = Utils.findEvent(trace, selectedTime, 0);\r
else\r
nextEvent = Utils.findEvent(trace, selectedTime, n);\r
selectTrace(-1);\r
}\r
\r
+ /**\r
+ * Zooming based on mouse cursor location with mouse scrolling\r
+ * \r
+ * @param zoomIn\r
+ */\r
+ public void zoom(boolean zoomIn) {\r
+ int globalX = getDisplay().getCursorLocation().x;\r
+ Point p = toControl(globalX, 0);\r
+ int nameSpace = _timeProvider.getNameSpace();\r
+ int timeSpace = _timeProvider.getTimeSpace();\r
+ int xPos = Math.max(nameSpace, Math.min(nameSpace + timeSpace, p.x));\r
+ long time0 = _timeProvider.getTime0();\r
+ long time1 = _timeProvider.getTime1();\r
+ long interval = time1 - time0;\r
+ if (interval == 0) {\r
+ interval = 1;\r
+ } // to allow getting out of single point interval\r
+ long newInterval;\r
+ if (zoomIn) {\r
+ newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());\r
+ } else {\r
+ newInterval = Math.round((double) interval * 1.25);\r
+ }\r
+ long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));\r
+ long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);\r
+ long newTime1 = newTime0 + newInterval;\r
+ _timeProvider.setStartFinishTime(newTime0, newTime1);\r
+ }\r
+\r
+ /**\r
+ * zoom in using single click\r
+ */\r
public void zoomIn() {\r
long _time0 = _timeProvider.getTime0();\r
long _time1 = _timeProvider.getTime1();\r
_timeProvider.setStartFinishTimeNotify(time0, time1);\r
}\r
\r
+ /**\r
+ * zoom out using single click\r
+ */\r
public void zoomOut() {\r
long _time0 = _timeProvider.getTime0();\r
long _time1 = _timeProvider.getTime1();\r
int nameWidth = _timeProvider.getNameSpace();\r
x -= nameWidth;\r
if (x >= 0 && size.x >= nameWidth) {\r
- hitTime = time0 + ((time1 - time0) * x) / (size.x - nameWidth);\r
+ hitTime = time0 + (long) ((time1 - time0) * ((double) (x + 1) / (size.x - nameWidth - 1))) - 1;\r
}\r
return hitTime;\r
}\r
return;\r
\r
int xr = bound.x + nameWidth;\r
- double K = (double) (bound.width - xr) / (time1 - time0);\r
+ double pixelsPerNanoSec = (bound.width - xr <= 2) ? 0\r
+ : (double) (bound.width - xr - 2) / (time1 - time0); // 2 pixels less to make sure end time is visible\r
\r
- int x0 = xr + (int) ((e.getTime() - time0) * K);\r
+ int x0 = xr + (int) ((e.getTime() - time0) * pixelsPerNanoSec);\r
if (x0 < xr)\r
return;\r
\r
\r
@Override\r
void paint(Rectangle bound, PaintEvent e) {\r
- // If no user preference defined for item height\r
- if (_itemHeight == _itemHeightDefault) {\r
- _itemHeight = getFontHeight() + 6;\r
- }\r
+ GC gc = e.gc;\r
+ gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND));\r
+ drawBackground(gc, bound.x, bound.y, bound.width, bound.height);\r
\r
if (bound.width < 2 || bound.height < 2 || null == _timeProvider)\r
return;\r
\r
_idealNameWidth = 0;\r
- GC gc = e.gc;\r
int nameWidth = _timeProvider.getNameSpace();\r
long time0 = _timeProvider.getTime0();\r
long time1 = _timeProvider.getTime1();\r
if (drawTracesInteraction)\r
drawTraceInteractions(bound, e.gc);\r
\r
- // fill free canvas area\r
- _rect0.x = bound.x;\r
- _rect0.y += _rect0.height;\r
- _rect0.width = bound.width;\r
- _rect0.height = bound.y + bound.height - _rect0.y;\r
- if (_rect0.y < bound.y + bound.height) {\r
- gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND));\r
- gc.fillRectangle(_rect0);\r
- }\r
// draw drag line, no line if name space is 0.\r
if (3 == _dragState) {\r
gc.setForeground(_colors.getColor(TraceColorScheme.BLACK));\r
\r
Utils.init(_rect1, rect);\r
boolean selected = item._selected;\r
- double K = (double) rect.width / (time1 - time0);\r
+ double pixelsPerNanoSec = (rect.width <= 2) ? 0\r
+ : (double) (rect.width - 2) / (time1 - time0); // 2 pixels less to make sure end time is visible\r
boolean group = item instanceof GroupItem;\r
\r
if (group) {\r
ITimeEvent nextEvent = null;\r
long currEventTime = currEvent.getTime();\r
long nextEventTime = currEventTime;\r
- x0 = rect.x + (int) ((currEventTime - time0) * K);\r
- int xEnd = rect.x + (int) ((time1 - time0) * K);\r
+ x0 = rect.x + (int) ((currEventTime - time0) * pixelsPerNanoSec);\r
+ int xEnd = rect.x + (int) ((time1 - time0) * pixelsPerNanoSec);\r
int x1 = -1;\r
int idx = 1;\r
\r
nextEvent = null;\r
nextEventTime = endTime;\r
}\r
- x1 = rect.x + (int) ((nextEventTime - time0) * K);\r
+ x1 = rect.x + (int) ((nextEventTime - time0) * pixelsPerNanoSec);\r
if (x1 >= rect.x) {\r
_rect1.x = x0 >= rect.x ? x0 : rect.x;\r
_rect1.width = (x1 <= xEnd ? x1 : xEnd) - _rect1.x;\r
}\r
\r
// draw selected time\r
- int x = rect.x + (int) ((selectedTime - time0) * K);\r
+ int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
if (x >= rect.x && x < rect.x + rect.width) {\r
gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
if (group)\r
Utils.init(_rect1, rect);\r
boolean selected = item._selected;\r
// K pixels per second\r
- double K = (double) rect.width / (time1 - time0);\r
+ double pixelsPerNanoSec = (rect.width <= 2) ? 0\r
+ : (double) (rect.width - 2) / (time1 - time0); // 2 pixels less to make sure end time is visible\r
// Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
// + time0 + " time1:" + time1 + " endTime: " + endTime);\r
\r
long currEventTime = currEvent.getTime();\r
long nextEventTime = currEventTime;\r
// x0 - Points to the beginning of the event being drawn\r
- double step = (double) ((currEventTime - time0) * K);\r
+ double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
x0 = rect.x + step;\r
// xEnd - Points to the end of the events rectangle\r
- double xEnd = rect.x + (double) ((time1 - time0) * K);\r
+ double xEnd = rect.x + (double) ((time1 - time0) * pixelsPerNanoSec);\r
double x1 = -1;\r
int idx = 1;\r
double xNext = 0;\r
// with space until next event\r
_rect1.x += _rect1.width;\r
x0 = x1;\r
- xNext = rect.x + (double) ((nextEventTime - time0) * K);\r
+ xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
}\r
// Fill space till next event\r
fillSpace(rect, gc, selected, x0, xNext, xEnd);\r
currEvent = nextEvent;\r
currEventTime = nextEventTime;\r
// Move x0 to the beginning of next event\r
- x0 = rect.x + (double) ((nextEventTime - time0) * K);\r
+ x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
// Trace.debug("rect.x: " + rect.x + " + " +\r
// "(nextEvenTime: "\r
// + nextEventTime + "- time0: " + time0 + ") * K: "\r
}\r
\r
// draw selected time\r
- int x = rect.x + (int) ((selectedTime - time0) * K);\r
+ int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
if (x >= rect.x && x < rect.x + rect.width) {\r
gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
if (group)\r
Utils.init(_rect1, rect);\r
boolean selected = item._selected;\r
// K pixels per second\r
- double K = (double) rect.width / (time1 - time0);\r
+ double pixelsPerNanoSec = (rect.width <= 2) ? 0\r
+ : (double) (rect.width - 2) / (time1 - time0); // 2 pixels lesser to make sure end time is visible\r
// Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
// + time0 + " time1:" + time1 + " endTime: " + endTime);\r
\r
if (group) {\r
// gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
// gc.fillRectangle(rect);\r
- // if (Trace.isDEBUG()) {\r
- // Trace.debug("\n\t\t\tGroup: " + ((GroupItem) item)._name);\r
- // }\r
} else if (item instanceof TraceItem) {\r
ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
\r
List<TimeEvent> list = trace.getTraceEvents();\r
// Iterator it = list.iterator();\r
int count = list.size();\r
- ITimeEvent lastEvent = null;\r
+ // ITimeEvent lastEvent = null;\r
// if (Trace.isDEBUG()) {\r
// Trace.debug("\n\t\t\tTrace: " + trace.getName()\r
// + utilImpl.getTraceClassName(trace));\r
// }\r
// Trace.debug("count is: " + count);\r
+ // Drawing rectangle is smaller than reserved space\r
+ _rect1.y += 3;\r
+ _rect1.height -= 6;\r
+\r
+ // Clean up to empty line to draw on top\r
+ int xEnd = rect.x + rect.width;\r
+ fillSpace(rect, gc, selected, _rect1.x, xEnd, xEnd);\r
if (count > 0) {\r
ITimeEvent currEvent = list.get(0);\r
ITimeEvent nextEvent = null;\r
// initial value\r
long nextEventTime = currEventTime;\r
// x0 - Points to the beginning of the event being drawn\r
- double step = (double) ((currEventTime - time0) * K);\r
+ double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
x0 = rect.x + step;\r
// xEnd - Points to the end of the events rectangle\r
- double xEnd = rect.x + (double) ((time1 - time0) * K);\r
double x1 = -1;\r
int idx = 1;\r
double xNext = 0;\r
\r
- // Drawing rectangle is smaller than reserved space\r
- _rect1.y += 3;\r
- _rect1.height -= 6;\r
-\r
- // Clean up to empty line to draw on top\r
- fillSpace(rect, gc, selected, _rect1.x, xEnd, xEnd);\r
// draw event states\r
- while (x0 <= xEnd && null != currEvent) {\r
+ while (/* x0 <= xEnd &&*/ null != currEvent) {\r
boolean stopped = false;// currEvent instanceof\r
// refresh current event duration as the loop moves\r
currEventDuration = currEvent.getDuration();\r
}\r
\r
// Calculate position to next event\r
- xNext = rect.x + (double) ((nextEventTime - time0) * K);\r
+ xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
\r
// Calculate end position of current event\r
if (currEventDuration < 0) {\r
- x1 = rect.x + (double) ((nextEventTime - time0) * K);\r
+ x1 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+ } else if (currEventDuration == 0) {\r
+ x1 = x0;\r
} else {\r
- x1 = currEventDuration == 0 ? (x0 + 2)\r
- : (x0 + (double) ((currEventDuration) * K));\r
+ x1 = x0 + (double) ((currEventDuration) * pixelsPerNanoSec);\r
}\r
\r
// If event end position x1 further away than start position\r
// Trace.debug("Next Event Pos: " + xNext\r
// + " End Of Current at: " + x1 + " Event Duration: "\r
// + currEventDuration);\r
- x1 = x1 > xNext ? xNext : x1;\r
+ if (currEventDuration != 0) {\r
+ x1 = x1 > xNext ? xNext : x1;\r
+ }\r
// if event end boundary is within time range\r
if (x1 >= rect.x && x0 <= xEnd) {\r
- // Fill with space until x0\r
- x0 = (double) (x0 >= rect.x ? x0 : rect.x);\r
- _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0);\r
+ if (currEventDuration != 0) {\r
+ x0 = (double) (x0 >= rect.x ? x0 : rect.x);\r
+ } else {\r
+ x1 = x0 + 2; // make punctual events 2 pixels wide\r
+ }\r
+ _rect1.width = (int) Math.round((x1 <= xEnd ? x1 : xEnd) - x0);\r
_rect1.x = (int) x0;\r
boolean timeSelected = currEventTime <= selectedTime\r
&& selectedTime < nextEventTime;\r
}\r
\r
// Fill space till next event\r
- fillSpace(rect, gc, selected, x0, xNext, xEnd);\r
+ // fillSpace(rect, gc, selected, x0, xNext, xEnd);\r
\r
- lastEvent = currEvent;\r
+ // lastEvent = currEvent;\r
currEvent = nextEvent;\r
currEventTime = nextEventTime;\r
// Move x0 to the beginning of next event\r
- x0 = rect.x + (double) ((nextEventTime - time0) * K);\r
+ x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
// Trace.debug("rect.x: " + rect.x + " + " +\r
// "(nextEvenTime: "\r
// + nextEventTime + "- time0: " + time0 + ") * K: "\r
}\r
}\r
\r
- // fill space after last event\r
- int xEnd = rect.x + rect.width;\r
- if (x0 < xEnd) {\r
- // Trace.debug("Space after last event, x0: " + x0 + ", xEnd: "\r
- // + xEnd);\r
- _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
- _rect1.width = xEnd - _rect1.x;\r
- gc.setBackground(_colors\r
- .getBkColor(selected, _isInFocus, false));\r
- gc.fillRectangle(_rect1);\r
- // draw middle line\r
- gc.setForeground(_colors.getColor(utilImpl\r
- .getEventColorVal(lastEvent)));\r
- int midy = _rect1.y + _rect1.height / 2;\r
- int lw = gc.getLineWidth();\r
- gc.setLineWidth(2);\r
- gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
- gc.setLineWidth(lw);\r
- }\r
-\r
// draw focus area\r
Utils.init(_rect1, rect);\r
gc.setForeground(_colors.getBkColor(selected, _isInFocus, false));\r
}\r
\r
// draw selected time\r
- int x = rect.x + (int) ((selectedTime - time0) * K);\r
+ int x = rect.x + (int) ((double) (selectedTime - time0) * pixelsPerNanoSec);\r
if (x >= rect.x && x < rect.x + rect.width) {\r
gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
if (group)\r
public void focusGained(FocusEvent e) {\r
_isInFocus = true;\r
redraw();\r
+ getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
}\r
\r
public void focusLost(FocusEvent e) {\r
_dragState = 0;\r
}\r
redraw();\r
+ getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
}\r
\r
public boolean isInFocus() {\r
int x = e.x - nameWidth;\r
if (x > 0 && size.x > nameWidth && _dragX != x) {\r
_dragX = x;\r
- double K = (double) (size.x - nameWidth)\r
- / (_time1bak - _time0bak);\r
- long timeDelta = (long) ((_dragX - _dragX0) / K);\r
+ double pixelsPerNanoSec = (size.x - nameWidth <= 2) ? 0\r
+ : (double) (size.x - nameWidth - 2) / (_time1bak - _time0bak); // 2 pixels less to make sure end time is visible\r
+ long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((_dragX - _dragX0) / pixelsPerNanoSec));\r
long time1 = _time1bak - timeDelta;\r
long maxTime = _timeProvider.getMaxTime();\r
if (time1 > maxTime)\r
if (_mouseHover != mouseHover)\r
redraw();\r
_mouseHover = mouseHover;\r
+ // Make sure any time changes are notified to the application e.g.\r
+ // getting back from the horizontal scroll bar or zoomed using the\r
+ // mouse wheel\r
+ _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
}\r
updateCursor(e.x, e.y);\r
}\r
}\r
selectItem(idx, false);\r
fireSelectionChanged();\r
+ } else {\r
+ selectItem(idx, false); // clear selection\r
}\r
}\r
}\r
}\r
\r
// Notify time provider to check the need for listener notification\r
- _timeProvider.mouseUp();\r
+ _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
}\r
\r
public void controlMoved(ControlEvent e) {\r
_topItem = 0;\r
redraw();\r
} else if (e.widget == getHorizontalBar() && null != _timeProvider) {\r
- int startTime = getHorizontalBar().getSelection();\r
+ int start = getHorizontalBar().getSelection();\r
long time0 = _timeProvider.getTime0();\r
long time1 = _timeProvider.getTime1();\r
long timeMin = _timeProvider.getMinTime();\r
\r
long range = time1 - time0;\r
// _timeRangeFixed = true;\r
- time0 = timeMin\r
- + (long) ((double) ((startTime * delta) / H_SCROLLBAR_MAX));\r
+ time0 = timeMin + (long) (delta * ((double) start / H_SCROLLBAR_MAX));\r
time1 = time0 + range;\r
- // Trace.debug("\nstartTime:" + startTime + " time0:" + time0\r
- // + " time1:" + time1 + " Delta:" + delta);\r
- _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+\r
+ // TODO: Follow-up with Bug 310310\r
+ // In Linux SWT.DRAG is the only value received\r
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310310\r
+ if (e.detail == SWT.DRAG) {\r
+ _timeProvider.setStartFinishTime(time0, time1);\r
+ } else {\r
+ _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+ }\r
}\r
}\r
\r
public void mouseEnter(MouseEvent e) {\r
}\r
\r
- /*\r
- * (non-Javadoc)\r
- * \r
- * @see\r
- * org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events\r
- * .MouseEvent)\r
- */\r
public void mouseExit(MouseEvent e) {\r
if (_mouseHover) {\r
_mouseHover = false;\r
}\r
\r
public void mouseScrolled(MouseEvent e) {\r
+ if (!_isInFocus)\r
+ return;\r
if (e.count > 0) {\r
- zoomIn();\r
+ zoom(true);\r
} else if (e.count < 0) {\r
- zoomOut();\r
+ zoom(false);\r
}\r
}\r
\r
import java.util.Iterator;\r
import java.util.Map;\r
\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.Messages;\r
+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
addItem(message, eventAddOns.get(message));\r
}\r
\r
- // start time\r
- long startTime = threadEvent == null ? thrd.getStartTime()\r
- : threadEvent.getTime();\r
-\r
- long duration = threadEvent == null ? -1 : threadEvent\r
- .getDuration();\r
-\r
- if (duration < 0 && threadEvent != null\r
- && nextEvent != null) {\r
- long stopTime = nextEvent.getTime();\r
- duration = stopTime - startTime;\r
+ long eventStartTime = -1;\r
+ long eventDuration = -1;\r
+ long eventEndTime = -1;\r
+ \r
+ if (threadEvent != null) {\r
+ eventStartTime = threadEvent.getTime();\r
+ eventDuration = threadEvent.getDuration();\r
+ if (eventDuration < 0 && nextEvent != null) {\r
+ eventEndTime = nextEvent.getTime();\r
+ eventDuration = eventEndTime - eventStartTime;\r
+ } else {\r
+ eventEndTime = eventStartTime + eventDuration;\r
+ }\r
}\r
- long eventEndtime = startTime + duration;\r
\r
// TODO: Check if we need "format" \r
// TimeFormat format = TimeFormat.RELATIVE;\r
// format = TimeFormat.ABSOLUTE; // Absolute format\r
// // (calendar)\r
// Add Date\r
- addItem(Messages._TRACE_DATE, Utils\r
- .formatDate(startTime));\r
+ addItem(Messages._TRACE_DATE, eventStartTime > -1 ?\r
+ Utils.formatDate(eventStartTime)\r
+ : "?");\r
+ if (eventDuration > 0) {\r
+ addItem(Messages._TRACE_START_TIME, eventStartTime > -1 ?\r
+ Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
+ : "?");\r
+ \r
+ addItem(Messages._TRACE_STOP_TIME, eventEndTime > -1 ?\r
+ Utils.formatTime(eventEndTime, TimeFormat.ABSOLUTE, res)\r
+ : "?");\r
+ } else {\r
+ addItem(Messages._TRACE_EVENT_TIME, eventStartTime > -1 ?\r
+ Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
+ : "?");\r
+ }\r
+ } else {\r
+ if (eventDuration > 0) {\r
+ addItem(Messages._TRACE_START_TIME, eventStartTime > -1 ?\r
+ Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
+ : "?");\r
+ \r
+ addItem(Messages._TRACE_STOP_TIME, eventEndTime > -1 ?\r
+ Utils.formatTime(eventEndTime, TimeFormat.RELATIVE, res)\r
+ : "?");\r
+ } else {\r
+ addItem(Messages._TRACE_EVENT_TIME, eventStartTime > -1 ?\r
+ Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
+ : "?");\r
+ }\r
}\r
- addItem(Messages._TRACE_START_TIME, Utils.formatTime(\r
- startTime, TimeFormat.RELATIVE, res));\r
-\r
- addItem(Messages._TRACE_STOP_TIME, Utils.formatTime(\r
- eventEndtime, TimeFormat.RELATIVE, res));\r
\r
- // Duration in relative format in any case\r
- addItem(Messages._DURATION, duration > -1 ? Utils\r
- .formatTime(duration, TimeFormat.RELATIVE, res)\r
- : "?");\r
+ if (eventDuration > 0) {\r
+ // Duration in relative format in any case\r
+ addItem(Messages._DURATION, eventDuration > -1 ?\r
+ Utils.formatTime(eventDuration, TimeFormat.RELATIVE, res)\r
+ : "?");\r
+ }\r
\r
} else if (item instanceof GroupItem) {\r
addItem(Messages._TRACE_GROUP_NAME, item.toString());\r
static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;\r
\r
static public final int LIGHT_LINE = 77;\r
- static public final int BACKGROUND_NAME = 78;\r
+ static public final int BACKGROUND_NAME = 78;\r
+ static public final int BACKGROUND_NAME_SEL = 79;\r
+ static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;\r
\r
// Interraction's colors\r
static public final int TI_START_THREAD = BLACK;\r
//\r
new RGB(100, 100, 100), // UNKNOWN\r
new RGB(174, 200, 124), // RUNNING\r
- new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1,\r
- 3), // SLEEPING\r
+ new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING\r
new RGB(210, 150, 60), // WAITING\r
new RGB(242, 225, 168), // BLOCKED\r
new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK\r
\r
new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND\r
new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND\r
- new SysCol(SWT.COLOR_LIST_SELECTION), // BACKGROUND_SEL\r
- new SysCol(SWT.COLOR_LIST_SELECTION_TEXT), // FOREGROUND_SEL\r
+ new RGB(232, 242, 254), // BACKGROUND_SEL\r
+ new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL\r
new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS\r
new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS\r
new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND\r
\r
new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(\r
SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE\r
- new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(\r
- SWT.COLOR_LIST_BACKGROUND), 1, 6), // BACKGROUND_NAME\r
+\r
+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6), // BACKGROUND_NAME\r
+ new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6), // BACKGROUND_NAME_SEL\r
+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS\r
};\r
\r
private Color _colors[];\r
}\r
\r
public Color getBkColor(boolean selected, boolean focused, boolean name) {\r
- if (selected && focused)\r
- return getColor(BACKGROUND_SEL);\r
- if (selected)\r
- return getColor(BACKGROUND_SEL_NOFOCUS);\r
- if (name)\r
- return getColor(BACKGROUND_NAME);\r
- return getColor(BACKGROUND);\r
+ if (name) {\r
+ if (selected && focused)\r
+ return getColor(BACKGROUND_NAME_SEL);\r
+ if (selected)\r
+ return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
+ return getColor(BACKGROUND_NAME);\r
+ } else {\r
+ if (selected && focused)\r
+ return getColor(BACKGROUND_SEL);\r
+ if (selected)\r
+ return getColor(BACKGROUND_SEL_NOFOCUS);\r
+ return getColor(BACKGROUND);\r
+ }\r
}\r
\r
public Color getFgColor(boolean selected, boolean focused) {\r
import java.util.Date;\r
import java.util.Iterator;\r
import java.util.List;\r
+import java.util.TimeZone;\r
import java.util.Vector;\r
\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
import org.eclipse.swt.graphics.Color;\r
import org.eclipse.swt.graphics.Device;\r
import org.eclipse.swt.graphics.GC;\r
SECONDS, MILLISEC, MICROSEC, NANOSEC\r
};\r
\r
- static private SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");\r
- static private SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy.MM.dd");\r
+ static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");\r
+ static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd");\r
+ static {\r
+ stimeformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ sdateformat.setTimeZone(TimeZone.getTimeZone("GMT"));\r
+ }\r
\r
// static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
// "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
* @param n\r
* @return\r
*/\r
- static ITimeEvent findEvent(ITmfTimeAnalysisEntry thread, long time, int n) {\r
- if (null == thread)\r
- return null;\r
- List<TimeEvent> list = thread.getTraceEvents();\r
- Iterator<TimeEvent> it = list.iterator();\r
- ITimeEvent event = null;\r
- ITimeEvent prevEvent = null;\r
- ITimeEvent nextEvent = null;\r
- if (it.hasNext()) {\r
- event = (ITimeEvent) it.next();\r
- long currStartTime = event.getTime();\r
- long currEndTime = currStartTime + event.getDuration();\r
-\r
- if (time < currStartTime) {\r
- if (1 != n)\r
- event = null;\r
- return event;\r
- }\r
- while (it.hasNext()) {\r
- currStartTime = event.getTime();\r
- currEndTime = currStartTime + event.getDuration();\r
- nextEvent = (ITimeEvent) it.next();\r
-\r
- long nextEventTime = nextEvent.getTime();\r
- currEndTime = currEndTime >= nextEventTime ? (nextEventTime - 1)\r
- : currEndTime;\r
-\r
-// Trace.debug("currStartTime: " + currStartTime\r
-// + " currEndTime: " + currEndTime + " nextEventTime: "\r
-// + nextEventTime + " time: " + time);\r
- if (currStartTime <= time && time <= currEndTime) {\r
- if (1 == n)\r
- event = nextEvent;\r
- else if (-1 == n)\r
- event = prevEvent;\r
- return event;\r
- }\r
-\r
- if (time > currEndTime && time < nextEventTime) {\r
- //Located in a non Event area\r
- if (2 == n || -1 == n) {\r
- return event;\r
- } else if (1 == n) {\r
- return nextEvent;\r
- }\r
- return null;\r
- }\r
-\r
- prevEvent = event;\r
- event = nextEvent;\r
- }\r
- }\r
- if (1 == n)\r
- event = null;\r
- else if (-1 == n)\r
- event = prevEvent;\r
- return event;\r
- }\r
+ static ITimeEvent findEvent(ITmfTimeAnalysisEntry thread, long time, int n) {\r
+ if (null == thread)\r
+ return null;\r
+ List<TimeEvent> list = thread.getTraceEvents();\r
+ Iterator<TimeEvent> it = list.iterator();\r
+ ITimeEvent nextEvent = null;\r
+ ITimeEvent currEvent = null;\r
+ ITimeEvent prevEvent = null;\r
+\r
+ while (it.hasNext()) {\r
+ nextEvent = (ITimeEvent) it.next();\r
+ long nextStartTime = nextEvent.getTime();\r
+ \r
+ if (nextStartTime > time) {\r
+ break;\r
+ }\r
+ \r
+ if (currEvent == null || currEvent.getTime() != nextStartTime) {\r
+ prevEvent = currEvent;\r
+ currEvent = nextEvent;\r
+ }\r
+ }\r
+ \r
+ if (n == -1) { //previous\r
+ if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
+ return prevEvent;\r
+ } else {\r
+ return currEvent;\r
+ }\r
+ } else if (n == 0) { //current\r
+ if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
+ return currEvent;\r
+ } else {\r
+ return null;\r
+ }\r
+ } else if (n == 1) { //next\r
+ return nextEvent;\r
+ } else if (n == 2) { //current or previous when in empty space\r
+ return currEvent;\r
+ }\r
+ \r
+ return null;\r
+ }\r
\r
// static public TRCPackage getPackage(Object element) {\r
// if (element instanceof TRCPackage)\r