2010-07-30 Francois Chouinard <fchouinard@gmail.com> Fix for Bug311930 and Bug32168
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / histogram / HistogramSelectedWindow.java
CommitLineData
378e7718
WB
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:
10 * William Bourque - Initial API and implementation
f05aabed
FC
11 *
12 * Modifications:
13 * 2010-07-16 Yuriy Vashchuk - Heritage correction and selection window
14 * optimisations.
378e7718 15 *******************************************************************************/
6e512b93
ASL
16package org.eclipse.linuxtools.lttng.ui.views.histogram;
17
050df4a5
WB
18/**
19 * <b><u>HistogramSelectedWindow</u></b>
20 * <p>
21 * Selection window represent the selected section of the trace in the HistogramCanvas.
22 * <p>
23 * The selected window have 3 important attributes :
24 * <ul>
25 * <li>Its central position
26 * <li>Its time width
27 * <li>Its visibility (to determine if we should draw it or not)
28 * </ul>
29 * The dimension are then deduced from the first 2 values.
30 * This mean the window is always a perfectly symetrical rectangle.
31 */
6e512b93 32public class HistogramSelectedWindow {
ecfd1d41 33
f05aabed
FC
34 private long timestampOfLeftPosition = 0;
35 private long timestampOfCenterPosition = 0;
36 private long timestampOfRightPosition = 0;
37 private long windowTimeWidth = 0L;
38 private int windowXPositionLeft = 0;
39 private int windowXPositionCenter = 0;
40 private int windowXPositionRight = 0;
41 private Boolean isSelectedWindowVisible = false;
ecfd1d41 42
050df4a5
WB
43 /**
44 * Default constructor for HistogramSelectedWindow.<p>
45 * Position and TimeWidth are set to given value.
46 *
47 * @param newTraceContent HistogramContent to read window's data from
48 * @param centralPosition Central X Position of the selection window in the canvas (0 to canvasWidth)
49 * @param newWindowWidth Time width (size) of the window. (0 or greater)
50 */
f05aabed
FC
51 public HistogramSelectedWindow(HistogramContent newTraceContent, long timestampOfLeftPosition, long newWindowWidth) {
52 if(newTraceContent != null) {
53 setWindowTimeWidth(newWindowWidth);
54 setTimestampOfLeftPosition(timestampOfLeftPosition);
55 setTimestampOfRightPosition(timestampOfLeftPosition + newWindowWidth);
56 setTimestampOfCenterPosition(timestampOfLeftPosition + newWindowWidth / 2);
57 }
050df4a5
WB
58 }
59
050df4a5
WB
60 /**
61 * Getter for the window visibility.<p>
62 *
63 * @return true if the window is visible (will be draw), false otherwise
64 */
ecfd1d41
WB
65 public boolean getSelectedWindowVisible() {
66 return isSelectedWindowVisible;
67 }
68
050df4a5
WB
69 /**
70 * Setter for the window visibility.<p>
71 * True means the window will be draw, false that it will be hidden.
72 *
73 * @param newIsSelectedWindowVisible The visibility value
74 */
544fe9b7 75 public void setSelectedWindowVisible(Boolean newIsSelectedWindowVisible) {
ecfd1d41
WB
76 this.isSelectedWindowVisible = newIsSelectedWindowVisible;
77 }
ecfd1d41 78
050df4a5
WB
79
80 /**
81 * Getter for the window time width (size)
82 *
83 * @return Window time width (size)
84 */
ecfd1d41
WB
85 public long getWindowTimeWidth() {
86 return windowTimeWidth;
87 }
88
050df4a5
WB
89 /**
90 * Setter for the window time width (size).<p>
91 * Width need to be a time (in nanoseconds) that's coherent to the data we are looking at.
92 *
93 * @param newWindowTimeWidth The new time width
94 */
1406f802 95 public void setWindowTimeWidth(long newWindowTimeWidth) {
ecfd1d41
WB
96 this.windowTimeWidth = newWindowTimeWidth;
97 }
98
050df4a5 99 /**
f05aabed
FC
100 * Getter for the timestamp of left border of the window.<p>
101 * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
050df4a5 102 *
f05aabed 103 * @return The left timestamp of the window, or 0 if it cannot compute it.
050df4a5 104 */
f05aabed
FC
105 public long getTimestampOfLeftPosition() {
106 return timestampOfLeftPosition;
ecfd1d41
WB
107 }
108
050df4a5 109 /**
f05aabed
FC
110 * Setter for the timestamp of left border of the window.<p>
111 * @param timestampOfLeftPosition The left timestamp of the window.
050df4a5 112 */
f05aabed
FC
113 public void setTimestampOfLeftPosition(long timestampOfLeftPosition) {
114 this.timestampOfLeftPosition = timestampOfLeftPosition;
115 }
ecfd1d41 116
050df4a5 117 /**
f05aabed
FC
118 * Getter for the timestamp of the center of the window.<p>
119 * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
050df4a5 120 *
f05aabed 121 * @return The center timestamp of the window, or 0 if it cannot compute it.
050df4a5 122 */
f05aabed
FC
123 public long getTimestampOfCenterPosition() {
124 return timestampOfCenterPosition;
ecfd1d41 125 }
f05aabed 126
050df4a5 127 /**
f05aabed 128 * Setter for the timestamp of center border of the window.<p>
050df4a5 129 */
f05aabed
FC
130 public void setTimestampOfCenterPosition(long timestampOfCenterPosition) {
131 this.timestampOfCenterPosition = timestampOfCenterPosition;
ecfd1d41
WB
132 }
133
050df4a5 134 /**
f05aabed
FC
135 * Setter for the timestamp of center border of the window.<p>
136 */
137 public void setTimestampOfLeftCenterRightPositions(long timestampOfCenterPosition) {
138 this.timestampOfLeftPosition = timestampOfCenterPosition - windowTimeWidth / 2;
139 this.timestampOfCenterPosition = timestampOfCenterPosition;
140 this.timestampOfRightPosition = timestampOfCenterPosition + windowTimeWidth / 2;
141 }
142
143 /**
144 * Getter for the timestamp of right border of the window.<p>
050df4a5
WB
145 * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.
146 *
f05aabed 147 * @return The right timestamp of the window, or 0 if it cannot compute it.
050df4a5 148 */
f05aabed
FC
149 public long getTimestampOfRightPosition() {
150 return timestampOfRightPosition;
833a21aa
WB
151 }
152
153 /**
f05aabed
FC
154 * Setter for the timestamp of right border of the window.<p>
155 * @param timestampOfRightPosition The right timestamp of the window.
156 */
157 public void setTimestampOfRightPosition(long timestampOfRightPosition) {
158 this.timestampOfRightPosition = timestampOfRightPosition;
159 }
160
161 /**
162 * Getter for the coordinate of left border of the window.<p>
833a21aa 163 *
f05aabed 164 * @return The left coordinate.
833a21aa 165 */
f05aabed
FC
166 public int getWindowXPositionLeft() {
167 return windowXPositionLeft;
ecfd1d41 168 }
f05aabed 169
050df4a5 170 /**
f05aabed
FC
171 * Setter for the coordinate of left border of the window.<p>
172 * @param windowXPositionLeft The left coordinate of the window.
173 */
174 public void setWindowXPositionLeft(int windowXPositionLeft) {
175 this.windowXPositionLeft = windowXPositionLeft;
176 }
177
178 /**
179 * Getter for the coordinate of center border of the window.<p>
050df4a5 180 *
f05aabed 181 * @return The center coordinate.
050df4a5 182 */
f05aabed
FC
183 public int getWindowXPositionCenter() {
184 return windowXPositionCenter;
185 }
186
187 /**
188 * Setter for the coordinate of center of the window.<p>
189 * @param windowXPositionCenter The center coordinate of the window.
190 */
191 public void setWindowXPositionCenter(int windowXPositionCenter) {
192 this.windowXPositionCenter = windowXPositionCenter;
193 }
194
195 /**
196 * Getter for the coordinate of right border of the window.<p>
197 *
198 * @return The right coordinate.
199 */
200 public int getWindowXPositionRight() {
201 return windowXPositionRight;
202 }
203
204 /**
205 * Setter for the coordinate of right border of the window.<p>
206 * @param windowXPositionRight The right coordinate of the window.
207 */
208 public void setWindowXPositionRight(int windowXPositionRight) {
209 this.windowXPositionRight = windowXPositionRight;
ecfd1d41 210 }
6e512b93 211}
This page took 0.039136 seconds and 5 git commands to generate.