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 java.lang.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 Classes Modifier and Type Class Description (package private) static class
AutoFilterManager.CompiledFilter
(package private) static class
AutoFilterManager.Match
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,AutoFilterButton>
buttons
The buttons currently displayed in map view.private AutoFilter
currentAutoFilter
The currently selected auto filter, if any.(package private) AutoFilterRule
enabledRule
The currently enabled rule, if any.private static AutoFilterManager
instance
The unique instance.private OSDLabel
lblOSD
A helper fordrawOSDText(Graphics2D)
.private FilterModel
model
The filter model.static BooleanProperty
PROP_AUTO_FILTER_ENABLED
Property to determines if the auto filter feature is enabled.static StringProperty
PROP_AUTO_FILTER_RULE
Property to determine the current auto filter rule.private java.util.List<AutoFilterRule>
rules
The list of registered auto filter rules.
-
Constructor Summary
Constructors Modifier Constructor Description private
AutoFilterManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addButton(AutoFilterButton button, int value, int i)
private void
addNewButtons(java.util.NavigableSet<java.lang.Integer> values)
void
dataChanged(DataChangedEvent event)
Called after big changes in dataset.void
drawOSDText(java.awt.Graphics2D g)
Draws a text on the map display that indicates that filters are active.void
enableAutoFilterRule(java.lang.String key)
Sets the currently enabled auto filter rule to the one defined for the given OSM key.void
enableAutoFilterRule(AutoFilterRule rule)
Sets the currently enabled auto filter rule.AutoFilterRule
getAutoFilterRule(java.lang.String key)
Returns the auto filter rule defined for the given OSM key.java.util.List<AutoFilterRule>
getAutoFilterRules()
Returns the list of registered auto filter rules.AutoFilter
getCurrentAutoFilter()
Returns the currently selected auto filter, if any.static AutoFilterManager
getInstance()
Returns the unique instance.private java.util.NavigableSet<java.lang.Integer>
getNumericValues()
void
layerAdded(LayerManager.LayerAddEvent e)
Notifies this listener that a layer has been added.void
layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Notifies this listener that the order of layers was changed.void
layerRemoving(LayerManager.LayerRemoveEvent e)
Notifies this listener that a layer was just removed.void
mapModeChange(MapMode oldMapMode, MapMode newMapMode)
Trigerred when map mode changes.void
nodeMoved(NodeMovedEvent event)
A node's coordinates were modified.void
otherDatasetChange(AbstractDatasetChangedEvent event)
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.void
preferenceChanged(PreferenceChangeEvent e)
Triggered when a preference entry value changes.void
primitivesAdded(PrimitivesAddedEvent event)
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.void
primitivesRemoved(PrimitivesRemovedEvent event)
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.boolean
registerAutoFilterRules(AutoFilterRule... filterRules)
Registers new auto filter rule(s).void
relationMembersChanged(RelationMembersChangedEvent event)
A relation's members have changed.private void
removeAllButtons()
private void
resetCurrentAutoFilter()
void
setCurrentAutoFilter(AutoFilter autoFilter)
Sets the currently selected auto filter, if any.void
tagsChanged(TagsChangedEvent event)
There was some change in the tag set of a primitive.boolean
unregisterAutoFilterRule(AutoFilterRule rule)
Unregisters an auto filter rule.private void
updateButtons()
private void
updateFiltersEvent(AbstractDatasetChangedEvent event, boolean affectedOnly)
private void
updateFiltersFull()
void
wayNodesChanged(WayNodesChangedEvent event)
A way's node list was changed.void
zoomChanged()
Method called when the zoom area has changed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.osm.event.DataSetListener
dataChangedIndividualEvents
-
-
-
-
Field Detail
-
PROP_AUTO_FILTER_ENABLED
public static final BooleanProperty PROP_AUTO_FILTER_ENABLED
Property to determines if the auto filter feature is enabled.
-
PROP_AUTO_FILTER_RULE
public static final StringProperty PROP_AUTO_FILTER_RULE
Property to determine the current auto filter rule.
-
instance
private static volatile AutoFilterManager instance
The unique instance.
-
buttons
private final java.util.Map<java.lang.Integer,AutoFilterButton> buttons
The buttons currently displayed in map view.
-
rules
private final java.util.List<AutoFilterRule> rules
The list of registered auto filter rules.
-
lblOSD
private final OSDLabel lblOSD
A helper fordrawOSDText(Graphics2D)
.
-
model
private final FilterModel model
The filter model.
-
enabledRule
AutoFilterRule enabledRule
The currently enabled rule, if any.
-
currentAutoFilter
private AutoFilter currentAutoFilter
The currently selected auto filter, if any.
-
-
Constructor Detail
-
AutoFilterManager
private AutoFilterManager()
-
-
Method Detail
-
getInstance
public static AutoFilterManager getInstance()
Returns the unique instance.- Returns:
- the unique instance
-
updateButtons
private void updateButtons()
-
addNewButtons
private void addNewButtons(java.util.NavigableSet<java.lang.Integer> values)
-
addButton
private void addButton(AutoFilterButton button, int value, int i)
-
removeAllButtons
private void removeAllButtons()
-
getNumericValues
private java.util.NavigableSet<java.lang.Integer> getNumericValues()
-
zoomChanged
public void zoomChanged()
Description copied from interface:NavigatableComponent.ZoomChangeListener
Method called when the zoom area has changed.- Specified by:
zoomChanged
in interfaceNavigatableComponent.ZoomChangeListener
-
dataChanged
public void dataChanged(DataChangedEvent event)
Description copied from interface:DataSetListener
Called 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:
dataChanged
in interfaceDataSetListener
- Parameters:
event
- data change event
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Description copied from interface:DataSetListener
A node's coordinates were modified.- Specified by:
nodeMoved
in interfaceDataSetListener
- Parameters:
event
- The event for the node that was moved.
-
otherDatasetChange
public void otherDatasetChange(AbstractDatasetChangedEvent event)
Description copied from interface:DataSetListener
Minor dataset change, currently only changeset id changed is supported, but can be extended in future.- Specified by:
otherDatasetChange
in interfaceDataSetListener
- Parameters:
event
- the event for data modification
-
primitivesAdded
public void primitivesAdded(PrimitivesAddedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.- Specified by:
primitivesAdded
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-visible primitives
-
primitivesRemoved
public void primitivesRemoved(PrimitivesRemovedEvent event)
Description copied from interface:DataSetListener
A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.- Specified by:
primitivesRemoved
in interfaceDataSetListener
- Parameters:
event
- An event for an collection of newly-invisible primitives
-
relationMembersChanged
public void relationMembersChanged(RelationMembersChangedEvent event)
Description copied from interface:DataSetListener
A relation's members have changed.- Specified by:
relationMembersChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the relation that was modified.
-
tagsChanged
public void tagsChanged(TagsChangedEvent event)
Description copied from interface:DataSetListener
There 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:
tagsChanged
in interfaceDataSetListener
- Parameters:
event
- the event for the primitive, whose tags were affected.
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Description copied from interface:DataSetListener
A way's node list was changed.- Specified by:
wayNodesChanged
in interfaceDataSetListener
- Parameters:
event
- The event for the way that was modified.
-
mapModeChange
public void mapModeChange(MapMode oldMapMode, MapMode newMapMode)
Description copied from interface:MapFrame.MapModeChangeListener
Trigerred when map mode changes.- Specified by:
mapModeChange
in interfaceMapFrame.MapModeChangeListener
- Parameters:
oldMapMode
- old map modenewMapMode
- new map mode
-
updateFiltersFull
private void updateFiltersFull()
-
updateFiltersEvent
private void updateFiltersEvent(AbstractDatasetChangedEvent event, boolean affectedOnly)
-
registerAutoFilterRules
public boolean registerAutoFilterRules(AutoFilterRule... filterRules)
Registers new auto filter rule(s).- Parameters:
filterRules
- new auto filter rules. Must not be null- Returns:
true
if the list changed as a result of the call- Throws:
java.lang.NullPointerException
- iffilterRules
is null
-
unregisterAutoFilterRule
public boolean unregisterAutoFilterRule(AutoFilterRule rule)
Unregisters an auto filter rule.- Parameters:
rule
- auto filter rule to remove. Must not be null- Returns:
true
if the list contained the specified rule- Throws:
java.lang.NullPointerException
- ifrule
is null
-
getAutoFilterRules
public java.util.List<AutoFilterRule> getAutoFilterRules()
Returns the list of registered auto filter rules.- Returns:
- the list of registered rules
-
getAutoFilterRule
public AutoFilterRule getAutoFilterRule(java.lang.String key)
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:
java.lang.NullPointerException
- if key is null
-
enableAutoFilterRule
public void enableAutoFilterRule(java.lang.String key)
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
public void enableAutoFilterRule(AutoFilterRule rule)
Sets the currently enabled auto filter rule.- Parameters:
rule
- new rule to enable. Null to disable the auto filter feature.
-
getCurrentAutoFilter
public AutoFilter getCurrentAutoFilter()
Returns the currently selected auto filter, if any.- Returns:
- the currently selected auto filter, or null
-
setCurrentAutoFilter
public void setCurrentAutoFilter(AutoFilter autoFilter)
Sets the currently selected auto filter, if any.- Parameters:
autoFilter
- the currently selected auto filter, or null
-
drawOSDText
public void drawOSDText(java.awt.Graphics2D g)
Draws a text on the map display that indicates that filters are active.- Parameters:
g
- The graphics to draw that text on.
-
resetCurrentAutoFilter
private void resetCurrentAutoFilter()
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListener
Triggered when a preference entry value changes.- Specified by:
preferenceChanged
in interfacePreferenceChangedListener
- Parameters:
e
- the preference change event
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies 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:
layerAdded
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies 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:
layerRemoving
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The layer to be removed (as event)
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies 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:
layerOrderChanged
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The order change event.
-
-