Class FilterModel

java.lang.Object
org.openstreetmap.josm.data.osm.FilterModel
All Implemented Interfaces:
ReorderableModel<Filter>, SortableModel<Filter>

public class FilterModel extends Object implements SortableModel<Filter>
The model that is used both for auto and manual filters.
Since:
12400
  • Field Details

    • disabledCount

      private int disabledCount
      number of primitives that are disabled but not hidden
    • disabledAndHiddenCount

      number of primitives that are disabled and hidden
    • changed

      private boolean changed
      true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
    • filters

      private final List<Filter> filters
    • filterMatcher

  • Constructor Details

  • Method Details

    • updateFilterMatcher

      private void updateFilterMatcher()
    • loadPrefs

      public void loadPrefs(String prefEntry)
      Initializes the model from preferences.
      Parameters:
      prefEntry - preference key
    • savePrefs

      public void savePrefs(String prefEntry)
      Saves the model to preferences.
      Parameters:
      prefEntry - preferences key
    • executeFilters

      public void executeFilters()
      Runs the filters on the current edit data set.
    • executeFilters

      public void executeFilters(Collection<? extends OsmPrimitive> primitives)
      Runs the filter on a list of primitives that are part of the edit data set.
      Parameters:
      primitives - The primitives
    • updateMap

      private static void updateMap()
    • clearFilterFlags

      public void clearFilterFlags()
      Clears all filtered flags from all primitives in the dataset
    • clearFilters

      public void clearFilters()
      Removes all filters from this model.
    • addFilter

      public boolean addFilter(Filter filter)
      Adds a new filter to the filter list.
      Parameters:
      filter - The new filter
      Returns:
      true (as specified by Collection.add(E))
    • addFilters

      public boolean addFilters(Filter... newFilters)
      Adds new filters to the filter list.
      Parameters:
      newFilters - The new filters
      Returns:
      true (as specified by Collection.add(E))
      Since:
      18556
    • moveFilters

      public boolean moveFilters(int delta, int... rowIndexes)
      Moves the filters in the given rows by a number of positions.
      Parameters:
      delta - negative or positive increment
      rowIndexes - The filter rows
      Returns:
      true if the filters have been moved down
      Since:
      15226
    • moveDownFilter

      public boolean moveDownFilter(int rowIndex)
      Moves down the filter in the given row.
      Parameters:
      rowIndex - The filter row
      Returns:
      true if the filter has been moved down
    • moveUpFilter

      public boolean moveUpFilter(int rowIndex)
      Moves up the filter in the given row
      Parameters:
      rowIndex - The filter row
      Returns:
      true if the filter has been moved up
    • removeFilter

      public Filter removeFilter(int rowIndex)
      Removes the filter that is displayed in the given row
      Parameters:
      rowIndex - The index of the filter to remove
      Returns:
      the filter previously at the specified position
      See Also:
    • removeFilters

      public Collection<Filter> removeFilters(int... rowIndexes)
      Removes the filters that are displayed in the given rows
      Parameters:
      rowIndexes - The indexes of the filters to remove
      Returns:
      the filters previously at the specified positions
      Since:
      18556
    • setValue

      public Filter setValue(int rowIndex, Filter filter)
      Description copied from interface: ReorderableModel
      Set object value at given index.
      Specified by:
      setValue in interface ReorderableModel<Filter>
      Parameters:
      rowIndex - index
      filter - new value
      Returns:
      the value previously at the specified position
    • getValue

      public Filter getValue(int rowIndex)
      Description copied from interface: ReorderableModel
      Get object value at given index.
      Specified by:
      getValue in interface ReorderableModel<Filter>
      Parameters:
      rowIndex - index
      Returns:
      object value at given index
    • drawOSDText

      public void drawOSDText(Graphics2D g, OSDLabel lblOSD, String header, String footer)
      Draws a text on the map display that indicates that filters are active.
      Parameters:
      g - The graphics to draw that text on.
      lblOSD - On Screen Display label
      header - The title to display at the beginning of OSD
      footer - The message to display at the bottom of OSD. Must end by </html>
    • getFilters

      public List<Filter> getFilters()
      Returns the list of filters.
      Returns:
      the list of filters
    • getFiltersCount

      public int getFiltersCount()
      Returns the number of filters.
      Returns:
      the number of filters
    • getDisabledCount

      public int getDisabledCount()
      Returns the number of primitives that are disabled but not hidden.
      Returns:
      the number of primitives that are disabled but not hidden
    • getDisabledAndHiddenCount

      Returns the number of primitives that are disabled and hidden.
      Returns:
      the number of primitives that are disabled and hidden
    • isChanged

      public boolean isChanged()
      Determines if the filter state (normal / disabled / hidden) of any primitive has changed in the process.
      Returns:
      true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
    • hasFilters

      public boolean hasFilters()
      Determines if at least one filter is enabled.
      Returns:
      true if at least one filter is enabled
      Since:
      14206
    • getAffectedPrimitives

      public static Collection<OsmPrimitive> getAffectedPrimitives(Collection<? extends OsmPrimitive> primitives)
      Returns the list of primitives whose filtering can be affected by change in primitive
      Parameters:
      primitives - list of primitives to check
      Returns:
      List of primitives whose filtering can be affected by change in source primitives
    • sort

      public void sort()
      Description copied from interface: SortableModel
      Sort the items.
      Specified by:
      sort in interface SortableModel<Filter>
    • reverse

      public void reverse()
      Description copied from interface: SortableModel
      Reverse the items order.
      Specified by:
      reverse in interface SortableModel<Filter>