Class AutoFilterRule
- java.lang.Object
-
- org.openstreetmap.josm.gui.autofilter.AutoFilterRule
-
public class AutoFilterRule extends java.lang.Object
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
Fields Modifier and Type Field Description private java.util.function.Function<OsmPrimitive,java.util.stream.IntStream>
defaultValueSupplier
private java.lang.String
key
private int
minZoomLevel
private static BooleanProperty
PROP_AUTO_FILTER_DEFAULTS
Property to determine if the auto filter should assume sensible defaults for values (such as layer=1 for bridge=yes).private java.util.function.ToIntFunction<java.lang.String>
valueExtractor
private java.util.function.IntFunction<java.lang.String>
valueFormatter
-
Constructor Summary
Constructors Constructor Description AutoFilterRule(java.lang.String key, int minZoomLevel)
Constructs a newAutoFilterRule
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.stream.IntStream
defaultLayer(OsmPrimitive osm)
static AutoFilterRule[]
defaultRules()
Returns the default list of auto filter rules.boolean
equals(java.lang.Object o)
java.lang.String
formatValue(int value)
Formats the numeric value(package private) static java.util.Optional<AutoFilterRule>
getDefaultRule(java.lang.String key)
Returns the default auto filter rule for the given keyjava.lang.String
getKey()
Returns the OSM key on which the rule applies.int
getMinZoomLevel()
Returns the minimum zoom level at which the rule applies.java.util.stream.IntStream
getTagValuesForPrimitive(OsmPrimitive osm)
Returns the numeric values for the given OSM primitiveint
hashCode()
AutoFilterRule
setDefaultValueSupplier(java.util.function.Function<OsmPrimitive,java.util.stream.IntStream> defaultValueSupplier)
Sets the function which yields default values for the given OSM primitive.AutoFilterRule
setValueExtractor(java.util.function.ToIntFunction<java.lang.String> valueExtractor)
Sets the function which extracts a numeric value from an OSM valueAutoFilterRule
setValueFormatter(java.util.function.IntFunction<java.lang.String> valueFormatter)
Sets a OSM value formatter that defines the associated button label.java.lang.String
toString()
-
-
-
Field Detail
-
PROP_AUTO_FILTER_DEFAULTS
private static final BooleanProperty 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
private final java.lang.String key
-
minZoomLevel
private final int minZoomLevel
-
defaultValueSupplier
private java.util.function.Function<OsmPrimitive,java.util.stream.IntStream> defaultValueSupplier
-
valueExtractor
private java.util.function.ToIntFunction<java.lang.String> valueExtractor
-
valueFormatter
private java.util.function.IntFunction<java.lang.String> valueFormatter
-
-
Constructor Detail
-
AutoFilterRule
public AutoFilterRule(java.lang.String key, int minZoomLevel)
Constructs a newAutoFilterRule
.- Parameters:
key
- the OSM key on which the rule appliesminZoomLevel
- the minimum zoom level at which the rule applies
-
-
Method Detail
-
getKey
public java.lang.String getKey()
Returns the OSM key on which the rule applies.- Returns:
- the OSM key on which the rule applies
-
getMinZoomLevel
public int getMinZoomLevel()
Returns the minimum zoom level at which the rule applies.- Returns:
- the minimum zoom level at which the rule applies
-
formatValue
public java.lang.String formatValue(int value)
Formats the numeric value- Parameters:
value
- the numeric value to format- Returns:
- the formatted value
-
setValueFormatter
public AutoFilterRule setValueFormatter(java.util.function.IntFunction<java.lang.String> valueFormatter)
Sets a OSM value formatter that defines the associated button label.- Parameters:
valueFormatter
- OSM value formatter. Cannot be null- Returns:
this
- Throws:
java.lang.NullPointerException
- ifvalueFormatter
is null
-
setDefaultValueSupplier
public AutoFilterRule setDefaultValueSupplier(java.util.function.Function<OsmPrimitive,java.util.stream.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:
java.lang.NullPointerException
- ifdefaultValueSupplier
is null
-
setValueExtractor
public AutoFilterRule setValueExtractor(java.util.function.ToIntFunction<java.lang.String> valueExtractor)
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:
java.lang.NullPointerException
- ifvalueExtractor
is null
-
getTagValuesForPrimitive
public java.util.stream.IntStream getTagValuesForPrimitive(OsmPrimitive osm)
Returns the numeric values for the given OSM primitive- Parameters:
osm
- the primitive- Returns:
- a stream of numeric values
-
defaultRules
public static AutoFilterRule[] 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
static java.util.Optional<AutoFilterRule> getDefaultRule(java.lang.String key)
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
private static java.util.stream.IntStream defaultLayer(OsmPrimitive osm)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-