Commit | Line | Data |
---|---|---|
fbd124dd BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2011 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 | * Bernd Hufmann - Initial API and implementation | |
11 | ******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.ui.views.distribution.model; | |
13 | ||
14 | /** | |
15 | * <b><u>HorDistributionData</u></b> | |
16 | * <p> | |
17 | * Implementation of DistributionData for horizontal direction. | |
18 | */ | |
19 | public class HorDistributionData extends DistributionData { | |
20 | ||
21 | // ------------------------------------------------------------------------ | |
22 | // Constructor | |
23 | // ------------------------------------------------------------------------ | |
24 | ||
25 | public HorDistributionData(int nbBuckets, int[][] buckets) { | |
26 | super(nbBuckets, buckets); | |
27 | } | |
28 | ||
29 | // ------------------------------------------------------------------------ | |
30 | // Abstract function implementation | |
31 | // ------------------------------------------------------------------------ | |
32 | /* | |
33 | * (non-Javadoc) | |
34 | * @see org.eclipse.linuxtools.lttng.ui.views.distribution.model.DistributionData#moveBuckets(int) | |
35 | */ | |
36 | @Override | |
37 | protected void moveBuckets(int offset) { | |
38 | for (int j = 0; j < fNbBuckets; j++) { | |
39 | ||
40 | for(int i = fNbBuckets - 1; i >= offset; i--) { | |
41 | fBuckets[i][j] = fBuckets[i-offset][j]; | |
42 | } | |
43 | ||
44 | for (int i = 0; i < offset; i++) { | |
45 | fBuckets[i][j] = 0; | |
46 | } | |
47 | } | |
48 | } | |
49 | ||
50 | /* | |
51 | * (non-Javadoc) | |
52 | * @see org.eclipse.linuxtools.lttng.ui.views.distribution.model.DistributionData#mergeBuckets() | |
53 | */ | |
54 | @Override | |
55 | protected void mergeBuckets() { | |
56 | ||
57 | for (int y = 0; y < fNbBuckets; y++) { | |
58 | for (int i = 0; i < fNbBuckets / 2; i++) { | |
59 | fBuckets[i][y] = fBuckets[2 * i][y] + fBuckets[2 * i + 1][y]; | |
60 | } | |
61 | ||
62 | for (int i = fNbBuckets / 2; i < fNbBuckets; i++) { | |
63 | fBuckets[i][y] = 0; | |
64 | } | |
65 | } | |
66 | fBucketDuration = fBucketDuration * 2; | |
67 | updateEndTime(); | |
68 | fLastBucket = fNbBuckets / 2 - 1; | |
69 | } | |
70 | } |