Draft of a HistogramView, in process of merging into the TimeFrameView
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / histogram / HistogramView.java
CommitLineData
6e512b93
ASL
1/*******************************************************************************
2 * Copyright (c) 2009 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:
b59134e1 10 * William Bourque - Initial API and implementation
6e512b93 11 *******************************************************************************/
8035003b 12
6e512b93
ASL
13package org.eclipse.linuxtools.lttng.ui.views.histogram;
14
b59134e1
WB
15
16import org.eclipse.linuxtools.lttng.event.LttngEvent;
17import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
18import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
19import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
20import org.eclipse.linuxtools.tmf.experiment.TmfExperimentSelectedSignal;
21import org.eclipse.linuxtools.tmf.experiment.TmfExperimentUpdatedSignal;
22import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
23import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
24import org.eclipse.linuxtools.tmf.ui.views.TmfView;
25import org.eclipse.swt.SWT;
26import org.eclipse.swt.layout.GridData;
6e512b93 27import org.eclipse.swt.widgets.Composite;
6e512b93 28
b59134e1 29public class HistogramView extends TmfView {
8035003b 30
62d1696a 31 public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.histogram";
b59134e1
WB
32
33
34 private HistogramRequest dataBackgroundFullRequest = null;
35 private TraceCanvas fullTraceCanvas = null;
36
37 private HistogramRequest selectedWindowRequest = null;
38 private TraceCanvas selectedWindowCanvas = null;
39
6e512b93 40 public HistogramView() {
b59134e1 41 super(ID);
6e512b93 42 }
b59134e1
WB
43
44
6e512b93 45 @Override
8035003b 46 public void createPartControl(Composite parent) {
b59134e1
WB
47
48 Composite folderGroup = new Composite(parent, SWT.NONE);
49
50// GridLayout gl = new GridLayout();
51// gl.marginHeight = 0;
52// gl.marginWidth = 0;
53// folderGroup.setLayout(gl);
54
55 folderGroup.setSize(parent.getDisplay().getBounds().width, parent.getDisplay().getBounds().height);
56 folderGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
57
58 fullTraceCanvas = new TraceCanvas(folderGroup, SWT.NONE, 2, 50);
59
60
61// GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
62// gd.heightHint = 50;
63// fullTraceCanvas.setLayoutData(gd);
64
65 fullTraceCanvas.redraw();
6e512b93 66 }
b59134e1 67
8035003b 68
b59134e1 69 @SuppressWarnings("unchecked")
6e512b93
ASL
70 @Override
71 public void setFocus() {
b59134e1
WB
72
73 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)TmfExperiment.getCurrentExperiment();
74
75 if ( (dataBackgroundFullRequest == null) && (tmpExperiment != null) ) {
76 // Create a new time range from "start" to "end"
77 // That way, we will get "everything" in the trace
78 LttngTimestamp ts1 = new LttngTimestamp( tmpExperiment.getStartTime() );
79 LttngTimestamp ts2 = new LttngTimestamp( tmpExperiment.getEndTime() );
80 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
81 dataBackgroundFullRequest = performRequest(tmpExperiment, fullTraceCanvas, tmpRange);
82
83 fullTraceCanvas.redraw();
84 }
6e512b93 85 }
b59134e1
WB
86
87
88 @SuppressWarnings("unchecked")
89 @TmfSignalHandler
90 public void experimentSelected(TmfExperimentSelectedSignal<LttngEvent> signal) {
91 fullTraceCanvas.getHistogramContent().resetContentData();
92 fullTraceCanvas.resetSelectedWindow();
93
94 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
95
96 // Create a new time range from "start" to "end"
97 // That way, we will get "everything" in the trace
98 //LttngTimestamp ts1 = new LttngTimestamp( tmpExperiment.getStartTime() );
99 //LttngTimestamp ts2 = new LttngTimestamp( tmpExperiment.getEndTime() );
100 LttngTimestamp ts1 = new LttngTimestamp( tmpExperiment.getStartTime() );
101 LttngTimestamp ts2 = new LttngTimestamp( tmpExperiment.getEndTime() );
102 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
103
104 dataBackgroundFullRequest = performRequest(tmpExperiment, fullTraceCanvas, tmpRange);
105
106 fullTraceCanvas.redraw();
107 }
108
109 // *** VERIFY ***
110 // this function is synchronized, is it a good idea?
111 public synchronized HistogramRequest performRequest(TmfExperiment<LttngEvent> experiment, TraceCanvas targetCanvas, TmfTimeRange newRange) {
112
113 HistogramRequest returnedRequest = null;
114
115 // The content holder we will use
116 HistogramContent content = targetCanvas.getHistogramContent();
117
118 // We use integer.MAX_VALUE because we want to make sure we get every events
119 returnedRequest = new HistogramRequest(LttngEvent.class, newRange, Integer.MAX_VALUE, content, targetCanvas );
120
121 content.setStartTime( experiment.getStartTime().getValue() );
122 content.setEndTime( experiment.getEndTime().getValue() );
123
124 // Set a (dynamic) time interval
125 content.setIntervalTime( (content.getEndTime() - content.getStartTime()) / content.getNbElement() );
126
127 // *** VERIFY ***
128 // This would enable "fixed interval" instead of dynamic one.
129 //
130 //content.setIntervalTime((long)(0.001 * (double)1000000000));
131
132 experiment.sendRequest(returnedRequest);
133
134 return returnedRequest;
135 }
8035003b 136
b59134e1
WB
137
138 @TmfSignalHandler
139 public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
140 System.out.println("experimentUpdated");
141
142 // *** TODO ***
143 // Update the histogram if the time changed
144 //
145
146 }
147
148
149 @TmfSignalHandler
150 public void currentTimeUpdated(TmfTimeSynchSignal signal) {
151 System.out.println("currentTimeUpdated");
152 }
6e512b93 153}
This page took 0.054959 seconds and 5 git commands to generate.