jAER project on SourceForge

net.sf.jaer.eventprocessing
Class EventFilter

java.lang.Object
  extended by net.sf.jaer.eventprocessing.EventFilter
Direct Known Subclasses:
EventFilter2D, EventFilterRaw

public abstract class EventFilter
extends java.lang.Object

An abstract class that all event processing methods should subclass. Subclasses are introspected to build a GUI to control the filter in FilterPanel.

Filters that are enclosed inside another filter are given a preferences node that is derived from the the chip class that the filter is used on and the enclosing filter class. The same preferences node name is used for FilterChain's that are enclosed inside an EventFilter.

Fires PropertyChangeEvent for the following

Author:
tobi
See Also:
which is where EventFilter's GUIs are built., to annotate the graphical output., which processes events., about enclosing filters inside other filters.

Field Summary
protected  boolean annotationEnabled
           
protected  AEChip chip
          chip that we are filtering for
protected  EventFilter enclosedFilter
          The enclosed single filter.
protected  FilterChain enclosedFilterChain
          An enclosed filterChain - these filters must be manually applied (coded) in the filterPacket method but a GUI for them is automagically built.
protected  boolean filterEnabled
          Used by filterPacket to say whether to filter events; default false
 java.util.logging.Logger log
          All filters can log to this logger
 EventProcessingPerformanceMeter perf
           
protected  java.util.HashMap<java.lang.String,java.lang.String> propertyTooltipMap
          The key,value table of property tooltip strings
protected  java.beans.PropertyChangeSupport support
          Can be used to provide change support, e.g.
 
Constructor Summary
EventFilter()
          Deprecated. - all filters need an AEChip object
EventFilter(AEChip chip)
          Creates a new instance of AbstractEventFilter but does not enable it.
 
Method Summary
 AEChip getChip()
           
static java.lang.String getDescription()
          Override this String (can be html formatted) to show it as the filter description in the GUI control FilterPanel.
 EventFilter getEnclosedFilter()
          Gets the enclosed filter
 FilterChain getEnclosedFilterChain()
          Returns the enclosed filter chain
 EventFilter getEnclosingFilter()
           
abstract  java.lang.Object getFilterState()
          Deprecated. - no one uses this
 java.util.prefs.Preferences getPrefs()
          Returns the Preferences node for this filter.
 java.beans.PropertyChangeSupport getPropertyChangeSupport()
          Fires PropertyChangeEvents when filter is enabled or disabled with key "filterEnabled"
protected  java.lang.String getPropertyTooltip(java.lang.String propertyName)
           
abstract  void initFilter()
          this should allocate and initialize memory: it may be called when the chip e.g.
 boolean isAnnotationEnabled()
          Each filter has an annotationEnabled flag that is used to graphical annotation of the filter, e.g.
 boolean isEnclosed()
          Is filter enclosed inside another filter?
 boolean isFilterEnabled()
          Filters can be enabled for processing.
 java.lang.String prefsEnabledKey()
          Returns the prefernces key for the filter
abstract  void resetFilter()
          should reset the filter to initial state
 void setAnnotationEnabled(boolean annotationEnabled)
           
 void setChip(AEChip chip)
           
 void setEnclosed(boolean enclosed, EventFilter enclosingFilter)
          Sets flag to show this instance is enclosed.
 void setEnclosedFilter(EventFilter enclosedFilter, EventFilter enclosingFilter)
          Sets another filter to be enclosed inside this one - this enclosed filter should be applied first and must be applied by the filter.
 void setEnclosedFilterChain(FilterChain enclosedFilterChain)
          Sets an enclosed filter chain which should by convention be processed first by the filter (but need not be).
 void setEnclosingFilter(EventFilter enclosingFilter)
          Sets the enclosing filter for this
 void setFilterEnabled(boolean enabled)
          Filters can be enabled for processing.
 void setPreferredEnabledState()
          Sets the filter enabled according to the preference for enabled
 void setPrefs(java.util.prefs.Preferences prefs)
          Sets the preferences node for this filter
protected  void setPropertyTooltip(java.lang.String propertyName, java.lang.String tooltip)
          Developers can use this to add an optional tooltip for a filter property so that the tip is shown as the tooltip for the label or checkbox property in the generated GUI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

perf

public EventProcessingPerformanceMeter perf

support

protected java.beans.PropertyChangeSupport support
Can be used to provide change support, e.g. for enabled state


log

public java.util.logging.Logger log
All filters can log to this logger


filterEnabled

protected boolean filterEnabled
Used by filterPacket to say whether to filter events; default false


chip

protected AEChip chip
chip that we are filtering for


enclosedFilter

protected EventFilter enclosedFilter
The enclosed single filter. This object is used for GUI building - any processing must be handled in filterPacket


enclosedFilterChain

protected FilterChain enclosedFilterChain
An enclosed filterChain - these filters must be manually applied (coded) in the filterPacket method but a GUI for them is automagically built. Initially null - subclasses must make a new FilterChain and set it for this filter.


annotationEnabled

protected boolean annotationEnabled

propertyTooltipMap

protected java.util.HashMap<java.lang.String,java.lang.String> propertyTooltipMap
The key,value table of property tooltip strings

Constructor Detail

EventFilter

public EventFilter()
Deprecated. - all filters need an AEChip object

default constructor


EventFilter

public EventFilter(AEChip chip)
Creates a new instance of AbstractEventFilter but does not enable it.

Parameters:
chip - the chip to filter for
See Also:
setPreferredEnabledState()
Method Detail

