6e6ab7a007f9748a0a35ffd2f11a8c1fae3c4658
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / histogram / HistogramContent.java
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
11 *******************************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.histogram;
13
14
15 /**
16 * <b><u>HistogramContent</u></b>
17 * <p>
18 * This class hold the content that will be used to draw the Histograms.
19 * <p>
20 */
21 public class HistogramContent {
22 // Start and end time of the content
23 protected Long startTime = 0L;
24 protected Long endTime = 0L;
25
26 // Some information about the content
27 // Most of them are required to calculate position and/or draw
28 // Make sure they stay consistent!
29 protected Long elementsTimeInterval = 0L;
30 protected Double heightFactor = 0.0;
31 protected Long heighestEventCount = 0L;
32 protected Integer maxHeight = 0;
33 protected Integer canvasWindowSize = 0;
34 protected Integer barsWidth = 0;
35
36 // This value is used to calculate at which point we should "cut" bar that are too tall.
37 // Default value is large enought so that no bar should be cut
38 protected Double maxDifferenceToAverage = HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE;
39 // This is a factor we might apply on the max difference to average, as example if we concatenate interval together
40 protected Double maxDifferenceFactor = 1.0;
41
42 // By default we will only consider element up to this position
43 protected Integer readyUpToPosition = 0;
44
45 // The average number of events in the content
46 // Note : this IS needed to draw
47 protected Integer averageNumberOfEvents = 0;
48
49 // This is to draw the selected event of the TMF framework in another color
50 // Set the 0 to ignore
51 protected Long selectedEventTimeInWindow = -1L;
52
53 // The table that hold the elements
54 protected HistogramElement[] elementTable;
55
56
57 /**
58 * Default constructor for the HistogramContent.
59 *
60 * @param tableSize The size ofthe element table that will be created.
61 * @param newCanvasSize The full size of the canvas. Used for positionning; need to be consistent with canvas.
62 * @param newMaxHeight The maximum height of a bar, usually same as the height of the canvas.
63 */
64 public HistogramContent(Integer tableSize, Integer newCanvasSize, Integer newBarWidth, Integer newMaxHeight) {
65 this(tableSize, newCanvasSize, newBarWidth, newMaxHeight, HistogramConstant.DEFAULT_DIFFERENCE_TO_AVERAGE);
66 }
67
68 /**
69 * Default constructor for the HistogramContent.
70 *
71 * @param tableSize The size ofthe element table that will be created.
72 * @param newCanvasSize The full size of the canvas. Used for positionning; need to be consistent with canvas.
73 * @param newMaxHeight The maximum height of a bar, usually same as the height of the canvas.
74 * @param newDiffToAverage This value at which point we "cut" bar that are too tall.
75 */
76 public HistogramContent(Integer tableSize, Integer newCanvasSize, Integer newBarWidth, Integer newMaxHeight, Double newDiffToAverage) {
77 canvasWindowSize = newCanvasSize;
78 barsWidth = newBarWidth;
79 maxHeight = newMaxHeight;
80 maxDifferenceToAverage = newDiffToAverage;
81
82 // Create a new element table from the above value
83 // The table will not get initialized until resetTable() is called.
84 createNewTable(tableSize);
85 }
86
87 /**
88 * Create a new table to hold the content element.<p>
89 * Note that the table is not initialized (and so unusable) until resetTable() is called.
90 *
91 * @param newTableSize The size (number of element) of the table.
92 */
93 public void createNewTable(Integer newTableSize) {
94 elementTable = new HistogramElement[newTableSize];
95
96 for ( int x=0; x<elementTable.length; x++) {
97 elementTable[x] = new HistogramElement();
98 elementTable[x].index = x;
99 }
100 }
101
102 /**
103 * Reset all HistogramContent attributes, but keep the elements table untouched.<p>
104 */
105 public void clearContentData() {
106 startTime = 0L;
107 endTime = 0L;
108
109 elementsTimeInterval = 0L;
110 heightFactor = 0.0;
111 heighestEventCount = 0L;
112
113 readyUpToPosition = 0;
114 }
115
116 /**
117 * Reset the data in the elements table.<p>
118 * NOTE : For this to be consistent and usuable, "startTime", "endTime" and "intervalTime" need to be set already.
119 */
120 public void resetTable() {
121 for ( int x=0; x<elementTable.length; x++) {
122 elementTable[x].index = x;
123 elementTable[x].firstIntervalTimestamp = startTime + (x*elementsTimeInterval);
124 elementTable[x].intervalNbEvents = 0L;
125 elementTable[x].intervalHeight = 0;
126 }
127 }
128
129 /**
130 * Reset the data in the elements table.<p>
131 * Start and EndTime will be used to calculate elementsTimeInterval.<p>
132 *
133 * @param newStartTime The new start time to use
134 * @param newEndTime The new stop time to use
135 */
136 public void resetTable(Long newStartTime, Long newEndTime) {
137 recalculateElementsTimeInterval(newStartTime, newEndTime);
138 resetTable(newStartTime, newEndTime, elementsTimeInterval);
139 }
140
141 /**
142 * Reset the data in the elements table.<p>
143 * elementsTimeInterval will be set to the one give, use this for fixed interval.<p>
144 *
145 * @param newStartTime The new start time to use
146 * @param newEndTime The new stop time to use
147 * @param newTimeInterval The new time interval to use
148 */
149 public void resetTable(Long newStartTime, Long newEndTime, Long newTimeInterval) {
150
151 startTime = newStartTime;
152 endTime = newEndTime;
153 recalculateElementsTimeInterval(newStartTime, newEndTime);
154
155 for ( int x=0; x<elementTable.length; x++) {
156 elementTable[x].index = x;
157 elementTable[x].firstIntervalTimestamp = startTime + (x*elementsTimeInterval);
158 elementTable[x].intervalNbEvents = 0L;
159 elementTable[x].intervalHeight = 0;
160 }
161 }
162
163 /**
164 * Clear (zeroed) the data in the elements table.<p>
165 * NOTE : Unlike reset, this does not recalculate the content,
166 * so it should be done either by hand or by calling reset table after.
167 */
168 public void clearTable() {
169 for ( int x=0; x<elementTable.length; x++) {
170 elementTable[x].index = x;
171 elementTable[x].firstIntervalTimestamp = 0L;
172 elementTable[x].intervalNbEvents = 0L;
173 elementTable[x].intervalHeight = 0;
174 }
175 }
176
177 /**
178 * Print all HistogramContent attributes, but the elements table.
179 */
180 public void printContentInfo() {
181 System.out.println("startTime : " + startTime);
182 System.out.println("endTime : " + endTime );
183 System.out.println();
184 System.out.println("intervalTime : " + elementsTimeInterval);
185 System.out.println("heightFactor : " + heightFactor);
186 System.out.println("heighestEventCount : " + heighestEventCount);
187 System.out.println();
188 System.out.println("readyUpToPosition : " + readyUpToPosition);
189 }
190
191 /**
192 * Print the data in the elements table.<p>
193 */
194 public void printTable() {
195 for ( int x=0; x<elementTable.length; x++) {
196 System.out.println("X:" + x + " -> " + elementTable[x].intervalNbEvents + ":" + elementTable[x].intervalHeight + " (" + elementTable[x].firstIntervalTimestamp + ")");
197 }
198 }
199
200 /**
201 * Getter for the timestamp of the selected event in the window.<p>
202 *
203 * @return The time of the event.
204 */
205 public Long getSelectedEventTimeInWindow() {
206 return selectedEventTimeInWindow;
207 }
208
209 /**
210 * Setter for the timestamp of the selected event in the window.<p>
211 *
212 * This allow to pinpoint a certain event or position in the window.
213 * Set to 0 or lower to ignore.
214 *
215 * @param newPosition The new event time.
216 */
217 public void setSelectedEventTimeInWindow(Long newTime) {
218 this.selectedEventTimeInWindow = newTime;
219 }
220
221 /**
222 * Get an element in the table by its index.<p>
223 * Null is returned if the index is out of range.<p>
224 * Note that you can get an element past "readyUpToPosition", the index is NOT tested against it.
225 *
226 * @param index The index of the element (0 < index < nbElement)
227 *
228 * @return The element found or null if the index is wrong.
229 */
230 public HistogramElement getElementByIndex(Integer index) {
231 HistogramElement returnedElement = null;
232
233 if ( (index >= 0) && (index < elementTable.length) ) {
234 returnedElement = elementTable[index];
235 }
236
237 return returnedElement;
238 }
239
240 /**
241 * Return the closest element to a X position on the canvas.<p>
242 * Note : canvasWindowSize need to be set correctly here, otherwise unexpected element might be returned.<p>
243 * <p>
244 * NOTE : This <b>ALWAYS</b> return an element;
245 * If calculation lead outside the table, the first or the last element will be returned.
246 *
247 * @param position The X position we are looking at (0 < pos < canvasWidth)
248 *
249 * @return The <i>closest</i> element found.
250 */
251 public HistogramElement getClosestElementFromXPosition(Integer position) {
252
253 int index = (int)Math.round((double)elementTable.length * ((double)position / (double)canvasWindowSize) );
254
255 // If we are out of bound, return the closest border (first or last element)
256 if ( index < 0) {
257 index = 0;
258 }
259 else if ( index >= elementTable.length ) {
260 index = (elementTable.length -1);
261 }
262
263 return elementTable[index];
264 }
265
266 /**
267 * Return the closest element's timestamp to a X position on the canvas.<p>
268 * Note : canvasWindowSize need to be set correctly here, otherwise unexpected timestamp might be returned.<p>
269 * <p>
270 * NOTE : This <b>ALWAYS</b> return a timestamp;
271 * If calculation lead outside the table, the first or the last timestamp will be returned.
272 *
273 * @param position The X position we are looking at (0 < pos < canvasWidth)
274 *
275 * @return The <i>closest</i> timestamp found.
276 */
277 public Long getClosestTimestampFromXPosition(Integer position) {
278 return getClosestElementFromXPosition(position).firstIntervalTimestamp;
279 }
280
281 /**
282 * Return the X position (relative to the canvas) of a certain element.<p>
283 * Note : canvasWindowSize need to be set correctly here, otherwise unexpected element might be returned.<p>
284 *
285 * NOTE : This <b>ALWAYS</b> return an element;
286 * If calculation lead outside the table, the first or the last element will be returned.
287 *
288 * @param targetElement The element we are looking to find the position
289 *
290 * @return The <i>closest</i> found element.
291 */
292 public int getXPositionFromElement(HistogramElement targetElement) {
293 return (int)Math.round( ((double)targetElement.index / (double)elementTable.length)*(double)canvasWindowSize );
294 }
295
296 /**
297 * Return the closest element to a timestamp (long) given.<p>
298 * Note : startTime and intervalTime need to be set correctly here, otherwise unexpected element might be returned.<p>
299 * <p>
300 * NOTE : This <b>ALWAYS</b> return an element;
301 * If calculation lead outside the table, the first or the last element will be returned.
302 *
303 * @param timestamp The timestamp (in nanosecond, as long) of the element we are looking for (startTime < timestamp < endTime)
304 *
305 * @return The <i>closest</i> element found.
306 */
307 public HistogramElement getClosestElementFromTimestamp(Long timestamp) {
308 int index = (int)( (timestamp - startTime)/elementsTimeInterval );
309
310 // If we are out of bound, return the closest border (first or last element)
311 if ( index < 0) {
312 index = 0;
313 }
314 else if ( index >= elementTable.length ) {
315 index = (elementTable.length -1);
316 }
317
318 return elementTable[index];
319 }
320
321 /**
322 * Return the closest X position to a timestamp (long) given.<p>
323 * Note : startTime and intervalTime need to be set correctly here, otherwise unexpected position might be returned.<p>
324 * <p>
325 * NOTE : This <b>ALWAYS</b> return a position;
326 * If calculation lead outside the table, the first or the last position will be returned.
327 *
328 * @param timestamp The timestamp (in nanosecond, as long) of the element we are looking for (startTime < timestamp < endTime)
329 *
330 * @return The <i>closest</i> position found.
331 */
332 public Integer getClosestXPositionFromTimestamp(Long timestamp) {
333 return getXPositionFromElement(getClosestElementFromTimestamp(timestamp));
334 }
335
336 /**
337 * Return the closest element to an element and a time interval to this element.<p>
338 * The time interval can be negative or positive (before or after the element).
339 *
340 * Note : IntervalTime and StartTime need to be set correctly here, otherwise unexpected result might be returned.<p>
341 *
342 * @param targetElement The element we compare the interval with.
343 * @param intervalToElement Time negative or positive time interval (in nanosecond) to this element.
344 *
345 * @return The <i>closest</i> found element, or null if given data are wrong.
346 */
347 public HistogramElement getClosestElementByElementAndTimeInterval(HistogramElement targetElement, Long intervalToElement) {
348
349 // Get the timestamp of the target element
350 // This should always be valid as long the table is initialized
351 Long elementTime = targetElement.firstIntervalTimestamp;
352 elementTime = elementTime + intervalToElement;
353
354 return getClosestElementFromTimestamp(elementTime);
355 }
356
357 /**
358 * Return the closest element to an element's timestamp (as long) and a time interval to this element.<p>
359 * The time interval can be negative or positive (before or after the element).
360 *
361 * Note : IntervalTime and StartTime need to be set correctly here, otherwise unexpected result might be returned.<p>
362 *
363 * @param timestamp The timestamp (in nanoseconds, as long) of the element we want to compare from.
364 * @param intervalToElement Time negative or positive time interval (in nanosecond) to this element.
365 *
366 * @return The <i>closest</i> found element, or null if given data are wrong.
367 */
368 public int getClosestElementByTimestampAndTimeInterval(Long timestamp, Long intervalToElement) {
369 HistogramElement targetElement = getClosestElementFromTimestamp(timestamp);
370 HistogramElement newElement = getClosestElementByElementAndTimeInterval(targetElement, intervalToElement);
371
372 return getXPositionFromElement(newElement);
373 }
374
375 /**
376 * Return the closest element to an element's position and a time interval to this element.<p>
377 * The time interval can be negative or positive (before or after the element).
378 *
379 * Note : IntervalTime and StartTime need to be set correctly here, otherwise unexpected result might be returned.<p>
380 *
381 * @param targetPosition The position (relative to the canvas) of the element we want to compare from.
382 * @param intervalToElement Time negative or positive time interval (in nanosecond) to this element.
383 *
384 * @return The <i>closest</i> found element, or null if given data are wrong.
385 */
386 public int getXPositionByPositionAndTimeInterval(int targetPosition, Long intervalToElement) {
387 HistogramElement targetElement = getClosestElementFromXPosition(targetPosition);
388 HistogramElement newElement = getClosestElementByElementAndTimeInterval(targetElement, intervalToElement);
389
390 return getXPositionFromElement(newElement);
391 }
392
393 /**
394 * Getter for the number of element.<p>
395 * The same as the value of tableSize given at construction.
396 *
397 * @return The number of element in the elements table.
398 */
399 public int getNbElement() {
400 return elementTable.length;
401 }
402
403 /**
404 * Getter for the average number of events by interval in the content.<p>
405 *
406 * Note : Might be set externally (instead of calculated internally), so consistency with the content is not guarantee.
407 *
408 * @return Average number of events we currently use in
409 */
410 public int getAverageNumberOfEvents() {
411 return averageNumberOfEvents;
412 }
413
414 /**
415 * Setter for averageNumberOfEvents.<p>
416 *
417 * Note : this is used in some drawing calculation so make sure this number make sense.
418 * Note : you might want to call recalculateEventHeight() if you change this.
419 *
420 * @param newAverageNumberOfEvents The new average number of events to use.
421 */
422 public void setAverageNumberOfEvents(int newAverageNumberOfEvents) {
423 this.averageNumberOfEvents = newAverageNumberOfEvents;
424 }
425
426 /**
427 * Recalculate the average number of events by time interval.<p>
428 *
429 * Note : This run over all the element so this is quite cpu intensive, use with care.
430 */
431 public void recalculateAverageNumberOfEvents() {
432
433 int nbInterval = 0;
434 int totalNbEvents = 0;
435
436 // Go over the element up to readyUpToPosition (further position might not be ready)
437 for ( int x=0; x<readyUpToPosition; x++) {
438 // Skip the empty interval if we were asked to do so.
439 if ( HistogramConstant.SKIP_EMPTY_INTERVALS_WHEN_CALCULATING_AVERAGE ) {
440 if ( elementTable[x].intervalNbEvents > 0 ) {
441 nbInterval++;
442 }
443 }
444 else {
445 nbInterval++;
446 }
447
448 totalNbEvents += elementTable[x].intervalNbEvents;
449 }
450 // Calculate the average here
451 averageNumberOfEvents = (int)((double)totalNbEvents / (double)nbInterval);
452 }
453
454 /**
455 * Getter for the start time of the content.<p>
456 *
457 * @return The start time we currently use.
458 */
459 public Long getStartTime() {
460 return startTime;
461 }
462
463 /**
464 * Setter for the start time of the content.<p>
465 * Note : You probably want to call "resetTable()" if you change this, otherwise data might be inconsistent.
466 *
467 * @param newStartTime the new start time
468 */
469 public void setStartTime(Long newStartTime) {
470 this.startTime = newStartTime;
471 }
472
473
474 /**
475 * Getter for the end time of the content.<p>
476 *
477 * @return The end time we currently use.
478 */
479 public Long getEndTime() {
480 return endTime;
481 }
482
483 /**
484 * Setter for the end time of the content.<p>
485 * Note : You probably want to call "resetTable()" if you change this, otherwise data might be inconsistent.
486 *
487 * @param newStartTime the new end time
488 */
489 public void setEndTime(Long newEndTime) {
490 this.endTime = newEndTime;
491 }
492
493 /**
494 * Getter for the complete time interval of the content.<p>
495 * Note : This return "endTime" minus "startTime", unlike getReadyTimeInterval() it won't check the actual time of elements.
496 *
497 * @return The complete time interval
498 */
499 public Long getCompleteTimeInterval() {
500 return ( endTime - startTime );
501 }
502
503 /**
504 * Getter for the time interval for the element between first and readyUpToPosition<p>
505 * Note : This return element[readyPosition].time - element[first].time , not the full interval like getCompleteTimeInterval()
506 *
507 * @return The time interval of the position that are ready.
508 */
509 public Long getReadyTimeInterval() {
510 return ( elementTable[readyUpToPosition].firstIntervalTimestamp - elementTable[0].firstIntervalTimestamp );
511 }
512
513 /**
514 * Getter for the height factor of the bar.<p>
515 * Note : height = "nb events in interval" * heightFactor
516 *
517 * @return Height factor currently used.
518 */
519 public Double getHeightFactor() {
520 return heightFactor;
521 }
522
523 /**
524 * Recalculate the height factor of the element table.<p>
525 * Assume values of "maxHeight", "heighestEventCount" or "averageNumberOfEvents" are set correctly.
526 */
527 public void recalculateHeightFactor() {
528 // Recalculate the new HeightFactor for the element;
529 // the highest bar will get "maxHeight" and other bar a fraction of it.
530 double diffToConsider = (maxDifferenceToAverage * maxDifferenceFactor * (double)barsWidth);
531 if ( heighestEventCount > (int)(diffToConsider * (double)averageNumberOfEvents) ) {
532 heightFactor = (double)maxHeight/( diffToConsider * (double)averageNumberOfEvents);
533 }
534 else {
535 heightFactor = (double)maxHeight/(double)heighestEventCount;
536 }
537 }
538
539 /**
540 * Recalculate the height of each bar in the elements table.<p>
541 * This assume "heightFactor" is already set correctly.<p>
542 *
543 * NOTE : if "maxHeight", "heighestEventCount" or "averageNumberOfEvents" changes,
544 * recalculateHeightFactor() should be recalled.
545 */
546 public void recalculateEventHeight() {
547 // Recalculate the height of the bars up to "readyUpToPosition"
548 for ( int x=0; x<readyUpToPosition; x++) {
549 elementTable[x].intervalHeight = (int)(elementTable[x].intervalNbEvents * heightFactor);
550 }
551 }
552
553 /**
554 * Recalculate the height of each bar in a certain interval of the elements table.<p>
555 * Unlike recalculateEventHeight(), this only recalculate for the given range, not the whole table.
556 *
557 */
558 public void recalculateEventHeightInInterval(Integer startPosition, Integer stopPosition) {
559 // Basic error checking on start : should be bigger than 0
560 if ( startPosition < 0 ) {
561 startPosition = 0;
562 }
563
564 // Basic error checking on start : should be smaller than length - 1
565 if ( stopPosition >= elementTable.length) {
566 stopPosition = (elementTable.length-1);
567 }
568
569 // Recalculate the height of the bars from startPosition to stopPosition
570 for ( int x=startPosition; x<stopPosition; x++) {
571 elementTable[x].intervalHeight = (int)(elementTable[x].intervalNbEvents * heightFactor);
572 }
573 }
574
575 /**
576 * Getter for the full size of the canvas.<p>
577 * This is used for the positionnal calculation so should be consistent with the real canvas size.
578 *
579 * @return Size of the canvas we currently use.
580 */
581 public Integer getCanvasWindowSize() {
582 return canvasWindowSize;
583 }
584
585 /**
586 * Set a new full size of the canvas.<p>
587 * This is used for the positionnal calculation so should be consistent with the real canvas size.
588 *
589 * @param newSize New canvas size;
590 */
591 public void setCanvasWindowSize(Integer newSize) {
592 canvasWindowSize = newSize;
593 }
594
595 /**
596 * Getter for the heighest event count recorded so far for an interval.<p>
597 *
598 * Note : Might be set externally (instead of calculated internally), so consistency with the content is not guarantee.
599 *
600 * @return Current heighestEventCount
601 */
602 public Long getHeighestEventCount() {
603 return heighestEventCount;
604 }
605
606 /**
607 * Setter for setHeighestEventCount.<p>
608 *
609 * Note : this is used in some drawing calculation so make sure this number make sense.
610 * Note : you might want to call recalculateEventHeight() if you change this.
611 *
612 * @param newHeighestEventCount Heighest event count for a single interval.
613 */
614 public void setHeighestEventCount(Long newHeighestEventCount) {
615 this.heighestEventCount = newHeighestEventCount;
616 }
617
618 /**
619 * Recalculate the heightest event count for a single time interval.<p>
620 *
621 * Note : This run over all the element so this is quite cpu intensive, use with care.
622 */
623 public void recalculateHeighestEventCount() {
624 // Go over the element up to readyUpToPosition (further position might not be ready)
625 for ( int x=0; x<readyUpToPosition; x++) {
626 if ( elementTable[x].intervalNbEvents > heighestEventCount ) {
627 this.heighestEventCount = elementTable[x].intervalNbEvents;
628 }
629 }
630 }
631
632 /**
633 * Getter for the max height of a bar in the content.<p>
634 *
635 * @return maximum height for a bar we currently use.
636 */
637 public Integer getMaxHeight() {
638 return maxHeight;
639 }
640
641 /**
642 * Setter for maxHeight.<p>
643 *
644 * Note : this is used in some drawing calculation so make sure this number make sense.
645 * Note : you might want to call recalculateEventHeight() if you change this.
646 *
647 * @param maxHeight The new maximum height for a bar to use.
648 */
649 public void setMaxHeight(Integer maxHeight) {
650 this.maxHeight = maxHeight;
651 }
652
653 /**
654 * Getter for the max difference to the average height a bar can have.<p>
655 * This determine at which point a bar too tall is "cut". Set a very large value (like 1000.0) to ignore.
656 *
657 * @return maximum difference to the average we currently use.
658 */
659 public Double getMaxDifferenceToAverage() {
660 return maxDifferenceToAverage;
661 }
662
663 /**
664 * Setter for the max difference to the average height a bar can have.<p>
665 * This determine at which point a bar too tall is "cut". Set a very large value (like 1000.0) to ignore.
666 *
667 * Note : this is used in some drawing calculation so make sure this number make sense.
668 * Note : you might want to call recalculateEventHeight() if you change this.
669 *
670 * @param newDiffToAverage The new maximum difference to the average to use.
671 */
672 public void setMaxDifferenceToAverage(Double newDiffToAverage) {
673 maxDifferenceToAverage = newDiffToAverage;
674 }
675
676
677 /**
678 * Getter for a factor applied to the max difference to the average height a bar can have.<p>
679 * This is muliplied to maxDifferenceToAverage. Set to value 1.0 to ignore.
680 *
681 * Note : this is useful if you concatenate some intervals to gether but want the average to be consistent
682 *
683 * @return maximum difference to the average we currently use.
684 */
685 public Double getMaxDifferenceToAverageFactor() {
686 return maxDifferenceFactor;
687 }
688
689 /**
690 * Setter for a factor applied to the max difference to the average height a bar can have.<p>
691 *
692 * Note : this is used in some drawing calculation so make sure this number make sense.
693 * Note : you might want to call recalculateEventHeight() if you change this.
694 * Note : setting to 0 will cause bar to have a zero size... use 1.0 to desactivate
695 *
696 * @param newFactor The new factor to use.
697 */
698 public void setMaxDifferenceToAverageFactor(Double newFactor) {
699 maxDifferenceFactor = newFactor;
700 }
701
702
703 /**
704 * Getter for the interval time of each interval.<p>
705 * This is usually "(EndTime - StartTime) / NbElement"
706 *
707 * @return Currently used interval time.
708 */
709 public Long getElementsTimeInterval() {
710 return elementsTimeInterval;
711 }
712
713
714 /**
715 * Setter for the interval time of each interval.<p>
716 *
717 * Note : this is used in some drawing calculation so make sure this number make sense.
718 * Note : you migth want to call resetTable() to to fill the element's table again if you change this.
719 *
720 * @return New interval time.
721 */
722 public void setElementsTimeInterval(Long newInterval) {
723 this.elementsTimeInterval = newInterval;
724 }
725
726
727 /**
728 * Calculate the correct time interval of each element from the given time.<p>
729 *
730 * @return The complete time interval
731 */
732 public void recalculateElementsTimeInterval(Long startTime, Long endTime) {
733 this.elementsTimeInterval = ((endTime - startTime)/getNbElement());
734 }
735
736
737 /**
738 * Getter for readyUpToPosition.<p>
739 * This should tell to which point the content is filled, calculated and ready to use.
740 *
741 * @return Last position processed so far.
742 */
743 public Integer getReadyUpToPosition() {
744 return readyUpToPosition;
745 }
746
747 /**
748 * Setter for readyUpToPosition.<p>
749 * Set a new point (position) up to where the content is filled, calculated and ready to use.
750 *
751 * @param newReadyUpToPosition The new position to use.
752 */
753 public void setReadyUpToPosition(int newReadyUpToPosition) {
754 this.readyUpToPosition = newReadyUpToPosition;
755 }
756
757 /**
758 * Getter for the bar width.<p>
759 * This is needed by the paint listener usually.
760 *
761 * @return current bars width;
762 */
763 public Integer getBarsWidth() {
764 return barsWidth;
765 }
766
767 /**
768 * Setter for the bar width.<p>
769 * Setting this to 0 will hide all the bar in the histogram.
770 *
771 * @param newBarsWidth new bars width;
772 */
773 public void setBarsWidth(Integer newBarsWidth) {
774 this.barsWidth = newBarsWidth;
775 }
776
777 }
This page took 0.048407 seconds and 4 git commands to generate.