Class AutoFilterManager
java.lang.Object
org.openstreetmap.josm.gui.autofilter.AutoFilterManager
- All Implemented Interfaces:
DataSetListener,LayerManager.LayerChangeListener,MapFrame.MapModeChangeListener,NavigatableComponent.ZoomChangeListener,PreferenceChangedListener
public final class AutoFilterManager
extends Object
implements NavigatableComponent.ZoomChangeListener, MapFrame.MapModeChangeListener, DataSetListener, PreferenceChangedListener, LayerManager.LayerChangeListener
The auto filter manager keeps track of registered auto filter rules and applies the active one on the fly,
when the map contents, location or zoom changes.
- Since:
- 12400
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classThe combination of multipleAutoFilterManager.CompiledFilters(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<OptionalInt,AutoFilterButton> The buttons currently displayed in map view.private final List<AutoFilter>The currently selected auto filters, if any.(package private) AutoFilterRuleThe currently enabled rule, if any.private static AutoFilterManagerThe unique instance.private final OSDLabelA helper fordrawOSDText(Graphics2D).private final FilterModelThe filter model.static final BooleanPropertyProperty to determine if the auto filter feature is enabled.static final BooleanPropertyProperty to determine if the auto filter feature completely hides elements instead of just disabling them.static final StringPropertyProperty to determine the current auto filter rule.private final List<AutoFilterRule>The list of registered auto filter rules. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddButton(AutoFilterButton button, Integer value, int i) voidaddCurrentAutoFilter(AutoFilter autoFilter) Adds another auto filter to current listprivate voidaddNewButtons(NavigableSet<Integer> values) voiddataChanged(DataChangedEvent event) Called after big changes in dataset.voidDraws a text on the map display that indicates that filters are active.voidSets the currently enabled auto filter rule to the one defined for the given OSM key.voidSets the currently enabled auto filter rule.getAutoFilterRule(String key) Returns the auto filter rule defined for the given OSM key.Returns the list of registered auto filter rules.Returns the currently selected auto filters, if any.Returns a combination of allgetCurrentAutoFilters(), if any.static AutoFilterManagerReturns the unique instance.private NavigableSet<Integer>voidNotifies this listener that a layer has been added.voidNotifies this listener that the order of layers was changed.voidNotifies this listener that a layer was just removed.voidmapModeChange(MapMode oldMapMode, MapMode newMapMode) Trigerred when map mode changes.voidnodeMoved(NodeMovedEvent event) A node's coordinates were modified.voidMinor dataset change, currently only changeset id changed is supported, but can be extended in future.voidTriggered when a preference entry value changes.voidA bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.voidA bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.booleanregisterAutoFilterRules(AutoFilterRule... filterRules) Registers new auto filter rule(s).voidA relation's members have changed.private voidvoidremoveCurrentAutoFilter(AutoFilter autoFilter) Remove a current auto filterprivate voidvoidsetCurrentAutoFilter(AutoFilter autoFilter) Sets the currently selected auto filter, if any.voidtagsChanged(TagsChangedEvent event) There was some change in the tag set of a primitive.booleanUnregisters an auto filter rule.private voidprivate voidupdateFiltersEvent(AbstractDatasetChangedEvent event, boolean affectedOnly) private voidprivate voidvoidA way's node list was changed.voidMethod called when the zoom area has changed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.osm.event.DataSetListener
dataChangedIndividualEvents
-
Field Details
-
PROP_AUTO_FILTER_ENABLED
Property to determine if the auto filter feature is enabled. -
PROP_AUTO_FILTER_HIDING
Property to determine if the auto filter feature completely hides elements instead of just disabling them. Equivalent toFilter.hiding -
PROP_AUTO_FILTER_RULE
Property to determine the current auto filter rule. -
instance
The unique instance. -
buttons
The buttons currently displayed in map view. -
rules
The list of registered auto filter rules. -
lblOSD
A helper fordrawOSDText(Graphics2D). -
model
The filter model. -
enabledRule
The currently enabled rule, if any. -
currentAutoFilters
The currently selected auto filters, if any. If more than one auto filter is active, elements will match if they match at least one of them.
-
-
Constructor Details
-
AutoFilterManager
private AutoFilterManager()
-
-
Method Details
-
getInstance
Returns the unique instance.- Returns:
- the unique instance
-
updateButtons
-
addButton
-
removeAllButtons
-
getNumericValues
-
zoomChanged
Description copied from interface:NavigatableComponent.ZoomChangeListenerMethod called when the zoom area has changed.- Specified by:
zoomChangedin interfaceNavigatableComponent.ZoomChangeListener
-
dataChanged
Description copied from interface:DataSetListenerCalled after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and after operation is completed (Dataset.endUpdate()),DataSetListener.dataChanged(DataChangedEvent event)is called.- Specified by:
dataChangedin interfaceDataSetListener- Parameters:
event- data change event
-
nodeMoved
Description copied from interface:DataSetListenerA node's coordinates were modified.- Specified by:
nodeMovedin interfaceDataSetListener- Parameters:
event- The event for the node that was moved.
-
otherDatasetChange
Description copied from interface:DataSetListenerMinor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChangein interfaceDataSetListener- Parameters:
event- the event for data modification
-
primitivesAdded
Description copied from interface:DataSetListenerA bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAddedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-visible primitives
-
primitivesRemoved
Description copied from interface:DataSetListenerA bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemovedin interfaceDataSetListener- Parameters:
event- An event for an collection of newly-invisible primitives
-
relationMembersChanged
Description copied from interface:DataSetListenerA relation's members have changed.- Specified by:
relationMembersChangedin interfaceDataSetListener- Parameters:
event- The event for the relation that was modified.
-
tagsChanged
Description copied from interface:DataSetListenerThere was some change in the tag set of a primitive. It can have been a tag addition, tag removal or change in tag value.- Specified by:
tagsChangedin interfaceDataSetListener- Parameters:
event- the event for the primitive, whose tags were affected.
-
wayNodesChanged
Description copied from interface:DataSetListenerA way's node list was changed.- Specified by:
wayNodesChangedin interfaceDataSetListener- Parameters:
event- The event for the way that was modified.
-
mapModeChange
Description copied from interface:MapFrame.MapModeChangeListenerTrigerred when map mode changes.- Specified by:
mapModeChangein interfaceMapFrame.MapModeChangeListener- Parameters:
oldMapMode- old map modenewMapMode- new map mode
-
updateFiltersFull
-
updateFiltersEvent
-
registerAutoFilterRules
Registers new auto filter rule(s).- Parameters:
filterRules- new auto filter rules. Must not be null- Returns:
trueif the list changed as a result of the call- Throws:
NullPointerException- iffilterRulesis null
-
unregisterAutoFilterRule
Unregisters an auto filter rule.- Parameters:
rule- auto filter rule to remove. Must not be null- Returns:
trueif the list contained the specified rule- Throws:
NullPointerException- ifruleis null
-
getAutoFilterRules
Returns the list of registered auto filter rules.- Returns:
- the list of registered rules
-
getAutoFilterRule
Returns the auto filter rule defined for the given OSM key.- Parameters:
key- OSM key used to identify rule. Can't be null.- Returns:
- the auto filter rule defined for the given OSM key, or null
- Throws:
NullPointerException- if key is null
-
enableAutoFilterRule
Sets the currently enabled auto filter rule to the one defined for the given OSM key.- Parameters:
key- OSM key used to identify new rule to enable. Null to disable the auto filter feature.
-
enableAutoFilterRule
Sets the currently enabled auto filter rule.- Parameters:
rule- new rule to enable. Null to disable the auto filter feature.
-
getCurrentAutoFilters
Returns the currently selected auto filters, if any.- Returns:
- the currently selected auto filters. Can be empty.
- Since:
- 19592
-
getCurrentCombinedFilter
Returns a combination of allgetCurrentAutoFilters(), if any.- Returns:
- a single combined filter, or null
- Since:
- 19592
-
setCurrentAutoFilter
Sets the currently selected auto filter, if any.- Parameters:
autoFilter- the currently selected auto filter, or null
-
addCurrentAutoFilter
Adds another auto filter to current list- Parameters:
autoFilter- the filter to add to current list- Since:
- 19592
-
removeCurrentAutoFilter
Remove a current auto filter- Parameters:
autoFilter- the filter to remove from current list- Since:
- 19592
-
updateModelFilters
-
drawOSDText
Draws a text on the map display that indicates that filters are active.- Parameters:
g- The graphics to draw that text on.
-
resetCurrentAutoFilter
-
preferenceChanged
Description copied from interface:PreferenceChangedListenerTriggered when a preference entry value changes.- Specified by:
preferenceChangedin interfacePreferenceChangedListener- Parameters:
e- the preference change event
-
layerAdded
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that a layer has been added.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerAddedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The new added layer event
-
layerRemoving
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that a layer was just removed.Listeners are called in the EDT thread after the layer was removed. Use
LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)to remove more layers. You should not do blocking or long-running tasks in this method.- Specified by:
layerRemovingin interfaceLayerManager.LayerChangeListener- Parameters:
e- The layer to be removed (as event)
-
layerOrderChanged
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that the order of layers was changed.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerOrderChangedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The order change event.
-