Package org.ka2ddo.yaac.filter
Class RadiusFilter
java.lang.Object
org.ka2ddo.yaac.filter.Filter
org.ka2ddo.yaac.filter.RadiusFilter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Cloneable
,PersistingFilter
This class implements a filter based on radius from a specified location
(defaulting to the beacon location for the station).
- Author:
- Andrew Pavlin, KA2DDO
-
Field Summary
Fields inherited from class org.ka2ddo.yaac.filter.Filter
RESULT_NEUTRAL, RESULT_PASS, RESULT_REJECT, RESULT_WEAK_PASS, RESULT_WEAK_REJECT
-
Constructor Summary
ConstructorDescriptionRadiusFilter
(String prefPrefix) Create a RadiusFilter instance with the specified prefix for the persistence parameter names. -
Method Summary
Modifier and TypeMethodDescriptionint
acceptAX25Frame
(AX25Frame frame) Indicate whether the specified message should be displayed.int
acceptLatLon
(double lat, double lon) Test if the specified position is within the current range.int
acceptMessage
(AX25Message msg) Indicate whether the specified message should be displayed.int
Indicate whether the specified station should be displayed.void
Register a listener for changes of this Filter.boolean
Specifies that this filter may reject some stations, messages, and/or frames.clone()
Creates and returns a copy of this object.void
close()
Closes this filter and releases any system resources associated with it.Report a tag name used to look up JavaHelp for a filter editor.Report a tag name used to look up the labelling for an editor panel for this editor instance in a ResourceBundle of translated names.Get the class name of a dynamically loadable class for the the GUI for this filter.double
Get the latitude center of this filter.double
Get the longitude center of this filter.double
Get the current radius in kilometers.boolean
Test if this RadiusFilter is enabled.boolean
Test if this RadiusFilter will use the local station's current position or an explicitly configured position.void
Deregisters a listener.void
setEnabled
(boolean enabled) Specify whether this RadiusFilter is enabled.void
setLatitude
(double latitude) Programmatically change the center point latitude of this RadiusFilter.void
setLongitude
(double longitude) Programmatically change the center point longitude of this RadiusFilter.void
setPrefPrefix
(String prefPrefix) Change the persisted parameter prefix for this instance of RadiusFilter.void
setRadiusInKM
(double radiusInKM) Set the current radius in kilometers.void
Reset the filter to a configuration that would pass the maximum amount of messages, packets, and stations.void
Set aTrackerListener
that should be cancelled when this RadiusFilter instance is closed.void
setUseHome
(boolean useHome) Specify if this RadiusFilter will use the local station's current position or an explicitly configured position.
-
Constructor Details
-
RadiusFilter
Create a RadiusFilter instance with the specified prefix for the persistence parameter names.- Parameters:
prefPrefix
- prefix String (can be empty string "") or null to indicate this filter should not be persisted
-
-
Method Details
-
getFilterUIName
Get the class name of a dynamically loadable class for the the GUI for this filter. The name is allowed to have a wildcard '*' in it where a GUI type ("gui" for standard Java or "android" for Android) can be substituted.- Specified by:
getFilterUIName
in classFilter
- Returns:
- String name of GUI class for this filter
-
setPrefPrefix
Change the persisted parameter prefix for this instance of RadiusFilter.- Specified by:
setPrefPrefix
in interfacePersistingFilter
- Parameters:
prefPrefix
- prefix String (can be empty string "") or null to indicate this filter should not be persisted
-
getLatitude
public double getLatitude()Get the latitude center of this filter.- Returns:
- double latitude in fractional degrees North
-
setLatitude
public void setLatitude(double latitude) Programmatically change the center point latitude of this RadiusFilter.- Parameters:
latitude
- latitude in fractional degrees North
-
getLongitude
public double getLongitude()Get the longitude center of this filter.- Returns:
- double longitude in fractional degrees East
-
setLongitude
public void setLongitude(double longitude) Programmatically change the center point longitude of this RadiusFilter.- Parameters:
longitude
- longitude in fractional degrees East
-
isEnabled
public boolean isEnabled()Test if this RadiusFilter is enabled.- Returns:
- boolean true if filter will affect processed messages
-
setEnabled
public void setEnabled(boolean enabled) Specify whether this RadiusFilter is enabled.- Parameters:
enabled
- boolean true if filter should affect processed messages
-
setToPassall
public void setToPassall()Reset the filter to a configuration that would pass the maximum amount of messages, packets, and stations.- Specified by:
setToPassall
in classFilter
-
canRejectSome
public boolean canRejectSome()Specifies that this filter may reject some stations, messages, and/or frames. Used to tell combining filters whether a sub-filter is in passall mode and therefore doesn't need to be checked for every call to the combiner, thereby saving CPU time when filtering when most filters are in passall mode.- Overrides:
canRejectSome
in classFilter
- Returns:
- boolean true if this filter is currently capable of rejecting something
- See Also:
-
isUseHome
public boolean isUseHome()Test if this RadiusFilter will use the local station's current position or an explicitly configured position.- Returns:
- boolean true if the Radius Filter will use the current GPS position (if available) or the configured fixed beacon position, false if the explicitly configured position will be used
-
setUseHome
public void setUseHome(boolean useHome) Specify if this RadiusFilter will use the local station's current position or an explicitly configured position.- Parameters:
useHome
- boolean true if the Radius Filter will use the current GPS position (if available) or the configured fixed beacon position, false if the explicitly configured position will be used
-
getRadiusInKM
public double getRadiusInKM()Get the current radius in kilometers.- Returns:
- radius in kilometers
-
setRadiusInKM
public void setRadiusInKM(double radiusInKM) Set the current radius in kilometers.- Parameters:
radiusInKM
- radius in kilometers
-
acceptAX25Frame
Indicate whether the specified message should be displayed.- Specified by:
acceptAX25Frame
in classFilter
- Parameters:
frame
- the timestamped AX25 frame record to analyze- Returns:
- RESULT_xxx constant indicating if message information should be displayed
-
acceptLatLon
public int acceptLatLon(double lat, double lon) Test if the specified position is within the current range. Used for reporting stations entering and leaving the "local" area.- Parameters:
lat
- latitude in fractional degrees North of position to testlon
- longitude in fractional degrees East of position to test- Returns:
- RESULT_PASS if specified position is within the current configured maximum distance from the filter's center point, otherwise RESULT_REJECT
- See Also:
-
acceptMessage
Indicate whether the specified message should be displayed.- Specified by:
acceptMessage
in classFilter
- Parameters:
msg
- the APRS Message record to analyze- Returns:
- RESULT_xxx constant indicating if message information should be displayed
-
acceptStation
Indicate whether the specified station should be displayed.- Specified by:
acceptStation
in classFilter
- Parameters:
ss
- StationState record to analyze- Returns:
- RESULT_xxx constant indicating if station information should be displayed
-
getFilterTypeTagName
Report a tag name used to look up the labelling for an editor panel for this editor instance in a ResourceBundle of translated names.- Specified by:
getFilterTypeTagName
in classFilter
- Returns:
- String to use in looking up form label for this filter's editor
-
getFilterHelpTagName
Report a tag name used to look up JavaHelp for a filter editor.- Specified by:
getFilterHelpTagName
in classFilter
- Returns:
- String name (as defined in HelpMap.jhm) for this filter's online help, or null if there is no filter specific help
-
addFilterChangeListener
Register a listener for changes of this Filter.- Specified by:
addFilterChangeListener
in classFilter
- Parameters:
l
- FilterChangeListener to register
-
removeFilterChangeListener
Deregisters a listener. The listener will no longer be informed of changes to this filter.- Specified by:
removeFilterChangeListener
in classFilter
- Parameters:
l
- FilterChangeListener to deregister
-
clone
Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any objectx
, the expression:x.clone() != x
x.clone().getClass() == x.getClass()
true
, but these are not absolute requirements. While it is typically the case that:x.clone().equals(x)
true
, this is not an absolute requirement. By convention, the returned object should be obtained by callingsuper.clone
. If a class and all of its superclasses (exceptObject
) obey this convention, it will be the case thatx.clone().getClass() == x.getClass()
. By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned bysuper.clone
before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned bysuper.clone
need to be modified.- Overrides:
clone
in classFilter
- Returns:
- a clone of this instance.
- Throws:
CloneNotSupportedException
- if the object's class does not support theCloneable
interface. Subclasses that override theclone
method can also throw this exception to indicate that an instance cannot be cloned.- See Also:
-
setTrackerListener
Set aTrackerListener
that should be cancelled when this RadiusFilter instance is closed.- Parameters:
l
- TrackerListener to associate with the filter, or null to not have an association
-
close
Closes this filter and releases any system resources associated with it. If the filter is already closed then invoking this method has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs
-