1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * William Bourque - Initial API and implementation
13 * 2010-06-10 Yuriy Vashchuk - GUI reorganisation, simplification and some
14 * related code improvements.
15 * 2010-06-20 Yuriy Vashchuk - Histograms optimisation.
16 * 2010-07-16 Yuriy Vashchuk - Histogram Canvas Heritage correction
17 *******************************************************************************/
19 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.histogram
;
21 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
22 import org
.eclipse
.linuxtools
.lttng
.event
.LttngTimestamp
;
23 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
24 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
25 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
26 import org
.eclipse
.linuxtools
.tmf
.experiment
.TmfExperiment
;
27 import org
.eclipse
.linuxtools
.tmf
.request
.ITmfDataRequest
;
28 import org
.eclipse
.linuxtools
.tmf
.request
.ITmfDataRequest
.ExecutionType
;
29 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfExperimentSelectedSignal
;
30 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
31 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
32 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
33 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfTrace
;
34 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
36 import org
.eclipse
.swt
.SWT
;
37 import org
.eclipse
.swt
.events
.ControlEvent
;
38 import org
.eclipse
.swt
.events
.ControlListener
;
39 import org
.eclipse
.swt
.graphics
.Font
;
40 import org
.eclipse
.swt
.graphics
.FontData
;
41 import org
.eclipse
.swt
.layout
.GridData
;
42 import org
.eclipse
.swt
.layout
.GridLayout
;
43 import org
.eclipse
.swt
.widgets
.Composite
;
44 import org
.eclipse
.swt
.widgets
.Text
;
47 * <b><u>HistogramView</u></b>
49 * View that contain an visual approach to the window that control the request.
50 * This is intended to replace the TimeFrameView
52 * This view is composed of 2 canvas, one for the whole experiment and one for the selectionned window in the experiment.
53 * It also contain a certain number of controls to print or change informations about the experiment.
55 public class HistogramView
extends TmfView
implements ControlListener
{
58 // Here is what's left to do in this view
60 // 1- Make sure the interval time is small enough on very big trace (bug 311930)
61 // The interval time of the content is dynamically assigned from the screen width and trace duration.
62 // However, on very big trace (more than 1 hour), we could end up with time interval that are > 1 seconds,
63 // which is not very precise.
64 // An algorithm need to be implemented to make sure we "increase" the number of interval in the content if
65 // their precision is getting too bad.
67 // 2- Make sure all control are thread safe (bug 309348)
68 // Right now, all the basic controls (i.e. Text and Label) are sensible to "Thread Access Exception" if
69 // updated from different threads; we need to carefully decide when/where to redraw them.
70 // This is a real problem since there is a lot of thread going on in this view.
71 // All basic control should be subclassed to offer "Asynchronous" functions.
73 // 3- Implement a "preferences view" for the HistogramView (bug 311935)
74 // There is a lot of adjustable preferences in the view, however there is no way to adjust them right now
75 // at run time. There should be a view of some kind of "menu" to allow the user to change them while executing.
76 // Most of the pertinent values are in HistogramConstant.java or in this file.
78 public static final String ID
= "org.eclipse.linuxtools.lttng.ui.views.histogram";
80 // "Minimum" screen width size. On smaller screen, we will apply several space saving technique
81 private static final int SCREEN_SMALL_IF_SMALLER_THAN
= 1600;
84 // 2010-06-20 Yuriy: We will use the dynamic height.
85 // Size of the "full trace" canvas
86 private static final int FULL_TRACE_CANVAS_HEIGHT = 25;
88 private static final int FULL_TRACE_BAR_WIDTH
= 1;
89 private static final double FULL_TRACE_DIFFERENCE_TO_AVERAGE
= 1.5;
91 // Size of the "Selected Window" canvas
94 private static final int SELECTED_WINDOW_CANVAS_WIDTH = 300;
95 private static final int SMALL_SELECTED_WINDOW_CANVAS_WIDTH = 200;
96 private static final int SELECTED_WINDOW_CANVAS_HEIGHT = 60;
98 private static final int SELECTED_WINDOW_BAR_WIDTH
= 1;
99 private static final double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE
= 10.0;
101 // For the two "events" label (Max and Min number of events in the selection), we force a width
102 // This will prevent the control from moving horizontally if the number of events in the selection varies
103 private static final int NB_EVENTS_FIXED_WIDTH
= 50;
105 // The "small font" height used to display time will be "default font" minus this constant
106 private static final int SMALL_FONT_MODIFIER
= 2;
107 private static final int VERY_SMALL_FONT_MODIFIER
= 4;
110 // This need to be changed as soon the framework implement a "window"
111 // private static long DEFAULT_WINDOW_SIZE = (10L * 100 * 1000 * 1000); // 1sec
112 private static long DEFAULT_WINDOW_SIZE
= (1L * 100 * 1000 * 1000); // .1sec
114 // The last experiment received/used by the view
115 private TmfExperiment
<LttngEvent
> lastUsedExperiment
= null;
117 // Parent of the view
118 private Composite parent
= null;
120 // Request and canvas for the "full trace" part
121 private HistogramRequest dataBackgroundFullRequest
= null;
122 private static ParentHistogramCanvas fullExperimentCanvas
= null;
124 // Request and canvas for the "selected window"
125 private HistogramRequest selectedWindowRequest
= null;
126 private static ChildrenHistogramCanvas selectedWindowCanvas
= null;
128 // Content of the timeTextGroup
129 // Since the user can modify them with erroneous value,
130 // we will keep track of the value internally
131 private long currentEventTime
= 0L;
133 // *** All the UI control below
135 // NOTE : All textboxes will be READ_ONLY.
136 // So the user will be able to select/copy the value in them but not to change it
137 private Text txtExperimentStartTime
= null;
138 private Text txtExperimentStopTime
= null;
140 private Text txtWindowStartTime
= null;
141 private Text txtWindowStopTime
= null;
142 private Text txtWindowMaxNbEvents
= null;
143 private Text txtWindowMinNbEvents
= null;
145 // We move the time label to header from TimeTextGroup.java
146 protected static final String NANOSEC_LABEL
= "(sec)";
147 private static final String WINDOW_TIMERANGE_LABEL_TEXT
= "Window Timerange, " + NANOSEC_LABEL
;
148 private static final String WINDOW_CURRENT_TIME_LABEL_TEXT
= "Cursor Centered on, " + NANOSEC_LABEL
;
149 private static final String EVENT_CURRENT_TIME_LABEL_TEXT
= "Current Event Time, " + NANOSEC_LABEL
;
150 private TimeTextGroup ntgTimeRangeWindow
= null;
151 private TimeTextGroup ntgCurrentWindowTime
= null;
152 private TimeTextGroup ntgCurrentEventTime
= null;
155 * Default contructor of the view
157 public HistogramView() {
162 * Create the UI controls of this view
164 * @param parent The composite parent of this view
167 public void createPartControl(Composite newParent
) {
172 Font font
= parent
.getFont();
173 FontData tmpFontData
= font
.getFontData()[0];
176 Font smallFont
= null;
177 int nbEventWidth
= -1;
178 int selectedCanvasWidth
= -1;
179 boolean doesTimeTextGroupNeedAdjustment
= false;
181 // Calculate if we need "small screen" fixes
182 if ( parent
.getDisplay().getBounds().width
< SCREEN_SMALL_IF_SMALLER_THAN
) {
184 // A lot smaller font for timstampe
185 smallFont
= new Font(font
.getDevice(), tmpFontData
.getName(), tmpFontData
.getHeight() - VERY_SMALL_FONT_MODIFIER
, tmpFontData
.getStyle());
189 // Smaller selection window canvas
190 selectedCanvasWidth = SMALL_SELECTED_WINDOW_CANVAS_WIDTH;
192 // Smaller event number text field
193 nbEventWidth
= NB_EVENTS_FIXED_WIDTH
/2;
195 // Tell the text group to ajust
196 doesTimeTextGroupNeedAdjustment
= true;
200 // Slightly smaller font for timestamp
201 smallFont
= new Font(font
.getDevice(), tmpFontData
.getName(), tmpFontData
.getHeight() - SMALL_FONT_MODIFIER
, tmpFontData
.getStyle());
202 // Usual size for selected window and event number text field
203 nbEventWidth
= NB_EVENTS_FIXED_WIDTH
;
206 selectedCanvasWidth = SELECTED_WINDOW_CANVAS_WIDTH;
208 // No ajustement needed by the text group
209 doesTimeTextGroupNeedAdjustment
= false;
214 /////////////////////////////////////////////////////////////////////////////////////
215 // Layout for the whole view, other elements will be in a child composite of this one
217 // Composite layoutSelectionWindow
218 // Composite layoutTimesSpinner
219 // Composite layoutExperimentHistogram
220 /////////////////////////////////////////////////////////////////////////////////////
221 Composite layoutFullView
= new Composite(parent
, SWT
.FILL
);
222 GridLayout gridFullView
= new GridLayout();
223 gridFullView
.numColumns
= 2;
224 gridFullView
.horizontalSpacing
= 0;
225 gridFullView
.verticalSpacing
= 0;
226 gridFullView
.marginHeight
= 0;
227 gridFullView
.marginWidth
= 0;
228 layoutFullView
.setLayout(gridFullView
);
231 /////////////////////////////////////////////////////////////////////////////////////
232 // Layout that contain the time spinner
234 // NanosecTextGroup spTimeRangeWindow
235 // NanosecTextGroup spCurrentWindowTime
236 // NanosecTextGroup spCurrentEventTime
237 /////////////////////////////////////////////////////////////////////////////////////
238 Composite layoutTimesSpinner
= new Composite(layoutFullView
, SWT
.NONE
);
239 GridLayout gridTimesSpinner
= new GridLayout();
240 gridTimesSpinner
.numColumns
= 3;
241 gridTimesSpinner
.marginHeight
= 0;
242 gridTimesSpinner
.marginWidth
= 0;
243 gridTimesSpinner
.horizontalSpacing
= 0;
244 gridTimesSpinner
.verticalSpacing
= 0;
245 layoutTimesSpinner
.setLayout(gridTimesSpinner
);
247 GridData gridDataCurrentEvent
= new GridData();
248 gridDataCurrentEvent
.horizontalAlignment
= SWT
.LEFT
;
249 gridDataCurrentEvent
.verticalAlignment
= SWT
.CENTER
;
250 ntgCurrentEventTime
= new TimeTextGroup(this, layoutTimesSpinner
, SWT
.BORDER
, SWT
.BORDER
, EVENT_CURRENT_TIME_LABEL_TEXT
, HistogramConstant
.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment
);
251 ntgCurrentEventTime
.setLayoutData(gridDataCurrentEvent
);
253 GridData gridDataTimeRange
= new GridData();
254 gridDataCurrentEvent
.horizontalAlignment
= SWT
.CENTER
;
255 gridDataCurrentEvent
.verticalAlignment
= SWT
.CENTER
;
256 ntgTimeRangeWindow
= new TimeTextGroup(this, layoutTimesSpinner
, SWT
.BORDER
, SWT
.BORDER
, WINDOW_TIMERANGE_LABEL_TEXT
, HistogramConstant
.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment
);
257 ntgTimeRangeWindow
.setLayoutData(gridDataTimeRange
);
259 GridData gridDataCurrentWindow
= new GridData();
260 gridDataCurrentEvent
.horizontalAlignment
= SWT
.RIGHT
;
261 gridDataCurrentEvent
.verticalAlignment
= SWT
.CENTER
;
262 ntgCurrentWindowTime
= new TimeTextGroup(this, layoutTimesSpinner
, SWT
.BORDER
, SWT
.BORDER
, WINDOW_CURRENT_TIME_LABEL_TEXT
, HistogramConstant
.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment
);
263 ntgCurrentWindowTime
.setLayoutData(gridDataCurrentWindow
);
266 /////////////////////////////////////////////////////////////////////////////////////
267 // Layout that contain the SelectionWindow
269 // Label txtWindowStartTime
270 // Label txtWindowStopTime
271 // Label txtWindowMaxNbEvents
272 // Label txtWindowMinNbEvents
273 // ChildrenHistogramCanvas selectedWindowCanvas
274 /////////////////////////////////////////////////////////////////////////////////////
275 Composite layoutSelectionWindow
= new Composite(layoutFullView
, SWT
.FILL
);
276 GridLayout gridSelectionWindow
= new GridLayout();
277 gridSelectionWindow
.numColumns
= 3;
278 gridSelectionWindow
.marginHeight
= 0;
279 gridSelectionWindow
.marginWidth
= 0;
280 gridSelectionWindow
.horizontalSpacing
= 0;
281 gridSelectionWindow
.verticalSpacing
= 0;
282 layoutSelectionWindow
.setLayout(gridSelectionWindow
);
284 GridData gridDataSelectionWindow
= new GridData();
285 gridDataSelectionWindow
.horizontalAlignment
= SWT
.FILL
;
286 gridDataSelectionWindow
.verticalAlignment
= SWT
.FILL
;
287 layoutSelectionWindow
.setLayoutData(gridDataSelectionWindow
);
289 GridData gridDataSelectionWindowCanvas
= new GridData();
290 gridDataSelectionWindowCanvas
.horizontalSpan
= 2;
291 gridDataSelectionWindowCanvas
.verticalSpan
= 2;
292 gridDataSelectionWindowCanvas
.horizontalAlignment
= SWT
.FILL
;
293 gridDataSelectionWindowCanvas
.grabExcessHorizontalSpace
= true;
294 gridDataSelectionWindowCanvas
.verticalAlignment
= SWT
.FILL
;
297 gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
298 gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
300 gridDataSelectionWindowCanvas
.widthHint
= selectedCanvasWidth
;
301 gridDataSelectionWindowCanvas
.minimumWidth
= selectedCanvasWidth
;
302 selectedWindowCanvas
= new ChildrenHistogramCanvas(this, layoutSelectionWindow
, SWT
.BORDER
);
303 selectedWindowCanvas
.setLayoutData(gridDataSelectionWindowCanvas
);
305 GridData gridDataWindowMaxEvents
= new GridData();
306 gridDataWindowMaxEvents
.horizontalAlignment
= SWT
.RIGHT
;
307 gridDataWindowMaxEvents
.verticalAlignment
= SWT
.TOP
;
308 // Force a width, to avoid the control to enlarge if the number of events change
309 gridDataWindowMaxEvents
.minimumWidth
= nbEventWidth
;
310 txtWindowMaxNbEvents
= new Text(layoutSelectionWindow
, SWT
.READ_ONLY
);
311 txtWindowMaxNbEvents
.setFont(smallFont
);
312 txtWindowMaxNbEvents
.setBackground(parent
.getDisplay().getSystemColor(SWT
.COLOR_TITLE_INACTIVE_BACKGROUND
));
313 txtWindowMaxNbEvents
.setEditable(false);
314 txtWindowMaxNbEvents
.setText("0");
315 txtWindowMaxNbEvents
.setLayoutData(gridDataWindowMaxEvents
);
317 GridData gridDataWindowMinEvents
= new GridData();
318 gridDataWindowMinEvents
.horizontalAlignment
= SWT
.RIGHT
;
319 gridDataWindowMinEvents
.verticalAlignment
= SWT
.BOTTOM
;
320 // Force a width, to avoid the control to enlarge if the number of events change
321 gridDataWindowMinEvents
.minimumWidth
= nbEventWidth
;
322 txtWindowMinNbEvents
= new Text(layoutSelectionWindow
, SWT
.READ_ONLY
);
323 txtWindowMinNbEvents
.setFont(smallFont
);
324 txtWindowMinNbEvents
.setBackground(parent
.getDisplay().getSystemColor(SWT
.COLOR_TITLE_INACTIVE_BACKGROUND
));
325 txtWindowMinNbEvents
.setEditable(false);
326 txtWindowMinNbEvents
.setText("0");
327 txtWindowMinNbEvents
.setLayoutData(gridDataWindowMinEvents
);
329 GridData gridDataWindowStart
= new GridData();
330 gridDataWindowStart
.horizontalAlignment
= SWT
.LEFT
;
331 gridDataWindowStart
.verticalAlignment
= SWT
.BOTTOM
;
332 txtWindowStartTime
= new Text(layoutSelectionWindow
, SWT
.READ_ONLY
);
333 txtWindowStartTime
.setFont(smallFont
);
334 txtWindowStartTime
.setBackground(parent
.getDisplay().getSystemColor(SWT
.COLOR_TITLE_INACTIVE_BACKGROUND
));
335 txtWindowStartTime
.setEditable(false);
336 txtWindowStartTime
.setText("0.000000000");
337 txtWindowStartTime
.setLayoutData(gridDataWindowStart
);
339 GridData gridDataWindowStop
= new GridData();
340 gridDataWindowStop
.horizontalAlignment
= SWT
.RIGHT
;
341 gridDataWindowStop
.verticalAlignment
= SWT
.BOTTOM
;
342 txtWindowStopTime
= new Text(layoutSelectionWindow
, SWT
.READ_ONLY
);
343 txtWindowStopTime
.setFont(smallFont
);
344 txtWindowStopTime
.setBackground(parent
.getDisplay().getSystemColor(SWT
.COLOR_TITLE_INACTIVE_BACKGROUND
));
345 txtWindowStopTime
.setEditable(false);
346 txtWindowStopTime
.setText("0.000000000");
347 txtWindowStopTime
.setLayoutData(gridDataWindowStop
);
351 // 2010-06-10 Yuriy: NOT NEEDED AFTER GUI IMPROVEMENTS. WORK FINE WITOUT THIS HACK
353 // To align properly AND to make sure the canvas size is fixed, we NEED to make sure all "section" of the
354 // gridlayout are taken (and if possible of a fixed size).
355 // However, SWT is VERY VERY DUMB and won't consider griddata that contain no control.
356 // Since there will be missing a section, the SelectedWindowCanvas + NbEventsText will take 3 spaces, but
357 // startTimeText + stopTimeText will take only 2 (as if empty the other griddata of 1 will get ignored).
358 // StopTime will then take over the missing space; I want to align "stopTime" right on the end of canvas, so
359 // the added space to stop time would make it being aligned improperly
360 // So I NEED the empty griddata to be considered!
362 // |---------------|---------------|-----------|
363 // |SelectionCanvas SelectionCanvas|NbEventText|
364 // |SelectionCanvas SelectionCanvas|NbEventText|
365 // |---------------|---------------|-----------|
366 // |StartTime | StopTime| ??? |
367 // |---------------|---------------|-----------|
369 // So since SWT will only consider griddata with control,
370 // I need to create a totally useless control in the ??? section.
371 // That's ugly, useless and it is generally a bad practice.
374 // Other interesting fact about SWT : the way it draws (Fill/Expand control in grid) will change if
375 // the control is a Text or a Label.
376 // A Label here will be "pushed" by startTime/stopTime Text and won't fill the full space as NbEventText.
377 // A Text here will NOT be "pushed" and would give a nice visual output.
378 // (NB : No, I am NOT kidding, try it for yourself!)
380 // Soooooo I guess I will use a Text here. Way to go SWT!
381 // Downside is that disabled textbox has a slightly different color (even if you force it yourself) so if I want
382 // to make the text "invisible", I have to keep it enabled (but read only), so it can be clicked on.
384 // Label uselessControlToByPassSWTStupidBug = new Label(layoutSelectionWindow, SWT.BORDER); // WON'T align correctly!!!
385 //GridData gridDataSpacer = new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1);
386 GridData gridDataSpacer = new GridData();
387 gridDataWindowStop.horizontalAlignment = SWT.FILL;
388 gridDataWindowStop.verticalAlignment = SWT.TOP;
389 gridDataSpacer.minimumWidth = nbEventWidth;
390 Text uselessControlToByPassSWTStupidBug = new Text(layoutSelectionWindow, SWT.READ_ONLY); // WILL align correctly!!!
391 uselessControlToByPassSWTStupidBug.setEditable(false);
392 uselessControlToByPassSWTStupidBug.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
393 uselessControlToByPassSWTStupidBug.setLayoutData(gridDataSpacer);
397 /////////////////////////////////////////////////////////////////////////////////////
398 // Layout that contain the complete experiment histogram and related controls.
400 // ParentHistogramCanvas fullExperimentCanvas
401 // Text txtExperimentStartTime
402 // Text txtExperimentStopTime
403 /////////////////////////////////////////////////////////////////////////////////////
404 Composite layoutExperimentHistogram
= new Composite(layoutFullView
, SWT
.FILL
);
406 GridLayout gridExperimentHistogram
= new GridLayout();
407 gridExperimentHistogram
.numColumns
= 2;
408 gridExperimentHistogram
.marginHeight
= 0;
409 gridExperimentHistogram
.marginWidth
= 0;
410 gridExperimentHistogram
.horizontalSpacing
= 0;
411 gridExperimentHistogram
.verticalSpacing
= 0;
412 layoutExperimentHistogram
.setLayout(gridExperimentHistogram
);
415 // 2010-06-10 Yuriy: NOT NEEDED AFTER GUI IMPROVEMENTS
416 GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
417 layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
420 // *** Everything related to the experiment canvas is below
421 GridData gridDataExperimentCanvas
= new GridData();
422 gridDataExperimentCanvas
.horizontalSpan
= 2;
423 gridDataExperimentCanvas
.horizontalAlignment
= SWT
.FILL
;
424 gridDataExperimentCanvas
.grabExcessHorizontalSpace
= true;
425 gridDataExperimentCanvas
.verticalAlignment
= SWT
.FILL
;
426 gridDataExperimentCanvas
.grabExcessVerticalSpace
= true;
428 // 2010-06-20 Yuriy: We use the dynamic height.
429 gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT;
430 gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
432 fullExperimentCanvas
= new ParentHistogramCanvas(this, layoutExperimentHistogram
, SWT
.BORDER
);
433 fullExperimentCanvas
.setLayoutData(gridDataExperimentCanvas
);
434 layoutExperimentHistogram
.setLayoutData(gridDataExperimentCanvas
);
436 GridData gridDataExperimentStart
= new GridData();
437 gridDataExperimentStart
.horizontalAlignment
= SWT
.LEFT
;
438 gridDataExperimentStart
.verticalAlignment
= SWT
.BOTTOM
;
439 txtExperimentStartTime
= new Text(layoutExperimentHistogram
, SWT
.READ_ONLY
);
440 txtExperimentStartTime
.setFont(smallFont
);
441 txtExperimentStartTime
.setText("0.000000000");
442 txtExperimentStartTime
.setBackground(parent
.getDisplay().getSystemColor(SWT
.COLOR_TITLE_INACTIVE_BACKGROUND
));
443 txtExperimentStartTime
.setEditable(false);
444 txtExperimentStartTime
.setLayoutData(gridDataExperimentStart
);
446 GridData gridDataExperimentStop
= new GridData();
447 gridDataExperimentStop
.horizontalAlignment
= SWT
.RIGHT
;
448 gridDataExperimentStop
.verticalAlignment
= SWT
.BOTTOM
;
449 txtExperimentStopTime
= new Text(layoutExperimentHistogram
, SWT
.READ_ONLY
);
450 txtExperimentStopTime
.setFont(smallFont
);
451 txtExperimentStopTime
.setText("0.000000000");
452 txtExperimentStopTime
.setBackground(parent
.getDisplay().getSystemColor(SWT
.COLOR_TITLE_INACTIVE_BACKGROUND
));
453 txtExperimentStopTime
.setEditable(false);
454 txtExperimentStopTime
.setLayoutData(gridDataExperimentStop
);
458 // This is mainly used because of a because in the "experimentSelected()" notification, we shouldn't need this
460 * Method called when the view receive the focus.<p>
461 * If ExperimentSelected didn't send us a request yet, get the current Experiment and fire requests
463 @SuppressWarnings("unchecked")
465 public void setFocus() {
466 // WARNING : This does not seem to be thread safe
467 TmfExperiment
<LttngEvent
> tmpExperiment
= (TmfExperiment
<LttngEvent
>)TmfExperiment
.getCurrentExperiment();
469 if ( (dataBackgroundFullRequest
== null) && (tmpExperiment
!= null) ) {
470 createCanvasAndRequests(tmpExperiment
);
473 // Call a redraw for everything
478 * Method called when the user select (double-click on) an experiment.<p>
479 * We will create the needed canvas and fire the requests.
481 * @param signal Signal received from the framework. Contain the experiment.
483 @SuppressWarnings("unchecked")
485 public void experimentSelected(TmfExperimentSelectedSignal
<LttngEvent
> signal
) {
486 TmfExperiment
<LttngEvent
> tmpExperiment
= (TmfExperiment
<LttngEvent
>)signal
.getExperiment();
487 createCanvasAndRequests(tmpExperiment
);
492 // Not sure what this should do since I don't know when it will be called
493 // Let's do the same thing as experimentSelected for now
496 * Method called when an experiment is updated (??).<p>
497 * ...for now, do nothing, as udating an experiment running in the background might cause crash
499 * @param signal Signal received from the framework. Contain the experiment.
502 @SuppressWarnings("unchecked")
504 public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
506 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
508 // Make sure the UI object are sane
509 resetControlsContent();
511 // Redraw the canvas right away to have something "clean" as soon as we can
512 fullExperimentCanvas.redraw();
513 selectedWindowCanvas.redraw();
515 // Recreate the request
516 createCanvasAndRequests(tmpExperiment);
521 * Method called when synchonization is active and that the user select an event.<p>
522 * We update the current event timeTextGroup and move the selected window if needed.
524 * @param signal Signal received from the framework. Contain the event.
527 public void currentTimeUpdated(TmfTimeSynchSignal signal
) {
528 // In case we received our own signal
529 if ( (signal
!= null) && (signal
.getSource() != this) ) {
530 TmfTimestamp currentTime
= signal
.getCurrentTime();
532 // Update the current event controls
533 currentEventTime
= currentTime
.getValue();
534 updateSelectedEventTime();
536 // If the given event is outside the selection window, recenter the window
537 if ( isGivenTimestampInSelectedWindow( currentEventTime
) == false) {
538 fullExperimentCanvas
.setWindowCenterPosition( fullExperimentCanvas
.getHistogramContent().getClosestXPositionFromTimestamp(currentEventTime
) );
539 // Notify control that the window changed
540 windowChangedNotification();
541 // Send a broadcast to the framework about the window change
542 sendTmfRangeSynchSignalBroadcast();
548 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
549 if ( (signal
!= null) && (signal
.getSource() != this) ) {
550 if ( lastUsedExperiment
!= null ) {
551 long currentTime
= signal
.getCurrentTime().getValue();
552 long windowStart
= signal
.getCurrentRange().getStartTime().getValue();
553 long windowEnd
= signal
.getCurrentRange().getEndTime().getValue();
554 long windowTimeWidth
= (windowEnd
- windowStart
);
556 // Recenter the window
557 fullExperimentCanvas
.setSelectedWindowSize(windowTimeWidth
);
558 fullExperimentCanvas
.setWindowCenterPosition( fullExperimentCanvas
.getHistogramContent().getClosestXPositionFromTimestamp(windowStart
+ (windowTimeWidth
/2)) );
561 // Views could send us incorrect current event value (event outside the current window)
562 // Here we make sure the value is sane, otherwise, we force it as the left border of the window
563 if ( isGivenTimestampInSelectedWindow( currentTime
) == false ) {
564 currentTime
= windowStart
;
566 currentEventTime
= currentTime
;
568 // Notify control that the window changed
569 windowChangedNotification();
571 // Make sure we redraw the change
572 fullExperimentCanvas
.redraw();
579 * Create the canvas needed and issue the requests
581 * @param newExperiment Experiment we will use for the request
583 private void createCanvasAndRequests(TmfExperiment
<LttngEvent
> newExperiment
) {
584 // Save the experiment we are about to use
585 lastUsedExperiment
= newExperiment
;
587 // // Create a copy of the trace that will be use only by the full experiment request
588 // TmfExperiment<LttngEvent> experimentCopy = newExperiment.createTraceCopy();
590 // Create the content for the full experiment.
591 // This NEED to be created first, as we use it in the selectedWindowCanvas
592 fullExperimentCanvas
.createNewHistogramContent(
593 fullExperimentCanvas
.getSize().x
,
594 FULL_TRACE_BAR_WIDTH
,
596 // 2010-06-20 Yuriy: We will use the dynamic height.
597 FULL_TRACE_CANVAS_HEIGHT
599 fullExperimentCanvas
.getSize().y
/ 2,
600 FULL_TRACE_DIFFERENCE_TO_AVERAGE
603 TmfTimeRange timeRange
= getExperimentTimeRange(newExperiment
);
605 // We will take the half of the full experiment length in case of bigger window size than the full experiment length
606 if(timeRange
.getEndTime().getValue() - timeRange
.getStartTime().getValue() > DEFAULT_WINDOW_SIZE
) {
607 fullExperimentCanvas
.createNewSelectedWindow(
608 timeRange
.getStartTime().getValue(),
612 fullExperimentCanvas
.createNewSelectedWindow(
613 timeRange
.getStartTime().getValue(),
614 (timeRange
.getEndTime().getValue() - timeRange
.getStartTime().getValue() ) / 2
618 currentEventTime
= timeRange
.getStartTime().getValue();
620 // Set the window of the fullTrace canvas visible.
621 fullExperimentCanvas
.getCurrentWindow().setSelectedWindowVisible(true);
622 fullExperimentCanvas
.getHistogramContent().resetTable(timeRange
.getStartTime().getValue(), timeRange
.getEndTime().getValue());
624 // Create the content for the selected window.
625 selectedWindowCanvas
.createNewHistogramContent(
626 selectedWindowCanvas
.getSize().x
,
627 SELECTED_WINDOW_BAR_WIDTH
,
628 selectedWindowCanvas
.getSize().y
,
629 SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE
631 selectedWindowCanvas
.getHistogramContent().resetTable(fullExperimentCanvas
.getCurrentWindow().getTimestampOfLeftPosition(), fullExperimentCanvas
.getCurrentWindow().getTimestampOfRightPosition());
633 // Make sure the UI object are sane
634 resetControlsContent();
636 // Redraw the canvas right away to have something "clean" as soon as we can
637 if ( dataBackgroundFullRequest
!= null ) {
638 fullExperimentCanvas
.redraw();
639 selectedWindowCanvas
.redraw();
641 // Nullify the (possible) old request to be sure we start we something clean
642 // Note : this is very important for the order of the request below,
643 // see "TODO" in performSelectedWindowEventsRequest
644 dataBackgroundFullRequest
= null;
645 selectedWindowRequest
= null;
647 // Perform both request.
648 // Order is important here, the small/synchronous request for the selection window should go first
649 performSelectedWindowEventsRequest(newExperiment
);
650 performAllTraceEventsRequest(newExperiment
);
653 // Before completing its indexing, the experiment doesn't know start/end time.
654 // However, LTTng individual traces have this knowledge so we should ask them
656 private TmfTimeRange
getExperimentTimeRange(TmfExperiment
<LttngEvent
> experiment
) {
657 // Before completing its indexing, the experiment doesn't know start/end time.
658 // However, LTTng individual traces have this knowledge so we should ask them
660 TmfTimestamp startTime
= TmfTimestamp
.BigCrunch
;
661 TmfTimestamp endTime
= TmfTimestamp
.BigBang
;
662 for (ITmfTrace trace
: experiment
.getTraces()) {
663 TmfContext context
= trace
.seekLocation(null);
665 TmfEvent event
= trace
.getNextEvent(context
);
666 TmfTimestamp traceStartTime
= event
.getTimestamp();
667 if (traceStartTime
.compareTo(startTime
, true) < 0)
668 startTime
= traceStartTime
;
669 TmfTimestamp traceEndTime
= trace
.getEndTime();
670 if (traceEndTime
.compareTo(endTime
, true) > 0)
671 endTime
= traceEndTime
;
673 TmfTimeRange tmpRange
= new TmfTimeRange(startTime
, endTime
);
678 * Perform a new request for the Selection window.<p>
679 * This assume the full experiment canvas has correct information about the selected window;
680 * we need the fullExperimentCanvas' HistogramContent to be created and a selection window to be set.
682 * @param experiment The experiment we will select from
684 public void performSelectedWindowEventsRequest(TmfExperiment
<LttngEvent
> experiment
) {
686 if(fullExperimentCanvas
!= null) {
687 HistogramSelectedWindow curSelectedWindow
= fullExperimentCanvas
.getCurrentWindow();
689 TmfTimeRange timeRange
= getExperimentTimeRange(experiment
);
691 // If no selection window exists, we will try to create one;
692 // however this will most likely fail as the content is probably not created either
693 if ( curSelectedWindow
== null ) {
694 // We will take the half of the full experiment length in case of bigger window size than the full experiment length
695 if(timeRange
.getEndTime().getValue() - timeRange
.getStartTime().getValue() > DEFAULT_WINDOW_SIZE
) {
696 fullExperimentCanvas
.createNewSelectedWindow(
697 timeRange
.getStartTime().getValue(),
701 fullExperimentCanvas
.createNewSelectedWindow(
702 timeRange
.getStartTime().getValue(),
703 (timeRange
.getEndTime().getValue() - timeRange
.getStartTime().getValue() ) / 2
706 curSelectedWindow
= fullExperimentCanvas
.getCurrentWindow();
709 // The request will go from the Left timestamp of the window to the Right timestamp
710 // This assume that out-of-bound value are handled by the SelectionWindow itself
711 LttngTimestamp ts1
= new LttngTimestamp( curSelectedWindow
.getTimestampOfLeftPosition() );
712 LttngTimestamp ts2
= new LttngTimestamp( curSelectedWindow
.getTimestampOfRightPosition() );
713 TmfTimeRange tmpRange
= new TmfTimeRange(ts1
, ts2
);
715 // Set a (dynamic) time interval
716 long intervalTime
= ( (ts2
.getValue() - ts1
.getValue()) / selectedWindowCanvas
.getHistogramContent().getNbElement() );
718 selectedWindowRequest
= performRequest(experiment
, selectedWindowCanvas
, tmpRange
, intervalTime
,
719 ExecutionType
.FOREGROUND
);
720 selectedWindowCanvas
.redrawAsynchronously();
726 * Perform a new request for the full experiment.<p>
727 * NOTE : this is very long, we need to implement a way to run this in parallel (see TODO)
729 * @param experiment The experiment we will select from
731 public void performAllTraceEventsRequest(TmfExperiment
<LttngEvent
> experiment
) {
732 // Create a new time range from "start" to "end"
733 // That way, we will get "everything" in the trace
734 // LttngTimestamp ts1 = new LttngTimestamp( experiment.getStartTime() );
735 // LttngTimestamp ts2 = new LttngTimestamp( experiment.getEndTime() );
736 // TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
738 TmfTimeRange tmpRange
= getExperimentTimeRange(experiment
);
739 TmfTimestamp startTime
= tmpRange
.getStartTime();
740 TmfTimestamp endTime
= tmpRange
.getEndTime();
742 // Set a (dynamic) time interval
743 long intervalTime
= ( (endTime
.getValue() - startTime
.getValue()) / fullExperimentCanvas
.getHistogramContent().getNbElement() );
746 // This would enable "fixed interval" instead of dynamic one.
747 // ... we don't need it, do we?
749 // long intervalTime = ((long)(0.001 * (double)1000000000));
752 // It would be interesting if there was a way to tell the framework to run the request "in parallel" here.
753 // Mean a completetly independant copy of the Expereiment would be done and we would proceed on that.
755 dataBackgroundFullRequest
= performRequest(experiment
, fullExperimentCanvas
, tmpRange
, intervalTime
, ExecutionType
.BACKGROUND
);
758 fullExperimentCanvas
.getCurrentWindow().setWindowXPositionLeft(fullExperimentCanvas
.getHistogramContent().getClosestXPositionFromTimestamp(fullExperimentCanvas
.getCurrentWindow().getTimestampOfLeftPosition()));
759 fullExperimentCanvas
.getCurrentWindow().setWindowXPositionCenter(fullExperimentCanvas
.getHistogramContent().getClosestXPositionFromTimestamp(fullExperimentCanvas
.getCurrentWindow().getTimestampOfCenterPosition()));
760 fullExperimentCanvas
.getCurrentWindow().setWindowXPositionRight(fullExperimentCanvas
.getHistogramContent().getClosestXPositionFromTimestamp(fullExperimentCanvas
.getCurrentWindow().getTimestampOfRightPosition()));
762 fullExperimentCanvas
.redrawAsynchronously();
766 // This function is synchronized, is it a good idea?
767 // Tis is done to make sure requests arrive somewhat in order,
768 // this is especially important when request are issued from different thread.
770 * Create a new request from the given data and send it to the framework.<p>
771 * The request will be queued and processed later.
773 * @param experiment The experiment we will process the request on
774 * @param targetCanvas The canvas that will received the result
775 * @param newRange The range of the request
776 * @param newInterval The interval of time we use to store the result into the HistogramContent
778 private synchronized HistogramRequest
performRequest(TmfExperiment
<LttngEvent
> experiment
, HistogramCanvas targetCanvas
, TmfTimeRange newRange
, long newInterval
, ITmfDataRequest
.ExecutionType execType
) {
779 HistogramRequest returnedRequest
= null;
783 // We use int.MAX_VALUE because we want every events BUT we don't know the number inside the range.
784 // HOWEVER, this would cause the request to run forever (or until it reach the end of trace).
785 // Seeting an EndTime does not seems to stop the request
786 returnedRequest
= new HistogramRequest(newRange
, Integer
.MAX_VALUE
, targetCanvas
, newInterval
, execType
);
788 // Send the request to the framework : it will be queued and processed later
789 experiment
.sendRequest(returnedRequest
);
791 return returnedRequest
;
795 * Function used to warn that the selection window changed.<p>
796 * This might be called because the window moved or because its size changed.<p>
798 * We will update the different control related to the selection window.
800 public void windowChangedNotification() {
802 if ( lastUsedExperiment
!= null ) {
803 // If a request is ongoing, try to stop it
804 if ( selectedWindowRequest
!= null && selectedWindowRequest
.isCompleted() == false ) {
805 selectedWindowRequest
.cancel();
808 if(fullExperimentCanvas
!= null) {
809 // If the current event time is outside the new window, change the current event
810 // The new current event will be the one closest to the LEFT side of the new window
811 if ( isGivenTimestampInSelectedWindow(currentEventTime
) == false ) {
812 currentEventChangeNotification( fullExperimentCanvas
.getCurrentWindow().getTimestampOfLeftPosition() );
816 // Perform a new request to read data about the new window
817 performSelectedWindowEventsRequest(lastUsedExperiment
);
822 * Function used to tell that the current event changed.<p>
823 * This might be called because the user changed the current event or
824 * because the last current event is now outside the selection window.<p>
826 * We update the related control and send a signal to notify other views of the new current event.
828 * @param newCurrentEventTime
830 public void currentEventChangeNotification(long newCurrentEventTime
) {
832 // Notify other views in the framework
833 if (currentEventTime
!= newCurrentEventTime
) {
834 currentEventTime
= newCurrentEventTime
;
836 // Update the UI control
837 updateSelectedEventTime();
841 public void sendTmfTimeSynchSignalBroadcast() {
843 // System.out.println("sendTmfTimeSynchSignalBroadcast " + System.currentTimeMillis());
845 // Send a signal to the framework
846 LttngTimestamp tmpTimestamp
= new LttngTimestamp(currentEventTime
);
847 broadcast(new TmfTimeSynchSignal(this, tmpTimestamp
));
851 * Function used to tell that the timerange (window) changed.<p>
852 * This will most likely be called if the time window is resized.
854 * We send a signal to notify other views of the new timerange.
856 public void sendTmfRangeSynchSignalBroadcast() {
858 if (TmfExperiment
.getCurrentExperiment() == null)
861 long startTime
= fullExperimentCanvas
.getCurrentWindow().getTimestampOfLeftPosition();
862 if ( startTime
< fullExperimentCanvas
.getHistogramContent().getStartTime() ) {
863 startTime
= fullExperimentCanvas
.getHistogramContent().getStartTime();
865 LttngTimestamp tmpStartTime
= new LttngTimestamp(startTime
);
867 long endTime
= fullExperimentCanvas
.getCurrentWindow().getTimestampOfRightPosition();
868 if ( endTime
> fullExperimentCanvas
.getHistogramContent().getEndTime() ) {
869 endTime
= fullExperimentCanvas
.getHistogramContent().getEndTime();
871 LttngTimestamp tmpEndTime
= new LttngTimestamp(endTime
);
873 TmfTimeRange tmpTimeRange
= new TmfTimeRange(tmpStartTime
, tmpEndTime
);
874 LttngTimestamp tmpEventTime
= new LttngTimestamp(currentEventTime
);
876 // Send a signal to the framework
877 broadcast(new TmfRangeSynchSignal(this, tmpTimeRange
, tmpEventTime
));
881 * Function that will be called when one of the time text group value is changed.<p>
882 * Since we don't (and can't unless we subclass them) know which one, we check them all.
884 public void timeTextGroupChangeNotification() {
886 if(ntgCurrentEventTime
!= null) {
887 // If the user changed the current event time, call the notification
888 long newCurrentTime
= ntgCurrentEventTime
.getValue();
889 if ( newCurrentTime
!= currentEventTime
) {
890 currentEventChangeNotification( newCurrentTime
);
891 // Send a broadcast to the framework about the window change
892 sendTmfTimeSynchSignalBroadcast();
896 if(ntgCurrentWindowTime
!= null && fullExperimentCanvas
!= null) {
897 // If the user changed the selected window time, recenter the window and call the notification
898 long newSelectedWindowTime
= ntgCurrentWindowTime
.getValue();
899 if ( newSelectedWindowTime
!= fullExperimentCanvas
.getCurrentWindow().getTimestampOfCenterPosition() ) {
900 fullExperimentCanvas
.setWindowCenterPosition(newSelectedWindowTime
);
901 windowChangedNotification();
902 // Send a broadcast to the framework about the window change
903 sendTmfRangeSynchSignalBroadcast();
907 if(ntgTimeRangeWindow
!= null && fullExperimentCanvas
!= null) {
908 // If the user changed the selected window size, resize the window and call the notification
909 long newSelectedWindowTimeRange
= ntgTimeRangeWindow
.getValue();
910 if ( newSelectedWindowTimeRange
!= fullExperimentCanvas
.getCurrentWindow().getWindowTimeWidth() ) {
911 fullExperimentCanvas
.resizeWindowByAbsoluteTime(newSelectedWindowTimeRange
);
912 windowChangedNotification();
913 // Send a broadcast to the framework about the window change
914 sendTmfRangeSynchSignalBroadcast();
921 * Getter for the last used experiment.<p>
922 * This might be different than the current experiment or even null.
924 * @return the last experiment we used in this view
926 public TmfExperiment
<LttngEvent
> getLastUsedExperiment() {
927 return lastUsedExperiment
;
931 * Check if a given timestamp is inside the selection window.<p>
932 * This assume fullExperimentCanvas contain a valid HistogramContent
934 * @param timestamp the timestamp to check
936 * @return if the time is inside the selection window or not
938 public boolean isGivenTimestampInSelectedWindow(long timestamp
) {
939 boolean returnedValue
= true;
941 // If the content is not set correctly, this will return weird (or even null) result
942 if ( (timestamp
< fullExperimentCanvas
.getCurrentWindow().getTimestampOfLeftPosition() ) ||
943 (timestamp
> fullExperimentCanvas
.getCurrentWindow().getTimestampOfRightPosition() ) )
945 returnedValue
= false;
948 return returnedValue
;
952 * Reset the content of all Controls.<p>
953 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
955 public void resetControlsContent() {
957 TmfExperiment
<LttngEvent
> tmpExperiment
= getLastUsedExperiment();
959 // Use the previous Start and End time, or default if they are not available
960 String startTime
= null;
961 String stopTime
= null;
962 if ( tmpExperiment
!= null ) {
963 startTime
= HistogramConstant
.formatNanoSecondsTime( tmpExperiment
.getStartTime().getValue() );
964 stopTime
= HistogramConstant
.formatNanoSecondsTime( tmpExperiment
.getEndTime().getValue() );
967 startTime
= HistogramConstant
.formatNanoSecondsTime( 0L );
968 stopTime
= HistogramConstant
.formatNanoSecondsTime( 0L );
971 txtExperimentStartTime
.setText( startTime
);
972 txtExperimentStopTime
.setText( stopTime
);
973 txtExperimentStartTime
.getParent().layout();
975 txtWindowMaxNbEvents
.setText("" + 0);
976 txtWindowMinNbEvents
.setText("" + 0);
977 txtWindowStartTime
.setText( HistogramConstant
.formatNanoSecondsTime( 0L ) );
978 txtWindowStopTime
.setText( HistogramConstant
.formatNanoSecondsTime( 0L ) );
979 txtWindowStartTime
.getParent().layout();
981 ntgCurrentWindowTime
.setValue( HistogramConstant
.formatNanoSecondsTime( 0L ) );
982 ntgTimeRangeWindow
.setValue( HistogramConstant
.formatNanoSecondsTime( 0L ) );
984 // Using "startTime" here can avoid an useless TmfTimeSynchSignal here
985 // However it look ugly to have only this time
986 ntgCurrentEventTime
.setValue( HistogramConstant
.formatNanoSecondsTime( 0L ) );
990 * Update the content of the controls related to the full experiment canvas<p>
991 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
993 public void updateFullExperimentInformation() {
995 if(fullExperimentCanvas
!= null) {
996 String startTime
= HistogramConstant
.formatNanoSecondsTime( fullExperimentCanvas
.getHistogramContent().getStartTime() );
997 String stopTime
= HistogramConstant
.formatNanoSecondsTime( fullExperimentCanvas
.getHistogramContent().getEndTime() );
999 txtExperimentStartTime
.setText( startTime
);
1000 txtExperimentStopTime
.setText( stopTime
);
1003 // Take one of the parent and call its layout to update control size
1004 // Since both control have the same parent, only one call is needed
1005 txtExperimentStartTime
.getParent().layout();
1007 // Update the selected window, just in case
1008 // This should give a better user experience and it is low cost
1009 updateSelectedWindowInformation();
1013 * Update the content of the controls related to the selection window canvas<p>
1014 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
1016 public void updateSelectedWindowInformation() {
1017 // Update the timestamp as well
1018 updateSelectedWindowTimestamp();
1020 if(selectedWindowCanvas
!= null) {
1021 txtWindowMaxNbEvents
.setText( Long
.toString(selectedWindowCanvas
.getHistogramContent().getHeighestEventCount()) );
1022 txtWindowMinNbEvents
.setText(Long
.toString(0));
1025 // Refresh the layout
1026 txtWindowMaxNbEvents
.getParent().layout();
1030 * Update the content of the controls related to the timestamp of the selection window<p>
1031 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
1033 public void updateSelectedWindowTimestamp() {
1035 if(selectedWindowCanvas
!= null) {
1036 String startTime
= HistogramConstant
.formatNanoSecondsTime( selectedWindowCanvas
.getHistogramContent().getStartTime() );
1037 String stopTime
= HistogramConstant
.formatNanoSecondsTime( selectedWindowCanvas
.getHistogramContent().getEndTime() );
1038 txtWindowStartTime
.setText( startTime
);
1039 txtWindowStopTime
.setText( stopTime
);
1042 if(fullExperimentCanvas
!= null) {
1043 ntgCurrentWindowTime
.setValue( fullExperimentCanvas
.getCurrentWindow().getTimestampOfCenterPosition() );
1044 ntgTimeRangeWindow
.setValue( fullExperimentCanvas
.getCurrentWindow().getWindowTimeWidth() );
1046 // If the current event time is outside the selection window, recenter our window
1047 if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime
.getValue()) == false ) {
1048 currentEventChangeNotification( fullExperimentCanvas
.getCurrentWindow().getTimestampOfCenterPosition() );
1052 // Take one control in each group to call to refresh the layout
1053 // Since both control have the same parent, only one call is needed
1054 txtWindowStartTime
.getParent().layout();
1055 ntgCurrentWindowTime
.getParent().layout();
1059 * Update the controls related current event.<p>
1060 * The call here SHOULD be thread safe and can be call from any threads.
1062 public void updateSelectedEventTime() {
1063 ntgCurrentEventTime
.setValueAsynchronously(currentEventTime
);
1064 // Tell the selection canvas which event is currently selected
1065 // This give a nice graphic output
1066 selectedWindowCanvas
.getHistogramContent().setSelectedEventTimeInWindow(currentEventTime
);
1067 selectedWindowCanvas
.redrawAsynchronously();
1071 * Method called when the view is moved.<p>
1073 * Just redraw everything...
1075 * @param event The controle event generated by the move.
1077 public void controlMoved(ControlEvent event
) {
1082 * Method called when the view is resized.<p>
1084 * We will make sure that the size didn't change more than the content size.<p>
1085 * Otherwise we need to perform a new request for the full experiment because we are missing data).
1087 * @param event The control event generated by the resize.
1089 public void controlResized(ControlEvent event
) {
1091 // Ouch! The screen enlarged (screen resolution changed?) so far that we miss content to fill the space.
1092 if ( parent
.getDisplay().getBounds().width
> fullExperimentCanvas
.getHistogramContent().getNbElement() ) {
1093 if ( lastUsedExperiment
!= null ) {
1094 createCanvasAndRequests(lastUsedExperiment
);
1101 * Getter of FullExperimentCanvas
1103 * @return FullExperimentCanvas object
1105 public static ParentHistogramCanvas
getFullExperimentCanvas() {
1106 return fullExperimentCanvas
;
1110 * Getter of SelectedWindowCanvas
1112 * @return SelectedWindowCanvas object
1114 public static ChildrenHistogramCanvas
getSelectedWindowCanvas() {
1115 return selectedWindowCanvas
;
1120 * Getter of DEFAULT_WINDOW_SIZE
1122 * @return DEFAULT_WINDOW_SIZE value
1124 public static long getDEFAULT_WINDOW_SIZE() {
1125 return DEFAULT_WINDOW_SIZE
;
1129 * Getter for dataBackgroundFullRequest variable
1130 * @return the dataBackgroundFullRequest instance
1132 public HistogramRequest
getDataBackgroundFullRequest() {
1133 return dataBackgroundFullRequest
;
1137 * Getter for selectedWindowRequest variable
1138 * @return the selectedWindowRequest instance
1140 public HistogramRequest
getSelectedWindowRequest() {
1141 return selectedWindowRequest
;