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

Package class diagram package AbstractFeatureFactory
java.lang.Object
  extended by org.android.activityminer.logic.features.AbstractFeatureFactory<T>
Type Parameters:
T - the enumeration type for the dimensions
Direct Known Subclasses:
FeatureFactoryForAccSensorObservations, FeatureFactoryForSensorObservations

public abstract class AbstractFeatureFactory<T extends Enum<T> & Dimensions>
extends Object

A factory to construct the necessary runtime representation of features and their associated calculators for a given set of feature types.


Field Summary
private  Context context
          The context.
private  SparseArray<Feature> featureMap
          The type to feature map
private  SparseArray<List<AbstractCalculator<T,?>>> mapDimension2Calculator
          The dimension to calculator map
private  SparseArray<List<AbstractCalculator<SensorObservationDimensions,?>>> mapSpecificDimension2Calculator
          The sensor dimension to calculator map (for specific location based dimensions )
 
Constructor Summary
AbstractFeatureFactory(Context context)
          Constructor
 
Method Summary
 FeatureExtractionConfiguration<T> create(FeatureTypes[] featureTypes, long sampleRate)
          Method to create the necessary feature and calculator types for the extraction of a given set of feature types.
private static
<T extends Enum<T> & Dimensions,S extends AbstractCalculator<T,?>>
S
getCalculator(SparseArray<List<AbstractCalculator<T,?>>> mapDimension2Calculator, int dimension, Type calculatorType)
          Does lookup a calculator class in the calculator map for the given dimension.
abstract  T getDimensionForId(int id)
          Getter for the dimension type of an unique dimension identifier
private  DimensionValueCache<T> getDimensionValueCache(T dimension)
          Does lookup a feature value cache in the calculator map for the given dimension.
private  Feature[] getFeatures()
          Getter for the feature map content
private  FFTCalculator<T> getFFTCalculator(T dimension)
          Does lookup the FFT calculator in the calculator map.
private  FFTEnergyCalculator<T> getFFTEnergyCalculator(T dimension)
          Does lookup the FFT energy calculator in the calculator map.
private  FFTEntropyCalculator<T> getFFTEntropyCalculator(T dimension)
          Does lookup the FFT entropy calculator in the calculator map.
private  FFTPeakCalculator<T> getFFTPeakCalculator(T dimension, long sampleRate)
          Does lookup the FFT peak calculator in the calculator map.
private  MaxDistanceInLocationsCalculator getMaxDistanceInLocationsCalculator()
          Does lookup the max distance in location calculator in the calculator map.
private  MaximumCalculator<T> getMaximumCalculator(T dimension)
          Does lookup a maximum calculator in the calculator map for the given dimension.
private  MeanCalculator<T> getMeanCalculator(T dimension)
          Does lookup a mean calculator in the calculator map for the given dimension.
private  MeanCrossingRateCalculator<T> getMeanCrossingRateCalculator(T dimension)
          Does lookup the mean crossing rate calculator in the calculator map for the given dimension.
private  MinimumCalculator<T> getMinimumCalculator(T dimension)
          Does lookup a minimum calculator in the calculator map for the given dimension.
private  SensorObservationCounter<T> getSensorObservationCounter()
          Does lookup the sensor observation counter in the calculator map.
private  SumCalculator<T> getSumCalculator(T dimension)
          Does lookup a sum calculator in the calculator map for the given dimension.
private  VarianceCalculator<T> getVarianceCalculator(T dimension)
          Does lookup the variance calculator in the calculator map for the given dimension.
protected  boolean isValid(FeatureTypes featureType)
          Test method if a feature type is valid for the known dimensions
 PreparationCalculator<T> newPreparationCalculator()
          Does create a preparation calculator to extract
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureMap

private final SparseArray<Feature> featureMap
The type to feature map


mapDimension2Calculator

private final SparseArray<List<AbstractCalculator<T extends Enum<T> & Dimensions,?>>> mapDimension2Calculator
The dimension to calculator map


mapSpecificDimension2Calculator

private final SparseArray<List<AbstractCalculator<SensorObservationDimensions,?>>> mapSpecificDimension2Calculator
The sensor dimension to calculator map (for specific location based dimensions )


