1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
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
10 * Jean-Christian Kouamé - Initial API and implementation
11 * Patrick Tasse - Updates to mipmap feature
12 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.core
.statesystem
.mipmap
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import java
.util
.List
;
19 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystemBuilder
;
20 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.StateValueTypeException
;
21 import org
.eclipse
.tracecompass
.statesystem
.core
.interval
.ITmfStateInterval
;
22 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.ITmfStateValue
;
23 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.ITmfStateValue
.Type
;
26 * The maximum mipmap feature.
28 * Each mipmap state value is the maximum numerical value of all the non-null
29 * lower-level state values it covers. The state value is of the same type as
32 public class MaxMipmapFeature
extends TmfMipmapFeature
{
38 * The quark for the attribute we want to mipmap
40 * The quark of the mipmap feature attribute
41 * @param mipmapResolution
42 * The resolution that will be use in the mipmap
44 * The state system in which to insert the state changes
46 public MaxMipmapFeature(final int baseQuark
, final int mipmapQuark
, final int mipmapResolution
, final ITmfStateSystemBuilder ss
) {
47 super(baseQuark
, mipmapQuark
, mipmapResolution
, ss
);
51 protected ITmfStateValue
computeMipmapValue(List
<ITmfStateInterval
> lowerIntervals
, long startTime
, long endTime
) {
52 ITmfStateValue maxValue
= null;
54 for (ITmfStateInterval interval
: lowerIntervals
) {
55 ITmfStateValue value
= interval
.getStateValue();
56 if (value
.getType() == Type
.DOUBLE
) {
57 if (maxValue
== null || value
.unboxDouble() > maxValue
.unboxDouble()) {
61 if (maxValue
== null || value
.unboxLong() > maxValue
.unboxLong()) {
66 } catch (StateValueTypeException e
) {
69 return checkNotNull(maxValue
);