tmf: Add support for time range selection
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramView.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * William Bourque - Initial API and implementation
11 * Yuriy Vashchuk - GUI reorganisation, simplification and some related code improvements.
12 * Yuriy Vashchuk - Histograms optimisation.
13 * Yuriy Vashchuk - Histogram Canvas Heritage correction
14 * Francois Chouinard - Cleanup and refactoring
15 * Francois Chouinard - Moved from LTTng to TMF
16 * Patrick Tasse - Update for mouse wheel zoom
17 *******************************************************************************/
18
19 package org.eclipse.linuxtools.tmf.ui.views.histogram;
20
21 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
22 import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
23 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
24 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
25 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalThrottler;
26 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
27 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
28 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
29 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
30 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
31 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
32 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
33 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
34 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
35 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
36 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
37 import org.eclipse.swt.SWT;
38 import org.eclipse.swt.events.MouseWheelListener;
39 import org.eclipse.swt.layout.GridData;
40 import org.eclipse.swt.layout.GridLayout;
41 import org.eclipse.swt.widgets.Composite;
42
43 /**
44 * The purpose of this view is to provide graphical time distribution statistics about the trace events.
45 * <p>
46 * The view is composed of two histograms and two controls:
47 * <ul>
48 * <li>an event distribution histogram for the whole trace;
49 * <li>an event distribution histogram for current time window (window span);
50 * <li>the timestamp of the currently selected event;
51 * <li>the window span (size of the time window of the smaller histogram).
52 * </ul>
53 * The histograms x-axis show their respective time range.
54 *
55 * @version 2.0
56 * @author Francois Chouinard
57 */
58 public class HistogramView extends TmfView {
59
60 // ------------------------------------------------------------------------
61 // Constants
62 // ------------------------------------------------------------------------
63
64 /**
65 * The view ID as defined in plugin.xml
66 */
67 public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.histogram"; //$NON-NLS-1$
68
69 // ------------------------------------------------------------------------
70 // Attributes
71 // ------------------------------------------------------------------------
72
73 // Parent widget
74 private Composite fParent;
75
76 // The current trace
77 private ITmfTrace fTrace;
78
79 // Current timestamp/time window - everything in the TIME_SCALE
80 private long fTraceStartTime;
81 private long fTraceEndTime;
82 private long fWindowStartTime;
83 private long fWindowEndTime;
84 private long fWindowSpan;
85 private long fSelectionBeginTime;
86 private long fSelectionEndTime;
87
88 // Time controls
89 private HistogramTextControl fCurrentEventTimeControl;
90 private HistogramTextControl fTimeSpanControl;
91
92 // Histogram/request for the full trace range
93 private static FullTraceHistogram fFullTraceHistogram;
94 private HistogramRequest fFullTraceRequest;
95
96 // Histogram/request for the selected time range
97 private static TimeRangeHistogram fTimeRangeHistogram;
98 private HistogramRequest fTimeRangeRequest;
99
100 // Throttlers for the time sync and time-range sync signals
101 private final TmfSignalThrottler fTimeSyncThrottle;
102 private final TmfSignalThrottler fTimeRangeSyncThrottle;
103
104 // ------------------------------------------------------------------------
105 // Constructor
106 // ------------------------------------------------------------------------
107
108 /**
109 * Default constructor
110 */
111 public HistogramView() {
112 super(ID);
113 fTimeSyncThrottle = new TmfSignalThrottler(this, 200);
114 fTimeRangeSyncThrottle = new TmfSignalThrottler(this, 200);
115 }
116
117 @Override
118 public void dispose() {
119 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
120 fTimeRangeRequest.cancel();
121 }
122 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
123 fFullTraceRequest.cancel();
124 }
125 fFullTraceHistogram.dispose();
126 fTimeRangeHistogram.dispose();
127 fCurrentEventTimeControl.dispose();
128 fTimeSpanControl.dispose();
129 super.dispose();
130 }
131
132 // ------------------------------------------------------------------------
133 // TmfView
134 // ------------------------------------------------------------------------
135
136 @Override
137 public void createPartControl(Composite parent) {
138
139 fParent = parent;
140
141 // Control labels
142 final String currentEventLabel = Messages.HistogramView_currentEventLabel;
143 final String windowSpanLabel = Messages.HistogramView_windowSpanLabel;
144
145 // --------------------------------------------------------------------
146 // Set the HistogramView layout
147 // --------------------------------------------------------------------
148
149 Composite viewComposite = new Composite(fParent, SWT.FILL);
150 GridLayout gridLayout = new GridLayout();
151 gridLayout.numColumns = 2;
152 gridLayout.horizontalSpacing = 5;
153 gridLayout.verticalSpacing = 0;
154 gridLayout.marginHeight = 0;
155 gridLayout.marginWidth = 0;
156 viewComposite.setLayout(gridLayout);
157
158 // Use all available space
159 GridData gridData = new GridData();
160 gridData.horizontalAlignment = SWT.FILL;
161 gridData.verticalAlignment = SWT.FILL;
162 gridData.grabExcessHorizontalSpace = true;
163 viewComposite.setLayoutData(gridData);
164
165 // --------------------------------------------------------------------
166 // Time controls
167 // --------------------------------------------------------------------
168
169 Composite controlsComposite = new Composite(viewComposite, SWT.FILL);
170 gridLayout = new GridLayout();
171 gridLayout.numColumns = 2;
172 gridLayout.marginHeight = 0;
173 gridLayout.marginWidth = 0;
174 gridLayout.horizontalSpacing = 5;
175 gridLayout.verticalSpacing = 0;
176 gridLayout.makeColumnsEqualWidth = false;
177 gridLayout.marginLeft = 5;
178 gridLayout.marginRight = 5;
179 controlsComposite.setLayout(gridLayout);
180
181 // Current event time control
182 gridData = new GridData();
183 gridData.horizontalAlignment = SWT.CENTER;
184 gridData.verticalAlignment = SWT.CENTER;
185 fCurrentEventTimeControl = new HistogramCurrentTimeControl(this, controlsComposite, currentEventLabel, 0L);
186 fCurrentEventTimeControl.setLayoutData(gridData);
187 fCurrentEventTimeControl.setValue(Long.MIN_VALUE);
188
189 // Window span time control
190 gridData = new GridData();
191 gridData.horizontalAlignment = SWT.CENTER;
192 gridData.verticalAlignment = SWT.CENTER;
193 fTimeSpanControl = new HistogramTimeRangeControl(this, controlsComposite, windowSpanLabel, 0L);
194 fTimeSpanControl.setLayoutData(gridData);
195 fTimeSpanControl.setValue(Long.MIN_VALUE);
196
197 // --------------------------------------------------------------------
198 // Time range histogram
199 // --------------------------------------------------------------------
200
201 Composite timeRangeComposite = new Composite(viewComposite, SWT.FILL);
202 gridLayout = new GridLayout();
203 gridLayout.numColumns = 1;
204 gridLayout.marginHeight = 0;
205 gridLayout.marginWidth = 0;
206 gridLayout.marginTop = 5;
207 gridLayout.horizontalSpacing = 0;
208 gridLayout.verticalSpacing = 0;
209 gridLayout.marginLeft = 5;
210 gridLayout.marginRight = 5;
211 timeRangeComposite.setLayout(gridLayout);
212
213 // Use remaining horizontal space
214 gridData = new GridData();
215 gridData.horizontalAlignment = SWT.FILL;
216 gridData.verticalAlignment = SWT.FILL;
217 gridData.grabExcessHorizontalSpace = true;
218 timeRangeComposite.setLayoutData(gridData);
219
220 // Histogram
221 fTimeRangeHistogram = new TimeRangeHistogram(this, timeRangeComposite);
222
223 // --------------------------------------------------------------------
224 // Full range histogram
225 // --------------------------------------------------------------------
226
227 Composite fullRangeComposite = new Composite(viewComposite, SWT.FILL);
228 gridLayout = new GridLayout();
229 gridLayout.numColumns = 1;
230 gridLayout.marginHeight = 0;
231 gridLayout.marginWidth = 0;
232 gridLayout.marginTop = 5;
233 gridLayout.horizontalSpacing = 0;
234 gridLayout.verticalSpacing = 0;
235 gridLayout.marginLeft = 5;
236 gridLayout.marginRight = 5;
237 fullRangeComposite.setLayout(gridLayout);
238
239 // Use remaining horizontal space
240 gridData = new GridData();
241 gridData.horizontalAlignment = SWT.FILL;
242 gridData.verticalAlignment = SWT.FILL;
243 gridData.horizontalSpan = 2;
244 gridData.grabExcessHorizontalSpace = true;
245 fullRangeComposite.setLayoutData(gridData);
246
247 // Histogram
248 fFullTraceHistogram = new FullTraceHistogram(this, fullRangeComposite);
249
250 // Add mouse wheel listener to time span control
251 MouseWheelListener listener = fFullTraceHistogram.getZoom();
252 fTimeSpanControl.addMouseWheelListener(listener);
253
254 ITmfTrace trace = getActiveTrace();
255 if (trace != null) {
256 traceSelected(new TmfTraceSelectedSignal(this, trace));
257 }
258 }
259
260 @Override
261 public void setFocus() {
262 fFullTraceHistogram.fCanvas.setFocus();
263 }
264
265 void refresh() {
266 fParent.layout(true);
267 }
268
269 // ------------------------------------------------------------------------
270 // Accessors
271 // ------------------------------------------------------------------------
272
273 /**
274 * Returns the current trace handled by the view
275 *
276 * @return the current trace
277 * @since 2.0
278 */
279 public ITmfTrace getTrace() {
280 return fTrace;
281 }
282
283 /**
284 * Returns the time range of the current selected window (base on default time scale).
285 *
286 * @return the time range of current selected window.
287 * @since 2.0
288 */
289 public TmfTimeRange getTimeRange() {
290 return new TmfTimeRange(
291 new TmfTimestamp(fWindowStartTime, ITmfTimestamp.NANOSECOND_SCALE),
292 new TmfTimestamp(fWindowEndTime, ITmfTimestamp.NANOSECOND_SCALE));
293 }
294
295 // ------------------------------------------------------------------------
296 // Operations
297 // ------------------------------------------------------------------------
298
299 /**
300 * Broadcast TmfSignal about new current selection time range.
301 * @param beginTime the begin time of current selection.
302 * @param endTime the end time of current selection.
303 */
304 void updateSelectionTime(long beginTime, long endTime) {
305 updateDisplayedSelectionTime(beginTime, endTime);
306 TmfTimestamp beginTs = new TmfTimestamp(beginTime, ITmfTimestamp.NANOSECOND_SCALE);
307 TmfTimestamp endTs = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE);
308 TmfTimeSynchSignal signal = new TmfTimeSynchSignal(this, beginTs, endTs);
309 fTimeSyncThrottle.queue(signal);
310 }
311
312 /**
313 * Broadcast TmfSignal about new selection time range.
314 * @param startTime the new start time
315 * @param endTime the new end time
316 */
317 void updateTimeRange(long startTime, long endTime) {
318 if (fTrace != null) {
319 // Build the new time range; keep the current time
320 TmfTimeRange timeRange = new TmfTimeRange(
321 new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE),
322 new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE));
323 fTimeSpanControl.setValue(endTime - startTime);
324
325 updateDisplayedTimeRange(startTime, endTime);
326
327 // Send the FW signal
328 TmfRangeSynchSignal signal = new TmfRangeSynchSignal(this, timeRange);
329 fTimeRangeSyncThrottle.queue(signal);
330 }
331 }
332
333 /**
334 * Broadcast TmfSignal about new selected time range.
335 * @param newDuration new duration (relative to current start time)
336 */
337 public synchronized void updateTimeRange(long newDuration) {
338 if (fTrace != null) {
339 long delta = newDuration - fWindowSpan;
340 long newStartTime = fWindowStartTime - (delta / 2);
341 setNewRange(newStartTime, newDuration);
342 }
343 }
344
345 private void setNewRange(long startTime, long duration) {
346 long realStart = startTime;
347
348 if (realStart < fTraceStartTime) {
349 realStart = fTraceStartTime;
350 }
351
352 long endTime = realStart + duration;
353 if (endTime > fTraceEndTime) {
354 endTime = fTraceEndTime;
355 if ((endTime - duration) > fTraceStartTime) {
356 realStart = endTime - duration;
357 } else {
358 realStart = fTraceStartTime;
359 }
360 }
361 updateTimeRange(realStart, endTime);
362 }
363
364 // ------------------------------------------------------------------------
365 // Signal handlers
366 // ------------------------------------------------------------------------
367
368 /**
369 * Handles trace opened signal. Loads histogram if new trace time range is not
370 * equal <code>TmfTimeRange.NULL_RANGE</code>
371 * @param signal the trace opened signal
372 * @since 2.0
373 */
374 @TmfSignalHandler
375 public void traceOpened(TmfTraceOpenedSignal signal) {
376 assert (signal != null);
377 fTrace = signal.getTrace();
378 loadTrace();
379 }
380
381 /**
382 * Handles trace selected signal. Loads histogram if new trace time range is not
383 * equal <code>TmfTimeRange.NULL_RANGE</code>
384 * @param signal the trace selected signal
385 * @since 2.0
386 */
387 @TmfSignalHandler
388 public void traceSelected(TmfTraceSelectedSignal signal) {
389 assert (signal != null);
390 if (fTrace != signal.getTrace()) {
391 fTrace = signal.getTrace();
392 loadTrace();
393 }
394 }
395
396 private void loadTrace() {
397 initializeHistograms();
398 fParent.redraw();
399 }
400
401 /**
402 * Handles trace closed signal. Clears the view and data model and cancels requests.
403 * @param signal the trace closed signal
404 * @since 2.0
405 */
406 @TmfSignalHandler
407 public void traceClosed(TmfTraceClosedSignal signal) {
408
409 if (signal.getTrace() != fTrace) {
410 return;
411 }
412
413 // Kill any running request
414 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
415 fTimeRangeRequest.cancel();
416 }
417 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
418 fFullTraceRequest.cancel();
419 }
420
421 // Initialize the internal data
422 fTrace = null;
423 fTraceStartTime = 0L;
424 fTraceEndTime = 0L;
425 fWindowStartTime = 0L;
426 fWindowEndTime = 0L;
427 fWindowSpan = 0L;
428 fSelectionBeginTime = 0L;
429 fSelectionEndTime = 0L;
430
431 // Clear the UI widgets
432 fFullTraceHistogram.clear();
433 fTimeRangeHistogram.clear();
434 fCurrentEventTimeControl.setValue(Long.MIN_VALUE);
435
436 fTimeSpanControl.setValue(Long.MIN_VALUE);
437 }
438
439 /**
440 * Handles trace range updated signal. Extends histogram according to the new time range. If a
441 * HistogramRequest is already ongoing, it will be cancelled and a new request with the new range
442 * will be issued.
443 *
444 * @param signal the trace range updated signal
445 * @since 2.0
446 */
447 @TmfSignalHandler
448 public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
449
450 if (signal.getTrace() != fTrace) {
451 return;
452 }
453
454 TmfTimeRange fullRange = signal.getRange();
455
456 fTraceStartTime = fullRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
457 fTraceEndTime = fullRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
458
459 fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
460 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
461
462 sendFullRangeRequest(fullRange);
463 }
464
465 /**
466 * Handles the trace updated signal. Used to update time limits (start and end time)
467 * @param signal the trace updated signal
468 * @since 2.0
469 */
470 @TmfSignalHandler
471 public void traceUpdated(TmfTraceUpdatedSignal signal) {
472 if (signal.getTrace() != fTrace) {
473 return;
474 }
475 TmfTimeRange fullRange = signal.getTrace().getTimeRange();
476 fTraceStartTime = fullRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
477 fTraceEndTime = fullRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
478
479 fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
480 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
481
482 fFullTraceHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
483 fTimeRangeHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
484
485 if ((fFullTraceRequest != null) && fFullTraceRequest.getRange().getEndTime().compareTo(signal.getRange().getEndTime()) < 0) {
486 sendFullRangeRequest(fullRange);
487 }
488 }
489
490 /**
491 * Handles the current time updated signal. Sets the current time in the time range
492 * histogram as well as the full histogram.
493 *
494 * @param signal the signal to process
495 */
496 @TmfSignalHandler
497 public void currentTimeUpdated(TmfTimeSynchSignal signal) {
498 // Because this can't happen :-)
499 assert (signal != null);
500
501 // Update the selected time range
502 ITmfTimestamp beginTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
503 ITmfTimestamp endTime = signal.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
504 updateDisplayedSelectionTime(beginTime.getValue(), endTime.getValue());
505 }
506
507 /**
508 * Updates the current time range in the time range histogram and full range histogram.
509 * @param signal the signal to process
510 */
511 @TmfSignalHandler
512 public void timeRangeUpdated(TmfRangeSynchSignal signal) {
513 // Because this can't happen :-)
514 assert (signal != null);
515
516 if (fTrace != null) {
517 // Validate the time range
518 TmfTimeRange range = signal.getCurrentRange().getIntersection(fTrace.getTimeRange());
519 if (range == null) {
520 return;
521 }
522
523 updateDisplayedTimeRange(
524 range.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(),
525 range.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
526
527 // Send the event request to populate the small histogram
528 sendTimeRangeRequest(fWindowStartTime, fWindowEndTime);
529
530 fTimeSpanControl.setValue(fWindowSpan);
531 }
532 }
533
534 // ------------------------------------------------------------------------
535 // Helper functions
536 // ------------------------------------------------------------------------
537
538 private void initializeHistograms() {
539 TmfTimeRange fullRange = updateTraceTimeRange();
540 long selectionBeginTime = fTraceManager.getSelectionBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
541 long selectionEndTime = fTraceManager.getSelectionEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
542 long startTime = fTraceManager.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
543 long duration = fTraceManager.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue() - startTime;
544
545 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
546 fTimeRangeRequest.cancel();
547 }
548 fTimeRangeHistogram.clear();
549 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
550 fTimeRangeHistogram.setTimeRange(startTime, duration);
551 fTimeRangeHistogram.setSelection(selectionBeginTime, selectionEndTime);
552
553 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
554 fFullTraceRequest.cancel();
555 }
556 fFullTraceHistogram.clear();
557 fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
558 fFullTraceHistogram.setTimeRange(startTime, duration);
559 fFullTraceHistogram.setSelection(selectionBeginTime, selectionEndTime);
560
561 fWindowStartTime = startTime;
562 fWindowSpan = duration;
563 fWindowEndTime = startTime + duration;
564
565 fSelectionBeginTime = selectionBeginTime;
566 fSelectionEndTime = selectionEndTime;
567 fCurrentEventTimeControl.setValue(fSelectionBeginTime);
568
569 fTimeSpanControl.setValue(duration);
570
571 if (!fullRange.equals(TmfTimeRange.NULL_RANGE)) {
572 sendTimeRangeRequest(startTime, startTime + duration);
573 sendFullRangeRequest(fullRange);
574 }
575 }
576
577 private void updateDisplayedSelectionTime(long beginTime, long endTime) {
578 fSelectionBeginTime = beginTime;
579 fSelectionEndTime = endTime;
580
581 fFullTraceHistogram.setSelection(fSelectionBeginTime, fSelectionEndTime);
582 fTimeRangeHistogram.setSelection(fSelectionBeginTime, fSelectionEndTime);
583 fCurrentEventTimeControl.setValue(fSelectionBeginTime);
584 }
585
586 private void updateDisplayedTimeRange(long start, long end) {
587 fWindowStartTime = start;
588 fWindowEndTime = end;
589 fWindowSpan = fWindowEndTime - fWindowStartTime;
590 fFullTraceHistogram.setTimeRange(fWindowStartTime, fWindowSpan);
591 }
592
593 private TmfTimeRange updateTraceTimeRange() {
594 fTraceStartTime = 0L;
595 fTraceEndTime = 0L;
596
597 TmfTimeRange timeRange = fTrace.getTimeRange();
598 if (!timeRange.equals(TmfTimeRange.NULL_RANGE)) {
599 fTraceStartTime = timeRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
600 fTraceEndTime = timeRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
601 }
602 return timeRange;
603 }
604
605 private void sendTimeRangeRequest(long startTime, long endTime) {
606 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
607 fTimeRangeRequest.cancel();
608 }
609 TmfTimestamp startTS = new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE);
610 TmfTimestamp endTS = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE);
611 TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
612
613 fTimeRangeHistogram.clear();
614 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
615 fTimeRangeHistogram.setTimeRange(startTime, endTime - startTime);
616
617 int cacheSize = fTrace.getCacheSize();
618 fTimeRangeRequest = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, TmfDataRequest.ALL_DATA, cacheSize, ExecutionType.FOREGROUND);
619 fTrace.sendRequest(fTimeRangeRequest);
620 }
621
622 private void sendFullRangeRequest(TmfTimeRange fullRange) {
623 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
624 fFullTraceRequest.cancel();
625 }
626 int cacheSize = fTrace.getCacheSize();
627 fFullTraceRequest = new HistogramRequest(fFullTraceHistogram.getDataModel(), fullRange, (int) fFullTraceHistogram.fDataModel.getNbEvents(),
628 TmfDataRequest.ALL_DATA, cacheSize, ExecutionType.BACKGROUND);
629 fTrace.sendRequest(fFullTraceRequest);
630 }
631
632 }
This page took 0.050384 seconds and 5 git commands to generate.