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 classAutoFilterManager.CompiledFilter(package private) static classAutoFilterManager.Match
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,AutoFilterButton>buttonsThe buttons currently displayed in map view.private AutoFiltercurrentAutoFilterThe currently selected auto filter, if any.(package private) AutoFilterRuleenabledRuleThe currently enabled rule, if any.private static AutoFilterManagerinstanceThe unique instance.private OSDLabellblOSDA helper fordrawOSDText(Graphics2D).private FilterModelmodelThe filter model.static BooleanPropertyPROP_AUTO_FILTER_ENABLEDProperty to determines if the auto filter feature is enabled.static StringPropertyPROP_AUTO_FILTER_RULEProperty to determine the current auto filter rule.private java.util.List<AutoFilterRule>rulesThe list of registered auto filter rules.
-
Constructor Summary
Constructors Modifier Constructor Description privateAutoFilterManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddButton(AutoFilterButton button, int value, int i)private voidaddNewButtons(java.util.NavigableSet<java.lang.Integer> values)voiddataChanged(DataChangedEvent event)Called after big changes in dataset.voiddrawOSDText(java.awt.Graphics2D g)Draws a text on the map display that indicates that filters are active.voidenableAutoFilterRule(java.lang.String key)Sets the currently enabled auto filter rule to the one defined for the given OSM key.voidenableAutoFilterRule(AutoFilterRule rule)Sets the currently enabled auto filter rule.AutoFilterRulegetAutoFilterRule(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.AutoFiltergetCurrentAutoFilter()Returns the currently selected auto filter, if any.static AutoFilterManagergetInstance()Returns the unique instance.private java.util.NavigableSet<java.lang.Integer>getNumericValues()voidlayerAdded(LayerManager.LayerAddEvent e)Notifies this listener that a layer has been added.voidlayerOrderChanged(LayerManager.LayerOrderChangeEvent e)Notifies this listener that the order of layers was changed.voidlayerRemoving(LayerManager.LayerRemoveEvent e)Notifies 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.voidotherDatasetChange(AbstractDatasetChangedEvent event)Minor dataset change, currently only changeset id changed is supported, but can be extended in future.voidpreferenceChanged(PreferenceChangeEvent e)Triggered when a preference entry value changes.voidprimitivesAdded(PrimitivesAddedEvent event)A bunch of primitives were added into the DataSet, or existing deleted/invisible primitives were resurrected.voidprimitivesRemoved(PrimitivesRemovedEvent event)A bunch of primitives were removed from the DataSet, or preexisting primitives were marked as deleted.booleanregisterAutoFilterRules(AutoFilterRule... filterRules)Registers new auto filter rule(s).voidrelationMembersChanged(RelationMembersChangedEvent event)A relation's members have changed.private voidremoveAllButtons()private voidresetCurrentAutoFilter()voidsetCurrentAutoFilter(AutoFilter autoFilter)Sets the currently selected auto filter, if any.voidtagsChanged(TagsChangedEvent event)There was some change in the tag set of a primitive.booleanunregisterAutoFilterRule(AutoFilterRule rule)Unregisters an auto filter rule.private voidupdateButtons()private voidupdateFiltersEvent(AbstractDatasetChangedEvent event, boolean affectedOnly)private voidupdateFiltersFull()voidwayNodesChanged(WayNodesChangedEvent event)A way's node list was changed.voidzoomChanged()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.ZoomChangeListenerMethod called when the zoom area has changed.- Specified by:
zoomChangedin interfaceNavigatableComponent.ZoomChangeListener
-
dataChanged
public void dataChanged(DataChangedEvent event)
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
public void nodeMoved(NodeMovedEvent event)
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
public void otherDatasetChange(AbstractDatasetChangedEvent event)
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
public void primitivesAdded(PrimitivesAddedEvent event)
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
public void primitivesRemoved(PrimitivesRemovedEvent event)
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
public void relationMembersChanged(RelationMembersChangedEvent event)
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
public void tagsChanged(TagsChangedEvent event)
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
public void wayNodesChanged(WayNodesChangedEvent event)
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
public void mapModeChange(MapMode oldMapMode, MapMode newMapMode)
Description copied from interface:MapFrame.MapModeChangeListenerTrigerred when map mode changes.- Specified by:
mapModeChangein 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:
trueif the list changed as a result of the call- Throws:
java.lang.NullPointerException- iffilterRulesis null
-
unregisterAutoFilterRule
public boolean unregisterAutoFilterRule(AutoFilterRule rule)
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:
java.lang.NullPointerException- ifruleis 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:PreferenceChangedListenerTriggered when a preference entry value changes.- Specified by:
preferenceChangedin interfacePreferenceChangedListener- Parameters:
e- the preference change event
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
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
public void layerRemoving(LayerManager.LayerRemoveEvent e)
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
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
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.
-
-