Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2013-05-28 18:54:20 +0000
committerPatrick Tasse2013-05-29 14:49:57 +0000
commit9163432129bb4babef40889e0ff2764e3e7766af (patch)
treedc3265aead0c3c95247717e39eb5b246f81ca389
parent5c2ed4ba139e573c0e0a07529a43daf0208c82d0 (diff)
downloadorg.eclipse.linuxtools-9163432129bb4babef40889e0ff2764e3e7766af.tar.gz
org.eclipse.linuxtools-9163432129bb4babef40889e0ff2764e3e7766af.tar.xz
org.eclipse.linuxtools-9163432129bb4babef40889e0ff2764e3e7766af.zip
Fix Sonar warnings in timegraph package
Change-Id: If20ef00dba5ac104f76a7f0b0e8a0095c7916652 Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/13294 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphPresentationProvider.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java36
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java634
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java45
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphBaseControl.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java245
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java923
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphItem.java58
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java648
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphSelection.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java114
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java102
13 files changed, 1327 insertions, 1522 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphPresentationProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphPresentationProvider.java
index 2b04ce6a97..eb030900d4 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphPresentationProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphPresentationProvider.java
@@ -31,12 +31,12 @@ public interface ITimeGraphPresentationProvider {
/** State table index for an invisible event
* @since 2.0
*/
- public final int INVISIBLE = -1;
+ final int INVISIBLE = -1;
/** State table index for a transparent event (only borders drawn)
* @since 2.0
*/
- public final int TRANSPARENT = -2;
+ final int TRANSPARENT = -2;
/**
* Returns the name of state types.
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java
index e142ad48a4..5eec1e566d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java
@@ -89,7 +89,7 @@ public class TimeGraphCombo extends Composite {
private List<? extends ITimeGraphEntry> fTopInput;
// The selection listener map
- private final HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper> fSelectionListenerMap = new HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper>();
+ private final Map<ITimeGraphSelectionListener, SelectionListenerWrapper> fSelectionListenerMap = new HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper>();
// The map of viewer filters
private final Map<ViewerFilter, ViewerFilter> fViewerFilterMap = new HashMap<ViewerFilter, ViewerFilter>();
@@ -141,7 +141,7 @@ public class TimeGraphCombo extends Composite {
public Object[] getElements(Object inputElement) {
Object[] elements = contentProvider.getElements(inputElement);
// add filler elements to ensure alignment with time analysis viewer
- Object[] oElements = Arrays.copyOf(elements, elements.length + fNumFillerRows, new Object[0].getClass());
+ Object[] oElements = Arrays.copyOf(elements, elements.length + fNumFillerRows, Object[].class);
for (int i = 0; i < fNumFillerRows; i++) {
oElements[elements.length + i] = FILLER;
}
@@ -271,7 +271,7 @@ public class TimeGraphCombo extends Composite {
*/
private class ViewerFilterWrapper extends ViewerFilter {
- ViewerFilter fWrappedFilter;
+ private ViewerFilter fWrappedFilter;
ViewerFilterWrapper(ViewerFilter filter) {
super();
@@ -352,7 +352,7 @@ public class TimeGraphCombo extends Composite {
// Bug in Linux. The tree header height is 0 in constructor,
// so we need to reset it later when the control is resized.
tree.addControlListener(new ControlAdapter() {
- int depth = 0;
+ private int depth = 0;
@Override
public void controlResized(ControlEvent e) {
if (depth == 0) {
@@ -371,7 +371,7 @@ public class TimeGraphCombo extends Composite {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
fTimeGraphViewer.setExpandedState((ITimeGraphEntry) event.getElement(), false);
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -382,7 +382,7 @@ public class TimeGraphCombo extends Composite {
@Override
public void treeExpanded(TreeExpansionEvent event) {
fTimeGraphViewer.setExpandedState((ITimeGraphEntry) event.getElement(), true);
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -417,7 +417,7 @@ public class TimeGraphCombo extends Composite {
TreeItem treeItem = tree.getItem(new Point(event.x, event.y));
if (treeItem == null || treeItem.getData() == FILLER) {
event.doit = false;
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
fTreeViewer.setSelection(new StructuredSelection());
fTimeGraphViewer.setSelection(null);
@@ -439,7 +439,7 @@ public class TimeGraphCombo extends Composite {
event.doit = false;
Slider scrollBar = fTimeGraphViewer.getVerticalBar();
fTimeGraphViewer.setTopIndex(scrollBar.getSelection() - event.count);
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -452,7 +452,7 @@ public class TimeGraphCombo extends Composite {
tree.addListener(SWT.KeyDown, new Listener() {
@Override
public void handleEvent(Event event) {
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
fTreeViewer.setSelection(new StructuredSelection());
event.doit = false;
@@ -486,7 +486,7 @@ public class TimeGraphCombo extends Composite {
fTimeGraphViewer.getTimeGraphControl().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -507,7 +507,7 @@ public class TimeGraphCombo extends Composite {
if (selection instanceof ITimeGraphEntry) {
fTimeGraphViewer.setSelection((ITimeGraphEntry) selection);
}
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -530,7 +530,7 @@ public class TimeGraphCombo extends Composite {
fTreeViewer.setSelection(new StructuredSelection());
}
fInhibitTreeSelection = false;
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -543,7 +543,7 @@ public class TimeGraphCombo extends Composite {
fTimeGraphViewer.getVerticalBar().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -556,7 +556,7 @@ public class TimeGraphCombo extends Composite {
fTimeGraphViewer.getTimeGraphControl().addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() == 0) {
return;
}
@@ -867,7 +867,7 @@ public class TimeGraphCombo extends Composite {
fTreeViewer.setSelection(new StructuredSelection());
}
fInhibitTreeSelection = false;
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(fTreeViewer.getTree());
+ List<TreeItem> treeItems = getVisibleExpandedItems(fTreeViewer.getTree());
if (treeItems.size() == 0) {
return;
}
@@ -914,7 +914,7 @@ public class TimeGraphCombo extends Composite {
// Internal
// ------------------------------------------------------------------------
- private ArrayList<TreeItem> getVisibleExpandedItems(Tree tree) {
+ private List<TreeItem> getVisibleExpandedItems(Tree tree) {
ArrayList<TreeItem> items = new ArrayList<TreeItem>();
for (TreeItem item : tree.getItems()) {
if (item.getData() == FILLER) {
@@ -928,7 +928,7 @@ public class TimeGraphCombo extends Composite {
return items;
}
- private ArrayList<TreeItem> getVisibleExpandedItems(TreeItem treeItem) {
+ private List<TreeItem> getVisibleExpandedItems(TreeItem treeItem) {
ArrayList<TreeItem> items = new ArrayList<TreeItem>();
for (TreeItem item : treeItem.getItems()) {
items.add(item);
@@ -964,7 +964,7 @@ public class TimeGraphCombo extends Composite {
if (fLinuxItemHeight != 0) {
return fLinuxItemHeight;
}
- ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+ List<TreeItem> treeItems = getVisibleExpandedItems(tree);
if (treeItems.size() > 1) {
final TreeItem treeItem0 = treeItems.get(0);
final TreeItem treeItem1 = treeItems.get(1);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
index a53da60313..2debbd2afe 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
@@ -16,6 +16,7 @@
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -61,48 +62,52 @@ import org.eclipse.swt.widgets.Slider;
*/
public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
- /** vars */
- private long _minTimeInterval;
- private long _selectedTime;
- private ITimeGraphEntry _selectedEntry;
- private long _beginTime;
- private long _endTime;
- private long _time0;
- private long _time1;
- private long _time0_;
- private long _time1_;
- private long _time0_extSynch = 0;
- private long _time1_extSynch = 0;
- private boolean _timeRangeFixed;
- private int _nameWidthPref = 200;
- private int _minNameWidth = 6;
- private int _nameWidth;
- private Composite _dataViewer;
-
- private TimeGraphControl _stateCtrl;
- private TimeGraphScale _timeScaleCtrl;
- private Slider _verticalScrollBar;
- private TimeGraphTooltipHandler _threadTip;
- private TimeGraphColorScheme _colors;
+ private static final int DEFAULT_NAME_WIDTH = 200;
+ private static final int MIN_NAME_WIDTH = 6;
+ private static final int MAX_NAME_WIDTH = 1000;
+ private static final int DEFAULT_HEIGHT = 22;
+ private static final long RECENTERING_MARGIN_FACTOR = 50;
+
+ private long fMinTimeInterval;
+ private long fSelectedTime;
+ private ITimeGraphEntry fSelectedEntry;
+ private long fBeginTime;
+ private long fEndTime;
+ private long fTime0;
+ private long fTime1;
+ private long fTime0Bound;
+ private long fTime1Bound;
+ private long fTime0ExtSynch = 0;
+ private long fTime1ExtSynch = 0;
+ private boolean fTimeRangeFixed;
+ private int fNameWidthPref = DEFAULT_NAME_WIDTH;
+ private int fMinNameWidth = MIN_NAME_WIDTH;
+ private int fNameWidth;
+ private Composite fDataViewer;
+
+ private TimeGraphControl fTimeGraphCtrl;
+ private TimeGraphScale fTimeScaleCtrl;
+ private Slider fVerticalScrollBar;
+ private TimeGraphColorScheme fColorScheme;
private ITimeGraphPresentationProvider fTimeGraphProvider;
- ArrayList<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<ITimeGraphSelectionListener>();
- ArrayList<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>();
- ArrayList<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>();
+ private List<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<ITimeGraphSelectionListener>();
+ private List<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>();
+ private List<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>();
// Time format, using Epoch reference, Relative time format(default) or Number
- private TimeFormat timeFormat = TimeFormat.RELATIVE;
- private int borderWidth = 0;
- private int timeScaleHeight = 22;
+ private TimeFormat fTimeFormat = TimeFormat.RELATIVE;
+ private int fBorderWidth = 0;
+ private int fTimeScaleHeight = DEFAULT_HEIGHT;
- private Action resetScale;
- private Action showLegendAction;
- private Action nextEventAction;
- private Action prevEventAction;
- private Action nextItemAction;
- private Action previousItemAction;
- private Action zoomInAction;
- private Action zoomOutAction;
+ private Action fResetScaleAction;
+ private Action fShowLegendAction;
+ private Action fNextEventAction;
+ private Action fPrevEventAction;
+ private Action fNextItemAction;
+ private Action fPreviousItemAction;
+ private Action fZoomInAction;
+ private Action fZoomOutAction;
/**
* Standard constructor
@@ -123,9 +128,9 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {
fTimeGraphProvider = timeGraphProvider;
- _stateCtrl.setTimeGraphProvider(timeGraphProvider);
- _threadTip = new TimeGraphTooltipHandler(_dataViewer.getShell(), fTimeGraphProvider, this);
- _threadTip.activateHoverHelp(_stateCtrl);
+ fTimeGraphCtrl.setTimeGraphProvider(timeGraphProvider);
+ TimeGraphTooltipHandler toolTipHandler = new TimeGraphTooltipHandler(fTimeGraphProvider, this);
+ toolTipHandler.activateHoverHelp(fTimeGraphCtrl);
}
/**
@@ -137,15 +142,15 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
public void setInput(ITimeGraphEntry[] input) {
ITimeGraphEntry[] realInput = input;
- if (_stateCtrl != null) {
+ if (fTimeGraphCtrl != null) {
if (realInput == null) {
realInput = new ITimeGraphEntry[0];
}
setTimeRange(realInput);
- _verticalScrollBar.setEnabled(true);
+ fVerticalScrollBar.setEnabled(true);
setTopIndex(0);
- _selectedTime = 0;
- _selectedEntry = null;
+ fSelectedTime = 0;
+ fSelectedEntry = null;
refreshAllData(realInput);
}
}
@@ -154,9 +159,9 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Refresh the view
*/
public void refresh() {
- setTimeRange(_stateCtrl.getTraces());
- _verticalScrollBar.setEnabled(true);
- refreshAllData(_stateCtrl.getTraces());
+ setTimeRange(fTimeGraphCtrl.getTraces());
+ fVerticalScrollBar.setEnabled(true);
+ refreshAllData(fTimeGraphCtrl.getTraces());
}
/**
@@ -193,16 +198,15 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
public void modelUpdate(ITimeGraphEntry[] traces, long start,
long end, boolean updateTimeBounds) {
- if (null != _stateCtrl) {
- //loadOptions();
+ if (null != fTimeGraphCtrl) {
updateInternalData(traces, start, end);
if (updateTimeBounds) {
- _timeRangeFixed = true;
+ fTimeRangeFixed = true;
// set window to match limits
- setStartFinishTime(_time0_, _time1_);
+ setStartFinishTime(fTime0Bound, fTime1Bound);
} else {
- _stateCtrl.redraw();
- _timeScaleCtrl.redraw();
+ fTimeGraphCtrl.redraw();
+ fTimeScaleCtrl.redraw();
}
}
}
@@ -223,14 +227,14 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
}
void loadOptions() {
- _minTimeInterval = 1;
- _selectedTime = -1;
- _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
- _nameWidthPref, _minNameWidth, 1000);
+ fMinTimeInterval = 1;
+ fSelectedTime = -1;
+ fNameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
+ fNameWidthPref, fMinNameWidth, MAX_NAME_WIDTH);
}
void saveOptions() {
- Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$
+ Utils.saveIntOption(getPreferenceString("namewidth"), fNameWidth); //$NON-NLS-1$
}
/**
@@ -244,71 +248,71 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
protected Control createDataViewer(Composite parent, int style) {
loadOptions();
- _colors = new TimeGraphColorScheme();
- _dataViewer = new Composite(parent, style) {
+ fColorScheme = new TimeGraphColorScheme();
+ fDataViewer = new Composite(parent, style) {
@Override
public void redraw() {
- _timeScaleCtrl.redraw();
- _stateCtrl.redraw();
+ fTimeScaleCtrl.redraw();
+ fTimeGraphCtrl.redraw();
super.redraw();
}
};
GridLayout gl = new GridLayout(2, false);
- gl.marginHeight = borderWidth;
+ gl.marginHeight = fBorderWidth;
gl.marginWidth = 0;
gl.verticalSpacing = 0;
gl.horizontalSpacing = 0;
- _dataViewer.setLayout(gl);
+ fDataViewer.setLayout(gl);
- _timeScaleCtrl = new TimeGraphScale(_dataViewer, _colors);
- _timeScaleCtrl.setTimeProvider(this);
- _timeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
- _timeScaleCtrl.setHeight(timeScaleHeight);
+ fTimeScaleCtrl = new TimeGraphScale(fDataViewer, fColorScheme);
+ fTimeScaleCtrl.setTimeProvider(this);
+ fTimeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
+ fTimeScaleCtrl.setHeight(fTimeScaleHeight);
- _verticalScrollBar = new Slider(_dataViewer, SWT.VERTICAL | SWT.NO_FOCUS);
- _verticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 2));
- _verticalScrollBar.addSelectionListener(new SelectionAdapter() {
+ fVerticalScrollBar = new Slider(fDataViewer, SWT.VERTICAL | SWT.NO_FOCUS);
+ fVerticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 2));
+ fVerticalScrollBar.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- setTopIndex(_verticalScrollBar.getSelection());
+ setTopIndex(fVerticalScrollBar.getSelection());
}
});
- _verticalScrollBar.setEnabled(false);
+ fVerticalScrollBar.setEnabled(false);
- _stateCtrl = createTimeGraphControl(_dataViewer, _colors);
+ fTimeGraphCtrl = createTimeGraphControl(fDataViewer, fColorScheme);
- _stateCtrl.setTimeProvider(this);
- _stateCtrl.addSelectionListener(this);
- _stateCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
- _stateCtrl.addMouseWheelListener(new MouseWheelListener() {
+ fTimeGraphCtrl.setTimeProvider(this);
+ fTimeGraphCtrl.addSelectionListener(this);
+ fTimeGraphCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
+ fTimeGraphCtrl.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
adjustVerticalScrollBar();
}
});
- _stateCtrl.addKeyListener(new KeyAdapter() {
+ fTimeGraphCtrl.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
adjustVerticalScrollBar();
}
});
- Composite filler = new Composite(_dataViewer, SWT.NONE);
+ Composite filler = new Composite(fDataViewer, SWT.NONE);
GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
- gd.heightHint = _stateCtrl.getHorizontalBar().getSize().y;
+ gd.heightHint = fTimeGraphCtrl.getHorizontalBar().getSize().y;
filler.setLayoutData(gd);
filler.setLayout(new FillLayout());
- _stateCtrl.addControlListener(new ControlAdapter() {
+ fTimeGraphCtrl.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent event) {
resizeControls();
}
});
resizeControls();
- _dataViewer.update();
+ fDataViewer.update();
adjustVerticalScrollBar();
- return _dataViewer;
+ return fDataViewer;
}
/**
@@ -316,9 +320,9 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
public void dispose() {
saveOptions();
- _stateCtrl.dispose();
- _dataViewer.dispose();
- _colors.dispose();
+ fTimeGraphCtrl.dispose();
+ fDataViewer.dispose();
+ fColorScheme.dispose();
}
/**
@@ -340,17 +344,17 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Resize the controls
*/
public void resizeControls() {
- Rectangle r = _dataViewer.getClientArea();
+ Rectangle r = fDataViewer.getClientArea();
if (r.isEmpty()) {
return;
}
int width = r.width;
- if (_nameWidth > width - _minNameWidth) {
- _nameWidth = width - _minNameWidth;
+ if (fNameWidth > width - fMinNameWidth) {
+ fNameWidth = width - fMinNameWidth;
}
- if (_nameWidth < _minNameWidth) {
- _nameWidth = _minNameWidth;
+ if (fNameWidth < fMinNameWidth) {
+ fNameWidth = fMinNameWidth;
}
adjustVerticalScrollBar();
}
@@ -362,22 +366,22 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The traces in the model
*/
public void setTimeRange(ITimeGraphEntry traces[]) {
- _endTime = 0;
- _beginTime = -1;
+ fEndTime = 0;
+ fBeginTime = -1;
for (int i = 0; i < traces.length; i++) {
ITimeGraphEntry entry = traces[i];
if (entry.getEndTime() >= entry.getStartTime() && entry.getEndTime() > 0) {
- if (_beginTime < 0 || entry.getStartTime() < _beginTime) {
- _beginTime = entry.getStartTime();
+ if (fBeginTime < 0 || entry.getStartTime() < fBeginTime) {
+ fBeginTime = entry.getStartTime();
}
- if (entry.getEndTime() > _endTime) {
- _endTime = entry.getEndTime();
+ if (entry.getEndTime() > fEndTime) {
+ fEndTime = entry.getEndTime();
}
}
}
- if (_beginTime < 0) {
- _beginTime = 0;
+ if (fBeginTime < 0) {
+ fBeginTime = 0;
}
}
@@ -385,21 +389,17 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Recalculate the time bounds
*/
public void setTimeBounds() {
- //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);
- _time0_ = _beginTime;
- if (_time0_ < 0) {
- _time0_ = 0;
+ fTime0Bound = fBeginTime;
+ if (fTime0Bound < 0) {
+ fTime0Bound = 0;
}
- // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;
- _time1_ = _endTime;
- // _time0_ = Math.floor(_time0_);
- // _time1_ = Math.ceil(_time1_);
- if (!_timeRangeFixed) {
- _time0 = _time0_;
- _time1 = _time1_;
+ fTime1Bound = fEndTime;
+ if (!fTimeRangeFixed) {
+ fTime0 = fTime0Bound;
+ fTime1 = fTime1Bound;
}
- if (_time1 - _time0 < _minTimeInterval) {
- _time1 = Math.min(_time1_, _time0 + _minTimeInterval);
+ if (fTime1 - fTime0 < fMinTimeInterval) {
+ fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval);
}
}
@@ -419,8 +419,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
// individual processes
setTimeRange(realTraces);
} else {
- _beginTime = start;
- _endTime = end;
+ fBeginTime = start;
+ fEndTime = end;
}
refreshAllData(realTraces);
@@ -431,13 +431,13 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
private void refreshAllData(ITimeGraphEntry[] traces) {
setTimeBounds();
- if (_selectedTime < _beginTime) {
- _selectedTime = _beginTime;
- } else if (_selectedTime > _endTime) {
- _selectedTime = _endTime;
+ if (fSelectedTime < fBeginTime) {
+ fSelectedTime = fBeginTime;
+ } else if (fSelectedTime > fEndTime) {
+ fSelectedTime = fEndTime;
}
- _stateCtrl.refreshData(traces);
- _timeScaleCtrl.redraw();
+ fTimeGraphCtrl.refreshData(traces);
+ fTimeScaleCtrl.redraw();
adjustVerticalScrollBar();
}
@@ -445,8 +445,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Callback for when this view is focused
*/
public void setFocus() {
- if (null != _stateCtrl) {
- _stateCtrl.setFocus();
+ if (null != fTimeGraphCtrl) {
+ fTimeGraphCtrl.setFocus();
}
}
@@ -456,7 +456,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return If the view is currently focused, or not
*/
public boolean isInFocus() {
- return _stateCtrl.isInFocus();
+ return fTimeGraphCtrl.isInFocus();
}
/**
@@ -465,7 +465,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The entry that is selected
*/
public ITimeGraphEntry getSelection() {
- return _stateCtrl.getSelectedTrace();
+ return fTimeGraphCtrl.getSelectedTrace();
}
/**
@@ -474,73 +474,73 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The index
*/
public int getSelectionIndex() {
- return _stateCtrl.getSelectedIndex();
+ return fTimeGraphCtrl.getSelectedIndex();
}
@Override
public long getTime0() {
- return _time0;
+ return fTime0;
}
@Override
public long getTime1() {
- return _time1;
+ return fTime1;
}
@Override
public long getMinTimeInterval() {
- return _minTimeInterval;
+ return fMinTimeInterval;
}
@Override
public int getNameSpace() {
- return _nameWidth;
+ return fNameWidth;
}
@Override
public void setNameSpace(int width) {
- _nameWidth = width;
- int w = _stateCtrl.getClientArea().width;
- if (_nameWidth > w - 6) {
- _nameWidth = w - 6;
+ fNameWidth = width;
+ int w = fTimeGraphCtrl.getClientArea().width;
+ if (fNameWidth > w - MIN_NAME_WIDTH) {
+ fNameWidth = w - MIN_NAME_WIDTH;
}
- if (_nameWidth < 6) {
- _nameWidth = 6;
+ if (fNameWidth < MIN_NAME_WIDTH) {
+ fNameWidth = MIN_NAME_WIDTH;
}
- _stateCtrl.adjustScrolls();
- _stateCtrl.redraw();
- _timeScaleCtrl.redraw();
+ fTimeGraphCtrl.adjustScrolls();
+ fTimeGraphCtrl.redraw();
+ fTimeScaleCtrl.redraw();
}
@Override
public int getTimeSpace() {
- int w = _stateCtrl.getClientArea().width;
- return w - _nameWidth;
+ int w = fTimeGraphCtrl.getClientArea().width;
+ return w - fNameWidth;
}
@Override
public long getSelectedTime() {
- return _selectedTime;
+ return fSelectedTime;
}
@Override
public long getBeginTime() {
- return _beginTime;
+ return fBeginTime;
}
@Override
public long getEndTime() {
- return _endTime;
+ return fEndTime;
}
@Override
public long getMaxTime() {
- return _time1_;
+ return fTime1Bound;
}
@Override
public long getMinTime() {
- return _time0_;
+ return fTime0Bound;
}
@Override
@@ -551,32 +551,32 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
@Override
public void notifyStartFinishTime() {
- notifyRangeListeners(_time0, _time1);
+ notifyRangeListeners(fTime0, fTime1);
}
@Override
public void setStartFinishTime(long time0, long time1) {
- _time0 = time0;
- if (_time0 < _time0_) {
- _time0 = _time0_;
+ fTime0 = time0;
+ if (fTime0 < fTime0Bound) {
+ fTime0 = fTime0Bound;
}
- if (_time0 > _time1_) {
- _time0 = _time1_;
+ if (fTime0 > fTime1Bound) {
+ fTime0 = fTime1Bound;
}
- _time1 = time1;
- if (_time1 < _time0_) {
- _time1 = _time0_;
+ fTime1 = time1;
+ if (fTime1 < fTime0Bound) {
+ fTime1 = fTime0Bound;
}
- if (_time1 > _time1_) {
- _time1 = _time1_;
+ if (fTime1 > fTime1Bound) {
+ fTime1 = fTime1Bound;
}
- if (_time1 - _time0 < _minTimeInterval) {
- _time1 = Math.min(_time1_, _time0 + _minTimeInterval);
+ if (fTime1 - fTime0 < fMinTimeInterval) {
+ fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval);
}
- _timeRangeFixed = true;
- _stateCtrl.adjustScrolls();
- _stateCtrl.redraw();
- _timeScaleCtrl.redraw();
+ fTimeRangeFixed = true;
+ fTimeGraphCtrl.adjustScrolls();
+ fTimeGraphCtrl.redraw();
+ fTimeScaleCtrl.redraw();
}
/**
@@ -588,17 +588,17 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The end time
*/
public void setTimeBounds(long beginTime, long endTime) {
- _beginTime = beginTime;
- _endTime = endTime;
- _time0_ = beginTime;
- _time1_ = endTime;
- _stateCtrl.adjustScrolls();
+ fBeginTime = beginTime;
+ fEndTime = endTime;
+ fTime0Bound = beginTime;
+ fTime1Bound = endTime;
+ fTimeGraphCtrl.adjustScrolls();
}
@Override
public void resetStartFinishTime() {
- setStartFinishTime(_time0_, _time1_);
- _timeRangeFixed = false;
+ setStartFinishTime(fTime0Bound, fTime1Bound);
+ fTimeRangeFixed = false;
}
@Override
@@ -612,61 +612,61 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
}
private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) {
- long time0 = _time0;
- long time1 = _time1;
+ long time0 = fTime0;
+ long time1 = fTime1;
if (ensureVisible) {
- long timeSpace = (long) ((_time1 - _time0) * .02);
- long timeMid = (long) ((_time1 - _time0) * .5);
- if (time < _time0 + timeSpace) {
- long dt = _time0 - time + timeMid;
- _time0 -= dt;
- _time1 -= dt;
- } else if (time > _time1 - timeSpace) {
- long dt = time - _time1 + timeMid;
- _time0 += dt;
- _time1 += dt;
+ long timeSpace = (fTime1 - fTime0) / RECENTERING_MARGIN_FACTOR;
+ long timeMid = (fTime1 - fTime0) / 2;
+ if (time < fTime0 + timeSpace) {
+ long dt = fTime0 - time + timeMid;
+ fTime0 -= dt;
+ fTime1 -= dt;
+ } else if (time > fTime1 - timeSpace) {
+ long dt = time - fTime1 + timeMid;
+ fTime0 += dt;
+ fTime1 += dt;
}
- if (_time0 < _time0_) {
- _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0));
- _time0 = _time0_;
- } else if (_time1 > _time1_) {
- _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_));
- _time1 = _time1_;
+ if (fTime0 < fTime0Bound) {
+ fTime1 = Math.min(fTime1Bound, fTime1 + (fTime0Bound - fTime0));
+ fTime0 = fTime0Bound;
+ } else if (fTime1 > fTime1Bound) {
+ fTime0 = Math.max(fTime0Bound, fTime0 - (fTime1 - fTime1Bound));
+ fTime1 = fTime1Bound;
}
}
- if (_time1 - _time0 < _minTimeInterval) {
- _time1 = Math.min(_time1_, _time0 + _minTimeInterval);
+ if (fTime1 - fTime0 < fMinTimeInterval) {
+ fTime1 = Math.min(fTime1Bound, fTime0 + fMinTimeInterval);
}
- _stateCtrl.adjustScrolls();
- _stateCtrl.redraw();
- _timeScaleCtrl.redraw();
+ fTimeGraphCtrl.adjustScrolls();
+ fTimeGraphCtrl.redraw();
+ fTimeScaleCtrl.redraw();
- boolean notifySelectedTime = (time != _selectedTime);
- _selectedTime = time;
+ boolean notifySelectedTime = (time != fSelectedTime);
+ fSelectedTime = time;
- if (doNotify && ((time0 != _time0) || (time1 != _time1))) {
- notifyRangeListeners(_time0, _time1);
+ if (doNotify && ((time0 != fTime0) || (time1 != fTime1))) {
+ notifyRangeListeners(fTime0, fTime1);
}
if (doNotify && notifySelectedTime) {
- notifyTimeListeners(_selectedTime);
+ notifyTimeListeners(fSelectedTime);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
- if (_selectedEntry != getSelection()) {
- _selectedEntry = getSelection();
- notifySelectionListeners(_selectedEntry);
+ if (fSelectedEntry != getSelection()) {
+ fSelectedEntry = getSelection();
+ notifySelectionListeners(fSelectedEntry);
}
}
@Override
public void widgetSelected(SelectionEvent e) {
- if (_selectedEntry != getSelection()) {
- _selectedEntry = getSelection();
- notifySelectionListeners(_selectedEntry);
+ if (fSelectedEntry != getSelection()) {
+ fSelectedEntry = getSelection();
+ notifySelectionListeners(fSelectedEntry);
}
}
@@ -674,7 +674,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Callback for when the next event is selected
*/
public void selectNextEvent() {
- _stateCtrl.selectNextEvent();
+ fTimeGraphCtrl.selectNextEvent();
adjustVerticalScrollBar();
}
@@ -682,7 +682,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Callback for when the previous event is selected
*/
public void selectPrevEvent() {
- _stateCtrl.selectPrevEvent();
+ fTimeGraphCtrl.selectPrevEvent();
adjustVerticalScrollBar();
}
@@ -690,7 +690,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Callback for when the next item is selected
*/
public void selectNextItem() {
- _stateCtrl.selectNextTrace();
+ fTimeGraphCtrl.selectNextTrace();
adjustVerticalScrollBar();
}
@@ -698,7 +698,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Callback for when the previous item is selected
*/
public void selectPrevItem() {
- _stateCtrl.selectPrevTrace();
+ fTimeGraphCtrl.selectPrevTrace();
adjustVerticalScrollBar();
}
@@ -706,25 +706,25 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Callback for the show legend action
*/
public void showLegend() {
- if (_dataViewer == null || _dataViewer.isDisposed()) {
+ if (fDataViewer == null || fDataViewer.isDisposed()) {
return;
}
- TimeGraphLegend.open(_dataViewer.getShell(), fTimeGraphProvider);
+ TimeGraphLegend.open(fDataViewer.getShell(), fTimeGraphProvider);
}
/**
* Callback for the Zoom In action
*/
public void zoomIn() {
- _stateCtrl.zoomIn();
+ fTimeGraphCtrl.zoomIn();
}
/**
* Callback for the Zoom Out action
*/
public void zoomOut() {
- _stateCtrl.zoomOut();
+ fTimeGraphCtrl.zoomOut();
}
private String getPreferenceString(String string) {
@@ -809,7 +809,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
private void notifyRangeListeners(long startTime, long endTime) {
// Check if the time has actually changed from last notification
- if (startTime != _time0_extSynch || endTime != _time1_extSynch) {
+ if (startTime != fTime0ExtSynch || endTime != fTime1ExtSynch) {
// Notify Time Scale Selection Listeners
TimeGraphRangeUpdateEvent event = new TimeGraphRangeUpdateEvent(this, startTime, endTime);
@@ -834,8 +834,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
if (event == null || source == this) {
return;
}
- _selectedEntry = event.getEntry();
- _stateCtrl.selectItem(_selectedEntry, false);
+ fSelectedEntry = event.getEntry();
+ fTimeGraphCtrl.selectItem(fSelectedEntry, false);
setSelectedTimeInt(event.getTime(), true, true);
adjustVerticalScrollBar();
@@ -855,8 +855,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
if (trace == null || source == this) {
return;
}
- _selectedEntry = trace;
- _stateCtrl.selectItem(trace, false);
+ fSelectedEntry = trace;
+ fTimeGraphCtrl.selectItem(trace, false);
setSelectedTimeInt(time, true, true);
}
@@ -868,8 +868,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The trace that was selected
*/
public void setSelection(ITimeGraphEntry trace) {
- _selectedEntry = trace;
- _stateCtrl.selectItem(trace, false);
+ fSelectedEntry = trace;
+ fTimeGraphCtrl.selectItem(trace, false);
adjustVerticalScrollBar();
}
@@ -901,8 +901,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
private void updateExtSynchTimers() {
// last time notification cache
- _time0_extSynch = _time0;
- _time1_extSynch = _time1;
+ fTime0ExtSynch = fTime0;
+ fTime1ExtSynch = fTime1;
}
/**
@@ -910,7 +910,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
@Override
public TimeFormat getTimeFormat() {
- return timeFormat;
+ return fTimeFormat;
}
/**
@@ -918,7 +918,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public void setTimeFormat(TimeFormat tf) {
- this.timeFormat = tf;
+ this.fTimeFormat = tf;
}
/**
@@ -927,7 +927,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The width
*/
public int getBorderWidth() {
- return borderWidth;
+ return fBorderWidth;
}
/**
@@ -938,8 +938,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
public void setBorderWidth(int borderWidth) {
if (borderWidth > -1) {
- this.borderWidth = borderWidth;
- GridLayout gl = (GridLayout)_dataViewer.getLayout();
+ this.fBorderWidth = borderWidth;
+ GridLayout gl = (GridLayout)fDataViewer.getLayout();
gl.marginHeight = borderWidth;
}
}
@@ -950,7 +950,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The height
*/
public int getHeaderHeight() {
- return timeScaleHeight;
+ return fTimeScaleHeight;
}
/**
@@ -961,8 +961,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
*/
public void setHeaderHeight(int headerHeight) {
if (headerHeight > -1) {
- this.timeScaleHeight = headerHeight;
- _timeScaleCtrl.setHeight(headerHeight);
+ this.fTimeScaleHeight = headerHeight;
+ fTimeScaleCtrl.setHeight(headerHeight);
}
}
@@ -972,8 +972,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The height
*/
public int getItemHeight() {
- if (_stateCtrl != null) {
- return _stateCtrl.getItemHeight();
+ if (fTimeGraphCtrl != null) {
+ return fTimeGraphCtrl.getItemHeight();
}
return 0;
}
@@ -985,8 +985,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The height to set
*/
public void setItemHeight(int rowHeight) {
- if (_stateCtrl != null) {
- _stateCtrl.setItemHeight(rowHeight);
+ if (fTimeGraphCtrl != null) {
+ fTimeGraphCtrl.setItemHeight(rowHeight);
}
}
@@ -997,8 +997,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The min width
*/
public void setMinimumItemWidth(int width) {
- if (_stateCtrl != null) {
- _stateCtrl.setMinimumItemWidth(width);
+ if (fTimeGraphCtrl != null) {
+ fTimeGraphCtrl.setMinimumItemWidth(width);
}
}
@@ -1008,10 +1008,10 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @param width The width
*/
public void setNameWidthPref(int width) {
- _nameWidthPref = width;
+ fNameWidthPref = width;
if (width == 0) {
- _minNameWidth = 0;
- _nameWidth = 0;
+ fMinNameWidth = 0;
+ fNameWidth = 0;
}
}
@@ -1023,7 +1023,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The width
*/
public int getNameWidthPref(int width) {
- return _nameWidthPref;
+ return fNameWidthPref;
}
/**
@@ -1032,7 +1032,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return the SWT control which displays this viewer's content
*/
public Control getControl() {
- return _dataViewer;
+ return fDataViewer;
}
/**
@@ -1042,7 +1042,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public TimeGraphControl getTimeGraphControl() {
- return _stateCtrl;
+ return fTimeGraphCtrl;
}
/**
@@ -1052,7 +1052,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public TimeGraphScale getTimeGraphScale() {
- return _timeScaleCtrl;
+ return fTimeScaleCtrl;
}
/**
@@ -1064,7 +1064,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public int getXForTime(long time) {
- return _stateCtrl.getXForTime(time);
+ return fTimeGraphCtrl.getXForTime(time);
}
/**
@@ -1076,7 +1076,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public long getTimeAtX(int x) {
- return _stateCtrl.getTimeAtX(x);
+ return fTimeGraphCtrl.getTimeAtX(x);
}
/**
@@ -1085,7 +1085,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return the selection provider
*/
public ISelectionProvider getSelectionProvider() {
- return _stateCtrl;
+ return fTimeGraphCtrl;
}
/**
@@ -1095,7 +1095,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* Wait indefinitely?
*/
public void waitCursor(boolean waitInd) {
- _stateCtrl.waitCursor(waitInd);
+ fTimeGraphCtrl.waitCursor(waitInd);
}
/**
@@ -1104,7 +1104,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The scroll bar
*/
public ScrollBar getHorizontalBar() {
- return _stateCtrl.getHorizontalBar();
+ return fTimeGraphCtrl.getHorizontalBar();
}
/**
@@ -1113,7 +1113,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The scroll bar
*/
public Slider getVerticalBar() {
- return _verticalScrollBar;
+ return fVerticalScrollBar;
}
/**
@@ -1123,7 +1123,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The index that will go to the top
*/
public void setTopIndex(int index) {
- _stateCtrl.setTopIndex(index);
+ fTimeGraphCtrl.setTopIndex(index);
adjustVerticalScrollBar();
}
@@ -1133,7 +1133,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The top index
*/
public int getTopIndex() {
- return _stateCtrl.getTopIndex();
+ return fTimeGraphCtrl.getTopIndex();
}
/**
@@ -1145,7 +1145,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* True for expanded, false for collapsed
*/
public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {
- _stateCtrl.setExpandedState(entry, expanded);
+ fTimeGraphCtrl.setExpandedState(entry, expanded);
adjustVerticalScrollBar();
}
@@ -1155,7 +1155,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public void collapseAll() {
- _stateCtrl.collapseAll();
+ fTimeGraphCtrl.collapseAll();
adjustVerticalScrollBar();
}
@@ -1165,7 +1165,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public void expandAll() {
- _stateCtrl.expandAll();
+ fTimeGraphCtrl.expandAll();
adjustVerticalScrollBar();
}
@@ -1175,7 +1175,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The element count
*/
public int getExpandedElementCount() {
- return _stateCtrl.getExpandedElementCount();
+ return fTimeGraphCtrl.getExpandedElementCount();
}
/**
@@ -1184,7 +1184,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The array of entries that are below this one
*/
public ITimeGraphEntry[] getExpandedElements() {
- return _stateCtrl.getExpandedElements();
+ return fTimeGraphCtrl.getExpandedElements();
}
/**
@@ -1194,7 +1194,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The listener to add
*/
public void addTreeListener(ITimeGraphTreeListener listener) {
- _stateCtrl.addTreeListener(listener);
+ fTimeGraphCtrl.addTreeListener(listener);
}
/**
@@ -1204,7 +1204,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* The listener to remove
*/
public void removeTreeListener(ITimeGraphTreeListener listener) {
- _stateCtrl.removeTreeListener(listener);
+ fTimeGraphCtrl.removeTreeListener(listener);
}
/**
@@ -1213,20 +1213,20 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getResetScaleAction() {
- if (resetScale == null) {
+ if (fResetScaleAction == null) {
// resetScale
- resetScale = new Action() {
+ fResetScaleAction = new Action() {
@Override
public void run() {
resetStartFinishTime();
notifyStartFinishTime();
}
};
- resetScale.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText);
- resetScale.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText);
- resetScale.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU));
+ fResetScaleAction.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText);
+ fResetScaleAction.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText);
+ fResetScaleAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU));
}
- return resetScale;
+ return fResetScaleAction;
}
/**
@@ -1235,20 +1235,20 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getShowLegendAction() {
- if (showLegendAction == null) {
+ if (fShowLegendAction == null) {
// showLegend
- showLegendAction = new Action() {
+ fShowLegendAction = new Action() {
@Override
public void run() {
showLegend();
}
};
- showLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText);
- showLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText);
- showLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND));
+ fShowLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText);
+ fShowLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText);
+ fShowLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND));
}
- return showLegendAction;
+ return fShowLegendAction;
}
/**
@@ -1257,20 +1257,20 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The action object
*/
public Action getNextEventAction() {
- if (nextEventAction == null) {
- nextEventAction = new Action() {
+ if (fNextEventAction == null) {
+ fNextEventAction = new Action() {
@Override
public void run() {
selectNextEvent();
}
};
- nextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText);
- nextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText);
- nextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT));
+ fNextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText);
+ fNextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText);
+ fNextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT));
}
- return nextEventAction;
+ return fNextEventAction;
}
/**
@@ -1279,20 +1279,20 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getPreviousEventAction() {
- if (prevEventAction == null) {
- prevEventAction = new Action() {
+ if (fPrevEventAction == null) {
+ fPrevEventAction = new Action() {
@Override
public void run() {
selectPrevEvent();
}
};
- prevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText);
- prevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText);
- prevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT));
+ fPrevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText);
+ fPrevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText);
+ fPrevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT));
}
- return prevEventAction;
+ return fPrevEventAction;
}
/**
@@ -1301,19 +1301,19 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getNextItemAction() {
- if (nextItemAction == null) {
+ if (fNextItemAction == null) {
- nextItemAction = new Action() {
+ fNextItemAction = new Action() {
@Override
public void run() {
selectNextItem();
}
};
- nextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText);
- nextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText);
- nextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM));
+ fNextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText);
+ fNextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText);
+ fNextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM));
}
- return nextItemAction;
+ return fNextItemAction;
}
/**
@@ -1322,19 +1322,19 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getPreviousItemAction() {
- if (previousItemAction == null) {
+ if (fPreviousItemAction == null) {
- previousItemAction = new Action() {
+ fPreviousItemAction = new Action() {
@Override
public void run() {
selectPrevItem();
}
};
- previousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText);
- previousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText);
- previousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM));
+ fPreviousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText);
+ fPreviousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText);
+ fPreviousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM));
}
- return previousItemAction;
+ return fPreviousItemAction;
}
/**
@@ -1343,18 +1343,18 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getZoomInAction() {
- if (zoomInAction == null) {
- zoomInAction = new Action() {
+ if (fZoomInAction == null) {
+ fZoomInAction = new Action() {
@Override
public void run() {
zoomIn();
}
};
- zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);
- zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);
- zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));
+ fZoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);
+ fZoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);
+ fZoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));
}
- return zoomInAction;
+ return fZoomInAction;
}
/**
@@ -1363,36 +1363,36 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @return The Action object
*/
public Action getZoomOutAction() {
- if (zoomOutAction == null) {
- zoomOutAction = new Action() {
+ if (fZoomOutAction == null) {
+ fZoomOutAction = new Action() {
@Override
public void run() {
zoomOut();
}
};
- zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);
- zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);
- zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));
+ fZoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);
+ fZoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);
+ fZoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));
}
- return zoomOutAction;
+ return fZoomOutAction;
}
private void adjustVerticalScrollBar() {
- int topIndex = _stateCtrl.getTopIndex();
- int countPerPage = _stateCtrl.countPerPage();
- int expandedElementCount = _stateCtrl.getExpandedElementCount();
+ int topIndex = fTimeGraphCtrl.getTopIndex();
+ int countPerPage = fTimeGraphCtrl.countPerPage();
+ int expandedElementCount = fTimeGraphCtrl.getExpandedElementCount();
if (topIndex + countPerPage > expandedElementCount) {
- _stateCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage));
+ fTimeGraphCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage));
}
- int selection = _stateCtrl.getTopIndex();
+ int selection = fTimeGraphCtrl.getTopIndex();
int min = 0;
int max = Math.max(1, expandedElementCount - 1);
int thumb = Math.min(max, Math.max(1, countPerPage - 1));
int increment = 1;
int pageIncrement = Math.max(1, countPerPage);
- _verticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement);
+ fVerticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement);
}
/**
@@ -1401,7 +1401,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 1.2
*/
public void addTimeGraphEntryMenuListener(MenuDetectListener listener) {
- _stateCtrl.addTimeGraphEntryMenuListener(listener);
+ fTimeGraphCtrl.addTimeGraphEntryMenuListener(listener);
}
/**
@@ -1410,7 +1410,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 1.2
*/
public void removeTimeGraphEntryMenuListener(MenuDetectListener listener) {
- _stateCtrl.removeTimeGraphEntryMenuListener(listener);
+ fTimeGraphCtrl.removeTimeGraphEntryMenuListener(listener);
}
/**
@@ -1419,7 +1419,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 1.2
*/
public void addTimeEventMenuListener(MenuDetectListener listener) {
- _stateCtrl.addTimeEventMenuListener(listener);
+ fTimeGraphCtrl.addTimeEventMenuListener(listener);
}
/**
@@ -1428,7 +1428,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 1.2
*/
public void removeTimeEventMenuListener(MenuDetectListener listener) {
- _stateCtrl.removeTimeEventMenuListener(listener);
+ fTimeGraphCtrl.removeTimeEventMenuListener(listener);
}
/**
@@ -1436,7 +1436,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public void addFilter(ViewerFilter filter) {
- _stateCtrl.addFilter(filter);
+ fTimeGraphCtrl.addFilter(filter);
refresh();
}
@@ -1445,7 +1445,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
* @since 2.0
*/
public void removeFilter(ViewerFilter filter) {
- _stateCtrl.removeFilter(filter);
+ fTimeGraphCtrl.removeFilter(filter);
refresh();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java
index b4f3bb476c..214938373b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java
@@ -13,6 +13,7 @@
* CheckedTreeSelectionDialog#createSelectionButtons(Composite) fails to
* align the selection buttons to the right
* François Rajotte - Support for multiple columns + selection control
+ * Patrick Tasse - Fix Sonar warnings
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs;
@@ -61,11 +62,13 @@ import org.eclipse.ui.dialogs.SelectionStatusDialog;
* @author François Rajotte
*/
public class TimeGraphFilterDialog extends SelectionStatusDialog {
- private final static int BUTTON_CHECK_SELECTED_ID = IDialogConstants.CLIENT_ID;
- private final static int BUTTON_UNCHECK_SELECTED_ID = IDialogConstants.CLIENT_ID + 1;
- private final static int BUTTON_CHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 2;
- private final static int BUTTON_UNCHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 3;
+ private static final int BUTTON_CHECK_SELECTED_ID = IDialogConstants.CLIENT_ID;
+ private static final int BUTTON_UNCHECK_SELECTED_ID = IDialogConstants.CLIENT_ID + 1;
+ private static final int BUTTON_CHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 2;
+ private static final int BUTTON_UNCHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 3;
+ private static final int DEFAULT_WIDTH = 60;
+ private static final int DEFAULT_HEIGHT = 18;
private CheckboxTreeViewer fViewer;
@@ -90,9 +93,9 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
private boolean fIsEmpty;
- private int fWidth = 60;
+ private int fWidth = DEFAULT_WIDTH;
- private int fHeight = 18;
+ private int fHeight = DEFAULT_HEIGHT;
private Object[] fExpandedElements;
@@ -148,7 +151,7 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
*/
public void addFilter(ViewerFilter filter) {
if (fFilters == null) {
- fFilters = new ArrayList<ViewerFilter>(4);
+ fFilters = new ArrayList<ViewerFilter>();
}
fFilters.add(filter);
}
@@ -181,7 +184,11 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
* The elements that will be expanded.
*/
public void setExpandedElements(Object[] elements) {
- fExpandedElements = elements;
+ if (elements != null) {
+ fExpandedElements = Arrays.copyOf(elements, elements.length);
+ } else {
+ fExpandedElements = null;
+ }
}
/**
@@ -215,7 +222,11 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
* @param columnNames An array of column names to display
*/
public void setColumnNames(String[] columnNames) {
- fColumnNames = columnNames;
+ if (columnNames != null) {
+ fColumnNames = Arrays.copyOf(columnNames, columnNames.length);
+ } else {
+ fColumnNames = null;
+ }
}
/**
@@ -246,10 +257,6 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
return getReturnCode();
}
- private void access$superCreate() {
- super.create();
- }
-
@Override
protected void cancelPressed() {
setResult(null);
@@ -266,7 +273,7 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
BusyIndicator.showWhile(null, new Runnable() {
@Override
public void run() {
- access$superCreate();
+ TimeGraphFilterDialog.super.create();
fViewer.setCheckedElements(getInitialElementSelections()
.toArray());
if (fExpandedElements != null) {
@@ -517,12 +524,10 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
private boolean evaluateIfTreeEmpty(Object input) {
Object[] elements = fContentProvider.getElements(input);
- if (elements.length > 0) {
- if (fFilters != null) {
- for (int i = 0; i < fFilters.size(); i++) {
- ViewerFilter curr = fFilters.get(i);
- elements = curr.filter(fViewer, input, elements);
- }
+ if (elements.length > 0 && fFilters != null) {
+ for (int i = 0; i < fFilters.size(); i++) {
+ ViewerFilter curr = fFilters.get(i);
+ elements = curr.filter(fViewer, input, elements);
}
}
return elements.length == 0;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java
index 74c3356996..49de317110 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java
@@ -98,7 +98,7 @@ public interface ITimeDataProvider {
* Ensure visibility of new time (will adjust time range if
* necessary)
*/
- public void setSelectedTimeNotify(long time, boolean ensureVisible);
+ void setSelectedTimeNotify(long time, boolean ensureVisible);
/**
* Updates the selected time and adjusts the time range if necessary without
@@ -110,7 +110,7 @@ public interface ITimeDataProvider {
* Ensure visibility of new time (will adjust time range if
* necessary)
*/
- public void setSelectedTime(long time, boolean ensureVisible);
+ void setSelectedTime(long time, boolean ensureVisible);
/**
* Reset the start and end times
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphBaseControl.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphBaseControl.java
index 04a36eeed5..9fd891838a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphBaseControl.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphBaseControl.java
@@ -44,10 +44,10 @@ public abstract class TimeGraphBaseControl extends Canvas implements PaintListen
public static final int SMALL_ICON_SIZE = 16;
/** Color scheme */
- protected TimeGraphColorScheme _colors;
+ private TimeGraphColorScheme fColorScheme;
/** Font size */
- protected int _fontHeight = 0;
+ private int fFontHeight = 0;
/**
* Basic constructor. Uses a default style value
@@ -66,28 +66,23 @@ public abstract class TimeGraphBaseControl extends Canvas implements PaintListen
*
* @param parent
* The parent composite object
- * @param colors
+ * @param colorScheme
* The color scheme to use
* @param style
* The index of the style to use
*/
- public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors, int style) {
+ public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colorScheme, int style) {
super(parent, style);
- _colors = colors;
+ fColorScheme = colorScheme;
addPaintListener(this);
}
@Override
- public void dispose() {
- super.dispose();
- }
-
- @Override
public void paintControl(PaintEvent e) {
if (e.widget != this) {
return;
}
- _fontHeight = e.gc.getFontMetrics().getHeight();
+ fFontHeight = e.gc.getFontMetrics().getHeight();
Rectangle bound = getClientArea();
if (!bound.isEmpty()) {
Color colBackup = e.gc.getBackground();
@@ -97,12 +92,23 @@ public abstract class TimeGraphBaseControl extends Canvas implements PaintListen
}
/**
+ * Retrieve the color scheme
+ *
+ * @return The color scheme
+ *
+ * @since 2.0
+ */
+ public TimeGraphColorScheme getColorScheme() {
+ return fColorScheme;
+ }
+
+ /**
* Retrieve the current font's height
*
* @return The height
*/
public int getFontHeight() {
- return _fontHeight;
+ return fFontHeight;
}
abstract void paint(Rectangle bound, PaintEvent e);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java
index dcf55aa409..eef9846390 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java
@@ -27,125 +27,125 @@ import org.eclipse.swt.graphics.Color;
public class TimeGraphColorScheme {
// elements color indices
- static public final int BLACK_STATE = 0;
- static public final int GREEN_STATE = 1;
- static public final int DARK_BLUE_STATE = 2;
- static public final int ORANGE_STATE = 3;
- static public final int GOLD_STATE = 4;
- static public final int RED_STATE = 5;
- static public final int GRAY_STATE = 6;
- static public final int DARK_GREEN_STATE = 7;
- static public final int DARK_YELLOW_STATE = 8;
- static public final int MAGENTA3_STATE = 9;
- static public final int PURPLE1_STATE = 10;
- static public final int PINK1_STATE = 11;
- static public final int AQUAMARINE_STATE = 12;
- static public final int LIGHT_BLUE_STATE = 13;
- static public final int CADET_BLUE_STATE = 14;
- static public final int OLIVE_STATE = 15;
-
- static public final int STATES0 = 0;
- static public final int STATES1 = 15;
+ public static final int BLACK_STATE = 0;
+ public static final int GREEN_STATE = 1;
+ public static final int DARK_BLUE_STATE = 2;
+ public static final int ORANGE_STATE = 3;
+ public static final int GOLD_STATE = 4;
+ public static final int RED_STATE = 5;
+ public static final int GRAY_STATE = 6;
+ public static final int DARK_GREEN_STATE = 7;
+ public static final int DARK_YELLOW_STATE = 8;
+ public static final int MAGENTA3_STATE = 9;
+ public static final int PURPLE1_STATE = 10;
+ public static final int PINK1_STATE = 11;
+ public static final int AQUAMARINE_STATE = 12;
+ public static final int LIGHT_BLUE_STATE = 13;
+ public static final int CADET_BLUE_STATE = 14;
+ public static final int OLIVE_STATE = 15;
+
+ public static final int STATES0 = 0;
+ public static final int STATES1 = 15;
// selected state elements color indices
- static public final int BLACK_STATE_SEL = 16;
- static public final int GREEN_STATE_SEL = 17;
- static public final int DARK_BLUE_STATE_SEL = 18;
- static public final int ORANGE_STATE_SEL = 19;
- static public final int GOLD_STATE_SEL = 20;
- static public final int RED_STATE_SEL = 21;
- static public final int GRAY_STATE_SEL = 22;
- static public final int DARK_GREEN_STATE_SEL = 23;
- static public final int DARK_YELLOW_STATE_SEL = 24;
- static public final int MAGENTA3_STATE_SEL = 25;
- static public final int PURPLE1_STATE_SEL = 26;
- static public final int PINK1_STATE_SEL = 27;
- static public final int AQUAMARINE_STATE_SEL = 28;
- static public final int LIGHT_BLUE_STATE_SEL = 29;
- static public final int CADET_BLUE_STATE_SEL = 30;
- static public final int OLIVE_STATE_SEL = 31;
-
- static public final int STATES_SEL0 = 16;
- static public final int STATES_SEL1 = 31;
+ public static final int BLACK_STATE_SEL = 16;
+ public static final int GREEN_STATE_SEL = 17;
+ public static final int DARK_BLUE_STATE_SEL = 18;
+ public static final int ORANGE_STATE_SEL = 19;
+ public static final int GOLD_STATE_SEL = 20;
+ public static final int RED_STATE_SEL = 21;
+ public static final int GRAY_STATE_SEL = 22;
+ public static final int DARK_GREEN_STATE_SEL = 23;
+ public static final int DARK_YELLOW_STATE_SEL = 24;
+ public static final int MAGENTA3_STATE_SEL = 25;
+ public static final int PURPLE1_STATE_SEL = 26;
+ public static final int PINK1_STATE_SEL = 27;
+ public static final int AQUAMARINE_STATE_SEL = 28;
+ public static final int LIGHT_BLUE_STATE_SEL = 29;
+ public static final int CADET_BLUE_STATE_SEL = 30;
+ public static final int OLIVE_STATE_SEL = 31;
+
+ public static final int STATES_SEL0 = 16;
+ public static final int STATES_SEL1 = 31;
// colors indices for viewer controls
- static public final int BACKGROUND = 32;
- static public final int FOREGROUND = 33;
- static public final int BACKGROUND_SEL = 34;
- static public final int FOREGROUND_SEL = 35;
- static public final int BACKGROUND_SEL_NOFOCUS = 36;
- static public final int FOREGROUND_SEL_NOFOCUS = 37;
- static public final int TOOL_BACKGROUND = 38;
- static public final int TOOL_FOREGROUND = 39;
+ public static final int BACKGROUND = 32;
+ public static final int FOREGROUND = 33;
+ public static final int BACKGROUND_SEL = 34;
+ public static final int FOREGROUND_SEL = 35;
+ public static final int BACKGROUND_SEL_NOFOCUS = 36;
+ public static final int FOREGROUND_SEL_NOFOCUS = 37;
+ public static final int TOOL_BACKGROUND = 38;
+ public static final int TOOL_FOREGROUND = 39;
// misc colors
- static public final int FIX_COLOR = 40;
- static public final int WHITE = 41;
- static public final int GRAY = 42;
- static public final int BLACK = 43;
- static public final int DARK_GRAY = 44;
+ public static final int FIX_COLOR = 40;
+ public static final int WHITE = 41;
+ public static final int GRAY = 42;
+ public static final int BLACK = 43;
+ public static final int DARK_GRAY = 44;
// selected border color indices
- static public final int BLACK_BORDER = 45;
- static public final int GREEN_BORDER = 46;
- static public final int DARK_BLUE_BORDER = 47;
- static public final int ORANGE_BORDER = 48;
- static public final int GOLD_BORDER = 49;
- static public final int RED_BORDER = 50;
- static public final int GRAY_BORDER = 51;
- static public final int DARK_GREEN_BORDER1 = 52;
- static public final int DARK_YELLOW_BORDER1 = 53;
- static public final int MAGENTA3_BORDER1 = 54;
- static public final int PURPLE1_BORDER1 = 55;
- static public final int PINK1_BORDER1 = 56;
- static public final int AQUAMARINE_BORDER1 = 57;
- static public final int LIGHT_BLUE_BORDER1 = 58;
- static public final int CADET_BLUE_STATE_BORDER = 59;
- static public final int OLIVE_BORDER2 = 60;
-
- static public final int STATES_BORDER0 = 45;
- static public final int STATES_BORDER1 = 60;
-
- static public final int MID_LINE = 61;
- static public final int RED = 62;
- static public final int GREEN = 63;
- static public final int BLUE = 64;
- static public final int YELLOW = 65;
- static public final int CYAN = 66;
- static public final int MAGENTA = 67;
-
- static public final int SELECTED_TIME = 68;
- static public final int LEGEND_BACKGROUND = 69;
- static public final int LEGEND_FOREGROUND = 70;
+ public static final int BLACK_BORDER = 45;
+ public static final int GREEN_BORDER = 46;
+ public static final int DARK_BLUE_BORDER = 47;
+ public static final int ORANGE_BORDER = 48;
+ public static final int GOLD_BORDER = 49;
+ public static final int RED_BORDER = 50;
+ public static final int GRAY_BORDER = 51;
+ public static final int DARK_GREEN_BORDER1 = 52;
+ public static final int DARK_YELLOW_BORDER1 = 53;
+ public static final int MAGENTA3_BORDER1 = 54;
+ public static final int PURPLE1_BORDER1 = 55;
+ public static final int PINK1_BORDER1 = 56;
+ public static final int AQUAMARINE_BORDER1 = 57;
+ public static final int LIGHT_BLUE_BORDER1 = 58;
+ public static final int CADET_BLUE_STATE_BORDER = 59;
+ public static final int OLIVE_BORDER2 = 60;
+
+ public static final int STATES_BORDER0 = 45;
+ public static final int STATES_BORDER1 = 60;
+
+ public static final int MID_LINE = 61;
+ public static final int RED = 62;
+ public static final int GREEN = 63;
+ public static final int BLUE = 64;
+ public static final int YELLOW = 65;
+ public static final int CYAN = 66;
+ public static final int MAGENTA = 67;
+
+ public static final int SELECTED_TIME = 68;
+ public static final int LEGEND_BACKGROUND = 69;
+ public static final int LEGEND_FOREGROUND = 70;
// group items' colors
- static public final int GR_BACKGROUND = 71;
- static public final int GR_FOREGROUND = 72;
- static public final int GR_BACKGROUND_SEL = 73;
- static public final int GR_FOREGROUND_SEL = 74;
- static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;
- static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;
-
- static public final int LIGHT_LINE = 77;
- static public final int BACKGROUND_NAME = 78;
- static public final int BACKGROUND_NAME_SEL = 79;
- static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;
+ public static final int GR_BACKGROUND = 71;
+ public static final int GR_FOREGROUND = 72;
+ public static final int GR_BACKGROUND_SEL = 73;
+ public static final int GR_FOREGROUND_SEL = 74;
+ public static final int GR_BACKGROUND_SEL_NOFOCUS = 75;
+ public static final int GR_FOREGROUND_SEL_NOFOCUS = 76;
+
+ public static final int LIGHT_LINE = 77;
+ public static final int BACKGROUND_NAME = 78;
+ public static final int BACKGROUND_NAME_SEL = 79;
+ public static final int BACKGROUND_NAME_SEL_NOFOCUS = 80;
// Interraction's colors
- static public final int TI_START_THREAD = BLACK;
- static public final int TI_HANDOFF_LOCK = BLUE;
- static public final int TI_NOTIFY_ALL = GREEN;
- static public final int TI_NOTIFY = GREEN;
- static public final int TI_NOTIFY_JOINED = DARK_GRAY;
- static public final int TI_INTERRUPT = RED;
- static public final int TI_WAIT_EXCEEDED = BLUE;
-
- static interface IColorProvider {
- public Color get();
+ public static final int TI_START_THREAD = BLACK;
+ public static final int TI_HANDOFF_LOCK = BLUE;
+ public static final int TI_NOTIFY_ALL = GREEN;
+ public static final int TI_NOTIFY = GREEN;
+ public static final int TI_NOTIFY_JOINED = DARK_GRAY;
+ public static final int TI_INTERRUPT = RED;
+ public static final int TI_WAIT_EXCEEDED = BLUE;
+
+ interface IColorProvider {
+ Color get();
}
static class SysCol implements IColorProvider {
- int syscol;
+ private int syscol;
SysCol(int syscol) {
this.syscol = syscol;
@@ -158,9 +158,9 @@ public class TimeGraphColorScheme {
}
static class RGB implements IColorProvider {
- int r;
- int g;
- int b;
+ private int r;
+ private int g;
+ private int b;
RGB(int r, int g, int b) {
this.r = r;
@@ -175,10 +175,10 @@ public class TimeGraphColorScheme {
}
static class Mix implements IColorProvider {
- IColorProvider cp1;
- IColorProvider cp2;
- int w1;
- int w2;
+ private IColorProvider cp1;
+ private IColorProvider cp2;
+ private int w1;
+ private int w2;
Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {
this.cp1 = cp1;
@@ -198,12 +198,11 @@ public class TimeGraphColorScheme {
public Color get() {
Color col1 = cp1.get();
Color col2 = cp2.get();
- Color col = Utils.mixColors(col1, col2, w1, w2);
- return col;
+ return Utils.mixColors(col1, col2, w1, w2);
}
}
- static private final IColorProvider _providersMap[] = {
+ private static final IColorProvider PROVIDERS_MAP[] = {
//
new RGB(100, 100, 100), // UNKNOWN
new RGB(174, 200, 124), // RUNNING
@@ -301,22 +300,22 @@ public class TimeGraphColorScheme {
new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS
};
- private final Color _colors[];
+ private final Color fColors[];
/**
* Default constructor
*/
public TimeGraphColorScheme() {
- _colors = new Color[_providersMap.length];
+ fColors = new Color[PROVIDERS_MAP.length];
}
/**
* Dispose this color scheme
*/
public void dispose() {
- for (int i = 0; i < _colors.length; i++) {
- Utils.dispose(_colors[i]);
- _colors[i] = null;
+ for (int i = 0; i < fColors.length; i++) {
+ Utils.dispose(fColors[i]);
+ fColors[i] = null;
}
}
@@ -328,16 +327,16 @@ public class TimeGraphColorScheme {
* @return The matching color
*/
public Color getColor(int idx) {
- if (null == _colors[idx]) {
+ if (null == fColors[idx]) {
if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {
Color col1 = getColor(idx - STATES_SEL0);
Color col2 = getColor(BACKGROUND_SEL);
- _colors[idx] = Utils.mixColors(col1, col2, 3, 1);
+ fColors[idx] = Utils.mixColors(col1, col2, 3, 1);
} else {
- _colors[idx] = _providersMap[idx].get();
+ fColors[idx] = PROVIDERS_MAP[idx].get();
}
}
- return _colors[idx];
+ return fColors[idx];
}
/**
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
index 47b5c7f828..dda1a0df29 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
@@ -15,9 +15,9 @@
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
@@ -72,15 +72,10 @@ import org.eclipse.swt.widgets.ScrollBar;
*/
public class TimeGraphControl extends TimeGraphBaseControl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider, MenuDetectListener {
+
/** Max scrollbar size */
public static final int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;
- /** Resource manager */
- protected LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
-
- /** Color map for event types */
- protected Color[] fEventColorMap = null;
-
private static final int DRAG_NONE = 0;
private static final int DRAG_TRACE_ITEM = 1;
private static final int DRAG_SPLIT_LINE = 2;
@@ -88,47 +83,53 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
private static final int CUSTOM_ITEM_HEIGHT = -1; // get item height from provider
- private static final double zoomCoeff = 1.5;
-
- private ITimeDataProvider _timeProvider;
- private boolean _isInFocus = false;
- private boolean _isDragCursor3 = false;
- private boolean _isWaitCursor = true;
- private boolean _mouseOverSplitLine = false;
- private int _itemHeight = CUSTOM_ITEM_HEIGHT;
- private int _minimumItemWidth = 0;
- private int _topIndex = 0;
- private int _dragState = DRAG_NONE;
- private int _dragX0 = 0;
- private int _dragX = 0;
- private int _idealNameSpace = 0;
- // private double _timeStep = 10000000;
- private long _time0bak;
- private long _time1bak;
+ private static final double ZOOM_FACTOR = 1.5;
+ private static final double ZOOM_IN_FACTOR = 0.8;
+ private static final double ZOOM_OUT_FACTOR = 1.25;
+
+ /** Resource manager */
+ private LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
+
+ /** Color map for event types */
+ private Color[] fEventColorMap = null;
+
+ private ITimeDataProvider fTimeProvider;
+ private boolean fIsInFocus = false;
+ private boolean fIsDragCursor = false;
+ private boolean fIsWaitCursor = true;
+ private boolean fMouseOverSplitLine = false;
+ private int fGlobalItemHeight = CUSTOM_ITEM_HEIGHT;
+ private int fMinimumItemWidth = 0;
+ private int fTopIndex = 0;
+ private int fDragState = DRAG_NONE;
+ private int fDragX0 = 0;
+ private int fDragX = 0;
+ private int fIdealNameSpace = 0;
+ private long fTime0bak;
+ private long fTime1bak;
private ITimeGraphPresentationProvider fTimeGraphProvider = null;
- private ItemData _data = null;
- private List<SelectionListener> _selectionListeners;
- private final List<ISelectionChangedListener> _selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
- private final List<ITimeGraphTreeListener> _treeListeners = new ArrayList<ITimeGraphTreeListener>();
- private final List<MenuDetectListener> _timeGraphEntryMenuListeners = new ArrayList<MenuDetectListener>();
- private final List<MenuDetectListener> _timeEventMenuListeners = new ArrayList<MenuDetectListener>();
- private final Cursor _dragCursor3;
- private final Cursor _WaitCursor;
- private final List<ViewerFilter> _filters = new ArrayList<ViewerFilter>();
+ private ItemData fItemData = null;
+ private List<SelectionListener> fSelectionListeners;
+ private final List<ISelectionChangedListener> fSelectionChangedListeners = new ArrayList<ISelectionChangedListener>();
+ private final List<ITimeGraphTreeListener> fTreeListeners = new ArrayList<ITimeGraphTreeListener>();
+ private final List<MenuDetectListener> fTimeGraphEntryMenuListeners = new ArrayList<MenuDetectListener>();
+ private final List<MenuDetectListener> fTimeEventMenuListeners = new ArrayList<MenuDetectListener>();
+ private final Cursor fDragCursor;
+ private final Cursor fWaitCursor;
+ private final List<ViewerFilter> fFilters = new ArrayList<ViewerFilter>();
private MenuDetectEvent fPendingMenuDetectEvent = null;
- // Vertical formatting formatting for the state control view
- private final boolean _visibleVerticalScroll = true;
- private int _borderWidth = 0;
- private int _headerHeight = 0;
+ private int fBorderWidth = 0;
+ private int fHeaderHeight = 0;
- private Listener mouseScrollFilterListener;
+ private Listener fMouseScrollFilterListener;
private MouseScrollNotifier fMouseScrollNotifier;
private final Object fMouseScrollNotifierLock = new Object();
+
private class MouseScrollNotifier extends Thread {
- private final static long DELAY = 400L;
- private final static long POLLING_INTERVAL = 10L;
+ private static final long DELAY = 400L;
+ private static final long POLLING_INTERVAL = 10L;
private long fLastScrollTime = Long.MAX_VALUE;
@Override
@@ -147,7 +148,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
if (isDisposed()) {
return;
}
- _timeProvider.notifyStartFinishTime();
+ fTimeProvider.notifyStartFinishTime();
}
});
}
@@ -173,7 +174,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
super(parent, colors, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.DOUBLE_BUFFERED);
- _data = new ItemData();
+ fItemData = new ItemData();
addFocusListener(this);
addMouseListener(this);
@@ -190,15 +191,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
scrollHor.addSelectionListener(this);
}
- _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);
- _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);
+ fDragCursor = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);
+ fWaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);
}
@Override
public void dispose() {
super.dispose();
- _dragCursor3.dispose();
- _WaitCursor.dispose();
+ fDragCursor.dispose();
+ fWaitCursor.dispose();
fResourceManager.dispose();
}
@@ -209,7 +210,6 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
*/
public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {
fTimeGraphProvider = timeGraphProvider;
- _data.provider = timeGraphProvider;
if (fEventColorMap != null) {
for (Color color : fEventColorMap) {
@@ -234,7 +234,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The time provider
*/
public void setTimeProvider(ITimeDataProvider timeProvider) {
- _timeProvider = timeProvider;
+ fTimeProvider = timeProvider;
adjustScrolls();
redraw();
}
@@ -249,10 +249,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
- if (null == _selectionListeners) {
- _selectionListeners = new ArrayList<SelectionListener>();
+ if (null == fSelectionListeners) {
+ fSelectionListeners = new ArrayList<SelectionListener>();
}
- _selectionListeners.add(listener);
+ fSelectionListeners.add(listener);
}
/**
@@ -262,8 +262,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The listener to remove
*/
public void removeSelectionListener(SelectionListener listener) {
- if (null != _selectionListeners) {
- _selectionListeners.remove(listener);
+ if (null != fSelectionListeners) {
+ fSelectionListeners.remove(listener);
}
}
@@ -271,8 +271,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* Selection changed callback
*/
public void fireSelectionChanged() {
- if (null != _selectionListeners) {
- Iterator<SelectionListener> it = _selectionListeners.iterator();
+ if (null != fSelectionListeners) {
+ Iterator<SelectionListener> it = fSelectionListeners.iterator();
while (it.hasNext()) {
SelectionListener listener = it.next();
listener.widgetSelected(null);
@@ -284,8 +284,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* Default selection callback
*/
public void fireDefaultSelection() {
- if (null != _selectionListeners) {
- Iterator<SelectionListener> it = _selectionListeners.iterator();
+ if (null != fSelectionListeners) {
+ Iterator<SelectionListener> it = fSelectionListeners.iterator();
while (it.hasNext()) {
SelectionListener listener = it.next();
listener.widgetDefaultSelected(null);
@@ -299,7 +299,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @return The array of traces
*/
public ITimeGraphEntry[] getTraces() {
- return _data.getTraces();
+ return fItemData.getTraces();
}
/**
@@ -308,14 +308,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @return The array of filters
*/
public boolean[] getTraceFilter() {
- return _data.getTraceFilter();
+ return fItemData.getTraceFilter();
}
/**
* Refresh the data for the thing
*/
public void refreshData() {
- _data.refreshData();
+ fItemData.refreshData();
adjustScrolls();
redraw();
}
@@ -327,7 +327,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The traces to refresh
*/
public void refreshData(ITimeGraphEntry[] traces) {
- _data.refreshData(traces);
+ fItemData.refreshData(traces);
adjustScrolls();
redraw();
}
@@ -336,18 +336,18 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* Adjust the scoll bars
*/
public void adjustScrolls() {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
getHorizontalBar().setValues(0, 1, 1, 1, 1, 1);
return;
}
// HORIZONTAL BAR
// Visible window
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
// Time boundaries
- long timeMin = _timeProvider.getMinTime();
- long timeMax = _timeProvider.getMaxTime();
+ long timeMin = fTimeProvider.getMinTime();
+ long timeMax = fTimeProvider.getMaxTime();
long delta = timeMax - timeMin;
@@ -370,27 +370,25 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
boolean changed = false;
int index = idx;
if (index < 0) {
- for (index = 0; index < _data._expandedItems.length; index++) {
- if (_data._expandedItems[index]._selected) {
+ for (index = 0; index < fItemData.fExpandedItems.length; index++) {
+ if (fItemData.fExpandedItems[index].fSelected) {
break;
}
}
}
- if (index >= _data._expandedItems.length) {
+ if (index >= fItemData.fExpandedItems.length) {
return changed;
}
- if (index < _topIndex) {
+ if (index < fTopIndex) {
setTopIndex(index);
- //FIXME:getVerticalBar().setSelection(_topItem);
if (redraw) {
redraw();
}
changed = true;
} else {
int page = countPerPage();
- if (index >= _topIndex + page) {
+ if (index >= fTopIndex + page) {
setTopIndex(index - page + 1);
- //FIXME:getVerticalBar().setSelection(_topItem);
if (redraw) {
redraw();
}
@@ -407,9 +405,9 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The index
*/
public void setTopIndex(int idx) {
- int index = Math.min(idx, _data._expandedItems.length - countPerPage());
+ int index = Math.min(idx, fItemData.fExpandedItems.length - countPerPage());
index = Math.max(0, index);
- _topIndex = index;
+ fTopIndex = index;
redraw();
}
@@ -422,10 +420,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* True if expanded, false if collapsed
*/
public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {
- Item item = _data.findItem(entry);
- if (item != null && item._expanded != expanded) {
- item._expanded = expanded;
- _data.updateExpandedItems();
+ Item item = fItemData.findItem(entry);
+ if (item != null && item.fExpanded != expanded) {
+ item.fExpanded = expanded;
+ fItemData.updateExpandedItems();
redraw();
}
}
@@ -436,10 +434,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 2.0
*/
public void collapseAll() {
- for (Item item : _data._items) {
- item._expanded = false;
+ for (Item item : fItemData.fItems) {
+ item.fExpanded = false;
}
- _data.updateExpandedItems();
+ fItemData.updateExpandedItems();
redraw();
}
@@ -449,10 +447,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 2.0
*/
public void expandAll() {
- for (Item item : _data._items) {
- item._expanded = true;
+ for (Item item : fItemData.fItems) {
+ item.fExpanded = true;
}
- _data.updateExpandedItems();
+ fItemData.updateExpandedItems();
redraw();
}
@@ -463,8 +461,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The listener to add
*/
public void addTreeListener(ITimeGraphTreeListener listener) {
- if (!_treeListeners.contains(listener)) {
- _treeListeners.add(listener);
+ if (!fTreeListeners.contains(listener)) {
+ fTreeListeners.add(listener);
}
}
@@ -475,8 +473,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The listener to remove
*/
public void removeTreeListener(ITimeGraphTreeListener listener) {
- if (_treeListeners.contains(listener)) {
- _treeListeners.remove(listener);
+ if (fTreeListeners.contains(listener)) {
+ fTreeListeners.remove(listener);
}
}
@@ -490,7 +488,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
*/
public void fireTreeEvent(ITimeGraphEntry entry, boolean expanded) {
TimeGraphTreeExpansionEvent event = new TimeGraphTreeExpansionEvent(this, entry);
- for (ITimeGraphTreeListener listener : _treeListeners) {
+ for (ITimeGraphTreeListener listener : fTreeListeners) {
if (expanded) {
listener.treeExpanded(event);
} else {
@@ -506,8 +504,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 1.2
*/
public void addTimeGraphEntryMenuListener(MenuDetectListener listener) {
- if (!_timeGraphEntryMenuListeners.contains(listener)) {
- _timeGraphEntryMenuListeners.add(listener);
+ if (!fTimeGraphEntryMenuListeners.contains(listener)) {
+ fTimeGraphEntryMenuListeners.add(listener);
}
}
@@ -519,8 +517,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 1.2
*/
public void removeTimeGraphEntryMenuListener(MenuDetectListener listener) {
- if (_timeGraphEntryMenuListeners.contains(listener)) {
- _timeGraphEntryMenuListeners.remove(listener);
+ if (fTimeGraphEntryMenuListeners.contains(listener)) {
+ fTimeGraphEntryMenuListeners.remove(listener);
}
}
@@ -531,7 +529,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The MenuDetectEvent, with field {@link TypedEvent#data} set to the selected {@link ITimeGraphEntry}
*/
private void fireMenuEventOnTimeGraphEntry(MenuDetectEvent event) {
- for (MenuDetectListener listener : _timeGraphEntryMenuListeners) {
+ for (MenuDetectListener listener : fTimeGraphEntryMenuListeners) {
listener.menuDetected(event);
}
}
@@ -544,8 +542,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 1.2
*/
public void addTimeEventMenuListener(MenuDetectListener listener) {
- if (!_timeEventMenuListeners.contains(listener)) {
- _timeEventMenuListeners.add(listener);
+ if (!fTimeEventMenuListeners.contains(listener)) {
+ fTimeEventMenuListeners.add(listener);
}
}
@@ -557,8 +555,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 1.2
*/
public void removeTimeEventMenuListener(MenuDetectListener listener) {
- if (_timeEventMenuListeners.contains(listener)) {
- _timeEventMenuListeners.remove(listener);
+ if (fTimeEventMenuListeners.contains(listener)) {
+ fTimeEventMenuListeners.remove(listener);
}
}
@@ -569,7 +567,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The MenuDetectEvent, with field {@link TypedEvent#data} set to the selected {@link ITimeEvent}
*/
private void fireMenuEventOnTimeEvent(MenuDetectEvent event) {
- for (MenuDetectListener listener : _timeEventMenuListeners) {
+ for (MenuDetectListener listener : fTimeEventMenuListeners) {
listener.menuDetected(event);
}
}
@@ -578,8 +576,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public ISelection getSelection() {
TimeGraphSelection sel = new TimeGraphSelection();
ITimeGraphEntry trace = getSelectedTrace();
- if (null != trace && null != _timeProvider) {
- long selectedTime = _timeProvider.getSelectedTime();
+ if (null != trace && null != fTimeProvider) {
+ long selectedTime = fTimeProvider.getSelectedTime();
ITimeEvent event = Utils.findEvent(trace, selectedTime, 0);
if (event != null) {
sel.add(event);
@@ -618,28 +616,28 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
boolean changed = false;
int lastSelection = -1;
- for (int i = 0; i < _data._expandedItems.length; i++) {
- Item item = _data._expandedItems[i];
- if (item._selected) {
+ for (int i = 0; i < fItemData.fExpandedItems.length; i++) {
+ Item item = fItemData.fExpandedItems[i];
+ if (item.fSelected) {
lastSelection = i;
- if ((1 == n) && (i < _data._expandedItems.length - 1)) {
- item._selected = false;
- item = _data._expandedItems[i + 1];
- item._selected = true;
+ if ((1 == n) && (i < fItemData.fExpandedItems.length - 1)) {
+ item.fSelected = false;
+ item = fItemData.fExpandedItems[i + 1];
+ item.fSelected = true;
changed = true;
} else if ((-1 == n) && (i > 0)) {
- item._selected = false;
- item = _data._expandedItems[i - 1];
- item._selected = true;
+ item.fSelected = false;
+ item = fItemData.fExpandedItems[i - 1];
+ item.fSelected = true;
changed = true;
}
break;
}
}
- if (lastSelection < 0 && _data._expandedItems.length > 0) {
- Item item = _data._expandedItems[0];
- item._selected = true;
+ if (lastSelection < 0 && fItemData.fExpandedItems.length > 0) {
+ Item item = fItemData.fExpandedItems[0];
+ item.fSelected = true;
changed = true;
}
@@ -657,15 +655,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* 1 for next event, -1 for previous event
*/
public void selectEvent(int n) {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
return;
}
ITimeGraphEntry trace = getSelectedTrace();
if (trace == null) {
return;
}
- long selectedTime = _timeProvider.getSelectedTime();
- long endTime = _timeProvider.getEndTime();
+ long selectedTime = fTimeProvider.getSelectedTime();
+ long endTime = fTimeProvider.getEndTime();
ITimeEvent nextEvent;
if (-1 == n && selectedTime > endTime) {
nextEvent = Utils.findEvent(trace, selectedTime, 0);
@@ -686,16 +684,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
if (nextTime > endTime) {
nextTime = endTime;
}
- } else if (n == -1) {
+ } else if (n == -1 && nextEvent.getTime() + nextEvent.getDuration() < selectedTime) {
// for previous event go to its end time unless we were already there
- if (nextEvent.getTime() + nextEvent.getDuration() < selectedTime) {
- nextTime = nextEvent.getTime() + nextEvent.getDuration();
- }
+ nextTime = nextEvent.getTime() + nextEvent.getDuration();
}
- _timeProvider.setSelectedTimeNotify(nextTime, true);
+ fTimeProvider.setSelectedTimeNotify(nextTime, true);
fireSelectionChanged();
} else if (1 == n) {
- _timeProvider.setSelectedTimeNotify(endTime, true);
+ fTimeProvider.setSelectedTimeNotify(endTime, true);
fireSelectionChanged();
}
}
@@ -706,7 +702,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void selectNextEvent() {
selectEvent(1);
// Notify if visible time window has been adjusted
- _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());
+ fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
}
/**
@@ -715,7 +711,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void selectPrevEvent() {
selectEvent(-1);
// Notify if visible time window has been adjusted
- _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());
+ fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
}
/**
@@ -740,25 +736,25 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void zoom(boolean zoomIn) {
int globalX = getDisplay().getCursorLocation().x;
Point p = toControl(globalX, 0);
- int nameSpace = _timeProvider.getNameSpace();
- int timeSpace = _timeProvider.getTimeSpace();
+ int nameSpace = fTimeProvider.getNameSpace();
+ int timeSpace = fTimeProvider.getTimeSpace();
int xPos = Math.max(nameSpace, Math.min(nameSpace + timeSpace, p.x));
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
long interval = time1 - time0;
if (interval == 0) {
interval = 1;
} // to allow getting out of single point interval
long newInterval;
if (zoomIn) {
- newInterval = Math.max(Math.round(interval * 0.8), _timeProvider.getMinTimeInterval());
+ newInterval = Math.max(Math.round(interval * ZOOM_IN_FACTOR), fTimeProvider.getMinTimeInterval());
} else {
- newInterval = (long) Math.ceil(interval * 1.25);
+ newInterval = (long) Math.ceil(interval * ZOOM_OUT_FACTOR);
}
long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));
long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);
long newTime1 = newTime0 + newInterval;
- _timeProvider.setStartFinishTime(newTime0, newTime1);
+ fTimeProvider.setStartFinishTime(newTime0, newTime1);
synchronized (fMouseScrollNotifierLock) {
if (fMouseScrollNotifier == null) {
fMouseScrollNotifier = new MouseScrollNotifier();
@@ -772,58 +768,55 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* zoom in using single click
*/
public void zoomIn() {
- long _time0 = _timeProvider.getTime0();
- long _time1 = _timeProvider.getTime1();
- long _range = _time1 - _time0;
- if (_range == 0) {
+ long prevTime0 = fTimeProvider.getTime0();
+ long prevTime1 = fTimeProvider.getTime1();
+ long prevRange = prevTime1 - prevTime0;
+ if (prevRange == 0) {
return;
}
- long selTime = _timeProvider.getSelectedTime();
- if (selTime <= _time0 || selTime >= _time1) {
- selTime = (_time0 + _time1) / 2;
+ long selTime = fTimeProvider.getSelectedTime();
+ if (selTime <= prevTime0 || selTime >= prevTime1) {
+ selTime = (prevTime0 + prevTime1) / 2;
}
- long time0 = selTime - (long) ((selTime - _time0) / zoomCoeff);
- long time1 = selTime + (long) ((_time1 - selTime) / zoomCoeff);
+ long time0 = selTime - (long) ((selTime - prevTime0) / ZOOM_FACTOR);
+ long time1 = selTime + (long) ((prevTime1 - selTime) / ZOOM_FACTOR);
- long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);
-
- // Trace.debug("selTime:" + selTime + " time0:" + time0 + " time1:"
- // + time1 + " inaccuracy:" + inaccuracy);
+ long inaccuracy = (fTimeProvider.getMaxTime() - fTimeProvider.getMinTime()) - (time1 - time0);
if (inaccuracy > 0 && inaccuracy < 100) {
- _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());
+ fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getMinTime(), fTimeProvider.getMaxTime());
return;
}
- long m = _timeProvider.getMinTimeInterval();
- if ((time1 - time0) < m) {
- time0 = selTime - (selTime - _time0) * m / _range;
- time1 = time0 + m;
+ long min = fTimeProvider.getMinTimeInterval();
+ if ((time1 - time0) < min) {
+ time0 = selTime - (selTime - prevTime0) * min / prevRange;
+ time1 = time0 + min;
}
- _timeProvider.setStartFinishTimeNotify(time0, time1);
+ fTimeProvider.setStartFinishTimeNotify(time0, time1);
}
/**
* zoom out using single click
*/
public void zoomOut() {
- long _time0 = _timeProvider.getTime0();
- long _time1 = _timeProvider.getTime1();
- long selTime = _timeProvider.getSelectedTime();
- if (selTime <= _time0 || selTime >= _time1) {
- selTime = (_time0 + _time1) / 2;
+ long prevTime0 = fTimeProvider.getTime0();
+ long prevTime1 = fTimeProvider.getTime1();
+ long selTime = fTimeProvider.getSelectedTime();
+ if (selTime <= prevTime0 || selTime >= prevTime1) {
+ selTime = (prevTime0 + prevTime1) / 2;
}
- long time0 = (long) (selTime - (selTime - _time0) * zoomCoeff);
- long time1 = (long) (selTime + (_time1 - selTime) * zoomCoeff);
+ long time0 = (long) (selTime - (selTime - prevTime0) * ZOOM_FACTOR);
+ long time1 = (long) (selTime + (prevTime1 - selTime) * ZOOM_FACTOR);
- long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);
+ long inaccuracy = (fTimeProvider.getMaxTime() - fTimeProvider.getMinTime()) - (time1 - time0);
if (inaccuracy > 0 && inaccuracy < 100) {
- _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());
+ fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getMinTime(), fTimeProvider.getMaxTime());
return;
}
- _timeProvider.setStartFinishTimeNotify(time0, time1);
+ fTimeProvider.setStartFinishTimeNotify(time0, time1);
}
/**
@@ -835,7 +828,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
ITimeGraphEntry trace = null;
int idx = getSelectedIndex();
if (idx >= 0) {
- trace = _data._expandedItems[idx]._trace;
+ trace = fItemData.fExpandedItems[idx].fTrace;
}
return trace;
}
@@ -847,9 +840,9 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
*/
public int getSelectedIndex() {
int idx = -1;
- for (int i = 0; i < _data._expandedItems.length; i++) {
- Item item = _data._expandedItems[i];
- if (item._selected) {
+ for (int i = 0; i < fItemData.fExpandedItems.length; i++) {
+ Item item = fItemData.fExpandedItems[i];
+ if (item.fSelected) {
idx = i;
break;
}
@@ -859,15 +852,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
boolean toggle(int idx) {
boolean toggled = false;
- if (idx >= 0 && idx < _data._expandedItems.length) {
- Item item = _data._expandedItems[idx];
- if (item._hasChildren) {
- item._expanded = !item._expanded;
- _data.updateExpandedItems();
+ if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
+ Item item = fItemData.fExpandedItems[idx];
+ if (item.fHasChildren) {
+ item.fExpanded = !item.fExpanded;
+ fItemData.updateExpandedItems();
adjustScrolls();
redraw();
toggled = true;
- fireTreeEvent(item._trace, item._expanded);
+ fireTreeEvent(item.fTrace, item.fExpanded);
}
}
return toggled;
@@ -877,30 +870,30 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
if (y < 0) {
return -1;
}
- if (_itemHeight == CUSTOM_ITEM_HEIGHT) {
+ if (fGlobalItemHeight == CUSTOM_ITEM_HEIGHT) {
int ySum = 0;
- for (int idx = _topIndex; idx < _data._expandedItems.length; idx++) {
- ySum += _data._expandedItems[idx].itemHeight;
+ for (int idx = fTopIndex; idx < fItemData.fExpandedItems.length; idx++) {
+ ySum += fItemData.fExpandedItems[idx].fItemHeight;
if (y < ySum) {
return idx;
}
}
return -1;
}
- int idx = y / _itemHeight;
- idx += _topIndex;
- if (idx < _data._expandedItems.length) {
+ int idx = y / fGlobalItemHeight;
+ idx += fTopIndex;
+ if (idx < fItemData.fExpandedItems.length) {
return idx;
}
return -1;
}
boolean isOverSplitLine(int x) {
- if (x < 0 || null == _timeProvider) {
+ if (x < 0 || null == fTimeProvider) {
return false;
}
int w = 4;
- int nameWidth = _timeProvider.getNameSpace();
+ int nameWidth = fTimeProvider.getNameSpace();
if (x > nameWidth - w && x < nameWidth + w) {
return true;
}
@@ -909,7 +902,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
ITimeGraphEntry getEntry(Point pt) {
int idx = getItemIndexAtY(pt.y);
- return idx >= 0 ? _data._expandedItems[idx]._trace : null;
+ return idx >= 0 ? fItemData.fExpandedItems[idx].fTrace : null;
}
/**
@@ -921,13 +914,13 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 2.0
*/
public int getXForTime(long time) {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
return -1;
}
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
int width = getCtrlSize().x;
- int nameSpace = _timeProvider.getNameSpace();
+ int nameSpace = fTimeProvider.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;
@@ -942,14 +935,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 2.0
*/
public long getTimeAtX(int coord) {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
return -1;
}
long hitTime = -1;
Point size = getCtrlSize();
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
- int nameWidth = _timeProvider.getNameSpace();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
+ int nameWidth = fTimeProvider.getNameSpace();
final int x = coord - nameWidth;
int timeWidth = size.x - nameWidth - RIGHT_MARGIN;
if (x >= 0 && size.x >= nameWidth) {
@@ -967,18 +960,18 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
void selectItem(int idx, boolean addSelection) {
boolean changed = false;
if (addSelection) {
- if (idx >= 0 && idx < _data._expandedItems.length) {
- Item item = _data._expandedItems[idx];
- changed = (item._selected == false);
- item._selected = true;
+ if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
+ Item item = fItemData.fExpandedItems[idx];
+ changed = !item.fSelected;
+ item.fSelected = true;
}
} else {
- for (int i = 0; i < _data._expandedItems.length; i++) {
- Item item = _data._expandedItems[i];
- if ((i == idx && !item._selected) || (idx == -1 && item._selected)) {
+ for (int i = 0; i < fItemData.fExpandedItems.length; i++) {
+ Item item = fItemData.fExpandedItems[i];
+ if ((i == idx && !item.fSelected) || (idx == -1 && item.fSelected)) {
changed = true;
}
- item._selected = i == idx;
+ item.fSelected = i == idx;
}
}
changed |= ensureVisibleItem(idx, true);
@@ -996,7 +989,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* If the selection is added or removed
*/
public void selectItem(ITimeGraphEntry trace, boolean addSelection) {
- int idx = _data.findItemIndex(trace);
+ int idx = fItemData.findItemIndex(trace);
selectItem(idx, addSelection);
}
@@ -1008,17 +1001,17 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public int countPerPage() {
int height = getCtrlSize().y;
int count = 0;
- if (_itemHeight == CUSTOM_ITEM_HEIGHT) {
+ if (fGlobalItemHeight == CUSTOM_ITEM_HEIGHT) {
int ySum = 0;
- for (int idx = _topIndex; idx < _data._expandedItems.length; idx++) {
- ySum += _data._expandedItems[idx].itemHeight;
+ for (int idx = fTopIndex; idx < fItemData.fExpandedItems.length; idx++) {
+ ySum += fItemData.fExpandedItems[idx].fItemHeight;
if (ySum >= height) {
return count;
}
count++;
}
- for (int idx = _topIndex - 1; idx >= 0; idx--) {
- ySum += _data._expandedItems[idx].itemHeight;
+ for (int idx = fTopIndex - 1; idx >= 0; idx--) {
+ ySum += fItemData.fExpandedItems[idx].fItemHeight;
if (ySum >= height) {
return count;
}
@@ -1027,7 +1020,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
return count;
}
if (height > 0) {
- count = height / _itemHeight;
+ count = height / fGlobalItemHeight;
}
return count;
}
@@ -1038,7 +1031,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @return The index
*/
public int getTopIndex() {
- return _topIndex;
+ return fTopIndex;
}
/**
@@ -1047,7 +1040,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @return The count of expanded items
*/
public int getExpandedElementCount() {
- return _data._expandedItems.length;
+ return fItemData.fExpandedItems.length;
}
/**
@@ -1057,8 +1050,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
*/
public ITimeGraphEntry[] getExpandedElements() {
ArrayList<ITimeGraphEntry> elements = new ArrayList<ITimeGraphEntry>();
- for (Item item : _data._expandedItems) {
- elements.add(item._trace);
+ for (Item item : fItemData.fExpandedItems) {
+ elements.add(item.fTrace);
}
return elements.toArray(new ITimeGraphEntry[0]);
}
@@ -1073,32 +1066,32 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
Rectangle getNameRect(Rectangle bound, int idx, int nameWidth) {
int x = bound.x;
- int y = bound.y + (idx - _topIndex) * _itemHeight;
+ int y = bound.y + (idx - fTopIndex) * fGlobalItemHeight;
int width = nameWidth;
- int height = _itemHeight;
- if (_itemHeight == CUSTOM_ITEM_HEIGHT) {
+ int height = fGlobalItemHeight;
+ if (fGlobalItemHeight == CUSTOM_ITEM_HEIGHT) {
int ySum = 0;
- for (int i = _topIndex; i < idx; i++) {
- ySum += _data._expandedItems[i].itemHeight;
+ for (int i = fTopIndex; i < idx; i++) {
+ ySum += fItemData.fExpandedItems[i].fItemHeight;
}
y = bound.y + ySum;
- height = _data._expandedItems[idx].itemHeight;
+ height = fItemData.fExpandedItems[idx].fItemHeight;
}
return new Rectangle(x, y, width, height);
}
Rectangle getStatesRect(Rectangle bound, int idx, int nameWidth) {
int x = bound.x + nameWidth;
- int y = bound.y + (idx - _topIndex) * _itemHeight;
+ int y = bound.y + (idx - fTopIndex) * fGlobalItemHeight;
int width = bound.width - x;
- int height = _itemHeight;
- if (_itemHeight == CUSTOM_ITEM_HEIGHT) {
+ int height = fGlobalItemHeight;
+ if (fGlobalItemHeight == CUSTOM_ITEM_HEIGHT) {
int ySum = 0;
- for (int i = _topIndex; i < idx; i++) {
- ySum += _data._expandedItems[i].itemHeight;
+ for (int i = fTopIndex; i < idx; i++) {
+ ySum += fItemData.fExpandedItems[i].fItemHeight;
}
y = bound.y + ySum;
- height = _data._expandedItems[idx].itemHeight;
+ height = fItemData.fExpandedItems[idx].fItemHeight;
}
return new Rectangle(x, y, width, height);
}
@@ -1106,53 +1099,53 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
@Override
void paint(Rectangle bounds, PaintEvent e) {
GC gc = e.gc;
- gc.setBackground(_colors.getColor(TimeGraphColorScheme.BACKGROUND));
+ gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.BACKGROUND));
drawBackground(gc, bounds.x, bounds.y, bounds.width, bounds.height);
- if (bounds.width < 2 || bounds.height < 2 || null == _timeProvider) {
+ if (bounds.width < 2 || bounds.height < 2 || null == fTimeProvider) {
return;
}
- _idealNameSpace = 0;
- int nameSpace = _timeProvider.getNameSpace();
+ fIdealNameSpace = 0;
+ int nameSpace = fTimeProvider.getNameSpace();
// draw empty name space background
- gc.setBackground(_colors.getBkColor(false, false, true));
+ gc.setBackground(getColorScheme().getBkColor(false, false, true));
drawBackground(gc, bounds.x, bounds.y, nameSpace, bounds.height);
- if (_dragState == DRAG_ZOOM) {
+ if (fDragState == DRAG_ZOOM) {
// draw selected zoom region background
- gc.setBackground(_colors.getBkColor(false, false, true));
- if (_dragX0 < _dragX) {
- gc.fillRectangle(new Rectangle(_dragX0, bounds.y, _dragX - _dragX0, bounds.height));
- } else if (_dragX0 > _dragX) {
- gc.fillRectangle(new Rectangle(_dragX, bounds.y, _dragX0 - _dragX, bounds.height));
+ gc.setBackground(getColorScheme().getBkColor(false, false, true));
+ if (fDragX0 < fDragX) {
+ gc.fillRectangle(new Rectangle(fDragX0, bounds.y, fDragX - fDragX0, bounds.height));
+ } else if (fDragX0 > fDragX) {
+ gc.fillRectangle(new Rectangle(fDragX, bounds.y, fDragX0 - fDragX, bounds.height));
}
}
- drawItems(bounds, _timeProvider, _data._expandedItems, _topIndex, nameSpace, gc);
+ drawItems(bounds, fTimeProvider, fItemData.fExpandedItems, fTopIndex, nameSpace, gc);
// draw selected time
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
- long selectedTime = _timeProvider.getSelectedTime();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
+ long selectedTime = fTimeProvider.getSelectedTime();
double pixelsPerNanoSec = (bounds.width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (bounds.width - nameSpace - RIGHT_MARGIN) / (time1 - time0);
int x = bounds.x + nameSpace + (int) ((selectedTime - time0) * pixelsPerNanoSec);
if (x >= nameSpace && x < bounds.x + bounds.width) {
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.SELECTED_TIME));
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
gc.drawLine(x, bounds.y, x, bounds.y + bounds.height);
}
// draw drag line, no line if name space is 0.
- if (DRAG_SPLIT_LINE == _dragState) {
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.BLACK));
+ if (DRAG_SPLIT_LINE == fDragState) {
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.BLACK));
gc.drawLine(bounds.x + nameSpace, bounds.y, bounds.x + nameSpace, bounds.y + bounds.height - 1);
- } else if (DRAG_ZOOM == _dragState && Math.max(_dragX, _dragX0) > nameSpace && _dragX != _dragX0) {
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
- gc.drawLine(_dragX0, bounds.y, _dragX0, bounds.y + bounds.height - 1);
- gc.drawLine(_dragX, bounds.y, _dragX, bounds.y + bounds.height - 1);
- } else if (DRAG_NONE == _dragState && _mouseOverSplitLine && _timeProvider.getNameSpace() > 0) {
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.RED));
+ } else if (DRAG_ZOOM == fDragState && Math.max(fDragX, fDragX0) > nameSpace && fDragX != fDragX0) {
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
+ gc.drawLine(fDragX0, bounds.y, fDragX0, bounds.y + bounds.height - 1);
+ gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
+ } else if (DRAG_NONE == fDragState && fMouseOverSplitLine && fTimeProvider.getNameSpace() > 0) {
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.RED));
gc.drawLine(bounds.x + nameSpace, bounds.y, bounds.x + nameSpace, bounds.y + bounds.height - 1);
}
}
@@ -1193,7 +1186,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @param gc Graphics context
*/
protected void drawItem(Item item, Rectangle bounds, ITimeDataProvider timeProvider, int i, int nameSpace, GC gc) {
- ITimeGraphEntry entry = item._trace;
+ ITimeGraphEntry entry = item.fTrace;
long time0 = timeProvider.getTime0();
long time1 = timeProvider.getTime1();
long selectedTime = timeProvider.getSelectedTime();
@@ -1203,7 +1196,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
return;
}
- if (! item._trace.hasTimeEvents()) {
+ if (! item.fTrace.hasTimeEvents()) {
Rectangle statesRect = getStatesRect(bounds, i, nameSpace);
nameRect.width += statesRect.width;
drawName(item, nameRect, gc);
@@ -1216,7 +1209,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
return;
}
if (time1 <= time0) {
- gc.setBackground(_colors.getBkColor(false, false, false));
+ gc.setBackground(getColorScheme().getBkColor(false, false, false));
gc.fillRectangle(rect);
fTimeGraphProvider.postDrawEntry(entry, rect, gc);
return;
@@ -1224,11 +1217,11 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
// Initialize _rect1 to same values as enclosing rectangle rect
Rectangle stateRect = Utils.clone(rect);
- boolean selected = item._selected;
+ boolean selected = item.fSelected;
// K pixels per second
double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);
- if (item._trace.hasTimeEvents()) {
+ if (item.fTrace.hasTimeEvents()) {
fillSpace(rect, gc, selected);
// Drawing rectangle is smaller than reserved space
stateRect.y += 3;
@@ -1258,7 +1251,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
}
}
boolean timeSelected = selectedTime >= event.getTime() && selectedTime < event.getTime() + event.getDuration();
- if (drawState(_colors, event, stateRect, gc, selected, timeSelected)) {
+ if (drawState(getColorScheme(), event, stateRect, gc, selected, timeSelected)) {
lastX = x;
}
}
@@ -1277,29 +1270,29 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* Graphics context
*/
protected void drawName(Item item, Rectangle bounds, GC gc) {
- boolean hasTimeEvents = item._trace.hasTimeEvents();
+ boolean hasTimeEvents = item.fTrace.hasTimeEvents();
if (! hasTimeEvents) {
- gc.setBackground(_colors.getBkColorGroup(item._selected, _isInFocus));
+ gc.setBackground(getColorScheme().getBkColorGroup(item.fSelected, fIsInFocus));
gc.fillRectangle(bounds);
- if (item._selected && _isInFocus) {
- gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, false));
+ if (item.fSelected && fIsInFocus) {
+ gc.setForeground(getColorScheme().getBkColor(item.fSelected, fIsInFocus, false));
gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1);
}
} else {
- gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, true));
- gc.setForeground(_colors.getFgColor(item._selected, _isInFocus));
+ gc.setBackground(getColorScheme().getBkColor(item.fSelected, fIsInFocus, true));
+ gc.setForeground(getColorScheme().getFgColor(item.fSelected, fIsInFocus));
gc.fillRectangle(bounds);
}
// No name to be drawn
- if (_timeProvider.getNameSpace() == 0) {
+ if (fTimeProvider.getNameSpace() == 0) {
return;
}
- int leftMargin = MARGIN + item.level * EXPAND_SIZE;
- if (item._hasChildren) {
- gc.setForeground(_colors.getFgColorGroup(false, false));
- gc.setBackground(_colors.getBkColor(false, false, false));
+ int leftMargin = MARGIN + item.fLevel * EXPAND_SIZE;
+ if (item.fHasChildren) {
+ gc.setForeground(getColorScheme().getFgColorGroup(false, false));
+ gc.setBackground(getColorScheme().getBkColor(false, false, false));
Rectangle rect = Utils.clone(bounds);
rect.x += leftMargin;
rect.y += (bounds.height - EXPAND_SIZE) / 2;
@@ -1309,14 +1302,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
int midy = rect.y + rect.height / 2;
gc.drawLine(rect.x + 2, midy, rect.x + rect.width - 3, midy);
- if (!item._expanded) {
+ if (!item.fExpanded) {
int midx = rect.x + rect.width / 2;
gc.drawLine(midx, rect.y + 2, midx, rect.y + rect.height - 3);
}
}
leftMargin += EXPAND_SIZE + MARGIN;
- Image img = fTimeGraphProvider.getItemImage(item._trace);
+ Image img = fTimeGraphProvider.getItemImage(item.fTrace);
if (img != null) {
// draw icon
int imgHeight = img.getImageData().height;
@@ -1326,10 +1319,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
gc.drawImage(img, x, y);
leftMargin += imgWidth + MARGIN;
}
- String name = item._name;
+ String name = item.fName;
Point size = gc.stringExtent(name);
- if (_idealNameSpace < leftMargin + size.x + MARGIN) {
- _idealNameSpace = leftMargin + size.x + MARGIN;
+ if (fIdealNameSpace < leftMargin + size.x + MARGIN) {
+ fIdealNameSpace = leftMargin + size.x + MARGIN;
}
if (hasTimeEvents) {
// cut long string with "..."
@@ -1350,7 +1343,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
// draw text
if (rect.width > 0) {
rect.y += (bounds.height - gc.stringExtent(name).y) / 2;
- gc.setForeground(_colors.getFgColor(item._selected, _isInFocus));
+ gc.setForeground(getColorScheme().getFgColor(item.fSelected, fIsInFocus));
int textWidth = Utils.drawText(gc, name, rect, true);
leftMargin += textWidth + MARGIN;
rect.y -= 2;
@@ -1360,7 +1353,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
int x = bounds.x + leftMargin;
int width = bounds.width - x;
int midy = bounds.y + bounds.height / 2;
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.MID_LINE));
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.MID_LINE));
gc.drawLine(x, midy, x + width, midy);
}
}
@@ -1414,9 +1407,6 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
}
boolean reallySelected = timeSelected && selected;
- if (reallySelected) {
- // modify the color?
- }
// fill all rect area
gc.setBackground(stateColor);
gc.fillRectangle(rect);
@@ -1448,18 +1438,18 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* Is this time event selected or not
*/
protected void fillSpace(Rectangle rect, GC gc, boolean selected) {
- gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));
+ gc.setBackground(getColorScheme().getBkColor(selected, fIsInFocus, false));
gc.fillRectangle(rect);
- if (_dragState == DRAG_ZOOM) {
- gc.setBackground(_colors.getBkColor(selected, _isInFocus, true));
- if (_dragX0 < _dragX) {
- gc.fillRectangle(new Rectangle(_dragX0, rect.y, _dragX - _dragX0, rect.height));
- } else if (_dragX0 > _dragX) {
- gc.fillRectangle(new Rectangle(_dragX, rect.y, _dragX0 - _dragX, rect.height));
+ if (fDragState == DRAG_ZOOM) {
+ gc.setBackground(getColorScheme().getBkColor(selected, fIsInFocus, true));
+ if (fDragX0 < fDragX) {
+ gc.fillRectangle(new Rectangle(fDragX0, rect.y, fDragX - fDragX0, rect.height));
+ } else if (fDragX0 > fDragX) {
+ gc.fillRectangle(new Rectangle(fDragX, rect.y, fDragX0 - fDragX, rect.height));
}
}
// draw middle line
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.MID_LINE));
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.MID_LINE));
int midy = rect.y + rect.height / 2;
gc.drawLine(rect.x, midy, rect.x + rect.width, midy);
}
@@ -1474,18 +1464,18 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
@Override
public void keyPressed(KeyEvent e) {
int idx = -1;
- if (_data._expandedItems.length == 0) {
+ if (fItemData.fExpandedItems.length == 0) {
return;
}
if (SWT.HOME == e.keyCode) {
idx = 0;
} else if (SWT.END == e.keyCode) {
- idx = _data._expandedItems.length - 1;
+ idx = fItemData.fExpandedItems.length - 1;
} else if (SWT.ARROW_DOWN == e.keyCode) {
idx = getSelectedIndex();
if (idx < 0) {
idx = 0;
- } else if (idx < _data._expandedItems.length - 1) {
+ } else if (idx < fItemData.fExpandedItems.length - 1) {
idx++;
}
} else if (SWT.ARROW_UP == e.keyCode) {
@@ -1506,8 +1496,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
idx = 0;
}
idx += page;
- if (idx >= _data._expandedItems.length) {
- idx = _data._expandedItems.length - 1;
+ if (idx >= fItemData.fExpandedItems.length) {
+ idx = fItemData.fExpandedItems.length - 1;
}
} else if (SWT.PAGE_UP == e.keyCode) {
int page = countPerPage();
@@ -1522,7 +1512,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
} else if (SWT.CR == e.keyCode) {
idx = getSelectedIndex();
if (idx >= 0) {
- if (_data._expandedItems[idx]._hasChildren) {
+ if (fItemData.fExpandedItems[idx].fHasChildren) {
toggle(idx);
} else {
fireDefaultSelection();
@@ -1542,9 +1532,9 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
@Override
public void focusGained(FocusEvent e) {
- _isInFocus = true;
- if (mouseScrollFilterListener == null) {
- mouseScrollFilterListener = new Listener() {
+ fIsInFocus = true;
+ if (fMouseScrollFilterListener == null) {
+ fMouseScrollFilterListener = new Listener() {
// This filter is used to prevent horizontal scrolling of the view
// when the mouse wheel is used to zoom
@Override
@@ -1552,21 +1542,21 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
event.doit = false;
}
};
- getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);
+ getDisplay().addFilter(SWT.MouseWheel, fMouseScrollFilterListener);
}
redraw();
}
@Override
public void focusLost(FocusEvent e) {
- _isInFocus = false;
- if (mouseScrollFilterListener != null) {
- getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);
- mouseScrollFilterListener = null;
+ fIsInFocus = false;
+ if (fMouseScrollFilterListener != null) {
+ getDisplay().removeFilter(SWT.MouseWheel, fMouseScrollFilterListener);
+ fMouseScrollFilterListener = null;
}
- if (DRAG_NONE != _dragState) {
+ if (DRAG_NONE != fDragState) {
setCapture(false);
- _dragState = DRAG_NONE;
+ fDragState = DRAG_NONE;
}
redraw();
}
@@ -1575,7 +1565,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @return If the current view is focused
*/
public boolean isInFocus() {
- return _isInFocus;
+ return fIsInFocus;
}
/**
@@ -1587,15 +1577,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void waitCursor(boolean waitInd) {
// Update cursor as indicated
if (waitInd) {
- setCursor(_WaitCursor);
- _isWaitCursor = true;
+ setCursor(fWaitCursor);
+ fIsWaitCursor = true;
} else {
setCursor(null);
- _isWaitCursor = false;
+ fIsWaitCursor = false;
}
// Get ready for next mouse move
- _isDragCursor3 = false;
+ fIsDragCursor = false;
}
/**
@@ -1611,73 +1601,73 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
void updateCursor(int x, int y) {
// if Wait cursor not active, check for the need to change to a drag
// cursor
- if (_isWaitCursor == false) {
+ if (!fIsWaitCursor) {
boolean isSplitLine = isOverSplitLine(x);
// No dragcursor is name space is fixed to zero
- if (isSplitLine && !_isDragCursor3 && _timeProvider.getNameSpace() > 0) {
- setCursor(_dragCursor3);
- _isDragCursor3 = true;
- } else if (!isSplitLine && _isDragCursor3) {
+ if (isSplitLine && !fIsDragCursor && fTimeProvider.getNameSpace() > 0) {
+ setCursor(fDragCursor);
+ fIsDragCursor = true;
+ } else if (!isSplitLine && fIsDragCursor) {
setCursor(null);
- _isDragCursor3 = false;
+ fIsDragCursor = false;
}
}
}
@Override
public void mouseMove(MouseEvent e) {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
return;
}
Point size = getCtrlSize();
- if (DRAG_TRACE_ITEM == _dragState) {
- int nameWidth = _timeProvider.getNameSpace();
+ if (DRAG_TRACE_ITEM == fDragState) {
+ int nameWidth = fTimeProvider.getNameSpace();
int x = e.x - nameWidth;
- if (x > 0 && size.x > nameWidth && _dragX != x) {
- _dragX = x;
- double pixelsPerNanoSec = (size.x - nameWidth <= RIGHT_MARGIN) ? 0 : (double) (size.x - nameWidth - RIGHT_MARGIN) / (_time1bak - _time0bak);
- long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((_dragX - _dragX0) / pixelsPerNanoSec));
- long time1 = _time1bak - timeDelta;
- long maxTime = _timeProvider.getMaxTime();
+ if (x > 0 && size.x > nameWidth && fDragX != x) {
+ fDragX = x;
+ double pixelsPerNanoSec = (size.x - nameWidth <= RIGHT_MARGIN) ? 0 : (double) (size.x - nameWidth - RIGHT_MARGIN) / (fTime1bak - fTime0bak);
+ long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((fDragX - fDragX0) / pixelsPerNanoSec));
+ long time1 = fTime1bak - timeDelta;
+ long maxTime = fTimeProvider.getMaxTime();
if (time1 > maxTime) {
time1 = maxTime;
}
- long time0 = time1 - (_time1bak - _time0bak);
- if (time0 < _timeProvider.getMinTime()) {
- time0 = _timeProvider.getMinTime();
- time1 = time0 + (_time1bak - _time0bak);
+ long time0 = time1 - (fTime1bak - fTime0bak);
+ if (time0 < fTimeProvider.getMinTime()) {
+ time0 = fTimeProvider.getMinTime();
+ time1 = time0 + (fTime1bak - fTime0bak);
}
- _timeProvider.setStartFinishTime(time0, time1);
+ fTimeProvider.setStartFinishTime(time0, time1);
}
- } else if (DRAG_SPLIT_LINE == _dragState) {
- _dragX = e.x;
- _timeProvider.setNameSpace(e.x);
- } else if (DRAG_ZOOM == _dragState) {
- _dragX = Math.min(Math.max(e.x, _timeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
+ } else if (DRAG_SPLIT_LINE == fDragState) {
+ fDragX = e.x;
+ fTimeProvider.setNameSpace(e.x);
+ } else if (DRAG_ZOOM == fDragState) {
+ fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
redraw();
- } else if (DRAG_NONE == _dragState) {
+ } else if (DRAG_NONE == fDragState) {
boolean mouseOverSplitLine = isOverSplitLine(e.x);
- if (_mouseOverSplitLine != mouseOverSplitLine) {
+ if (fMouseOverSplitLine != mouseOverSplitLine) {
redraw();
}
- _mouseOverSplitLine = mouseOverSplitLine;
+ fMouseOverSplitLine = mouseOverSplitLine;
}
updateCursor(e.x, e.y);
}
@Override
public void mouseDoubleClick(MouseEvent e) {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
return;
}
if (1 == e.button && (e.stateMask & SWT.BUTTON_MASK) == 0) {
- if (isOverSplitLine(e.x) && _timeProvider.getNameSpace() != 0) {
- _timeProvider.setNameSpace(_idealNameSpace);
+ if (isOverSplitLine(e.x) && fTimeProvider.getNameSpace() != 0) {
+ fTimeProvider.setNameSpace(fIdealNameSpace);
boolean mouseOverSplitLine = isOverSplitLine(e.x);
- if (_mouseOverSplitLine != mouseOverSplitLine) {
+ if (fMouseOverSplitLine != mouseOverSplitLine) {
redraw();
}
- _mouseOverSplitLine = mouseOverSplitLine;
+ fMouseOverSplitLine = mouseOverSplitLine;
return;
}
int idx = getItemIndexAtY(e.y);
@@ -1690,37 +1680,36 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
@Override
public void mouseDown(MouseEvent e) {
- if (_dragState != DRAG_NONE || null == _timeProvider) {
+ if (fDragState != DRAG_NONE || null == fTimeProvider) {
return;
}
int idx;
if (1 == e.button) {
- int nameSpace = _timeProvider.getNameSpace();
- if (nameSpace != 0) {
- if (isOverSplitLine(e.x)) {
- _dragState = DRAG_SPLIT_LINE;
- _dragX = _dragX0 = e.x;
- _time0bak = _timeProvider.getTime0();
- _time1bak = _timeProvider.getTime1();
- redraw();
- return;
- }
+ int nameSpace = fTimeProvider.getNameSpace();
+ if (nameSpace != 0 && isOverSplitLine(e.x)) {
+ fDragState = DRAG_SPLIT_LINE;
+ fDragX = e.x;
+ fDragX0 = fDragX;
+ fTime0bak = fTimeProvider.getTime0();
+ fTime1bak = fTimeProvider.getTime1();
+ redraw();
+ return;
}
idx = getItemIndexAtY(e.y);
if (idx >= 0) {
- Item item = _data._expandedItems[idx];
- if (item._hasChildren && e.x < nameSpace && e.x < MARGIN + (item.level + 1) * EXPAND_SIZE) {
+ Item item = fItemData.fExpandedItems[idx];
+ if (item.fHasChildren && e.x < nameSpace && e.x < MARGIN + (item.fLevel + 1) * EXPAND_SIZE) {
toggle(idx);
} else {
long hitTime = getTimeAtX(e.x);
if (hitTime >= 0) {
- // _timeProvider.setSelectedTimeInt(hitTime, false);
setCapture(true);
- _dragState = DRAG_TRACE_ITEM;
- _dragX = _dragX0 = e.x - nameSpace;
- _time0bak = _timeProvider.getTime0();
- _time1bak = _timeProvider.getTime1();
+ fDragState = DRAG_TRACE_ITEM;
+ fDragX = e.x - nameSpace;
+ fDragX0 = fDragX;
+ fTime0bak = fTimeProvider.getTime0();
+ fTime1bak = fTimeProvider.getTime1();
}
}
selectItem(idx, false);
@@ -1731,12 +1720,13 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
fireSelectionChanged();
}
} else if (3 == e.button) {
- if (_timeProvider.getTime0() == _timeProvider.getTime1() || getCtrlSize().x - _timeProvider.getNameSpace() <= 0) {
+ if (fTimeProvider.getTime0() == fTimeProvider.getTime1() || getCtrlSize().x - fTimeProvider.getNameSpace() <= 0) {
return;
}
setCapture(true);
- _dragX = _dragX0 = Math.min(Math.max(e.x, _timeProvider.getNameSpace()), getCtrlSize().x - RIGHT_MARGIN);
- _dragState = DRAG_ZOOM;
+ fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), getCtrlSize().x - RIGHT_MARGIN);
+ fDragX0 = fDragX;
+ fDragState = DRAG_ZOOM;
}
}
@@ -1745,35 +1735,35 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
if (fPendingMenuDetectEvent != null && e.button == 3) {
menuDetected(fPendingMenuDetectEvent);
}
- if (DRAG_NONE != _dragState) {
+ if (DRAG_NONE != fDragState) {
setCapture(false);
- if (e.button == 1 && DRAG_TRACE_ITEM == _dragState) {
- if (_dragX == _dragX0) { // click without drag
+ if (e.button == 1 && DRAG_TRACE_ITEM == fDragState) {
+ if (fDragX == fDragX0) { // click without drag
long time = getTimeAtX(e.x);
- _timeProvider.setSelectedTimeNotify(time, false);
+ fTimeProvider.setSelectedTimeNotify(time, false);
} else {
// Notify time provider to check the need for listener
// notification
- _timeProvider.notifyStartFinishTime();
+ fTimeProvider.notifyStartFinishTime();
}
- _dragState = DRAG_NONE;
- } else if (e.button == 1 && DRAG_SPLIT_LINE == _dragState) {
+ fDragState = DRAG_NONE;
+ } else if (e.button == 1 && DRAG_SPLIT_LINE == fDragState) {
redraw();
- _dragState = DRAG_NONE;
- } else if (e.button == 3 && DRAG_ZOOM == _dragState) {
- int nameWidth = _timeProvider.getNameSpace();
- if (Math.max(_dragX, _dragX0) > nameWidth && _dragX != _dragX0) {
- long time0 = getTimeAtX(_dragX0);
- long time1 = getTimeAtX(_dragX);
+ fDragState = DRAG_NONE;
+ } else if (e.button == 3 && DRAG_ZOOM == fDragState) {
+ int nameWidth = fTimeProvider.getNameSpace();
+ if (Math.max(fDragX, fDragX0) > nameWidth && fDragX != fDragX0) {
+ long time0 = getTimeAtX(fDragX0);
+ long time1 = getTimeAtX(fDragX);
if (time0 < time1) {
- _timeProvider.setStartFinishTimeNotify(time0, time1);
+ fTimeProvider.setStartFinishTimeNotify(time0, time1);
} else {
- _timeProvider.setStartFinishTimeNotify(time1, time0);
+ fTimeProvider.setStartFinishTimeNotify(time1, time0);
}
} else {
redraw();
}
- _dragState = DRAG_NONE;
+ fDragState = DRAG_NONE;
}
}
}
@@ -1784,8 +1774,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
@Override
public void mouseExit(MouseEvent e) {
- if (_mouseOverSplitLine) {
- _mouseOverSplitLine = false;
+ if (fMouseOverSplitLine) {
+ fMouseOverSplitLine = false;
redraw();
}
}
@@ -1796,7 +1786,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
@Override
public void mouseScrolled(MouseEvent e) {
- if ((mouseScrollFilterListener == null) || _dragState != DRAG_NONE) {
+ if ((fMouseScrollFilterListener == null) || fDragState != DRAG_NONE) {
return;
}
boolean zoomScroll = false;
@@ -1807,14 +1797,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
if (e.x > getCtrlSize().x) {
// over the horizontal scroll bar
zoomScroll = false;
- } else if (e.y >= 0 && e.y < getCtrlSize().y && e.x < _timeProvider.getNameSpace()) {
+ } else if (e.y >= 0 && e.y < getCtrlSize().y && e.x < fTimeProvider.getNameSpace()) {
// over the name space
zoomScroll = false;
} else {
zoomScroll = true;
}
}
- if (zoomScroll && _timeProvider.getTime0() != _timeProvider.getTime1()) {
+ if (zoomScroll && fTimeProvider.getTime0() != fTimeProvider.getTime1()) {
if (e.count > 0) {
zoom(true);
} else if (e.count < 0) {
@@ -1842,16 +1832,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void widgetSelected(SelectionEvent e) {
if (e.widget == getVerticalBar()) {
setTopIndex(getVerticalBar().getSelection());
- } else if (e.widget == getHorizontalBar() && null != _timeProvider) {
+ } else if (e.widget == getHorizontalBar() && null != fTimeProvider) {
int start = getHorizontalBar().getSelection();
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
- long timeMin = _timeProvider.getMinTime();
- long timeMax = _timeProvider.getMaxTime();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
+ long timeMin = fTimeProvider.getMinTime();
+ long timeMax = fTimeProvider.getMaxTime();
long delta = timeMax - timeMin;
long range = time1 - time0;
- // _timeRangeFixed = true;
time0 = timeMin + Math.round(delta * ((double) start / H_SCROLLBAR_MAX));
time1 = time0 + range;
@@ -1859,23 +1848,16 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
// In Linux SWT.DRAG is the only value received
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310310
if (e.detail == SWT.DRAG) {
- _timeProvider.setStartFinishTime(time0, time1);
+ fTimeProvider.setStartFinishTime(time0, time1);
} else {
- _timeProvider.setStartFinishTimeNotify(time0, time1);
+ fTimeProvider.setStartFinishTimeNotify(time0, time1);
}
}
}
- /**
- * @return The current visibility of the vertical scroll bar
- */
- public boolean isVisibleVerticalScroll() {
- return _visibleVerticalScroll;
- }
-
@Override
public int getBorderWidth() {
- return _borderWidth;
+ return fBorderWidth;
}
/**
@@ -1885,14 +1867,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The width
*/
public void setBorderWidth(int borderWidth) {
- this._borderWidth = borderWidth;
+ this.fBorderWidth = borderWidth;
}
/**
* @return The current height of the header row
*/
public int getHeaderHeight() {
- return _headerHeight;
+ return fHeaderHeight;
}
/**
@@ -1902,14 +1884,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The height
*/
public void setHeaderHeight(int headerHeight) {
- this._headerHeight = headerHeight;
+ this.fHeaderHeight = headerHeight;
}
/**
* @return The height of regular item rows
*/
public int getItemHeight() {
- return _itemHeight;
+ return fGlobalItemHeight;
}
/**
@@ -1919,7 +1901,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* The height
*/
public void setItemHeight(int rowHeight) {
- this._itemHeight = rowHeight;
+ this.fGlobalItemHeight = rowHeight;
}
/**
@@ -1928,42 +1910,39 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @param width The minimum width
*/
public void setMinimumItemWidth(int width) {
- this._minimumItemWidth = width;
+ this.fMinimumItemWidth = width;
}
/**
* @return The minimum item width
*/
public int getMinimumItemWidth() {
- return _minimumItemWidth;
+ return fMinimumItemWidth;
}
/**
* @return The entries that are currently filtered out
+ *
+ * @since 2.0
*/
- public Vector<ITimeGraphEntry> getFilteredOut() {
- return _data.getFilteredOut();
+ public List<ITimeGraphEntry> getFilteredOut() {
+ return fItemData.getFilteredOut();
}
- // @Override
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
- if (listener != null) {
- if (!_selectionChangedListeners.contains(listener)) {
- _selectionChangedListeners.add(listener);
- }
+ if (listener != null && !fSelectionChangedListeners.contains(listener)) {
+ fSelectionChangedListeners.add(listener);
}
}
- // @Override
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
if (listener != null) {
- _selectionChangedListeners.remove(listener);
+ fSelectionChangedListeners.remove(listener);
}
}
- // @Override
@Override
public void setSelection(ISelection selection) {
if (selection instanceof TimeGraphSelection) {
@@ -1982,8 +1961,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 2.0
*/
public void addFilter(ViewerFilter filter) {
- if (!_filters.contains(filter)) {
- _filters.add(filter);
+ if (!fFilters.contains(filter)) {
+ fFilters.add(filter);
}
}
@@ -1992,16 +1971,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
* @since 2.0
*/
public void removeFilter(ViewerFilter filter) {
- _filters.remove(filter);
+ fFilters.remove(filter);
}
private class ItemData {
- public Item[] _expandedItems = new Item[0];
- public Item[] _items = new Item[0];
- private ITimeGraphEntry _traces[] = new ITimeGraphEntry[0];
- private boolean traceFilter[] = new boolean[0];
- private final Vector<ITimeGraphEntry> filteredOut = new Vector<ITimeGraphEntry>();
- public ITimeGraphPresentationProvider provider;
+ private Item[] fExpandedItems = new Item[0];
+ private Item[] fItems = new Item[0];
+ private ITimeGraphEntry fTraces[] = new ITimeGraphEntry[0];
+ private boolean fTraceFilter[] = new boolean[0];
+ private final ArrayList<ITimeGraphEntry> fFilteredOut = new ArrayList<ITimeGraphEntry>();
public ItemData() {
}
@@ -2011,9 +1989,9 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
return null;
}
- for (int i = 0; i < _items.length; i++) {
- Item item = _items[i];
- if (item._trace == entry) {
+ for (int i = 0; i < fItems.length; i++) {
+ Item item = fItems[i];
+ if (item.fTrace == entry) {
return item;
}
}
@@ -2026,9 +2004,9 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
return -1;
}
- for (int i = 0; i < _expandedItems.length; i++) {
- Item item = _expandedItems[i];
- if (item._trace == trace) {
+ for (int i = 0; i < fExpandedItems.length; i++) {
+ Item item = fExpandedItems[i];
+ if (item.fTrace == trace) {
return i;
}
}
@@ -2038,18 +2016,18 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void refreshData() {
List<Item> itemList = new ArrayList<Item>();
- filteredOut.clear();
+ fFilteredOut.clear();
ITimeGraphEntry selection = getSelectedTrace();
- for (int i = 0; i < _traces.length; i++) {
- ITimeGraphEntry entry = _traces[i];
+ for (int i = 0; i < fTraces.length; i++) {
+ ITimeGraphEntry entry = fTraces[i];
refreshData(itemList, null, 0, entry);
}
- _items = itemList.toArray(new Item[0]);
+ fItems = itemList.toArray(new Item[0]);
updateExpandedItems();
if (selection != null) {
- for (Item item : _expandedItems) {
- if (item._trace == selection) {
- item._selected = true;
+ for (Item item : fExpandedItems) {
+ if (item.fTrace == selection) {
+ item.fSelected = true;
break;
}
}
@@ -2059,13 +2037,13 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
private void refreshData(List<Item> itemList, Item parent, int level, ITimeGraphEntry entry) {
Item item = new Item(entry, entry.getName(), level);
if (parent != null) {
- parent.children.add(item);
+ parent.fChildren.add(item);
}
- item.itemHeight = provider.getItemHeight(entry);
+ item.fItemHeight = fTimeGraphProvider.getItemHeight(entry);
itemList.add(item);
if (entry.hasChildren()) {
- item._expanded = true;
- item._hasChildren = true;
+ item.fExpanded = true;
+ item.fHasChildren = true;
for (ITimeGraphEntry child : entry.getChildren()) {
refreshData(itemList, item, level + 1, child);
}
@@ -2074,27 +2052,27 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
public void updateExpandedItems() {
List<Item> expandedItemList = new ArrayList<Item>();
- for (int i = 0; i < _traces.length; i++) {
- ITimeGraphEntry entry = _traces[i];
+ for (int i = 0; i < fTraces.length; i++) {
+ ITimeGraphEntry entry = fTraces[i];
Item item = findItem(entry);
refreshExpanded(expandedItemList, item);
}
- _expandedItems = expandedItemList.toArray(new Item[0]);
+ fExpandedItems = expandedItemList.toArray(new Item[0]);
}
private void refreshExpanded(List<Item> expandedItemList, Item item) {
// Check for filters
boolean display = true;
- for (ViewerFilter filter : _filters) {
- if (!filter.select(null, item._trace.getParent(), item._trace)) {
+ for (ViewerFilter filter : fFilters) {
+ if (!filter.select(null, item.fTrace.getParent(), item.fTrace)) {
display = false;
break;
}
}
if (display) {
expandedItemList.add(item);
- if (item._hasChildren && item._expanded) {
- for (Item child : item.children) {
+ if (item.fHasChildren && item.fExpanded) {
+ for (Item child : item.fChildren) {
refreshExpanded(expandedItemList, child);
}
}
@@ -2102,50 +2080,55 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
}
public void refreshData(ITimeGraphEntry traces[]) {
- if (traces == null || traces.length == 0) {
- traceFilter = null;
- } else if (traceFilter == null || traces.length != traceFilter.length) {
- traceFilter = new boolean[traces.length];
- java.util.Arrays.fill(traceFilter, true);
+ if (traces == null) {
+ fTraceFilter = null;
+ fTraces = null;
+ } else {
+ if (traces.length == 0) {
+ fTraceFilter = null;
+ } else if (fTraceFilter == null || traces.length != fTraceFilter.length) {
+ fTraceFilter = new boolean[traces.length];
+ java.util.Arrays.fill(fTraceFilter, true);
+ }
+ fTraces = Arrays.copyOf(traces, traces.length);
}
- _traces = traces;
refreshData();
}
public ITimeGraphEntry[] getTraces() {
- return _traces;
+ return fTraces;
}
public boolean[] getTraceFilter() {
- return traceFilter;
+ return fTraceFilter;
}
- public Vector<ITimeGraphEntry> getFilteredOut() {
- return filteredOut;
+ public List<ITimeGraphEntry> getFilteredOut() {
+ return fFilteredOut;
}
}
private class Item {
- public boolean _expanded;
- public boolean _selected;
- public boolean _hasChildren;
- public int itemHeight;
- public int level;
- public List<Item> children;
- public String _name;
- public ITimeGraphEntry _trace;
+ private boolean fExpanded;
+ private boolean fSelected;
+ private boolean fHasChildren;
+ private int fItemHeight;
+ private int fLevel;
+ private List<Item> fChildren;
+ private String fName;
+ private ITimeGraphEntry fTrace;
public Item(ITimeGraphEntry trace, String name, int level) {
- this._trace = trace;
- this._name = name;
- this.level = level;
- this.children = new ArrayList<Item>();
+ this.fTrace = trace;
+ this.fName = name;
+ this.fLevel = level;
+ this.fChildren = new ArrayList<Item>();
}
@Override
public String toString() {
- return _name;
+ return fName;
}
}
@@ -2154,7 +2137,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
*/
@Override
public void menuDetected(MenuDetectEvent e) {
- if (null == _timeProvider) {
+ if (null == fTimeProvider) {
return;
}
if (e.detail == SWT.MENU_MOUSE) {
@@ -2167,19 +2150,19 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
return;
}
fPendingMenuDetectEvent = null;
- if (_dragState != DRAG_ZOOM || _dragX != _dragX0) {
+ if (fDragState != DRAG_ZOOM || fDragX != fDragX0) {
return;
}
} else {
- if (_dragState != DRAG_NONE) {
+ if (fDragState != DRAG_NONE) {
return;
}
}
Point p = toControl(e.x, e.y);
int idx = getItemIndexAtY(p.y);
- if (idx >= 0 && idx < _data._expandedItems.length) {
- Item item = _data._expandedItems[idx];
- ITimeGraphEntry entry = item._trace;
+ if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
+ Item item = fItemData.fExpandedItems[idx];
+ ITimeGraphEntry entry = item.fTrace;
if (entry.hasTimeEvents()) {
ITimeEvent event = Utils.findEvent(entry, getTimeAtX(p.x), 2);
if (event != null) {
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphItem.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphItem.java
deleted file mode 100644
index f2a7eb515f..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphItem.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tasse - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
-
-/**
- * Item in the generic time graph view
- *
- * @version 1.0
- * @author Patrick Tasse
- */
-@SuppressWarnings("javadoc")
-public class TimeGraphItem {
- public boolean _expanded;
- public boolean _selected;
- public boolean _hasChildren;
- public int itemHeight;
- public int level;
- public List<TimeGraphItem> children;
- public String _name;
- public ITimeGraphEntry _trace;
-
- /**
- * Standard constructor
- *
- * @param trace
- * The entry matching to trace to which this item is associated
- * @param name
- * The name of the item
- * @param level
- * The tree level of this entry (0 = top level)
- */
- public TimeGraphItem(ITimeGraphEntry trace, String name, int level) {
- this._trace = trace;
- this._name = name;
- this.level = level;
- this.children = new ArrayList<TimeGraphItem>();
- }
-
- @Override
- public String toString() {
- return _name;
- }
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java
index 708bdfb6a4..1853547034 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java
@@ -43,20 +43,8 @@ import org.eclipse.swt.widgets.Composite;
public class TimeGraphScale extends TimeGraphBaseControl implements
MouseListener, MouseMoveListener {
- /**
- * Standard constructor
- *
- * @param parent
- * The parent composite object
- * @param colors
- * The color scheme to use
- */
- public TimeGraphScale(Composite parent, TimeGraphColorScheme colors) {
- super(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS | SWT.DOUBLE_BUFFERED);
- addMouseListener(this);
- addMouseMoveListener(this);
- }
-
+ private static final long MICROSEC_IN_NS = 1000;
+ private static final long MILLISEC_IN_NS = 1000000;
private static final long SEC_IN_NS = 1000000000;
private static final long MIN_IN_NS = 60 * SEC_IN_NS;
private static final long HOUR_IN_NS = 60 * MIN_IN_NS;
@@ -71,15 +59,47 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
private static final Calendar GREGORIAN_CALENDAR = Calendar.getInstance();
- private ITimeDataProvider _timeProvider;
- private int _dragState = 0;
- private int _dragX0 = 0;
- private int _dragX = 0;
- private long _time0bak;
- private long _time1bak;
- private boolean _isInUpdate;
- private final Rectangle _rect0 = new Rectangle(0, 0, 0, 0);
- private int _height;
+ private static final TimeDraw TIMEDRAW_NANOSEC = new TimeDrawNanosec();
+ private static final TimeDraw TIMEDRAW_MICROSEC = new TimeDrawMicrosec();
+ private static final TimeDraw TIMEDRAW_MILLISEC = new TimeDrawMillisec();
+ private static final TimeDraw TIMEDRAW_SEC = new TimeDrawSec();
+ private static final TimeDraw TIMEDRAW_ABS_NANOSEC = new TimeDrawAbsNanoSec();
+ private static final TimeDraw TIMEDRAW_ABS_MICROSEC = new TimeDrawAbsMicroSec();
+ private static final TimeDraw TIMEDRAW_ABS_MILLISEC = new TimeDrawAbsMillisec();
+ private static final TimeDraw TIMEDRAW_ABS_SEC = new TimeDrawAbsSec();
+ private static final TimeDraw TIMEDRAW_ABS_MIN = new TimeDrawAbsMin();
+ private static final TimeDraw TIMEDRAW_ABS_HRS = new TimeDrawAbsHrs();
+ private static final TimeDraw TIMEDRAW_ABS_DAY = new TimeDrawAbsDay();
+ private static final TimeDraw TIMEDRAW_ABS_MONTH = new TimeDrawAbsMonth();
+ private static final TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();
+ private static final TimeDraw TIMEDRAW_NUMBER = new TimeDrawNumber();
+
+ private static final int NO_BUTTON = 0;
+ private static final int LEFT_BUTTON = 1;
+ private static final int RIGHT_BUTTON = 3;
+
+ private ITimeDataProvider fTimeProvider;
+ private int fDragState = NO_BUTTON;
+ private int fDragX0 = 0;
+ private int fDragX = 0;
+ private long fTime0bak;
+ private long fTime1bak;
+ private boolean fIsInUpdate;
+ private int fHeight;
+
+ /**
+ * Standard constructor
+ *
+ * @param parent
+ * The parent composite object
+ * @param colors
+ * The color scheme to use
+ */
+ public TimeGraphScale(Composite parent, TimeGraphColorScheme colors) {
+ super(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS | SWT.DOUBLE_BUFFERED);
+ addMouseListener(this);
+ addMouseMoveListener(this);
+ }
/**
* Assign the time provider for this scale
@@ -88,14 +108,12 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
* The provider to use
*/
public void setTimeProvider(ITimeDataProvider timeProvider) {
- _timeProvider = timeProvider;
+ fTimeProvider = timeProvider;
}
- private long _timeDelta;
-
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
- return super.computeSize(wHint, _height, changed);
+ return super.computeSize(wHint, fHeight, changed);
}
/**
@@ -105,13 +123,14 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
* The height to use
*/
public void setHeight(int height) {
- this._height = height;
+ this.fHeight = height;
}
- private void calcTimeDelta(int width, double pixelsPerNanoSec) {
+ private long calcTimeDelta(int width, double pixelsPerNanoSec) {
+ long timeDelta;
double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec;
long unit = 1;
- if (_timeProvider != null && _timeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
+ if (fTimeProvider != null && fTimeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
if (minDelta > 6 * MONTH_IN_NS) {
unit = YEAR_IN_NS;
} else if (minDelta > 3 * MONTH_IN_NS) {
@@ -131,49 +150,35 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
} else if (minDelta > 20 * SEC_IN_NS) {
unit = 30 * SEC_IN_NS;
} else if (minDelta <= 1) {
- _timeDelta = 1;
- return;
+ timeDelta = 1;
+ return timeDelta;
}
}
double log = Math.log10(minDelta / unit);
long pow10 = (long) log;
double remainder = log - pow10;
if (remainder < LOG10_1) {
- _timeDelta = (long) Math.pow(10, pow10) * unit;
+ timeDelta = (long) Math.pow(10, pow10) * unit;
} else if (remainder < LOG10_2) {
- _timeDelta = 2 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 2 * (long) Math.pow(10, pow10) * unit;
} else if (remainder < LOG10_3 && unit >= HOUR_IN_NS && unit < YEAR_IN_NS) {
- _timeDelta = 3 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 3 * (long) Math.pow(10, pow10) * unit;
} else if (remainder < LOG10_5) {
- _timeDelta = 5 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 5 * (long) Math.pow(10, pow10) * unit;
} else {
- _timeDelta = 10 * (long) Math.pow(10, pow10) * unit;
+ timeDelta = 10 * (long) Math.pow(10, pow10) * unit;
}
- if (_timeDelta<=0) {
- _timeDelta=1;
+ if (timeDelta <= 0) {
+ timeDelta = 1;
}
+ return timeDelta;
}
- private static TimeDraw TIMEDRAW_NANOSEC = new TimeDrawNanosec();
- private static TimeDraw TIMEDRAW_MICROSEC = new TimeDrawMicrosec();
- private static TimeDraw TIMEDRAW_MILLISEC = new TimeDrawMillisec();
- private static TimeDraw TIMEDRAW_SEC = new TimeDrawSec();
- private static TimeDraw TIMEDRAW_ABS_NANOSEC = new TimeDrawAbsNanoSec();
- private static TimeDraw TIMEDRAW_ABS_MICROSEC = new TimeDrawAbsMicroSec();
- private static TimeDraw TIMEDRAW_ABS_MILLISEC = new TimeDrawAbsMillisec();
- private static TimeDraw TIMEDRAW_ABS_SEC = new TimeDrawAbsSec();
- private static TimeDraw TIMEDRAW_ABS_MIN = new TimeDrawAbsMin();
- private static TimeDraw TIMEDRAW_ABS_HRS = new TimeDrawAbsHrs();
- private static TimeDraw TIMEDRAW_ABS_DAY = new TimeDrawAbsDay();
- private static TimeDraw TIMEDRAW_ABS_MONTH = new TimeDrawAbsMonth();
- private static TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();
- private static TimeDraw TIMEDRAW_NUMBER = new TimeDrawNumber();
-
TimeDraw getTimeDraw(long timeDelta) {
TimeDraw timeDraw;
- if (_timeProvider != null) {
+ if (fTimeProvider != null) {
- if (_timeProvider.getTimeFormat() == TimeFormat.CALENDAR) {
+ if (fTimeProvider.getTimeFormat() == TimeFormat.CALENDAR) {
if (timeDelta >= YEAR_IN_NS) {
timeDraw = TIMEDRAW_ABS_YEAR;
} else if (timeDelta >= MONTH_IN_NS) {
@@ -186,25 +191,25 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
timeDraw = TIMEDRAW_ABS_MIN;
} else if (timeDelta >= SEC_IN_NS) {
timeDraw = TIMEDRAW_ABS_SEC;
- } else if (timeDelta >= 1000000) {
+ } else if (timeDelta >= MILLISEC_IN_NS) {
timeDraw = TIMEDRAW_ABS_MILLISEC;
- } else if (timeDelta >= 1000) {
+ } else if (timeDelta >= MICROSEC_IN_NS) {
timeDraw = TIMEDRAW_ABS_MICROSEC;
} else {
timeDraw = TIMEDRAW_ABS_NANOSEC;
}
return timeDraw;
- } else if (_timeProvider.getTimeFormat() == TimeFormat.NUMBER) {
+ } else if (fTimeProvider.getTimeFormat() == TimeFormat.NUMBER) {
timeDraw = TIMEDRAW_NUMBER;
return timeDraw;
}
}
- if (timeDelta >= 1000000000) {
+ if (timeDelta >= SEC_IN_NS) {
timeDraw = TIMEDRAW_SEC;
- } else if (timeDelta >= 1000000) {
+ } else if (timeDelta >= MILLISEC_IN_NS) {
timeDraw = TIMEDRAW_MILLISEC;
- } else if (timeDelta >= 1000) {
+ } else if (timeDelta >= MICROSEC_IN_NS) {
timeDraw = TIMEDRAW_MICROSEC;
} else {
timeDraw = TIMEDRAW_NANOSEC;
@@ -215,48 +220,49 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
@Override
void paint(Rectangle rect, PaintEvent e) {
- if (_isInUpdate || null == _timeProvider) {
+ if (fIsInUpdate || null == fTimeProvider) {
return;
}
GC gc = e.gc;
gc.fillRectangle(rect);
- long time0 = _timeProvider.getTime0();
- long time1 = _timeProvider.getTime1();
- long selectedTime = _timeProvider.getSelectedTime();
- int leftSpace = _timeProvider.getNameSpace();
- int timeSpace = _timeProvider.getTimeSpace();
+ long time0 = fTimeProvider.getTime0();
+ long time1 = fTimeProvider.getTime1();
+ long selectedTime = fTimeProvider.getSelectedTime();
+ int leftSpace = fTimeProvider.getNameSpace();
+ int timeSpace = fTimeProvider.getTimeSpace();
- gc.setBackground(_colors.getColor(TimeGraphColorScheme.TOOL_BACKGROUND));
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
- Utils.init(_rect0, rect);
+ gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_BACKGROUND));
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
+ Rectangle rect0 = new Rectangle(0, 0, 0, 0);
+ Utils.init(rect0, rect);
// draw top left area
- _rect0.width = leftSpace;
- _rect0.x += 4;
- _rect0.width -= 4;
- Rectangle absHeaderRect = new Rectangle(_rect0.x, _rect0.y, _rect0.width, _rect0.height);
- _rect0.x -= 4;
- _rect0.width += 4;
+ rect0.width = leftSpace;
+ rect0.x += 4;
+ rect0.width -= 4;
+ Rectangle absHeaderRect = new Rectangle(rect0.x, rect0.y, rect0.width, rect0.height);
+ rect0.x -= 4;
+ rect0.width += 4;
// prepare and draw right rect of the timescale
- _rect0.x += leftSpace;
- _rect0.width = rect.width - leftSpace;
+ rect0.x += leftSpace;
+ rect0.width = rect.width - leftSpace;
// draw bottom border and erase all other area
gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1,
rect.y + rect.height - 1);
- _rect0.height--;
- gc.fillRectangle(_rect0);
+ rect0.height--;
+ gc.fillRectangle(rect0);
- if (3 == _dragState && null != _timeProvider) {
+ if (RIGHT_BUTTON == fDragState && null != fTimeProvider) {
// draw selected zoom region background
- gc.setBackground(_colors.getBkColor(true, false, true));
- if (_dragX0 < _dragX) {
- gc.fillRectangle(new Rectangle(leftSpace + _dragX0, _rect0.y, _dragX - _dragX0, _rect0.height));
- } else if (_dragX0 > _dragX) {
- gc.fillRectangle(new Rectangle(leftSpace + _dragX, _rect0.y, _dragX0 - _dragX, _rect0.height));
+ gc.setBackground(getColorScheme().getBkColor(true, false, true));
+ if (fDragX0 < fDragX) {
+ gc.fillRectangle(new Rectangle(leftSpace + fDragX0, rect0.y, fDragX - fDragX0, rect0.height));
+ } else if (fDragX0 > fDragX) {
+ gc.fillRectangle(new Rectangle(leftSpace + fDragX, rect0.y, fDragX0 - fDragX, rect0.height));
}
}
@@ -269,98 +275,98 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
int labelWidth = gc.getCharWidth('0') * numDigits;
double pixelsPerNanoSec = (timeSpace <= RIGHT_MARGIN) ? 0 :
(double) (timeSpace - RIGHT_MARGIN) / (time1 - time0);
- calcTimeDelta(labelWidth, pixelsPerNanoSec);
+ long timeDelta = calcTimeDelta(labelWidth, pixelsPerNanoSec);
- TimeDraw timeDraw = getTimeDraw(_timeDelta);
+ TimeDraw timeDraw = getTimeDraw(timeDelta);
// draw selected zoom region lines
- if (3 == _dragState && null != _timeProvider) {
- gc.drawLine(leftSpace + _dragX0, rect.y, leftSpace + _dragX0, rect.y + rect.height);
- gc.drawLine(leftSpace + _dragX, rect.y, leftSpace + _dragX, rect.y + rect.height);
+ if (RIGHT_BUTTON == fDragState && null != fTimeProvider) {
+ gc.drawLine(leftSpace + fDragX0, rect.y, leftSpace + fDragX0, rect.y + rect.height);
+ gc.drawLine(leftSpace + fDragX, rect.y, leftSpace + fDragX, rect.y + rect.height);
}
- if (_rect0.isEmpty()) {
+ if (rect0.isEmpty()) {
return;
}
// draw selected time
- int x = _rect0.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);
- if (x >= _rect0.x && x < _rect0.x + _rect0.width) {
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.SELECTED_TIME));
- gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y
- + _rect0.height);
- gc.setForeground(_colors.getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
+ int x = rect0.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);
+ if (x >= rect0.x && x < rect0.x + rect0.width) {
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
+ gc.drawLine(x, rect0.y + rect0.height - 6, x, rect0.y
+ + rect0.height);
+ gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
}
// draw time scale ticks
- _rect0.y = rect.y;
- _rect0.height = rect.height - 4;
- _rect0.width = labelWidth;
+ rect0.y = rect.y;
+ rect0.height = rect.height - 4;
+ rect0.width = labelWidth;
long time;
- if (_timeProvider != null && _timeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
- time = floorToCalendar(time0, _timeDelta);
+ if (fTimeProvider != null && fTimeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
+ time = floorToCalendar(time0, timeDelta);
} else {
- time = (time0 / _timeDelta) * _timeDelta;
+ time = (time0 / timeDelta) * timeDelta;
if (time != time0) {
- time += _timeDelta;
+ time += timeDelta;
}
}
- int y = _rect0.y + _rect0.height;
+ int y = rect0.y + rect0.height;
- if (_timeProvider != null && _timeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
+ if (fTimeProvider != null && fTimeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
timeDraw.drawAbsHeader(gc, time, absHeaderRect);
}
while (true) {
x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));
- if (x >= rect.x + leftSpace + rect.width - _rect0.width) {
+ if (x >= rect.x + leftSpace + rect.width - rect0.width) {
break;
}
if (x >= rect.x + leftSpace) {
gc.drawLine(x, y, x, y + 4);
- _rect0.x = x;
- if (x + _rect0.width <= rect.x + rect.width) {
- timeDraw.draw(gc, time, _rect0);
+ rect0.x = x;
+ if (x + rect0.width <= rect.x + rect.width) {
+ timeDraw.draw(gc, time, rect0);
}
}
- if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - _timeDelta || _timeDelta == 0) {
+ if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - timeDelta || timeDelta == 0) {
break;
}
- if (_timeProvider != null && _timeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
- if (_timeDelta >= YEAR_IN_NS) {
- long millis = time / 1000000L;
+ if (fTimeProvider != null && fTimeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
+ if (timeDelta >= YEAR_IN_NS) {
+ long millis = time / MILLISEC_IN_NS;
GREGORIAN_CALENDAR.setTime(new Date(millis));
- GREGORIAN_CALENDAR.add(Calendar.YEAR, (int) (_timeDelta / YEAR_IN_NS));
+ GREGORIAN_CALENDAR.add(Calendar.YEAR, (int) (timeDelta / YEAR_IN_NS));
millis = GREGORIAN_CALENDAR.getTimeInMillis();
- time = millis * 1000000L;
- } else if (_timeDelta >= MONTH_IN_NS) {
- long millis = time / 1000000L;
+ time = millis * MILLISEC_IN_NS;
+ } else if (timeDelta >= MONTH_IN_NS) {
+ long millis = time / MILLISEC_IN_NS;
GREGORIAN_CALENDAR.setTime(new Date(millis));
- GREGORIAN_CALENDAR.add(Calendar.MONTH, (int) (_timeDelta / MONTH_IN_NS));
+ GREGORIAN_CALENDAR.add(Calendar.MONTH, (int) (timeDelta / MONTH_IN_NS));
millis = GREGORIAN_CALENDAR.getTimeInMillis();
- time = millis * 1000000L;
- } else if (_timeDelta >= DAY_IN_NS) {
- long millis = time / 1000000L;
+ time = millis * MILLISEC_IN_NS;
+ } else if (timeDelta >= DAY_IN_NS) {
+ long millis = time / MILLISEC_IN_NS;
GREGORIAN_CALENDAR.setTime(new Date(millis));
- GREGORIAN_CALENDAR.add(Calendar.DAY_OF_MONTH, (int) (_timeDelta / DAY_IN_NS));
+ GREGORIAN_CALENDAR.add(Calendar.DAY_OF_MONTH, (int) (timeDelta / DAY_IN_NS));
millis = GREGORIAN_CALENDAR.getTimeInMillis();
- time = millis * 1000000L;
+ time = millis * MILLISEC_IN_NS;
} else {
- time += _timeDelta;
+ time += timeDelta;
}
} else {
- time += _timeDelta;
+ time += timeDelta;
}
}
}
- private long floorToCalendar(long time, long timeDelta) {
+ private static long floorToCalendar(long time, long timeDelta) {
long ret = time;
- if (_timeDelta >= YEAR_IN_NS) {
- GREGORIAN_CALENDAR.setTime(new Date(ret / 1000000));
+ if (timeDelta >= YEAR_IN_NS) {
+ GREGORIAN_CALENDAR.setTime(new Date(ret / MILLISEC_IN_NS));
int year = GREGORIAN_CALENDAR.get(Calendar.YEAR);
int yearDelta = (int) (timeDelta / YEAR_IN_NS);
year = (year / yearDelta) * yearDelta;
@@ -371,9 +377,9 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);
GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);
GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);
- ret = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;
- } else if (_timeDelta >= MONTH_IN_NS) {
- GREGORIAN_CALENDAR.setTime(new Date(ret / 1000000));
+ ret = GREGORIAN_CALENDAR.getTimeInMillis() * MILLISEC_IN_NS;
+ } else if (timeDelta >= MONTH_IN_NS) {
+ GREGORIAN_CALENDAR.setTime(new Date(ret / MILLISEC_IN_NS));
int month = GREGORIAN_CALENDAR.get(Calendar.MONTH);
int monthDelta = (int) (timeDelta / MONTH_IN_NS);
month = (month / monthDelta) * monthDelta;
@@ -383,9 +389,9 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);
GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);
GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);
- ret = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;
+ ret = GREGORIAN_CALENDAR.getTimeInMillis() * MILLISEC_IN_NS;
} else {
- long offset = GREGORIAN_CALENDAR.getTimeZone().getOffset(ret / 1000000L) * 1000000L;
+ long offset = GREGORIAN_CALENDAR.getTimeZone().getOffset(ret / MILLISEC_IN_NS) * MILLISEC_IN_NS;
ret += offset;
ret = (ret / timeDelta) * timeDelta;
ret -= offset;
@@ -397,7 +403,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
int numDigits = 5;
long timeRange = time1 - time0;
- if (_timeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
+ if (fTimeProvider.getTimeFormat().equals(TimeFormat.CALENDAR)) {
// Calculate the number of digits to represent the minutes provided
// 11:222
// HH:mm:ss
@@ -410,7 +416,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
numDigits += 6;
}
} else {
- long sec = time1 / 1000000000;
+ long sec = time1 / SEC_IN_NS;
numDigits = Long.toString(sec).length();
int thousandGroups = (numDigits - 1) / 3;
numDigits += thousandGroups;
@@ -423,90 +429,91 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
@Override
public void mouseDown(MouseEvent e) {
getParent().setFocus();
- if (_dragState == 0 && null != _timeProvider) {
- int x = e.x - _timeProvider.getNameSpace();
- if (1 == e.button && x > 0) {
+ if (fDragState == NO_BUTTON && null != fTimeProvider) {
+ int x = e.x - fTimeProvider.getNameSpace();
+ if (LEFT_BUTTON == e.button && x > 0) {
setCapture(true);
- _dragState = 1;
- } else if (3 == e.button) {
- _dragState = 3;
+ fDragState = LEFT_BUTTON;
+ } else if (RIGHT_BUTTON == e.button) {
+ fDragState = RIGHT_BUTTON;
}
if (x < 0) {
x = 0;
- } else if (x > getSize().x - _timeProvider.getNameSpace()) {
- x = getSize().x - _timeProvider.getNameSpace();
+ } else if (x > getSize().x - fTimeProvider.getNameSpace()) {
+ x = getSize().x - fTimeProvider.getNameSpace();
}
- _dragX = _dragX0 = x;
- _time0bak = _timeProvider.getTime0();
- _time1bak = _timeProvider.getTime1();
+ fDragX = x;
+ fDragX0 = x;
+ fTime0bak = fTimeProvider.getTime0();
+ fTime1bak = fTimeProvider.getTime1();
}
}
@Override
public void mouseUp(MouseEvent e) {
- if (e.button == 1 && _dragState == 1) {
+ if (e.button == LEFT_BUTTON && fDragState == LEFT_BUTTON) {
setCapture(false);
- _dragState = 0;
+ fDragState = NO_BUTTON;
// Notify time provider to check the need for listener notification
- if (_dragX != _dragX0 && _timeProvider.getTime0() != _timeProvider.getTime1()) {
- _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());
+ if (fDragX != fDragX0 && fTimeProvider.getTime0() != fTimeProvider.getTime1()) {
+ fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
}
- } else if (e.button == 3 && _dragState == 3 && null != _timeProvider) {
- _dragState = 0;
- if (_dragX0 == _dragX || _timeProvider.getTime0() == _timeProvider.getTime1()) {
+ } else if (e.button == RIGHT_BUTTON && fDragState == RIGHT_BUTTON && null != fTimeProvider) {
+ fDragState = NO_BUTTON;
+ if (fDragX0 == fDragX || fTimeProvider.getTime0() == fTimeProvider.getTime1()) {
redraw();
return;
}
- int timeSpace = _timeProvider.getTimeSpace();
- int leftSpace = _timeProvider.getNameSpace();
+ int timeSpace = fTimeProvider.getTimeSpace();
+ int leftSpace = fTimeProvider.getNameSpace();
int x = Math.max(0, e.x - leftSpace);
if (timeSpace > 0) {
- _dragX = x;
- if (_dragX0 > _dragX) { // drag right to left
- _dragX = _dragX0;
- _dragX0 = x;
+ fDragX = x;
+ if (fDragX0 > fDragX) { // drag right to left
+ fDragX = fDragX0;
+ fDragX0 = x;
}
- long time0 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / timeSpace));
- long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX / timeSpace));
+ long time0 = fTime0bak + (long) ((fTime1bak - fTime0bak) * ((double) fDragX0 / timeSpace));
+ long time1 = fTime0bak + (long) ((fTime1bak - fTime0bak) * ((double) fDragX / timeSpace));
- _timeProvider.setStartFinishTimeNotify(time0, time1);
- _time0bak = _timeProvider.getTime0();
- _time1bak = _timeProvider.getTime1();
+ fTimeProvider.setStartFinishTimeNotify(time0, time1);
+ fTime0bak = fTimeProvider.getTime0();
+ fTime1bak = fTimeProvider.getTime1();
}
}
}
@Override
public void mouseMove(MouseEvent e) {
- if (_dragX0 < 0 || _dragState == 0 || _timeProvider == null) {
+ if (fDragX0 < 0 || fDragState == NO_BUTTON || fTimeProvider == null) {
return;
}
Point size = getSize();
- int leftSpace = _timeProvider.getNameSpace();
- int timeSpace = _timeProvider.getTimeSpace();
+ int leftSpace = fTimeProvider.getNameSpace();
+ int timeSpace = fTimeProvider.getTimeSpace();
int x = e.x - leftSpace;
- if (1 == _dragState) {
- if (x > 0 && size.x > leftSpace && _dragX != x) {
- _dragX = x;
- if (_timeProvider.getTime0() == _timeProvider.getTime1()) {
+ if (LEFT_BUTTON == fDragState) {
+ if (x > 0 && size.x > leftSpace && fDragX != x) {
+ fDragX = x;
+ if (fTimeProvider.getTime0() == fTimeProvider.getTime1()) {
return;
}
- long interval = (long) ((_time1bak - _time0bak) * ((double) _dragX0 / _dragX));
+ long interval = (long) ((fTime1bak - fTime0bak) * ((double) fDragX0 / fDragX));
if (interval == Long.MAX_VALUE) {
- _timeProvider.setStartFinishTime(_time0bak, Long.MAX_VALUE);
+ fTimeProvider.setStartFinishTime(fTime0bak, Long.MAX_VALUE);
} else {
- long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / _dragX));
- _timeProvider.setStartFinishTime(_time0bak, time1);
+ long time1 = fTime0bak + (long) ((fTime1bak - fTime0bak) * ((double) fDragX0 / fDragX));
+ fTimeProvider.setStartFinishTime(fTime0bak, time1);
}
}
- } else if (3 == _dragState) {
+ } else if (RIGHT_BUTTON == fDragState) {
if (x < 0) {
- _dragX = 0;
+ fDragX = 0;
} else if (x > timeSpace) {
- _dragX = timeSpace;
+ fDragX = timeSpace;
} else {
- _dragX = x;
+ fDragX = x;
}
redraw();
}
@@ -514,29 +521,35 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
@Override
public void mouseDoubleClick(MouseEvent e) {
- if (e.button == 1 && null != _timeProvider && _timeProvider.getTime0() != _timeProvider.getTime1() && (e.stateMask & SWT.BUTTON_MASK) == 0) {
- _timeProvider.resetStartFinishTime();
- _timeProvider.notifyStartFinishTime();
- _time0bak = _timeProvider.getTime0();
- _time1bak = _timeProvider.getTime1();
+ if (e.button == 1 && null != fTimeProvider && fTimeProvider.getTime0() != fTimeProvider.getTime1() && (e.stateMask & SWT.BUTTON_MASK) == 0) {
+ fTimeProvider.resetStartFinishTime();
+ fTimeProvider.notifyStartFinishTime();
+ fTime0bak = fTimeProvider.getTime0();
+ fTime1bak = fTimeProvider.getTime1();
}
}
}
abstract class TimeDraw {
- static String S = "" ; //$NON-NLS-1$
- static String S0 = "0" ; //$NON-NLS-1$
- static String S00 = "00"; //$NON-NLS-1$
- protected static final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
- protected static final SimpleDateFormat stimeformatheader = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
- protected static final SimpleDateFormat sminformat = new SimpleDateFormat("HH:mm"); //$NON-NLS-1$
- protected static final SimpleDateFormat sminformatheader = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
- protected static final SimpleDateFormat shrsformat = new SimpleDateFormat("MMM dd HH:mm"); //$NON-NLS-1$
- protected static final SimpleDateFormat shrsformatheader = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
- protected static final SimpleDateFormat sdayformat = new SimpleDateFormat("MMM dd"); //$NON-NLS-1$
- protected static final SimpleDateFormat sdayformatheader = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
- protected static final SimpleDateFormat smonthformat = new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
- protected static final SimpleDateFormat syearformat = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
+ protected static final long MICROSEC_IN_NS = 1000;
+ protected static final long MILLISEC_IN_NS = 1000000;
+ protected static final long MILLISEC_IN_US = 1000;
+ protected static final long SEC_IN_NS = 1000000000;
+ protected static final long SEC_IN_MS = 1000;
+ private static final String S = "" ; //$NON-NLS-1$
+ private static final String S0 = "0" ; //$NON-NLS-1$
+ private static final String S00 = "00"; //$NON-NLS-1$
+ protected static final long PAD_1000 = 1000;
+ protected static final SimpleDateFormat SEC_FORMAT_HEADER = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
+ protected static final SimpleDateFormat SEC_FORMAT = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
+ protected static final SimpleDateFormat MIN_FORMAT_HEADER = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
+ protected static final SimpleDateFormat MIN_FORMAT = new SimpleDateFormat("HH:mm"); //$NON-NLS-1$
+ protected static final SimpleDateFormat HOURS_FORMAT_HEADER = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
+ protected static final SimpleDateFormat HOURS_FORMAT = new SimpleDateFormat("MMM dd HH:mm"); //$NON-NLS-1$
+ protected static final SimpleDateFormat DAY_FORMAT_HEADER = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
+ protected static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("MMM dd"); //$NON-NLS-1$
+ protected static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
+ protected static final SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
static String sep(long n) {
StringBuilder retVal = new StringBuilder();
@@ -566,324 +579,213 @@ abstract class TimeDraw {
public abstract void draw(GC gc, long time, Rectangle rect);
/**
- * Override to draw absolute time header This is for the time information
+ * Override to draw absolute time header. This is for the time information
* not shown in the draw of each tick
*
* @param gc
* Graphics context
- * @param time
- * Timestamp
+ * @param nanosec
+ * time in nanosec
* @param absHeaderRect
* Header rectangle
*/
- public void drawAbsHeader(GC gc, long time, Rectangle absHeaderRect) {
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle absHeaderRect) {
}
-
- public abstract String hint();
}
class TimeDrawSec extends TimeDraw {
- static String _hint = "sec"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- long correctTime = time / 1000000000;
- Utils.drawText(gc, sep(correctTime), rect, true);
- }
-
- @Override
- public String hint() {
- return _hint;
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ long sec = nanosec / SEC_IN_NS;
+ Utils.drawText(gc, sep(sec), rect, true);
}
}
class TimeDrawMillisec extends TimeDraw {
- static String _hint = "0.000"; //$NON-NLS-1$
-
- @Override
- public void draw(GC gc, long time, Rectangle rect) {
- long correctTime = time / 1000000;
- long ms = correctTime % 1000;
- correctTime /= 1000;
- Utils.drawText(gc, sep(correctTime) + "." + pad(ms), rect, true); //$NON-NLS-1$
- }
-
@Override
- public String hint() {
- return _hint;
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ long millisec = nanosec / MILLISEC_IN_NS;
+ long ms = millisec % PAD_1000;
+ long sec = millisec / SEC_IN_MS;
+ Utils.drawText(gc, sep(sec) + "." + pad(ms), rect, true); //$NON-NLS-1$
}
}
class TimeDrawMicrosec extends TimeDraw {
- static String _hint = "0.000 000"; //$NON-NLS-1$
-
- @Override
- public void draw(GC gc, long time, Rectangle rect) {
- long correctTime = time / 1000;
- long mcs = correctTime % 1000;
- correctTime /= 1000;
- long ms = correctTime % 1000;
- correctTime /= 1000;
- Utils.drawText(gc, sep(correctTime) + "." + pad(ms) + " " + pad(mcs), rect, true); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
@Override
- public String hint() {
- return _hint;
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ long microsec = nanosec / MICROSEC_IN_NS;
+ long us = microsec % PAD_1000;
+ long millisec = microsec / MILLISEC_IN_US;
+ long ms = millisec % PAD_1000;
+ long sec = millisec / SEC_IN_MS;
+ Utils.drawText(gc, sep(sec) + "." + pad(ms) + " " + pad(us), rect, true); //$NON-NLS-1$ //$NON-NLS-2$
}
}
class TimeDrawNanosec extends TimeDraw {
- static String _hint = "0.000 000 000"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- long ns = time % 1000;
- long correctTime = time / 1000;
- long mcs = correctTime % 1000;
- correctTime /= 1000;
- long ms = correctTime % 1000;
- correctTime /= 1000;
- Utils.drawText(gc, sep(correctTime) + "." + pad(ms) + " " + pad(mcs) + " " + pad(ns), rect, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Override
- public String hint() {
- return _hint;
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ long ns = nanosec % PAD_1000;
+ long microsec = nanosec / MICROSEC_IN_NS;
+ long us = microsec % PAD_1000;
+ long millisec = microsec / MILLISEC_IN_US;
+ long ms = millisec % PAD_1000;
+ long sec = millisec / SEC_IN_MS;
+ Utils.drawText(gc, sep(sec) + "." + pad(ms) + " " + pad(us) + " " + pad(ns), rect, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
class TimeDrawAbsYear extends TimeDraw {
- static String _hint = "YYYY"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = syearformat.format(new Date(time / 1000000));
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = YEAR_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
Utils.drawText(gc, stime, rect, true);
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsMonth extends TimeDraw {
- static String _hint = "YYYY Mmm"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = smonthformat.format(new Date(time / 1000000));
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = MONTH_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
Utils.drawText(gc, stime, rect, true);
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsDay extends TimeDraw {
- static String _hint = "Mmm dd"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = sdayformat.format(new Date(time / 1000000));
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = DAY_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
Utils.drawText(gc, stime, rect, true);
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = sdayformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = DAY_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsHrs extends TimeDraw {
- static String _hint = "Mmm dd HH:mm"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = shrsformat.format(new Date(time / 1000000));
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = HOURS_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
Utils.drawText(gc, stime, rect, true);
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = shrsformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = HOURS_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsMin extends TimeDraw {
- static String _hint = "HH:mm"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = sminformat.format(new Date(time / 1000000));
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = MIN_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
Utils.drawText(gc, stime, rect, true);
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = sminformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = MIN_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsSec extends TimeDraw {
- static String _hint = "HH:mm:ss"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = stimeformat.format(new Date(time / 1000000));
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = SEC_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
Utils.drawText(gc, stime, rect, true);
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = stimeformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsMillisec extends TimeDraw {
- static String _hint = "HH:ss:ms"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = stimeformat.format(new Date(time / 1000000));
- String ns = Utils.formatNs(time, Resolution.MILLISEC);
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = SEC_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
+ String ns = Utils.formatNs(nanosec, Resolution.MILLISEC);
Utils.drawText(gc, stime + "." + ns, rect, true); //$NON-NLS-1$
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = stimeformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsMicroSec extends TimeDraw {
- static String _hint = "HH:ss:ms:mcs"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = stimeformat.format(new Date(time / 1000000));
- String micr = Utils.formatNs(time, Resolution.MICROSEC);
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = SEC_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
+ String micr = Utils.formatNs(nanosec, Resolution.MICROSEC);
Utils.drawText(gc, stime + "." + micr, rect, true); //$NON-NLS-1$
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = stimeformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
class TimeDrawAbsNanoSec extends TimeDraw {
- static String _hint = "HH:ss:ms:mcs:ns"; //$NON-NLS-1$
-
@Override
- public void draw(GC gc, long time, Rectangle rect) {
- String stime = stimeformat.format(new Date(time / 1000000));
- String ns = Utils.formatNs(time, Resolution.NANOSEC);
+ public void draw(GC gc, long nanosec, Rectangle rect) {
+ String stime = SEC_FORMAT.format(new Date(nanosec / MILLISEC_IN_NS));
+ String ns = Utils.formatNs(nanosec, Resolution.NANOSEC);
Utils.drawText(gc, stime + "." + ns, rect, true); //$NON-NLS-1$
}
@Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = stimeformatheader.format(new Date(time / 1000000));
+ public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
+ String header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
int headerwidth = gc.stringExtent(header).x + 4;
if (headerwidth <= rect.width) {
rect.x += (rect.width - headerwidth);
Utils.drawText(gc, header, rect, true);
}
}
-
- @Override
- public String hint() {
- return _hint;
- }
}
-
class TimeDrawNumber extends TimeDraw {
-
@Override
public void draw(GC gc, long time, Rectangle rect) {
String stime = NumberFormat.getInstance().format(time);
Utils.drawText(gc, stime, rect, true);
}
-
- @Override
- public void drawAbsHeader(GC gc, long time, Rectangle rect) {
- String header = NumberFormat.getInstance().format(time);
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
- }
-
- @Override
- public String hint() {
- return "cycle"; //$NON-NLS-1$
- }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphSelection.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphSelection.java
index 408500ea96..6e9fd39c62 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphSelection.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphSelection.java
@@ -29,7 +29,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
*/
public class TimeGraphSelection implements IStructuredSelection {
- List<Object> list = new ArrayList<Object>();
+ private List<Object> list = new ArrayList<Object>();
/**
* Default constructor
@@ -45,7 +45,9 @@ public class TimeGraphSelection implements IStructuredSelection {
* The initial selection to add to this one
*/
public TimeGraphSelection(Object sel) {
- add(sel);
+ if (sel != null) {
+ list.add(sel);
+ }
}
/**
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java
index 7df5c1685d..035015850d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphTooltipHandler.java
@@ -48,45 +48,46 @@ import org.eclipse.swt.widgets.Shell;
*/
public class TimeGraphTooltipHandler {
- private Shell _tipShell;
- private Composite _tipComposite;
- private Point _tipPosition;
- private final ITimeDataProvider _timeDataProvider;
- ITimeGraphPresentationProvider _utilImp = null;
+ private static final int OFFSET = 16;
+
+ private Shell fTipShell;
+ private Composite fTipComposite;
+ private final ITimeDataProvider fTimeDataProvider;
+ private ITimeGraphPresentationProvider fTimeGraphProvider = null;
/**
* Standard constructor
*
- * @param parent
- * The parent shell (unused, can be null)
- * @param rUtilImpl
+ * @param graphProv
* The presentation provider
* @param timeProv
* The time provider
+ *
+ * @since 2.0
*/
- public TimeGraphTooltipHandler(Shell parent, ITimeGraphPresentationProvider rUtilImpl,
+ public TimeGraphTooltipHandler(ITimeGraphPresentationProvider graphProv,
ITimeDataProvider timeProv) {
- this._utilImp = rUtilImpl;
- this._timeDataProvider = timeProv;
+ this.fTimeGraphProvider = graphProv;
+ this.fTimeDataProvider = timeProv;
}
private void createTooltipShell(Shell parent) {
final Display display = parent.getDisplay();
- if (_tipShell != null && ! _tipShell.isDisposed()) {
- _tipShell.dispose();
+ if (fTipShell != null && ! fTipShell.isDisposed()) {
+ fTipShell.dispose();
}
- _tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL);
+ fTipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginWidth = 2;
gridLayout.marginHeight = 2;
- _tipShell.setLayout(gridLayout);
- _tipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ fTipShell.setLayout(gridLayout);
+ fTipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- _tipComposite = new Composite(_tipShell, SWT.NONE);
- _tipComposite.setLayout(new GridLayout(3, false));
- setupControl(_tipComposite);
+ fTipComposite = new Composite(fTipShell, SWT.NONE);
+ fTipComposite.setLayout(new GridLayout(3, false));
+ setupControl(fTipComposite);
}
@@ -100,8 +101,8 @@ public class TimeGraphTooltipHandler {
control.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
- if (_tipShell != null && ! _tipShell.isDisposed()) {
- _tipShell.dispose();
+ if (fTipShell != null && ! fTipShell.isDisposed()) {
+ fTipShell.dispose();
}
}
});
@@ -109,8 +110,8 @@ public class TimeGraphTooltipHandler {
control.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- if (_tipShell != null && ! _tipShell.isDisposed()) {
- _tipShell.dispose();
+ if (fTipShell != null && ! fTipShell.isDisposed()) {
+ fTipShell.dispose();
}
}
});
@@ -118,24 +119,24 @@ public class TimeGraphTooltipHandler {
control.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
- if (_tipShell != null && ! _tipShell.isDisposed()) {
+ if (fTipShell != null && ! fTipShell.isDisposed()) {
Point pt = control.toDisplay(e.x, e.y);
- if (! _tipShell.getBounds().contains(pt)) {
- _tipShell.dispose();
+ if (! fTipShell.getBounds().contains(pt)) {
+ fTipShell.dispose();
}
}
}
private void addItem(String name, String value) {
- Label nameLabel = new Label(_tipComposite, SWT.NO_FOCUS);
+ Label nameLabel = new Label(fTipComposite, SWT.NO_FOCUS);
nameLabel.setText(name);
setupControl(nameLabel);
- Label separator = new Label(_tipComposite, SWT.NO_FOCUS | SWT.SEPARATOR | SWT.VERTICAL);
+ Label separator = new Label(fTipComposite, SWT.NO_FOCUS | SWT.SEPARATOR | SWT.VERTICAL);
GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
gd.heightHint = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
separator.setLayoutData(gd);
setupControl(separator);
- Label valueLabel = new Label(_tipComposite, SWT.NO_FOCUS);
+ Label valueLabel = new Label(fTipComposite, SWT.NO_FOCUS);
valueLabel.setText(value);
setupControl(valueLabel);
}
@@ -156,18 +157,17 @@ public class TimeGraphTooltipHandler {
// if there is no current event at the start of the current pixel range,
// or if the current event starts before the current pixel range,
// use the next event as long as it starts within the current pixel range
- if (currEvent == null || currEvent.getTime() < currPixelTime) {
- if (nextEvent != null && nextEvent.getTime() < nextPixelTime) {
- currEvent = nextEvent;
- currPixelTime = nextEvent.getTime();
- }
+ if ((currEvent == null || currEvent.getTime() < currPixelTime) &&
+ (nextEvent != null && nextEvent.getTime() < nextPixelTime)) {
+ currEvent = nextEvent;
+ currPixelTime = nextEvent.getTime();
}
// state name
- String stateTypeName = _utilImp.getStateTypeName(entry);
+ String stateTypeName = fTimeGraphProvider.getStateTypeName(entry);
String entryName = entry.getName();
if (stateTypeName == null) {
- stateTypeName = _utilImp.getStateTypeName();
+ stateTypeName = fTimeGraphProvider.getStateTypeName();
}
if (!entryName.isEmpty()) {
@@ -179,13 +179,13 @@ public class TimeGraphTooltipHandler {
}
// state
- String state = _utilImp.getEventName(currEvent);
+ String state = fTimeGraphProvider.getEventName(currEvent);
if (state != null) {
addItem(Messages.TmfTimeTipHandler_TRACE_STATE, state);
}
// This block receives a list of <String, String> values to be added to the tip table
- Map<String, String> eventAddOns = _utilImp.getEventHoverToolTipInfo(currEvent, currPixelTime);
+ Map<String, String> eventAddOns = fTimeGraphProvider.getEventHoverToolTipInfo(currEvent, currPixelTime);
if (eventAddOns != null) {
for (Iterator<String> iter = eventAddOns.keySet().iterator(); iter.hasNext();) {
String message = iter.next();
@@ -207,7 +207,7 @@ public class TimeGraphTooltipHandler {
}
Resolution res = Resolution.NANOSEC;
- TimeFormat tf = _timeDataProvider.getTimeFormat();
+ TimeFormat tf = fTimeDataProvider.getTimeFormat();
if (tf == TimeFormat.CALENDAR) {
addItem(Messages.TmfTimeTipHandler_TRACE_DATE, eventStartTime > -1 ?
Utils.formatDate(eventStartTime)
@@ -248,18 +248,18 @@ public class TimeGraphTooltipHandler {
TimeGraphControl timeGraphControl = (TimeGraphControl) event.widget;
createTooltipShell(timeGraphControl.getShell());
ITimeGraphEntry entry = timeGraphControl.getEntry(pt);
- for (Control child : _tipComposite.getChildren()) {
+ for (Control child : fTipComposite.getChildren()) {
child.dispose();
}
fillValues(pt, timeGraphControl, entry);
- if (_tipComposite.getChildren().length == 0) {
+ if (fTipComposite.getChildren().length == 0) {
return;
}
- _tipShell.pack();
- _tipPosition = control.toDisplay(pt);
- _tipShell.pack();
- setHoverLocation(_tipShell, _tipPosition);
- _tipShell.setVisible(true);
+ fTipShell.pack();
+ Point tipPosition = control.toDisplay(pt);
+ fTipShell.pack();
+ setHoverLocation(fTipShell, tipPosition);
+ fTipShell.setVisible(true);
}
});
}
@@ -267,41 +267,41 @@ public class TimeGraphTooltipHandler {
private static void setHoverLocation(Shell shell, Point position) {
Rectangle displayBounds = shell.getDisplay().getBounds();
Rectangle shellBounds = shell.getBounds();
- if (position.x + shellBounds.width + 16 > displayBounds.width && position.x - shellBounds.width - 16 >= 0) {
- shellBounds.x = position.x - shellBounds.width - 16;
+ if (position.x + shellBounds.width + OFFSET > displayBounds.width && position.x - shellBounds.width - OFFSET >= 0) {
+ shellBounds.x = position.x - shellBounds.width - OFFSET;
} else {
- shellBounds.x = Math.max(Math.min(position.x + 16, displayBounds.width - shellBounds.width), 0);
+ shellBounds.x = Math.max(Math.min(position.x + OFFSET, displayBounds.width - shellBounds.width), 0);
}
- if (position.y + shellBounds.height + 16 > displayBounds.height && position.y - shellBounds.height - 16 >= 0) {
- shellBounds.y = position.y - shellBounds.height - 16;
+ if (position.y + shellBounds.height + OFFSET > displayBounds.height && position.y - shellBounds.height - OFFSET >= 0) {
+ shellBounds.y = position.y - shellBounds.height - OFFSET;
} else {
- shellBounds.y = Math.max(Math.min(position.y + 16, displayBounds.height - shellBounds.height), 0);
+ shellBounds.y = Math.max(Math.min(position.y + OFFSET, displayBounds.height - shellBounds.height), 0);
}
shell.setBounds(shellBounds);
}
private void setupControl(Control control) {
- control.setForeground(_tipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- control.setBackground(_tipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ control.setForeground(fTipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ control.setBackground(fTipShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
control.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
- _tipShell.dispose();
+ fTipShell.dispose();
}
});
control.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
- _tipShell.dispose();
+ fTipShell.dispose();
}
});
control.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- _tipShell.dispose();
+ fTipShell.dispose();
}
});
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
index aee9f428ed..298967c090 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
@@ -37,6 +37,9 @@ import org.eclipse.swt.widgets.Display;
*/
public class Utils {
+ private Utils() {
+ }
+
/** Time format for dates and timestamp */
public enum TimeFormat {
/** Relative to the start of the trace */
@@ -72,8 +75,10 @@ public class Utils {
NANOSEC
}
- static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
- static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
+ private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
+ private static final long SEC_IN_NS = 1000000000;
+ private static final long MILLISEC_IN_NS = 1000000;
static Rectangle clone(Rectangle source) {
return new Rectangle(source.x, source.y, source.width, source.height);
@@ -85,7 +90,7 @@ public class Utils {
* @param rect
* The Rectangle to initialize
*/
- static public void init(Rectangle rect) {
+ public static void init(Rectangle rect) {
rect.x = 0;
rect.y = 0;
rect.width = 0;
@@ -106,7 +111,7 @@ public class Utils {
* @param height
* The height of the rectangle
*/
- static public void init(Rectangle rect, int x, int y, int width, int height) {
+ public static void init(Rectangle rect, int x, int y, int width, int height) {
rect.x = x;
rect.y = y;
rect.width = width;
@@ -121,7 +126,7 @@ public class Utils {
* @param source
* The reference Rectangle to copy
*/
- static public void init(Rectangle rect, Rectangle source) {
+ public static void init(Rectangle rect, Rectangle source) {
rect.x = source.x;
rect.y = source.y;
rect.width = source.width;
@@ -138,7 +143,7 @@ public class Utils {
* @param y
* The reduction in height
*/
- static public void deflate(Rectangle rect, int x, int y) {
+ public static void deflate(Rectangle rect, int x, int y) {
rect.x += x;
rect.y += y;
rect.width -= x + x;
@@ -155,7 +160,7 @@ public class Utils {
* @param y
* The augmentation in height
*/
- static public void inflate(Rectangle rect, int x, int y) {
+ public static void inflate(Rectangle rect, int x, int y) {
rect.x -= x;
rect.y -= y;
rect.width += x + x;
@@ -184,7 +189,7 @@ public class Utils {
* The gamma level for color 2
* @return The resulting color
*/
- static public Color mixColors(Device display, Color c1, Color c2, int w1,
+ public static Color mixColors(Device display, Color c1, Color c2, int w1,
int w2) {
return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed())
/ (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen())
@@ -199,7 +204,7 @@ public class Utils {
* The color ID
* @return The resulting color
*/
- static public Color getSysColor(int id) {
+ public static Color getSysColor(int id) {
Color col = Display.getCurrent().getSystemColor(id);
return new Color(col.getDevice(), col.getRGB());
}
@@ -218,7 +223,7 @@ public class Utils {
* The gamma level for color 2
* @return The resulting color
*/
- static public Color mixColors(Color col1, Color col2, int w1, int w2) {
+ public static Color mixColors(Color col1, Color col2, int w1, int w2) {
return mixColors(Display.getCurrent(), col1, col2, w1, w2);
}
@@ -235,7 +240,7 @@ public class Utils {
* Should we transpose the color
* @return The X coordinate where we have written
*/
- static public int drawText(GC gc, String text, Rectangle rect, boolean transp) {
+ public static int drawText(GC gc, String text, Rectangle rect, boolean transp) {
Point size = gc.stringExtent(text);
gc.drawText(text, rect.x, rect.y, transp);
return size.x;
@@ -256,7 +261,7 @@ public class Utils {
* Should we transpose the color
* @return The X coordinate where we have written
*/
- static public int drawText(GC gc, String text, int x, int y, boolean transp) {
+ public static int drawText(GC gc, String text, int x, int y, boolean transp) {
Point size = gc.stringExtent(text);
gc.drawText(text, x, y, transp);
return size.x;
@@ -283,7 +288,7 @@ public class Utils {
*
* @since 2.0
*/
- static public int drawText(GC gc, String text, int x, int y, int width, boolean isCentered, boolean isTransparent) {
+ public static int drawText(GC gc, String text, int x, int y, int width, boolean isCentered, boolean isTransparent) {
int len = text.length();
int textWidth = 0;
boolean isReallyCentered = isCentered;
@@ -314,7 +319,7 @@ public class Utils {
* @param resolution the resolution
* @return the formatted time
*/
- static public String formatTime(long time, TimeFormat format, Resolution resolution) {
+ public static String formatTime(long time, TimeFormat format, Resolution resolution) {
// if format is absolute (Calendar)
if (format == TimeFormat.CALENDAR) {
return formatTimeAbs(time, resolution);
@@ -330,16 +335,7 @@ public class Utils {
str.append('-');
}
- long sec = (long) (t * 1E-9);
- // TODO: Expand to make it possible to select the minute, second, nanosecond format
- //printing minutes is suppressed just sec and ns
- // if (sec / 60 < 10)
- // str.append('0');
- // str.append(sec / 60);
- // str.append(':');
- // sec %= 60;
- // if (sec < 10)
- // str.append('0');
+ long sec = t / SEC_IN_NS;
str.append(sec);
String ns = formatNs(t, resolution);
if (!ns.equals("")) { //$NON-NLS-1$
@@ -358,7 +354,7 @@ public class Utils {
* @return the formatted date
*/
public static String formatDate(long absTime) {
- String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));
+ String sdate = DATE_FORMAT.format(new Date(absTime / MILLISEC_IN_NS));
return sdate;
}
@@ -371,11 +367,11 @@ public class Utils {
* The resolution to use
* @return the formatted time
*/
- static public String formatTimeAbs(long time, Resolution res) {
+ public static String formatTimeAbs(long time, Resolution res) {
StringBuffer str = new StringBuffer();
// format time from nanoseconds to calendar time HH:MM:SS
- String stime = stimeformat.format(new Date((long) (time * 1E-6)));
+ String stime = TIME_FORMAT.format(new Date(time / MILLISEC_IN_NS));
str.append(stime);
str.append('.');
// append the Milliseconds, MicroSeconds and NanoSeconds as specified in
@@ -399,36 +395,15 @@ public class Utils {
public static String formatNs(long srcTime, Resolution res) {
StringBuffer str = new StringBuffer();
long time = srcTime;
- boolean neg = time < 0;
- if (neg) {
+ if (time < 0) {
time = -time;
}
- // The following approach could be used although performance
- // decreases in half.
- // String strVal = String.format("%09d", time);
- // String tmp = strVal.substring(strVal.length() - 9);
-
long ns = time;
- ns %= 1000000000;
- if (ns < 10) {
- str.append("00000000"); //$NON-NLS-1$
- } else if (ns < 100) {
- str.append("0000000"); //$NON-NLS-1$
- } else if (ns < 1000) {
- str.append("000000"); //$NON-NLS-1$
- } else if (ns < 10000) {
- str.append("00000"); //$NON-NLS-1$
- } else if (ns < 100000) {
- str.append("0000"); //$NON-NLS-1$
- } else if (ns < 1000000) {
- str.append("000"); //$NON-NLS-1$
- } else if (ns < 10000000) {
- str.append("00"); //$NON-NLS-1$
- } else if (ns < 100000000) {
- str.append("0"); //$NON-NLS-1$
- }
- str.append(ns);
+ ns %= SEC_IN_NS;
+ String nanos = Long.toString(ns);
+ str.append("000000000".substring(nanos.length())); //$NON-NLS-1$
+ str.append(nanos);
if (res == Resolution.MILLISEC) {
return str.substring(0, 3);
@@ -453,15 +428,7 @@ public class Utils {
* The maximal accepted value
* @return The value that was read
*/
- static public int loadIntOption(String opt, int def, int min, int max) {
- // int val =
- // TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);
- // if (0 == val)
- // val = def;
- // if (val < min)
- // val = min;
- // if (val > max)
- // val = max;
+ public static int loadIntOption(String opt, int def, int min, int max) {
return def;
}
@@ -473,8 +440,7 @@ public class Utils {
* @param val
* The option value
*/
- static public void saveIntOption(String opt, int val) {
- // TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);
+ public static void saveIntOption(String opt, int val) {
}
static ITimeEvent getFirstEvent(ITimeGraphEntry entry) {
@@ -554,7 +520,7 @@ public class Utils {
* The original signature
* @return The pretty signature
*/
- static public String fixMethodSignature(String origSig) {
+ public static String fixMethodSignature(String origSig) {
String sig = origSig;
int pos = sig.indexOf('(');
if (pos >= 0) {
@@ -572,7 +538,7 @@ public class Utils {
* The pretty-printed signature
* @return The original method signature
*/
- static public String restoreMethodSignature(String ppSig) {
+ public static String restoreMethodSignature(String ppSig) {
String ret = ""; //$NON-NLS-1$
String sig = ppSig;
@@ -660,7 +626,7 @@ public class Utils {
* same number obtained in two different ways to actually look
* different.
*/
- static public int compare(double d1, double d2) {
+ public static int compare(double d1, double d2) {
if (d1 > d2) {
return 1;
}
@@ -683,7 +649,7 @@ public class Utils {
* is smaller, equal, or bigger (alphabetically) than the second
* one.
*/
- static public int compare(String s1, String s2) {
+ public static int compare(String s1, String s2) {
if (s1 != null && s2 != null) {
return s1.compareToIgnoreCase(s2);
}

Back to the top