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>defaultValueSupplierprivate java.lang.Stringkeyprivate intminZoomLevelprivate static BooleanPropertyPROP_AUTO_FILTER_DEFAULTSProperty 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>valueExtractorprivate 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.IntStreamdefaultLayer(OsmPrimitive osm)static AutoFilterRule[]defaultRules()Returns the default list of auto filter rules.booleanequals(java.lang.Object o)java.lang.StringformatValue(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.StringgetKey()Returns the OSM key on which the rule applies.intgetMinZoomLevel()Returns the minimum zoom level at which the rule applies.java.util.stream.IntStreamgetTagValuesForPrimitive(OsmPrimitive osm)Returns the numeric values for the given OSM primitiveinthashCode()AutoFilterRulesetDefaultValueSupplier(java.util.function.Function<OsmPrimitive,java.util.stream.IntStream> defaultValueSupplier)Sets the function which yields default values for the given OSM primitive.AutoFilterRulesetValueExtractor(java.util.function.ToIntFunction<java.lang.String> valueExtractor)Sets the function which extracts a numeric value from an OSM valueAutoFilterRulesetValueFormatter(java.util.function.IntFunction<java.lang.String> valueFormatter)Sets a OSM value formatter that defines the associated button label.java.lang.StringtoString()
-
-
-
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- ifvalueFormatteris 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- ifdefaultValueSupplieris 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- ifvalueExtractoris 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-