prefsEnabledKey

public java.lang.String prefsEnabledKey()
Returns the prefernces key for the filter

Returns:
".filterEnabled" e.g. DirectionSelectiveFilter.filterEnabled

getFilterState

public abstract java.lang.Object getFilterState()
Deprecated. - no one uses this

should return the filter state in some useful form


resetFilter

public abstract void resetFilter()
should reset the filter to initial state


initFilter

public abstract void initFilter()
this should allocate and initialize memory: it may be called when the chip e.g. size parameters are changed after creation of the filter


isFilterEnabled

public boolean isFilterEnabled()
Filters can be enabled for processing.

Returns:
true if filter is enabled

setFilterEnabled

public void setFilterEnabled(boolean enabled)
Filters can be enabled for processing. Setting enabled also sets an enclosed filter to the same state. Setting filter enabled state only stores the preference value for enabled state if the filter is not enclosed inside another filter, to avoid setting global preferences for the filter enabled state.

Fires a property change event "filterEnabled" so that GUIs can be updated.

Parameters:
enabled - true to enable filter. false should have effect that output events are the same as input.
See Also:
setPreferredEnabledState()

setPreferredEnabledState

public void setPreferredEnabledState()
Sets the filter enabled according to the preference for enabled


getChip

public AEChip getChip()
Returns:
the chip this filter is filtering for

setChip

public void setChip(AEChip chip)
Parameters:
chip - the chip to filter

getPropertyChangeSupport

public java.beans.PropertyChangeSupport getPropertyChangeSupport()
Fires PropertyChangeEvents when filter is enabled or disabled with key "filterEnabled"

Returns:
change support

getEnclosedFilter

public EventFilter getEnclosedFilter()
Gets the enclosed filter

Returns:
the enclosed filter

setEnclosedFilter

public void setEnclosedFilter(EventFilter enclosedFilter,
                              EventFilter enclosingFilter)
Sets another filter to be enclosed inside this one - this enclosed filter should be applied first and must be applied by the filter. This enclosed filter is displayed hierarchically in the FilterPanel used in FilterFrame.

Parameters:
enclosedFilter - the filter to enclose
enclosingFilter - the filter that is enclosing this filter
See Also:
setEnclosed(boolean, net.sf.jaer.eventprocessing.EventFilter)

isAnnotationEnabled

public boolean isAnnotationEnabled()
Each filter has an annotationEnabled flag that is used to graphical annotation of the filter, e.g. a spatial border, text strings, global graphical overlay, etc. isAnnotationEnabled returns true if the filter is not enclosed and the filter is enabled and annotation is enabled. It returns false if the filter is enclosed and the enclosing filter is not enabled.

Returns:
true to show filter annotation should be shown

setAnnotationEnabled

public void setAnnotationEnabled(boolean annotationEnabled)
Parameters:
annotationEnabled - true to draw annotations

isEnclosed

public boolean isEnclosed()
Is filter enclosed inside another filter?

Returns:
true if this filter is enclosed inside another

setEnclosed

public void setEnclosed(boolean enclosed,
                        EventFilter enclosingFilter)
Sets flag to show this instance is enclosed. If this flag is set to true, then preferences node is changed to a node unique for the enclosing filter class.

Parameters:
enclosingFilter - the filter that is enclosing this
enclosed - true if this filter is enclosed

setPropertyTooltip

protected void setPropertyTooltip(java.lang.String propertyName,
                                  java.lang.String tooltip)
Developers can use this to add an optional tooltip for a filter property so that the tip is shown as the tooltip for the label or checkbox property in the generated GUI.

In netbeans, you can add this macro to ease entering tooltips for filter parameters:

 select-word copy-to-clipboard caret-begin-line caret-down "{setPropertyTooltip(\"" paste-from-clipboard "\",\"\");}" insert-break caret-up caret-end-line caret-backward caret-backward caret-backward caret-backward
 

Parameters:
propertyName - the name of the property (e.g. an int, float, or boolean, e.g. "dt")
tooltip - the tooltip String to display

getPropertyTooltip

protected java.lang.String getPropertyTooltip(java.lang.String propertyName)
Returns:
the tooltip for the property

getEnclosedFilterChain

public FilterChain getEnclosedFilterChain()
Returns the enclosed filter chain

Returns:
the chain

setEnclosedFilterChain

public void setEnclosedFilterChain(FilterChain enclosedFilterChain)
Sets an enclosed filter chain which should by convention be processed first by the filter (but need not be). Also flags all the filters in the chain as enclosed.

Parameters:
enclosedFilterChain - the chain

getPrefs

public java.util.prefs.Preferences getPrefs()
Returns the Preferences node for this filter. This node is based on the chip class package but may be modified to a sub-node if the filter is enclosed inside another filter.

Returns:
the preferences node
See Also:
setEnclosed(boolean, net.sf.jaer.eventprocessing.EventFilter)

setPrefs

public void setPrefs(java.util.prefs.Preferences prefs)
Sets the preferences node for this filter

Parameters:
prefs - the node

getEnclosingFilter

public EventFilter getEnclosingFilter()
Returns:
the enclosing filter if this filter is enclosed

setEnclosingFilter

public void setEnclosingFilter(EventFilter enclosingFilter)
Sets the enclosing filter for this


getDescription

public static java.lang.String getDescription()
Override this String (can be html formatted) to show it as the filter description in the GUI control FilterPanel.


jAER project on SourceForge