Class PivotStore

java.lang.Object
ca.spatial.table.PivotStore
All Implemented Interfaces:
com.jidesoft.pivot.PivotDataSource, EventListener, TableModelListener

public class PivotStore extends Object implements com.jidesoft.pivot.PivotDataSource, TableModelListener
Provide AttributeStore data for a pivot table
  • Method Details

    • getPeriodCount

      public int getPeriodCount()
    • getTitle

      public String getTitle()
    • isSuspendable

      public boolean isSuspendable()
    • suspend

      public boolean suspend()
    • resume

      public boolean resume()
    • close

      public void close()
      Call when disposing of pivot table in order to disconnect listeners
    • getFieldCount

      public int getFieldCount()
      Gets number of fields in this data source.
      Specified by:
      getFieldCount in interface com.jidesoft.pivot.PivotDataSource
      Returns:
      the field count.
    • getCalculatedColumnAt

      public com.jidesoft.grid.CalculatedColumn getCalculatedColumnAt(int column)
      Get the calculated column at the position
    • addCalculatedColumn

      public com.jidesoft.grid.CalculatedColumn addCalculatedColumn(String name, String expression)
      Add a calculated column
    • setWeightColumn

      public ca.spatial.table.PivotStore.WeightedColumn setWeightColumn(String columnName, String weightColumn)
      Set the column that will be used as a weighted average factor. When calculating the weighted average the column of interest will be weighted by this column.
    • getWeightColumn

      public String getWeightColumn(String columnName)
    • getFieldName

      public String getFieldName(int fieldIndex)
      Gets the field name. The name should be unique in this data source.
      Specified by:
      getFieldName in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      fieldIndex - the field index.
      Returns:
      the field name.
    • getFieldTitle

      public String getFieldTitle(int fieldIndex)
      Gets the field title.
      Specified by:
      getFieldTitle in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      fieldIndex - the field index.
      Returns:
      the title of the field.
      Since:
      3.2.4
    • getFieldType

      public Class getFieldType(int fieldIndex)
      Gets the field type.
      Specified by:
      getFieldType in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      fieldIndex - the field index.
      Returns:
      the field type.
    • getRowCount

      public int getRowCount()
      Gets the row count. If there is filtering, it should return the row count after filtering.
      Specified by:
      getRowCount in interface com.jidesoft.pivot.PivotDataSource
      Returns:
      the row count.
    • getValueAt

      public Object getValueAt(int rowIndex, int fieldIndex)
      Gets the value at the specified field index and the row index.
      Specified by:
      getValueAt in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      rowIndex - the row index. It is the index after filtering.
      fieldIndex - the field index.
      Returns:
      the value.
    • setValueAt

      public void setValueAt(Object value, int rowIndex, int fieldIndex)
      Gets the value at the specified field index and the row index.
      Specified by:
      setValueAt in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      value - the new value.
      fieldIndex - the field index.
      rowIndex - the row index. It is the index after filtering.
    • getPossibleValues

      public Set<Object> getPossibleValues(int fieldIndex, boolean filterField, boolean isNullAllowed)
      Gets the possible values for the field.
      Specified by:
      getPossibleValues in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      fieldIndex - the field index.
      filterField - whether the field is a filter field. If true, possible values will all values as in the original data source. If false, the rows will be filtered first based on the setFilter(Object[],int,boolean) and then collect all the possible values.
      isNullAllowed - whether null value is allowed.
      Returns:
      the possible values.
    • clearFilters

      public void clearFilters()
      Tells the data source to clear all existing filters so that we can start to use setFilter(Object[],int,boolean) method to set the filters.
      Specified by:
      clearFilters in interface com.jidesoft.pivot.PivotDataSource
    • hasFilter

      public boolean hasFilter()
      Get if the data source has filter applying on it.
      Specified by:
      hasFilter in interface com.jidesoft.pivot.PivotDataSource
      Returns:
      true if there are filters. Otherwise false.
    • setFilter

      public void setFilter(Object[] values, int fieldIndex, boolean filterField)
      Sets the possible values for the field.
      Specified by:
      setFilter in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      values - the possible values.
      filterField - whether the field is a filter field.
      fieldIndex - the field index.
    • setExcludeFilter

      public void setExcludeFilter(Object[] values, int fieldIndex, boolean filterField)
      Sets the deselected possible values for the field.
      Specified by:
      setExcludeFilter in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      values - the deselected possible values.
      filterField - whether the field is a filter field.
      fieldIndex - the field index.
    • setFilter

      public void setFilter(com.jidesoft.filter.Filter filter, int fieldIndex, boolean filterField)
      Sets the Filter for the field.
      Specified by:
      setFilter in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      filter - the Filter.
      filterField - whether the field is a filter field.
      fieldIndex - the field index.
    • applyFilters

      public void applyFilters(int[] rowFieldIndices, int[] columnFieldIndices, int[] dataFieldIndices, int[] filterFieldIndices)
      Tells the data source to apply the filters after all filters have been set using setFilter(Object[],int,boolean) method. This method tells you the field indices of each area. In TableModelPivotDataSource implementation, we simply call applyFilters() as that implementation doesn't need to know the field indices.
      Specified by:
      applyFilters in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      rowFieldIndices - the field indices for row fields.
      columnFieldIndices - the field indices for column fields.
      dataFieldIndices - the field indices for data fields.
      filterFieldIndices - the field indices for filter fields.
    • applyFilters

      public void applyFilters()
      Tells the data source to apply the filters after all filters have been set using setFilter(Object[],int,boolean) method. If you need to know the field indices of each area, you can override other applyFilters method with four int[] parameters.
      Specified by:
      applyFilters in interface com.jidesoft.pivot.PivotDataSource
    • getFilteredRowIndex

      public int getFilteredRowIndex(int actualRowIndex)
      Gets the row index after filtering so that we can use getValueAt(int,int) or setValueAt(Object,int,int) methods.
      Specified by:
      getFilteredRowIndex in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      actualRowIndex - the actual row index.
      Returns:
      the filtered row index. -1 of the row is filtered.
    • getActualRowIndex

      public int getActualRowIndex(int visualRowIndex)
      Gets the actual row index in the original table model.
      Specified by:
      getActualRowIndex in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      visualRowIndex - the visual row index.
      Returns:
      the actual row index. -1 of the row is filtered.
    • addTableModelListener

      public void addTableModelListener(TableModelListener listener)
      Adds the table model listener. Although there is no table model concept in the data source, TableModelEvent can still be used to indicate data change in the data source. Please note, the row index is the index as in the original data without filtering. When you fire the table model event, you can leave the source of it to null.
      Specified by:
      addTableModelListener in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      listener - the table model listener to be added.
    • removeTableModelListener

      public void removeTableModelListener(TableModelListener listener)
      Removes the table model listener that was added earlier.
      Specified by:
      removeTableModelListener in interface com.jidesoft.pivot.PivotDataSource
      Parameters:
      listener - the table model listener to be removed.
    • tableChanged

      public void tableChanged(TableModelEvent e)
      Specified by:
      tableChanged in interface TableModelListener