Class FilterModel

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean changed
      true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
      private int disabledAndHiddenCount
      number of primitives that are disabled and hidden
      private int disabledCount
      number of primitives that are disabled but not hidden
      private FilterMatcher filterMatcher  
      private java.util.List<Filter> filters  
    • Constructor Summary

      Constructors 
      Constructor Description
      FilterModel()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addFilter​(Filter filter)
      Adds a new filter to the filter list.
      boolean addFilters​(Filter... newFilters)
      Adds new filters to the filter list.
      void clearFilterFlags()
      Clears all filtered flags from all primitives in the dataset
      void clearFilters()
      Removes all filters from this model.
      void drawOSDText​(java.awt.Graphics2D g, OSDLabel lblOSD, java.lang.String header, java.lang.String footer)
      Draws a text on the map display that indicates that filters are active.
      void executeFilters()
      Runs the filters on the current edit data set.
      void executeFilters​(java.util.Collection<? extends OsmPrimitive> primitives)
      Runs the filter on a list of primitives that are part of the edit data set.
      static java.util.Collection<OsmPrimitive> getAffectedPrimitives​(java.util.Collection<? extends OsmPrimitive> primitives)
      Returns the list of primitives whose filtering can be affected by change in primitive
      int getDisabledAndHiddenCount()
      Returns the number of primitives that are disabled and hidden.
      int getDisabledCount()
      Returns the number of primitives that are disabled but not hidden.
      java.util.List<Filter> getFilters()
      Returns the list of filters.
      int getFiltersCount()
      Returns the number of filters.
      Filter getValue​(int rowIndex)
      Get object value at given index.
      boolean hasFilters()
      Determines if at least one filter is enabled.
      boolean isChanged()
      Determines if the filter state (normal / disabled / hidden) of any primitive has changed in the process.
      void loadPrefs​(java.lang.String prefEntry)
      Initializes the model from preferences.
      boolean moveDownFilter​(int rowIndex)
      Moves down the filter in the given row.
      boolean moveFilters​(int delta, int... rowIndexes)
      Moves the filters in the given rows by a number of positions.
      boolean moveUpFilter​(int rowIndex)
      Moves up the filter in the given row
      Filter removeFilter​(int rowIndex)
      Removes the filter that is displayed in the given row
      java.util.Collection<Filter> removeFilters​(int... rowIndexes)
      Removes the filters that are displayed in the given rows
      void reverse()
      Reverse the items order.
      void savePrefs​(java.lang.String prefEntry)
      Saves the model to preferences.
      Filter setValue​(int rowIndex, Filter filter)
      Set object value at given index.
      void sort()
      Sort the items.
      private void updateFilterMatcher()  
      private static void updateMap()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • disabledCount

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

        private int 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
    • Method Detail

      • loadPrefs

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

        public void savePrefs​(java.lang.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​(java.util.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:
        for bulk removal
      • removeFilters

        public java.util.Collection<FilterremoveFilters​(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
      • drawOSDText

        public void drawOSDText​(java.awt.Graphics2D g,
                                OSDLabel lblOSD,
                                java.lang.String header,
                                java.lang.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 java.util.List<FiltergetFilters()
        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

        public int 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 java.util.Collection<OsmPrimitivegetAffectedPrimitives​(java.util.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