Class AutoFilterRule
java.lang.Object
org.openstreetmap.josm.gui.autofilter.AutoFilterRule
An auto filter rule determines how auto filter can be built from visible map data.
Several rules can be registered, but only one rule is active at the same time.
Rules are identified by the OSM key on which they apply.
The dynamic values discovering operates only below a certain zoom level, for performance reasons.
- Since:
- 12400
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe union ofkeyand the keys provided bysetExtraKeys(List).private Function<OsmPrimitive,IntStream> private final Stringprivate final intprivate booleanprivate static final BooleanPropertyProperty to determine if the auto filter should assume sensible defaults for values (such as layer=1 for bridge=yes).private ToIntFunction<String>private IntFunction<String> -
Constructor Summary
ConstructorsConstructorDescriptionAutoFilterRule(String key, int minZoomLevel) Constructs a newAutoFilterRule. -
Method Summary
Modifier and TypeMethodDescriptionprivate static IntStreamdefaultLayer(OsmPrimitive osm) static AutoFilterRule[]Returns the default list of auto filter rules.Adds a filter button for OSM primitives which have no value for the key.booleanformatValue(Integer value) Formats the numeric value(package private) static Optional<AutoFilterRule>getDefaultRule(String key) Returns the default auto filter rule for the given keygetKey()Returns the OSM key on which the rule applies.intReturns the minimum zoom level at which the rule applies.booleanReturns true if there should be a filter button for OSM primitives which have no value for the key.getTagValuesForPrimitive(OsmPrimitive osm, boolean directValuesOnly) Returns the numeric values for the given OSM primitiveprivate IntStreamgetTagValuesForPrimitive(OsmPrimitive osm, String key, boolean directValuesOnly) inthashCode()setDefaultValueSupplier(Function<OsmPrimitive, IntStream> defaultValueSupplier) Sets the function which yields default values for the given OSM primitive.setExtraKeys(List<String> extraKeys) Sets extra OSM keys on which the rule applies in addition to the primary key (getKey()).setValueExtractor(ToIntFunction<String> valueExtractor) Sets the function which extracts a numeric value from an OSM valuesetValueFormatter(IntFunction<String> valueFormatter) Sets a OSM value formatter that defines the associated button label.toString()
-
Field Details
-
PROP_AUTO_FILTER_DEFAULTS
Property to determine if the auto filter should assume sensible defaults for values (such as layer=1 for bridge=yes). -
key
-
minZoomLevel
-
defaultValueSupplier
-
valueExtractor
-
valueFormatter
-
noValueFilter
-
allKeys
The union ofkeyand the keys provided bysetExtraKeys(List).
-
-
Constructor Details
-
AutoFilterRule
Constructs a newAutoFilterRule.- Parameters:
key- the OSM key on which the rule appliesminZoomLevel- the minimum zoom level at which the rule applies
-
-
Method Details
-
getKey
Returns the OSM key on which the rule applies.- Returns:
- the OSM key on which the rule applies
-
getMinZoomLevel
Returns the minimum zoom level at which the rule applies.- Returns:
- the minimum zoom level at which the rule applies
-
getNoValueFilter
Returns true if there should be a filter button for OSM primitives which have no value for the key.- Since:
- 19592
-
formatValue
Formats the numeric value- Parameters:
value- the numeric value to format- Returns:
- the formatted value
- Since:
- 19592
-
setValueFormatter
Sets a OSM value formatter that defines the associated button label.- Parameters:
valueFormatter- OSM value formatter. Cannot be null- Returns:
this- Throws:
NullPointerException- ifvalueFormatteris null
-
setDefaultValueSupplier
public AutoFilterRule setDefaultValueSupplier(Function<OsmPrimitive, IntStream> defaultValueSupplier) Sets the function which yields default values for the given OSM primitive. This function is invoked if the primitive does not have this key.- Parameters:
defaultValueSupplier- the function which yields default values for the given OSM primitive- Returns:
this- Throws:
NullPointerException- ifdefaultValueSupplieris null
-
setValueExtractor
Sets the function which extracts a numeric value from an OSM value- Parameters:
valueExtractor- the function which extracts a numeric value from an OSM value- Returns:
this- Throws:
NullPointerException- ifvalueExtractoris null
-
enableNoValueFilter
Adds a filter button for OSM primitives which have no value for the key. -
setExtraKeys
Sets extra OSM keys on which the rule applies in addition to the primary key (getKey()). This allows a filter to look at the values of more than one key at the same time.- Parameters:
extraKeys- the list of extra keys, may be empty- Returns:
this- Throws:
NullPointerException- ifextraKeysis null- Since:
- 19592
-
getTagValuesForPrimitive
Returns the numeric values for the given OSM primitive- Parameters:
osm- the primitivedirectValuesOnly- whether "inner" values from ranges (such as 6 and 7 for 5-8) should be omitted- Returns:
- a stream of numeric values
- Since:
- 19592
-
getTagValuesForPrimitive
-
defaultRules
Returns the default list of auto filter rules. Plugins can extend the list by registering additional rules.- Returns:
- the default list of auto filter rules
-
getDefaultRule
Returns the default auto filter rule for the given key- Parameters:
key- the OSM key- Returns:
- default auto filter rule for the given key
-
defaultLayer
-
equals
-
hashCode
-
toString
-