Class Filter

    • Constructor Summary

      Constructors 
      Constructor Description
      Filter()
      Constructs a new filter for the first column of a data model.
      Filter​(int column)
      Constructs a new filter for the specified column of a data model in absolute model coordinates.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void assign​(ComponentAdapter adapter)
      Binds this filter to the specified ComponentAdapter.
      int convertRowIndexToModel​(int row)
      Convert row index from view coordinates to model coordinates accounting for the presence of sorters and filters.
      int convertRowIndexToView​(int row)
      Convert row index from model coordinates to view coordinates accounting for the presence of sorters and filters.
      protected abstract void filter()
      Performs the filter operation defined by this filter.
      protected void fireFilterChanged()
      Notifies interested parties that this filter has changed.
      int getColumnIndex()
      Returns the model index of the column that this filter has been bound to.
      java.lang.String getColumnName()  
      protected int getInputSize()
      Returns the number of records of this filter's input ("model").
      protected java.lang.String getInputString​(int row, int column)
      Returns the string representation of cell at the specified row and column.
      protected java.lang.Object getInputValue​(int row, int column)
      Returns the value of the cell at the specified row and column.
      protected Filter getMappingFilter()
      Returns the filter to use for accessing input.
      protected FilterPipeline getPipeline()  
      abstract int getSize()
      Returns the number of records that remain in this filter's output ("view") after the input records have been filtered.
      java.lang.String getStringAt​(int row, int column)
      Returns the string representation at the specified row and column.
      java.lang.Object getValueAt​(int row, int column)
      Returns the value at the specified row and column.
      protected abstract void init()
      Provides filter-specific initialization.
      boolean isCellEditable​(int row, int column)
      Returns editability of the cell identified by the specified row and column index.
      protected abstract int mapTowardModel​(int row)
      PRE: 0 <= row < getSize();
      protected int mapTowardView​(int row)
      PRE: 0 <= row < getInputSize();
      void refresh()
      Refreshes the internal state of the filter, performs the filter operation and regenerates row mappings from the previous filter.
      protected void refresh​(boolean reset)
      Refreshes the internal state of the filter, optionally resetting the cache of existing row mappings from this filter to the previous filter.
      protected abstract void reset()
      Resets the internal row mappings from this filter to the previous filter.
      void setColumnIndex​(int modelColumn)
      TODO: PENDING: not tested!
      void setValueAt​(java.lang.Object aValue, int row, int column)
      Sets the specified value as the new value for the cell identified by the specified row and column index.
      • Methods inherited from class java.lang.Object

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

      • Filter

        public Filter()
        Constructs a new filter for the first column of a data model.
      • Filter

        public Filter​(int column)
        Constructs a new filter for the specified column of a data model in absolute model coordinates.
        Parameters:
        column - column index in absolute model coordinates
    • Method Detail

      • refresh

        public void refresh()
        Refreshes the internal state of the filter, performs the filter operation and regenerates row mappings from the previous filter. If this filter is bound to a filter pipeline (as most filters are), it also triggers a filterChanged notification.
      • getColumnIndex

        public int getColumnIndex()
        Returns the model index of the column that this filter has been bound to.
        Returns:
        the column index in absolute model coordinates
      • setColumnIndex

        public void setColumnIndex​(int modelColumn)
        TODO: PENDING: not tested!
        Parameters:
        column - column index in absolute model coordinates
      • getColumnName

        public java.lang.String getColumnName()
      • convertRowIndexToModel

        public int convertRowIndexToModel​(int row)
        Convert row index from view coordinates to model coordinates accounting for the presence of sorters and filters. PRE: 0 <= row < getSize()
        Parameters:
        row - the row index in this filter's output ("view") coordinates
        Returns:
        row index in absolute model coordinates
      • convertRowIndexToView

        public int convertRowIndexToView​(int row)
        Convert row index from model coordinates to view coordinates accounting for the presence of sorters and filters.
        Parameters:
        row - row index in model coordinates
        Returns:
        row index in this filter's "view" coordinates
      • getValueAt

        public java.lang.Object getValueAt​(int row,
                                           int column)
        Returns the value at the specified row and column. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()
        Parameters:
        row - the row index in this filter's output ("view") coordinates
        column - column index in absolute model coordinates
        Returns:
        the value at the specified row and column
      • getStringAt

        public java.lang.String getStringAt​(int row,
                                            int column)
        Returns the string representation at the specified row and column. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()
        Parameters:
        row - the row index in this filter's output ("view") coordinates
        column - column index in model coordinates
        Returns:
        the string representation of the cell at the specified row and column.
      • setValueAt

        public void setValueAt​(java.lang.Object aValue,
                               int row,
                               int column)
        Sets the specified value as the new value for the cell identified by the specified row and column index. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()
        Parameters:
        aValue - new value for the specified cell
        row - the row index in this filter's output ("view") coordinates
        column - the column index in absolute model coordinates
      • isCellEditable

        public boolean isCellEditable​(int row,
                                      int column)
        Returns editability of the cell identified by the specified row and column index. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()
        Parameters:
        row - the row index in this filter's output ("view") coordinates
        column - column index in model coordinates
        Returns:
        true if the cell at the specified row/col is editable
      • getSize

        public abstract int getSize()
        Returns the number of records that remain in this filter's output ("view") after the input records have been filtered.
        Returns:
        the number of records that remain in this filter's output ("view") after the input records have been filtered
      • getInputSize

        protected int getInputSize()
        Returns the number of records of this filter's input ("model").
        Returns:
        the number of records of this filter's input ("model").
      • getInputValue

        protected java.lang.Object getInputValue​(int row,
                                                 int column)
        Returns the value of the cell at the specified row and column. The column index is in absolute column coordinates.
        Parameters:
        row - in the coordinates of what is the filter's input ("model").
        column - in model coordinates
        Returns:
        the value of the cell at the specified row and column.
      • getInputString

        protected java.lang.String getInputString​(int row,
                                                  int column)
        Returns the string representation of cell at the specified row and column.
        Parameters:
        row - in the coordinates of what is the filter's "model" (== input) coordinates
        column - in model coordinates
        Returns:
        the string representation of the cell at the specified row and column.
      • init

        protected abstract void init()
        Provides filter-specific initialization. Called from the Filter constructor.
      • reset

        protected abstract void reset()
        Resets the internal row mappings from this filter to the previous filter.
      • filter

        protected abstract void filter()
        Performs the filter operation defined by this filter.
      • mapTowardModel

        protected abstract int mapTowardModel​(int row)
        PRE: 0 <= row < getSize();
        Parameters:
        row -
        Returns:
        TODO:
      • mapTowardView

        protected int mapTowardView​(int row)
        PRE: 0 <= row < getInputSize();
        Parameters:
        row -
        Returns:
        TODO:
      • getMappingFilter

        protected Filter getMappingFilter()
        Returns the filter to use for accessing input. That's the previous (model is first) filter if this is part of a pipeline or null if this is standalone or the first in the pipeline.
        Returns:
        filter to use for accessing input
      • refresh

        protected void refresh​(boolean reset)
        Refreshes the internal state of the filter, optionally resetting the cache of existing row mappings from this filter to the previous filter. Always performs the filter operation and regenerates row mappings from the previous filter. If this filter is bound to a filter pipeline (as most filters are), it also triggers a filterChanged notification.
        Parameters:
        reset - true if existing row mappings from this filter to the previous filter should be reset; false, if the existing row mappings should be preserved.
      • fireFilterChanged

        protected void fireFilterChanged()
        Notifies interested parties that this filter has changed.