context

private final Context context
The context.

Constructor Detail

AbstractFeatureFactory

public AbstractFeatureFactory(Context context)
Constructor

Parameters:
context - the context
Method Detail

getDimensionForId

public abstract T getDimensionForId(int id)
Getter for the dimension type of an unique dimension identifier

Parameters:
id - the dimension identifier
Returns:
the dimension type
See Also:
DimensionIds

create

public final FeatureExtractionConfiguration<T> create(FeatureTypes[] featureTypes,
                                                      long sampleRate)
Method to create the necessary feature and calculator types for the extraction of a given set of feature types.

Parameters:
featureTypes - the feature types to create features for
sampleRate - the configured sample rate
Returns:
a configuration with the created features and the shared calculators

getFeatures

private Feature[] getFeatures()
Getter for the feature map content

Returns:
the feature map content

newPreparationCalculator

public final PreparationCalculator<T> newPreparationCalculator()
Does create a preparation calculator to extract

Returns:
the preparation calculator for sensor observations

isValid

protected boolean isValid(FeatureTypes featureType)
Test method if a feature type is valid for the known dimensions

Parameters:
featureType - the feature type
Returns:
true if feature type is valid for the known dimensions, false otherwise

getFFTEntropyCalculator

private final FFTEntropyCalculator<T> getFFTEntropyCalculator(T dimension)
Does lookup the FFT entropy calculator in the calculator map.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getFFTEnergyCalculator

private final FFTEnergyCalculator<T> getFFTEnergyCalculator(T dimension)
Does lookup the FFT energy calculator in the calculator map.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getFFTPeakCalculator

private final FFTPeakCalculator<T> getFFTPeakCalculator(T dimension,
                                                        long sampleRate)
Does lookup the FFT peak calculator in the calculator map.

Parameters:
dimension - the dimension
sampleRate - the sample rate as time-stamp delta in milliseconds between two observations
Returns:
the requested calculator

getFFTCalculator

private final FFTCalculator<T> getFFTCalculator(T dimension)
Does lookup the FFT calculator in the calculator map.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getMaxDistanceInLocationsCalculator

private final MaxDistanceInLocationsCalculator getMaxDistanceInLocationsCalculator()
Does lookup the max distance in location calculator in the calculator map.

Returns:
the requested calculator

getMeanCrossingRateCalculator

private final MeanCrossingRateCalculator<T> getMeanCrossingRateCalculator(T dimension)
Does lookup the mean crossing rate calculator in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getSensorObservationCounter

private final SensorObservationCounter<T> getSensorObservationCounter()
Does lookup the sensor observation counter in the calculator map.

Returns:
the requested calculator

getVarianceCalculator

private final VarianceCalculator<T> getVarianceCalculator(T dimension)
Does lookup the variance calculator in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getMeanCalculator

private final MeanCalculator<T> getMeanCalculator(T dimension)
Does lookup a mean calculator in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getDimensionValueCache

private final DimensionValueCache<T> getDimensionValueCache(T dimension)
Does lookup a feature value cache in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getMaximumCalculator

private final MaximumCalculator<T> getMaximumCalculator(T dimension)
Does lookup a maximum calculator in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getMinimumCalculator

private final MinimumCalculator<T> getMinimumCalculator(T dimension)
Does lookup a minimum calculator in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getSumCalculator

private final SumCalculator<T> getSumCalculator(T dimension)
Does lookup a sum calculator in the calculator map for the given dimension.

Parameters:
dimension - the dimension
Returns:
the requested calculator

getCalculator

private static final <T extends Enum<T> & Dimensions,S extends AbstractCalculator<T,?>> S getCalculator(SparseArray<List<AbstractCalculator<T,?>>> mapDimension2Calculator,
                                                                                                       int dimension,
                                                                                                       Type calculatorType)
Does lookup a calculator class in the calculator map for the given dimension.

Type Parameters:
S - the time series calculator type
T - the enumeration type for the dimensions
Parameters:
mapDimension2Calculator - the map
dimension - the dimension
calculatorType - the calculator type
Returns:
the instance of the requested calculator or null if not created yet