import org.eclipse.swt.widgets.ScrollBar;\r
import org.eclipse.swt.widgets.Slider;\r
\r
+/**\r
+ * Generic time graph viewer implementation\r
+ *\r
+ * @version 1.0\r
+ * @author Patrick Tasse, and others\r
+ */\r
public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {\r
\r
/** vars */\r
\r
/**\r
* Sets the timegraph provider used by this timegraph viewer.\r
- * \r
+ *\r
* @param timeGraphProvider the timegraph provider\r
*/\r
public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {\r
\r
public void resizeControls() {\r
Rectangle r = _dataViewer.getClientArea();\r
- if (r.isEmpty())\r
+ if (r.isEmpty()) {\r
return;\r
+ }\r
\r
int width = r.width;\r
- if (_nameWidth > width - _minNameWidth)\r
+ if (_nameWidth > width - _minNameWidth) {\r
_nameWidth = width - _minNameWidth;\r
- if (_nameWidth < _minNameWidth)\r
+ }\r
+ if (_nameWidth < _minNameWidth) {\r
_nameWidth = _minNameWidth;\r
+ }\r
adjustVerticalScrollBar();\r
}\r
\r
public void setTimeBounds() {\r
//_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
_time0_ = _beginTime;\r
- if (_time0_ < 0)\r
+ if (_time0_ < 0) {\r
_time0_ = 0;\r
+ }\r
// _time1_ = _time0_ + (_endTime - _time0_) * 1.05;\r
_time1_ = _endTime;\r
// _time0_ = Math.floor(_time0_);\r
* @param end\r
*/\r
void updateInternalData(ITimeGraphEntry[] traces, long start, long end) {\r
- if (null == traces)\r
+ if (null == traces) {\r
traces = new ITimeGraphEntry[0];\r
+ }\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
}\r
\r
public void setFocus() {\r
- if (null != _stateCtrl)\r
+ if (null != _stateCtrl) {\r
_stateCtrl.setFocus();\r
+ }\r
}\r
\r
public boolean isInFocus() {\r
public void setNameSpace(int width) {\r
_nameWidth = width;\r
width = _stateCtrl.getClientArea().width;\r
- if (_nameWidth > width - 6)\r
+ if (_nameWidth > width - 6) {\r
_nameWidth = width - 6;\r
- if (_nameWidth < 6)\r
+ }\r
+ if (_nameWidth < 6) {\r
_nameWidth = 6;\r
+ }\r
_stateCtrl.adjustScrolls();\r
_stateCtrl.redraw();\r
_timeScaleCtrl.redraw();\r
\r
/*\r
* (non-Javadoc)\r
- * \r
+ *\r
* @see\r
* org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
* #setStartFinishTimeNotify(long, long)\r
\r
/*\r
* (non-Javadoc)\r
- * \r
+ *\r
* @see\r
* org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
* #setStartFinishTime(long, long)\r
@Override\r
public void setStartFinishTime(long time0, long time1) {\r
_time0 = time0;\r
- if (_time0 < _time0_)\r
+ if (_time0 < _time0_) {\r
_time0 = _time0_;\r
- if (_time0 > _time1_)\r
+ }\r
+ if (_time0 > _time1_) {\r
_time0 = _time1_;\r
+ }\r
_time1 = time1;\r
- if (_time1 < _time0_)\r
+ if (_time1 < _time0_) {\r
_time1 = _time0_;\r
- if (_time1 > _time1_)\r
+ }\r
+ if (_time1 > _time1_) {\r
_time1 = _time1_;\r
- if (_time1 - _time0 < _minTimeInterval)\r
+ }\r
+ if (_time1 - _time0 < _minTimeInterval) {\r
_time1 = Math.min(_time1_, _time0 + _minTimeInterval);\r
+ }\r
_timeRangeFixed = true;\r
_stateCtrl.adjustScrolls();\r
_stateCtrl.redraw();\r
public void setSelectedTimeNotify(long time, boolean ensureVisible) {\r
setSelectedTimeInt(time, ensureVisible, true);\r
}\r
- \r
+\r
@Override\r
public void setSelectedTime(long time, boolean ensureVisible) {\r
setSelectedTimeInt(time, ensureVisible, false);\r
_stateCtrl.adjustScrolls();\r
_stateCtrl.redraw();\r
_timeScaleCtrl.redraw();\r
- \r
- \r
+\r
+\r
boolean notifySelectedTime = (time != _selectedTime);\r
_selectedTime = time;\r
- \r
+\r
if (doNotify && ((time0 != _time0) || (time1 != _time1))) {\r
notifyRangeListeners(_time0, _time1);\r
}\r
- \r
+\r
if (doNotify && notifySelectedTime) {\r
notifyTimeListeners(_selectedTime);\r
}\r
}\r
\r
public void showLegend() {\r
- if (_dataViewer == null || _dataViewer.isDisposed())\r
+ if (_dataViewer == null || _dataViewer.isDisposed()) {\r
return;\r
+ }\r
\r
TimeGraphLegend.open(_dataViewer.getShell(), fTimeGraphProvider);\r
}\r
\r
/**\r
* Get the selection provider\r
- * \r
+ *\r
* @return the selection provider\r
*/\r
public ISelectionProvider getSelectionProvider() {\r
\r
/*\r
* (non-Javadoc)\r
- * \r
+ *\r
* @see\r
* org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
* #waitCursor(boolean)\r
resetScale.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText);\r
resetScale.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText);\r
resetScale.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU));\r
- } \r
+ }\r
return resetScale;\r
}\r
\r
\r
return showLegendAction;\r
}\r
- \r
+\r
public Action getNextEventAction() {\r
if (nextEventAction == null) {\r
nextEventAction = new Action() {\r
nextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText);\r
nextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText);\r
nextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT));\r
- } \r
+ }\r
\r
return nextEventAction;\r
}\r
prevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText);\r
prevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText);\r
prevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT));\r
- } \r
+ }\r
\r
return prevEventAction;\r
}\r
}\r
return previousItemAction;\r
}\r
- \r
+\r
public Action getZoomInAction() {\r
if (zoomInAction == null) {\r
zoomInAction = new Action() {\r
}\r
return zoomOutAction;\r
}\r
- \r
- \r
+\r
+\r
private void adjustVerticalScrollBar() {\r
int topIndex = _stateCtrl.getTopIndex();\r
int countPerPage = _stateCtrl.countPerPage();\r
int pageIncrement = Math.max(1, countPerPage);\r
_verticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement);\r
}\r
- \r
- \r
+\r
+\r
\r
}\r