1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 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 * Francois Chouinard - Initial API and implementation
11 * Bernd Hufmann - Added setter and getter
12 * Francois Chouinard - Moved from LTTng to TMF
13 *******************************************************************************/
15 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
17 import java
.util
.Arrays
;
20 * <b><u>HistogramScaledData</u></b>
22 * Convenience class/struct for scaled histogram data.
24 public class HistogramScaledData
{
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 public static final int OUT_OF_RANGE_BUCKET
= -1;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
40 public long fBucketDuration
;
41 public long fMaxValue
;
42 public int fCurrentBucket
;
43 public int fLastBucket
;
44 public double fScalingFactor
;
45 public long fFirstBucketTime
;
46 public long fFirstEventTime
;
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
52 public HistogramScaledData(int width
, int height
, int barWidth
) {
56 fData
= new int[width
/fBarWidth
];
57 Arrays
.fill(fData
, 0);
66 public HistogramScaledData(HistogramScaledData other
) {
67 fWidth
= other
.fWidth
;
68 fHeight
= other
.fHeight
;
69 fBarWidth
= other
.fBarWidth
;
70 fData
= Arrays
.copyOf(other
.fData
, fWidth
);
71 fBucketDuration
= other
.fBucketDuration
;
72 fMaxValue
= other
.fMaxValue
;
73 fCurrentBucket
= other
.fCurrentBucket
;
74 fLastBucket
= other
.fLastBucket
;
75 fScalingFactor
= other
.fScalingFactor
;
76 fFirstBucketTime
= other
.fFirstBucketTime
;
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
83 public long getFirstBucketTime() {
84 return fFirstBucketTime
;
87 public void setFirstBucketTime(long firstEventTime
) {
88 fFirstBucketTime
= firstEventTime
;
91 public long getLastBucketTime() {
92 return getBucketStartTime(fLastBucket
);
95 public long getBucketStartTime(int index
) {
96 return fFirstBucketTime
+ index
* fBucketDuration
;
99 public long getBucketEndTime(int index
) {
100 return getBucketStartTime(index
) + fBucketDuration
;