org.android.activityminer.app.filter
Class FilterTestActivity

Package class diagram package FilterTestActivity
java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.view.ContextThemeWrapper
              extended by android.app.Activity
                  extended by org.android.activityminer.app.util.SharedPreferenceChangeAwareActivity
                      extended by org.android.activityminer.app.recording.AbstractRecordingActivity<AccSensorObservationDimensions>
                          extended by org.android.activityminer.app.filter.FilterTestActivity
All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2, KeyEvent.Callback, LayoutInflater.Factory, LayoutInflater.Factory2, View.OnCreateContextMenuListener, Window.Callback, SharedPreferenceChangeNotificationReceiver, SharedPreferenceChangeObserver

public class FilterTestActivity
extends AbstractRecordingActivity<AccSensorObservationDimensions>

A test activity for the different low pass filter types.


Nested Class Summary
private  class FilterTestActivity.StopTask
          The automatic stop task.
 
Field Summary
private  ObservableAccSensorScanner accScanner
          The observable accelerometer scanner.
private  AbstractAccelerometerDataSource accSource
          The accelerometer data source
private  AdaptiveLowPassFilter adaptiveLowPassFilter
          The adaptive low pass filter.
private  FilterAxisView[] axisViews
          The views for the raw and filtered data graphs.
private  ButterworthLowPassFilter bwLowPassFilter
          The butterworth low pass filter.
private  int[] colors
          Graph colors for the different filter types.
private  List<SensorObservationCutout<AccSensorObservationDimensions,Double>> cutOuts
          The lists to store observed and filtered accelerometer samples in.
private  AtomicBoolean[] filterIsVisible
          The filter visibility flags.
private  LowPassFilter[] knownFilters
          The filter list.
private  LinearLayout[] layouts
          The linear layouts holding the graph views
private  long maxRecordingTime
          The maximum duration in milliseconds for a recording.
private  FilterTestActivity.StopTask stopTask
          The task to stop recording.
private  TextView[] textViews
          The etxt views with the layout labels
 
Fields inherited from class android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAPTIONING_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
FilterTestActivity()
          Constructor
 
Method Summary
private  void applyFilter(FilterTypes filterType)
          Method to invoke a single filter on the raw data.
private  void changeFilterState(FilterTypes filterType, boolean enabled)
          Does change the enabled state for a filter with the given type.
protected  long getCutOutSize()
          Getter for the cut-out window size in milliseconds
private  Double[] getValuesForAxis(SensorObservationCutout<AccSensorObservationDimensions,Double> filterDataFrame, FilterAxisView.AxisTypes axisType)
          Method to get the time series data for a specific axis from a filter data frame.
protected  boolean onAboutToStartRecording()
          Call-back method for recording start preparation.
 void onBetaPreferenceChange(double beta)
          The handler for beta value preference changes.
 void onBWCutOffPreferenceChanged(double cf)
          The handler for Butterworth filter cut-off frequency preference changes.
 void onBWFilterOrderPreferenceChanged(int order)
          The handler for Butterworth filter order changes.
protected  void onCreate(Bundle savedInstanceState)
           
 boolean onCreateOptionsMenu(Menu menu)
           
protected  void onDestroy()
           
private  boolean onEnableFilter1(boolean enabled)
          Option menu handler for filter1 enabled state changes.
private  boolean onEnableFilter2(boolean enabled)
          Option menu handler for filter2 enabled state changes.
private  boolean onFilterConfiguration()
          Option menu handler for filter configuration.
 void onMinCutOffPreferenceChanged(double minCutOff)
          The handler for minimum cut-off frequency preference changes.
protected  void onNewCutOut(SensorObservationCutout<AccSensorObservationDimensions,Double> cutOut)
          Event handler for new extracted sensor observation cut-outs
 boolean onOptionsItemSelected(MenuItem item)
           
protected  ObservableSensorScanner<AccSensorObservationDimensions,Double> onPrepare()
          Call-back method for load preparation.
protected  void onRecordingStopped(boolean wasStoppedByUser, long stopTime)
          Call-back method for recording stopped post processing.
private  void setBeta(double beta)
          Does update the beta value.
private  void setBWCutOffFrequency(double cf)
           
private  void setBWFilterOrder(int order)
           
private  void setMinCutOffFreq(double minCutOff)
          Does update the minimum cut off frequency value.
private  void updateFilterSeries(FilterTypes filterType)
          Method to recalculate the filter values for specific filter types and to update the related series in the graph views for the axis data.
private  void updateViewForNewSamples()
          Method to update the whole view for new sample data.
 
