Commit | Line | Data |
---|---|---|
8e364f8e PT |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * 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 | * Jean-Christian Kouamé - Initial API and implementation | |
11 | * Patrick Tasse - Updates to mipmap feature | |
12 | *******************************************************************************/ | |
13 | package org.eclipse.linuxtools.internal.tmf.core.statesystem.mipmap; | |
14 | ||
15 | import java.util.List; | |
16 | ||
bcec0116 AM |
17 | import org.eclipse.linuxtools.statesystem.core.ITmfStateSystemBuilder; |
18 | import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException; | |
19 | import org.eclipse.linuxtools.statesystem.core.interval.ITmfStateInterval; | |
20 | import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue; | |
21 | import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue.Type; | |
8e364f8e PT |
22 | |
23 | /** | |
24 | * The minimum mipmap feature. | |
25 | * | |
26 | * Each mipmap state value is the minimum numerical value of all the non-null | |
27 | * lower-level state values it covers. The state value is of the same type as | |
28 | * the base attribute. | |
29 | */ | |
30 | public class MinMipmapFeature extends TmfMipmapFeature { | |
31 | ||
32 | /** | |
33 | * Constructor | |
34 | * | |
35 | * @param baseQuark | |
36 | * The quark for the attribute we want to mipmap | |
37 | * @param mipmapQuark | |
38 | * The quark of the mipmap feature attribute | |
39 | * @param mipmapResolution | |
40 | * The resolution that will be use in the mipmap | |
41 | * @param ss | |
42 | * The state system in which to insert the state changes | |
43 | */ | |
44 | public MinMipmapFeature(final int baseQuark, final int mipmapQuark, final int mipmapResolution, final ITmfStateSystemBuilder ss) { | |
45 | super(baseQuark, mipmapQuark, mipmapResolution, ss); | |
46 | } | |
47 | ||
48 | @Override | |
49 | protected ITmfStateValue computeMipmapValue(List<ITmfStateInterval> lowerIntervals, long startTime, long endTime) { | |
50 | ITmfStateValue minValue = null; | |
51 | try { | |
52 | for (ITmfStateInterval interval : lowerIntervals) { | |
53 | ITmfStateValue value = interval.getStateValue(); | |
54 | if (value.getType() == Type.DOUBLE) { | |
55 | if (minValue == null || value.unboxDouble() < minValue.unboxDouble()) { | |
56 | minValue = value; | |
57 | } | |
58 | } else { | |
59 | if (minValue == null || value.unboxLong() < minValue.unboxLong()) { | |
60 | minValue = value; | |
61 | } | |
62 | } | |
63 | } | |
64 | } catch (StateValueTypeException e) { | |
65 | e.printStackTrace(); | |
66 | } | |
67 | return minValue; | |
68 | } | |
69 | } |