/*****************************************************************************
- * Copyright (c) 2007, 2008 Intel Corporation, 2009, 2010, 2011, 2012 Ericsson.
+ * Copyright (c) 2007, 2013 Intel Corporation, 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
* Alexander N. Alexeev, Intel - Add monitors statistics support
* Alvaro Sanchez-Leon - Adapted for TMF
* Patrick Tasse - Refactoring
- *
*****************************************************************************/
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;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TimeGraphLegend;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider2;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphScale;
* @version 1.0
* @author Patrick Tasse, and others
*/
-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;
+public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
+
+ 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 ITimeGraphEntry fSelectedEntry;
+ private long fBeginTime;
+ private long fEndTime;
+ private long fTime0;
+ private long fTime1;
+ private long fSelectionBegin = 0;
+ private long fSelectionEnd = 0;
+ 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
*/
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);
}
/**
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;
+ fSelectionBegin = 0;
+ fSelectionEnd = 0;
+ fSelectedEntry = null;
refreshAllData(realInput);
}
}
* Refresh the view
*/
public void refresh() {
- setInput(_stateCtrl.getTraces());
+ setTimeRange(fTimeGraphCtrl.getTraces());
+ fVerticalScrollBar.setEnabled(true);
+ refreshAllData(fTimeGraphCtrl.getTraces());
}
/**
*/
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();
}
}
}
}
void loadOptions() {
- _minTimeInterval = 1;
- _selectedTime = -1;
- _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
- _nameWidthPref, _minNameWidth, 1000);
+ fMinTimeInterval = 1;
+ fSelectionBegin = -1;
+ fSelectionEnd = -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$
}
/**
*/
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.setTimeGraphScale(fTimeScaleCtrl);
+ 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;
}
/**
*/
public void dispose() {
saveOptions();
- _stateCtrl.dispose();
- _dataViewer.dispose();
- _colors.dispose();
+ fTimeGraphCtrl.dispose();
+ fDataViewer.dispose();
+ fColorScheme.dispose();
}
/**
* 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();
}
* 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;
}
}
* 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);
}
}
// individual processes
setTimeRange(realTraces);
} else {
- _beginTime = start;
- _endTime = end;
+ fBeginTime = start;
+ fEndTime = end;
}
refreshAllData(realTraces);
*/
private void refreshAllData(ITimeGraphEntry[] traces) {
setTimeBounds();
- if (_selectedTime < _beginTime) {
- _selectedTime = _beginTime;
- } else if (_selectedTime > _endTime) {
- _selectedTime = _endTime;
+ if (fSelectionBegin < fBeginTime) {
+ fSelectionBegin = fBeginTime;
+ } else if (fSelectionBegin > fEndTime) {
+ fSelectionBegin = fEndTime;
+ }
+ if (fSelectionEnd < fBeginTime) {
+ fSelectionEnd = fBeginTime;
+ } else if (fSelectionEnd > fEndTime) {
+ fSelectionEnd = fEndTime;
}
- _stateCtrl.refreshData(traces);
- _timeScaleCtrl.redraw();
+ fTimeGraphCtrl.refreshData(traces);
+ fTimeScaleCtrl.redraw();
adjustVerticalScrollBar();
}
* Callback for when this view is focused
*/
public void setFocus() {
- if (null != _stateCtrl) {
- _stateCtrl.setFocus();
+ if (null != fTimeGraphCtrl) {
+ fTimeGraphCtrl.setFocus();
}
}
* @return If the view is currently focused, or not
*/
public boolean isInFocus() {
- return _stateCtrl.isInFocus();
+ return fTimeGraphCtrl.isInFocus();
}
/**
* @return The entry that is selected
*/
public ITimeGraphEntry getSelection() {
- return _stateCtrl.getSelectedTrace();
+ return fTimeGraphCtrl.getSelectedTrace();
}
/**
* @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;
}
+ @SuppressWarnings("deprecation")
+ @Deprecated
@Override
public long getSelectedTime() {
- return _selectedTime;
+ return fSelectionBegin;
}
@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;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider
- * #setStartFinishTimeNotify(long, long)
+ /**
+ * @since 3.0
*/
+ @Override
+ public long getSelectionBegin() {
+ return fSelectionBegin;
+ }
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public long getSelectionEnd() {
+ return fSelectionEnd;
+ }
+
@Override
public void setStartFinishTimeNotify(long time0, long time1) {
setStartFinishTime(time0, time1);
notifyRangeListeners(time0, time1);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()
- */
@Override
public void notifyStartFinishTime() {
- notifyRangeListeners(_time0, _time1);
+ notifyRangeListeners(fTime0, fTime1);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider
- * #setStartFinishTime(long, long)
- */
@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();
}
/**
* 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
setSelectedTimeInt(time, ensureVisible, false);
}
+ /**
+ * @since 3.0
+ */
+ @Override
+ public void setSelectionRangeNotify(long beginTime, long endTime) {
+ boolean changed = (beginTime != fSelectionBegin || endTime != fSelectionEnd);
+ fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime));
+ fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime));
+ fTimeGraphCtrl.redraw();
+ fTimeScaleCtrl.redraw();
+ if (changed) {
+ notifyTimeListeners(fSelectionBegin, fSelectionEnd);
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public void setSelectionRange(long beginTime, long endTime) {
+ fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime));
+ fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime));
+ fTimeGraphCtrl.redraw();
+ fTimeScaleCtrl.redraw();
+ }
+
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 != fSelectionBegin || time != fSelectionEnd);
+ fSelectionBegin = time;
+ fSelectionEnd = time;
- boolean notifySelectedTime = (time != _selectedTime);
- _selectedTime = 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(fSelectionBegin, fSelectionEnd);
}
}
@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);
}
}
* Callback for when the next event is selected
*/
public void selectNextEvent() {
- _stateCtrl.selectNextEvent();
+ fTimeGraphCtrl.selectNextEvent();
adjustVerticalScrollBar();
}
* Callback for when the previous event is selected
*/
public void selectPrevEvent() {
- _stateCtrl.selectPrevEvent();
+ fTimeGraphCtrl.selectPrevEvent();
adjustVerticalScrollBar();
}
* Callback for when the next item is selected
*/
public void selectNextItem() {
- _stateCtrl.selectNextTrace();
+ fTimeGraphCtrl.selectNextTrace();
adjustVerticalScrollBar();
}
* Callback for when the previous item is selected
*/
public void selectPrevItem() {
- _stateCtrl.selectPrevTrace();
+ fTimeGraphCtrl.selectPrevTrace();
adjustVerticalScrollBar();
}
* 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) {
fTimeListeners.remove(listener);
}
- private void notifyTimeListeners(long time) {
- TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, time);
+ private void notifyTimeListeners(long startTime, long endTime) {
+ TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, startTime, endTime);
for (ITimeGraphTimeListener listener : fTimeListeners) {
listener.timeSelected(event);
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);
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();
if (trace == null || source == this) {
return;
}
- _selectedEntry = trace;
- _stateCtrl.selectItem(trace, false);
+ fSelectedEntry = trace;
+ fTimeGraphCtrl.selectItem(trace, false);
setSelectedTimeInt(time, true, true);
}
* The trace that was selected
*/
public void setSelection(ITimeGraphEntry trace) {
- _selectedEntry = trace;
- _stateCtrl.selectItem(trace, false);
+ fSelectedEntry = trace;
+ fTimeGraphCtrl.selectItem(trace, false);
adjustVerticalScrollBar();
}
*/
private void updateExtSynchTimers() {
// last time notification cache
- _time0_extSynch = _time0;
- _time1_extSynch = _time1;
+ fTime0ExtSynch = fTime0;
+ fTime1ExtSynch = fTime1;
}
/**
*/
@Override
public TimeFormat getTimeFormat() {
- return timeFormat;
+ return fTimeFormat;
}
/**
* @since 2.0
*/
public void setTimeFormat(TimeFormat tf) {
- this.timeFormat = tf;
+ this.fTimeFormat = tf;
}
/**
* @return The width
*/
public int getBorderWidth() {
- return borderWidth;
+ return fBorderWidth;
}
/**
*/
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;
}
}
* @return The height
*/
public int getHeaderHeight() {
- return timeScaleHeight;
+ return fTimeScaleHeight;
}
/**
*/
public void setHeaderHeight(int headerHeight) {
if (headerHeight > -1) {
- this.timeScaleHeight = headerHeight;
- _timeScaleCtrl.setHeight(headerHeight);
+ this.fTimeScaleHeight = headerHeight;
+ fTimeScaleCtrl.setHeight(headerHeight);
}
}
* @return The height
*/
public int getItemHeight() {
- if (_stateCtrl != null) {
- return _stateCtrl.getItemHeight();
+ if (fTimeGraphCtrl != null) {
+ return fTimeGraphCtrl.getItemHeight();
}
return 0;
}
* The height to set
*/
public void setItemHeight(int rowHeight) {
- if (_stateCtrl != null) {
- _stateCtrl.setItemHeight(rowHeight);
+ if (fTimeGraphCtrl != null) {
+ fTimeGraphCtrl.setItemHeight(rowHeight);
}
}
* The min width
*/
public void setMinimumItemWidth(int width) {
- if (_stateCtrl != null) {
- _stateCtrl.setMinimumItemWidth(width);
+ if (fTimeGraphCtrl != null) {
+ fTimeGraphCtrl.setMinimumItemWidth(width);
}
}
* @param width The width
*/
public void setNameWidthPref(int width) {
- _nameWidthPref = width;
+ fNameWidthPref = width;
if (width == 0) {
- _minNameWidth = 0;
- _nameWidth = 0;
+ fMinNameWidth = 0;
+ fNameWidth = 0;
}
}
* @return The width
*/
public int getNameWidthPref(int width) {
- return _nameWidthPref;
+ return fNameWidthPref;
}
/**
* @return the SWT control which displays this viewer's content
*/
public Control getControl() {
- return _dataViewer;
+ return fDataViewer;
}
/**
* Returns the time graph control associated with this viewer.
*
* @return the time graph control
+ * @since 2.0
*/
- TimeGraphControl getTimeGraphControl() {
- return _stateCtrl;
+ public TimeGraphControl getTimeGraphControl() {
+ return fTimeGraphCtrl;
}
/**
* Returns the time graph scale associated with this viewer.
*
* @return the time graph scale
+ * @since 2.0
*/
- TimeGraphScale getTimeGraphScale() {
- return _timeScaleCtrl;
+ public TimeGraphScale getTimeGraphScale() {
+ return fTimeScaleCtrl;
}
/**
* @since 2.0
*/
public int getXForTime(long time) {
- return _stateCtrl.getXForTime(time);
+ return fTimeGraphCtrl.getXForTime(time);
}
/**
* @since 2.0
*/
public long getTimeAtX(int x) {
- return _stateCtrl.getTimeAtX(x);
+ return fTimeGraphCtrl.getTimeAtX(x);
}
/**
* @return the selection provider
*/
public ISelectionProvider getSelectionProvider() {
- return _stateCtrl;
+ return fTimeGraphCtrl;
}
/**
* Wait indefinitely?
*/
public void waitCursor(boolean waitInd) {
- _stateCtrl.waitCursor(waitInd);
+ fTimeGraphCtrl.waitCursor(waitInd);
}
/**
* @return The scroll bar
*/
public ScrollBar getHorizontalBar() {
- return _stateCtrl.getHorizontalBar();
+ return fTimeGraphCtrl.getHorizontalBar();
}
/**
* @return The scroll bar
*/
public Slider getVerticalBar() {
- return _verticalScrollBar;
+ return fVerticalScrollBar;
}
/**
* The index that will go to the top
*/
public void setTopIndex(int index) {
- _stateCtrl.setTopIndex(index);
+ fTimeGraphCtrl.setTopIndex(index);
adjustVerticalScrollBar();
}
* @return The top index
*/
public int getTopIndex() {
- return _stateCtrl.getTopIndex();
+ return fTimeGraphCtrl.getTopIndex();
}
/**
* True for expanded, false for collapsed
*/
public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {
- _stateCtrl.setExpandedState(entry, expanded);
+ fTimeGraphCtrl.setExpandedState(entry, expanded);
adjustVerticalScrollBar();
}
* @since 2.0
*/
public void collapseAll() {
- _stateCtrl.collapseAll();
+ fTimeGraphCtrl.collapseAll();
adjustVerticalScrollBar();
}
* @since 2.0
*/
public void expandAll() {
- _stateCtrl.expandAll();
+ fTimeGraphCtrl.expandAll();
adjustVerticalScrollBar();
}
* @return The element count
*/
public int getExpandedElementCount() {
- return _stateCtrl.getExpandedElementCount();
+ return fTimeGraphCtrl.getExpandedElementCount();
}
/**
* @return The array of entries that are below this one
*/
public ITimeGraphEntry[] getExpandedElements() {
- return _stateCtrl.getExpandedElements();
+ return fTimeGraphCtrl.getExpandedElements();
}
/**
* The listener to add
*/
public void addTreeListener(ITimeGraphTreeListener listener) {
- _stateCtrl.addTreeListener(listener);
+ fTimeGraphCtrl.addTreeListener(listener);
}
/**
* The listener to remove
*/
public void removeTreeListener(ITimeGraphTreeListener listener) {
- _stateCtrl.removeTreeListener(listener);
+ fTimeGraphCtrl.removeTreeListener(listener);
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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);
}
/**
* @since 1.2
*/
public void addTimeGraphEntryMenuListener(MenuDetectListener listener) {
- _stateCtrl.addTimeGraphEntryMenuListener(listener);
+ fTimeGraphCtrl.addTimeGraphEntryMenuListener(listener);
}
/**
* @since 1.2
*/
public void removeTimeGraphEntryMenuListener(MenuDetectListener listener) {
- _stateCtrl.removeTimeGraphEntryMenuListener(listener);
+ fTimeGraphCtrl.removeTimeGraphEntryMenuListener(listener);
}
/**
* @since 1.2
*/
public void addTimeEventMenuListener(MenuDetectListener listener) {
- _stateCtrl.addTimeEventMenuListener(listener);
+ fTimeGraphCtrl.addTimeEventMenuListener(listener);
}
/**
* @since 1.2
*/
public void removeTimeEventMenuListener(MenuDetectListener listener) {
- _stateCtrl.removeTimeEventMenuListener(listener);
+ fTimeGraphCtrl.removeTimeEventMenuListener(listener);
}
/**
* @since 2.0
*/
public void addFilter(ViewerFilter filter) {
- _stateCtrl.addFilter(filter);
+ fTimeGraphCtrl.addFilter(filter);
refresh();
}
* @since 2.0
*/
public void removeFilter(ViewerFilter filter) {
- _stateCtrl.removeFilter(filter);
+ fTimeGraphCtrl.removeFilter(filter);
refresh();
}