Methods inherited from class org.android.activityminer.app.recording.AbstractRecordingActivity
doStartRecording, doStopRecording, enableRecordingButton, getActualObservationTime, getLastCutout, getMinRecordingTime, getRemainingTimeForMinRecordingLength, getSampleRate, isInterestedInLimitViolations, isRecording, isRecordingButtonEnabled, onBackPressed, onConfigurationChanged, onDefaultRecordingTimeChange, onPause, postDelayed, removeCallbacks, setMinRecordingTime, startRecording
 
Methods inherited from class org.android.activityminer.app.util.SharedPreferenceChangeAwareActivity
getConfiguration, onClassSelectionChange, onCountDownTimeChange, onCrossValidationParameterKChange, onEvaluationAccuracyThresholdChanged, onFeatureSelection, onGravitationCutOffPreferenceChanged, onKNNClassifierParameterKChange, onKNNClassifierParameterNormalizeChange, onLimitViolation, onLocationDataUsageFlagChange, onMaximumRecordingTimeChange, onMaximumSampleRateChange, onOverlapSizeChange, onOwnLinAccImplementationUsageFlagChange, onSampleRateChange, onSelectedAccFilterChanged, onSelectedClassifierChange, onWindowSizeChange
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onChildTitleChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onNewIntent, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistData, onRestart, onRestoreInstanceState, onResume, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, reportFullyDrawn, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
applyOverrideConfiguration, attachBaseContext, getResources, getTheme, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accScanner

private ObservableAccSensorScanner accScanner
The observable accelerometer scanner.


adaptiveLowPassFilter

private AdaptiveLowPassFilter adaptiveLowPassFilter
The adaptive low pass filter.


bwLowPassFilter

private ButterworthLowPassFilter bwLowPassFilter
The butterworth low pass filter.


cutOuts

private List<SensorObservationCutout<AccSensorObservationDimensions,Double>> cutOuts
The lists to store observed and filtered accelerometer samples in.


axisViews

private final FilterAxisView[] axisViews
The views for the raw and filtered data graphs.


layouts

private final LinearLayout[] layouts
The linear layouts holding the graph views


textViews

private final TextView[] textViews
The etxt views with the layout labels


colors

private final int[] colors
Graph colors for the different filter types.


knownFilters

private LowPassFilter[] knownFilters
The filter list.


filterIsVisible

private AtomicBoolean[] filterIsVisible
The filter visibility flags.


stopTask

private FilterTestActivity.StopTask stopTask
The task to stop recording.


maxRecordingTime

private final long maxRecordingTime
The maximum duration in milliseconds for a recording.


accSource

private AbstractAccelerometerDataSource accSource
The accelerometer data source

Constructor Detail

FilterTestActivity

public FilterTestActivity()
Constructor

Method Detail

onPrepare

protected final ObservableSensorScanner<AccSensorObservationDimensions,Double> onPrepare()
Description copied from class: AbstractRecordingActivity
Call-back method for load preparation. This Method is called every time the GUI is loaded, thus on creation and orientation changes.

Specified by:
onPrepare in class AbstractRecordingActivity<AccSensorObservationDimensions>
Returns:
the observable raw time series data source to use.

setBWCutOffFrequency

private final void setBWCutOffFrequency(double cf)
Parameters:
cf - the cut-off frequency to set

setBWFilterOrder

private final void setBWFilterOrder(int order)
Parameters:
order -

setMinCutOffFreq

private final void setMinCutOffFreq(double minCutOff)
Does update the minimum cut off frequency value.

Parameters:
minCutOff - the minimum cut off frequency value to set.

setBeta

private final void setBeta(double beta)
Does update the beta value.

Parameters:
beta - the beta value to set.

onCreate

protected final void onCreate(Bundle savedInstanceState)
Overrides:
onCreate in class AbstractRecordingActivity<AccSensorObservationDimensions>

onDestroy

protected void onDestroy()
Overrides:
onDestroy in class AbstractRecordingActivity<AccSensorObservationDimensions>

onAboutToStartRecording

protected final boolean onAboutToStartRecording()
Description copied from class: AbstractRecordingActivity
Call-back method for recording start preparation.

Overrides:
onAboutToStartRecording in class AbstractRecordingActivity<AccSensorObservationDimensions>
Returns:
if true recording will be started , otherwise you need to call AbstractRecordingActivity.startRecording() Method by your own as soon as you are ready.

onRecordingStopped

protected final void onRecordingStopped(boolean wasStoppedByUser,
                                        long stopTime)
Description copied from class: AbstractRecordingActivity
Call-back method for recording stopped post processing.

