import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalThrottler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
private static TimeRangeHistogram fTimeRangeHistogram;
private HistogramRequest fTimeRangeRequest;
+ // Throttlers for the time sync and time-range sync signals
+ private final TmfSignalThrottler fTimeSyncThrottle;
+ private final TmfSignalThrottler fTimeRangeSyncThrottle;
+
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
*/
public HistogramView() {
super(ID);
+ fTimeSyncThrottle = new TmfSignalThrottler(this, 200);
+ fTimeRangeSyncThrottle = new TmfSignalThrottler(this, 200);
}
@Override
@Override
public void handleData(ITmfEvent event) {
if (event != null) {
- TmfTimeSynchSignal signal = new TmfTimeSynchSignal(this, event.getTimestamp());
- TmfSignalManager.dispatchSignal(signal);
+ ITmfTimestamp ts = event.getTimestamp();
+ updateDisplayedCurrentTime(ts.normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
+ TmfTimeSynchSignal signal = new TmfTimeSynchSignal(this, ts);
+ fTimeSyncThrottle.queue(signal);
}
}
};
ITmfTimestamp currentTime = new TmfTimestamp(fCurrentTimestamp, ITmfTimestamp.NANOSECOND_SCALE);
fTimeSpanControl.setValue(endTime - startTime);
+ updateDisplayedTimeRange(startTime, endTime);
+
// Send the FW signal
TmfRangeSynchSignal signal = new TmfRangeSynchSignal(this, timeRange, currentTime);
- TmfSignalManager.dispatchSignal(signal);
+ fTimeRangeSyncThrottle.queue(signal);
}
}
// Update the selected event time
ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
- fCurrentTimestamp = currentTime.getValue();
-
- // Notify the relevant widgets
- fFullTraceHistogram.setCurrentEvent(fCurrentTimestamp);
- fTimeRangeHistogram.setCurrentEvent(fCurrentTimestamp);
- fCurrentEventTimeControl.setValue(fCurrentTimestamp);
+ updateDisplayedCurrentTime(currentTime.getValue());
}
/**
return;
}
- // Update the time range
- fWindowStartTime = range.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
- fWindowEndTime = range.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
- fWindowSpan = fWindowEndTime - fWindowStartTime;
+ updateDisplayedTimeRange(
+ range.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(),
+ range.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
- // Notify the relevant widgets
+ // Send the event request to populate the small histogram
sendTimeRangeRequest(fWindowStartTime, fWindowEndTime);
- fFullTraceHistogram.setTimeRange(fWindowStartTime, fWindowSpan);
fTimeSpanControl.setValue(fWindowSpan);
}
}
}
+ private void updateDisplayedCurrentTime(long time) {
+ fCurrentTimestamp = time;
+
+ fFullTraceHistogram.setCurrentEvent(fCurrentTimestamp);
+ fTimeRangeHistogram.setCurrentEvent(fCurrentTimestamp);
+ fCurrentEventTimeControl.setValue(fCurrentTimestamp);
+ }
+
+ private void updateDisplayedTimeRange(long start, long end) {
+ fWindowStartTime = start;
+ fWindowEndTime = end;
+ fWindowSpan = fWindowEndTime - fWindowStartTime;
+ fFullTraceHistogram.setTimeRange(fWindowStartTime, fWindowSpan);
+ }
+
private TmfTimeRange updateTraceTimeRange() {
fTraceStartTime = 0L;
fTraceEndTime = 0L;
private long fRangeStartTime;
private long fRangeDuration;
- private MouseScrollCounter fScrollCounter;
-
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
- /**
- * Stops the zooming (multiple consecutive execution)
- */
- public synchronized void stop() {
- if (fScrollCounter != null) {
- fScrollCounter.interrupt();
- fScrollCounter = null;
- }
- }
-
/**
* The the full time range of the histogram
*
@Override
public synchronized void mouseScrolled(MouseEvent event) {
- if (fScrollCounter == null) {
- fScrollCounter = new MouseScrollCounter(this);
- fScrollCounter.start();
- }
- fScrollCounter.incrementMouseScroll(event.count);
+ zoom(event.count);
}
private synchronized void zoom(int nbClicks) {
- // The job is finished
- fScrollCounter = null;
-
// Compute the new time range
long requestedRange = (nbClicks > 0) ? Math.round(ZOOM_FACTOR * fRangeDuration) : (long) Math.ceil(fRangeDuration * (1.0 / ZOOM_FACTOR));
}
return realEnd;
}
-
- // ------------------------------------------------------------------------
- // DelayedMouseScroll
- // ------------------------------------------------------------------------
-
- private static class MouseScrollCounter extends Thread {
-
- // --------------------------------------------------------------------
- // Constants
- // --------------------------------------------------------------------
-
- private final static long QUIET_TIME = 100L;
- private final static long POLLING_INTERVAL = 10L;
-
- // --------------------------------------------------------------------
- // Attributes
- // --------------------------------------------------------------------
-
- private HistogramZoom fZoom = null;
-
- private long fLastPoolTime = 0L;
- private int nbScrollClick = 0;
-
- // --------------------------------------------------------------------
- // Constructors
- // --------------------------------------------------------------------
-
- /**
- * Constructor of inner class to handle consecutive scrolls of mouse wheel.
- * @param zoom the histogram zoom reference
- */
- public MouseScrollCounter(HistogramZoom zoom) {
- fZoom = zoom;
- fLastPoolTime = System.currentTimeMillis();
- }
-
- // --------------------------------------------------------------------
- // Operation
- // --------------------------------------------------------------------
-
- /**
- * Increments the number of scroll clicks.
- * @param nbScrolls the number to add to the current value
- */
- public void incrementMouseScroll(int nbScrolls) {
- fLastPoolTime = System.currentTimeMillis();
- nbScrollClick += nbScrolls;
- }
-
- // --------------------------------------------------------------------
- // Thread
- // --------------------------------------------------------------------
-
- @Override
- public void run() {
- while ((System.currentTimeMillis() - fLastPoolTime) < QUIET_TIME) {
- try {
- Thread.sleep(POLLING_INTERVAL);
- } catch (Exception e) {
- return;
- }
- }
- // Done waiting. Notify the histogram.
- if (!isInterrupted()) {
- fZoom.zoom(nbScrollClick);
- }
- }
- }
-
}