org.android.activityminer.logic.features.calculators
Class FFTCalculator<T extends Enum<T> & Dimensions>

Package class diagram package FFTCalculator
java.lang.Object
  extended by org.android.activityminer.logic.features.calculators.AbstractCalculator<T,U>
      extended by org.android.activityminer.logic.features.calculators.AbstractCompositeCalculator<T,Double>
          extended by org.android.activityminer.logic.features.calculators.FFTCalculator<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
ObservableEventSource<FFTCalculatorEvent>, ObserverRegistration<FFTCalculatorEvent>, Calculator<Double>, CompositeCalculator<Double>

public final class FFTCalculator<T extends Enum<T> & Dimensions>
extends AbstractCompositeCalculator<T,Double>
implements ObservableEventSource<FFTCalculatorEvent>

Implementation of an observable FFT component calculator. It can be observed for all but the DC component which is returned as calculator value. Energy spectrum is calculated as the squared magnitudes of the FFT coefficients: for the FFT coefficient FFT(i)=(re, im) the magnitude is mag(i)=Math.sqrt(re*re + im*im) and the spectral energy is se(i)=(mag(i)*mag(i)).


Field Summary
private  int cntComponents
          The count of FFT components.
private  ObservableEventSource<FFTCalculatorEvent> fftEventSource
          The event source to delegate to.
private  DimensionValueCache<T> valueCache
          The value cache.
 
Fields inherited from class org.android.activityminer.logic.features.calculators.AbstractCalculator
dimension, value
 
Constructor Summary
FFTCalculator(DimensionValueCache<T> valueCache)
          Constructor
 
Method Summary
 int getComponentCount()
          Getter for the component count
 Double getCompositeValue()
          Does calculate the composite value.
 Double getInitialValue()
          Method for value initialization.
 DimensionValueCache<T> getValueCache()
          Getter for the value cache calculator.
 boolean hasObservers()
           
 void notify(FFTCalculatorEvent data)
           
 void registerEventObserver(EventObserver<? extends FFTCalculatorEvent> observer)
           
 void removeAllObservers()
           
 void unregisterEventObserver(EventObserver<? extends FFTCalculatorEvent> observer)
           
 
Methods inherited from class org.android.activityminer.logic.features.calculators.AbstractCompositeCalculator
getValue, reset
 
Methods inherited from class org.android.activityminer.logic.features.calculators.AbstractCalculator
getDimension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cntComponents

private int cntComponents
The count of FFT components.


fftEventSource

private final ObservableEventSource<FFTCalculatorEvent> fftEventSource
The event source to delegate to.


valueCache

private final DimensionValueCache<T extends Enum<T> & Dimensions> valueCache
The value cache.

Constructor Detail

FFTCalculator

public FFTCalculator(DimensionValueCache<T> valueCache)
Constructor

Parameters:
valueCache - the value cache
Method Detail

getComponentCount

public final int getComponentCount()
Getter for the component count

Returns:
the component count

getInitialValue

public final Double getInitialValue()
Description copied from interface: Calculator
Method for value initialization.

Specified by:
getInitialValue in interface Calculator<Double>
Returns:
the initialized value

getCompositeValue

public Double getCompositeValue()
Description copied from interface: CompositeCalculator
Does calculate the composite value.

Specified by:
getCompositeValue in interface CompositeCalculator<Double>
Returns:
the composite value

getValueCache

public DimensionValueCache<T> getValueCache()
Getter for the value cache calculator.

Returns:
the value cache

registerEventObserver

public void registerEventObserver(EventObserver<? extends FFTCalculatorEvent> observer)
Specified by:
registerEventObserver in interface ObserverRegistration<FFTCalculatorEvent>

unregisterEventObserver

public void unregisterEventObserver(EventObserver<? extends FFTCalculatorEvent> observer)
Specified by:
unregisterEventObserver in interface ObserverRegistration<FFTCalculatorEvent>

removeAllObservers

public void removeAllObservers()
Specified by:
removeAllObservers in interface ObserverRegistration<FFTCalculatorEvent>

notify

public void notify(FFTCalculatorEvent data)
Specified by:
notify in interface ObservableEventSource<FFTCalculatorEvent>

hasObservers

public boolean hasObservers()
Specified by:
hasObservers in interface ObservableEventSource<FFTCalculatorEvent>