Specified by:
onRecordingStopped in class AbstractRecordingActivity<AccSensorObservationDimensions>
Parameters:
wasStoppedByUser - flag is recording was stopped manually by the user
stopTime - the time the recording was stopped in milliseconds

updateViewForNewSamples

private final void updateViewForNewSamples()
Method to update the whole view for new sample data.


updateFilterSeries

private final void updateFilterSeries(FilterTypes filterType)
Method to recalculate the filter values for specific filter types and to update the related series in the graph views for the axis data.

Parameters:
filterType - the filter type

getValuesForAxis

private final Double[] getValuesForAxis(SensorObservationCutout<AccSensorObservationDimensions,Double> filterDataFrame,
                                        FilterAxisView.AxisTypes axisType)
Method to get the time series data for a specific axis from a filter data frame.

Parameters:
filterDataFrame - the frame to retrieve time series from
axisType - the axis to retrieve time series for
Returns:
the time series data as array

applyFilter

private final void applyFilter(FilterTypes filterType)
Method to invoke a single filter on the raw data.

Parameters:
filterType - the filter type identifier

onCreateOptionsMenu

public final boolean onCreateOptionsMenu(Menu menu)
Overrides:
onCreateOptionsMenu in class Activity

onOptionsItemSelected

public final boolean onOptionsItemSelected(MenuItem item)
Overrides:
onOptionsItemSelected in class Activity

changeFilterState

private final void changeFilterState(FilterTypes filterType,
                                     boolean enabled)
Does change the enabled state for a filter with the given type.

Parameters:
filterType - the filter type
enabled - enabled state for the filter

onEnableFilter2

private final boolean onEnableFilter2(boolean enabled)
Option menu handler for filter2 enabled state changes.

Parameters:
enabled - enabled state for the filter
Returns:
true if successful, false otherwise

onEnableFilter1

private final boolean onEnableFilter1(boolean enabled)
Option menu handler for filter1 enabled state changes.

Parameters:
enabled - enabled state for the filter
Returns:
true if successful, false otherwise

onFilterConfiguration

private final boolean onFilterConfiguration()
Option menu handler for filter configuration.

Returns:
true if successful, false otherwise

onBWCutOffPreferenceChanged

public final void onBWCutOffPreferenceChanged(double cf)
Description copied from interface: SharedPreferenceChangeObserver
The handler for Butterworth filter cut-off frequency preference changes.

Specified by:
onBWCutOffPreferenceChanged in interface SharedPreferenceChangeObserver
Overrides:
onBWCutOffPreferenceChanged in class SharedPreferenceChangeAwareActivity
Parameters:
cf - the new cut-off frequency value

onBWFilterOrderPreferenceChanged

public final void onBWFilterOrderPreferenceChanged(int order)
Description copied from interface: SharedPreferenceChangeObserver
The handler for Butterworth filter order changes.

Specified by:
onBWFilterOrderPreferenceChanged in interface SharedPreferenceChangeObserver
Overrides:
onBWFilterOrderPreferenceChanged in class SharedPreferenceChangeAwareActivity
Parameters:
order - the new filter order

onMinCutOffPreferenceChanged

public final void onMinCutOffPreferenceChanged(double minCutOff)
Description copied from interface: SharedPreferenceChangeObserver
The handler for minimum cut-off frequency preference changes.

Specified by:
onMinCutOffPreferenceChanged in interface SharedPreferenceChangeObserver
Overrides:
onMinCutOffPreferenceChanged in class SharedPreferenceChangeAwareActivity
Parameters:
minCutOff - the new minimum cut-off frequency value

onBetaPreferenceChange

public final void onBetaPreferenceChange(double beta)
Description copied from interface: SharedPreferenceChangeObserver
The handler for beta value preference changes.

Specified by:
onBetaPreferenceChange in interface SharedPreferenceChangeObserver
Overrides:
onBetaPreferenceChange in class SharedPreferenceChangeAwareActivity
Parameters:
beta - the new beta value

onNewCutOut

protected void onNewCutOut(SensorObservationCutout<AccSensorObservationDimensions,Double> cutOut)
Description copied from class: AbstractRecordingActivity
Event handler for new extracted sensor observation cut-outs

Specified by:
onNewCutOut in class AbstractRecordingActivity<AccSensorObservationDimensions>
Parameters:
cutOut - the new cut-out

getCutOutSize

protected long getCutOutSize()
Description copied from class: AbstractRecordingActivity
Getter for the cut-out window size in milliseconds

Specified by:
getCutOutSize in class AbstractRecordingActivity<AccSensorObservationDimensions>
Returns:
the cut out size