JIDE 3.5.15

com.jidesoft.pivot
Class CalculatedPivotDataModel

java.lang.Object
  extended by com.jidesoft.pivot.PivotDataModel
      extended by com.jidesoft.pivot.CalculatedPivotDataModel
All Implemented Interfaces:
IPivotDataModel, PivotConstants, PivotValueProvider, PivotValueProviderListener, EventListener, TableModelListener

public class CalculatedPivotDataModel
extends PivotDataModel
implements IPivotDataModel, PivotValueProviderListener, TableModelListener


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jidesoft.pivot.PivotDataModel
PivotDataModel.RowMerger
 
Field Summary
 
Fields inherited from class com.jidesoft.pivot.PivotDataModel
_dataSource, listenerList, PROPERTY_HIDE_REDUNDANT_SUBTOTAL, PROPERTY_HIDE_SINGLE_DATA_FIELD, PROPERTY_SHOW_GRAND_TOTAL_FOR_COLUMN, PROPERTY_SHOW_GRAND_TOTAL_FOR_ROW, PROPERTY_SHOW_SUBTOTAL_AS_CHILD
 
Fields inherited from interface com.jidesoft.pivot.PivotConstants
AREA_COLUMN, AREA_DATA, AREA_FILTER, AREA_NAMES, AREA_NOT_ASSIGNED, AREA_ROW, COMPARE_TO_NEXT, COMPARE_TO_PREVIOUS, HEADER_SELECTION_DATA_TABLE_ONLY, HEADER_SELECTION_HEADER_TABLE_ONLY, RANGE_IN_TOTAL, RUNNING_SUMMARY_DIFFERENCE, RUNNING_SUMMARY_PERCENTAGE_FROM, RUNNING_SUMMARY_PERCENTAGE_OF, RUNNING_SUMMARY_PERCENTAGE_TOTAL, RUNNING_SUMMARY_TOTAL, STATISTICS_CALCULATION_DEFAULT, STATISTICS_CALCULATION_RUNNING, STATISTICS_CALCULATION_RUNNING_IN_COLUMN, STATISTICS_CALCULATION_RUNNING_LEAF, SUBTOTAL_AUTOMATIC, SUBTOTAL_CUSTOM, SUBTOTAL_NONE, SUMMARY_COUNT, SUMMARY_CUSTOM, SUMMARY_MAX, SUMMARY_MEAN, SUMMARY_MIN, SUMMARY_NAMES, SUMMARY_NONE, SUMMARY_RESERVED_MAX, SUMMARY_STDDEV, SUMMARY_SUM, SUMMARY_VAR
 
Constructor Summary
CalculatedPivotDataModel(IPivotDataModel pivotDataModel)
           
CalculatedPivotDataModel(PivotDataSource dataSource)
           
CalculatedPivotDataModel(PivotValueProvider pivotValueProvider, TableModel tableModel)
           
CalculatedPivotDataModel(TableModel tableModel)
           
 
Method Summary
 void calculate()
          Calculates the pivot data.
protected  Object calculateStatistics(RunningSummary runningSummary, Object[] objects)
           
protected  Values[] collectChildrenValues(Values parentValues, boolean isRowValues, int summaryType)
          Deprecated. 
protected  Values[] collectChildrenValues(Values parentValues, boolean isRowValues, int summaryType, int statisticsType)
          Collects the children value for calculation.
protected  Object[] collectValuesForCell(PivotField field, Values rowKeys, Values columnKeys, int summaryType)
           
protected  HeaderTableModel createColumnHeaderTableModel(CompoundKey[] keys)
          Creates the column header table model.
protected  IPivotDataModel createPivotDataModel(PivotDataSource dataSource)
           
protected  IPivotDataModel createPivotDataModel(TableModel tableModel)
           
protected  PivotField createPivotField(TableModel tableModel, int columnIndex)
           
protected  HeaderTableModel createRowHeaderTableModel(CompoundKey[] keys)
          Creates the row header table model.
 int[] getColumnFieldIndices()
          Gets the model indices for the column fields.
 PivotField[] getColumnFields()
          Gets the column fields.
 int getColumnHeaderColumnIndexAt(int rowIndex)
          Gets the column index in the column header table which has the data from the original table model at the specified rowIndex.
 CompoundKey[] getColumnKeys()
          Get column key array.
 List<Integer> getDataAt(CompoundKey rowKey, CompoundKey columnKey)
          Gets the row index list that matches with the rowKey and columnKey.
 int[] getDataFieldIndices()
          Gets the model indices for the data fields.
 PivotField[] getDataFields()
          Gets the data fields.
 PivotDataSource getDataSource()
          Gets the data source.
 PivotField getField(int index)
          Gets the PivotField by the index.
 PivotField getField(String name)
          Gets the PivotField by the name.
 PivotField[] getFields()
          Gets all the PivotFields.
 int[] getFilterFieldIndices()
          Gets the model indices for the filter fields.
 PivotField[] getFilterFields()
          Gets the filter fields.
 Object getPivotDataModel()
           
 PivotValueProvider getPivotValueProvider()
           
 Object[] getPossibleValues(PivotField field)
          Retrieve the possible values for the designated field.
 int[] getRowFieldIndices()
          Gets the model indices for the row fields.
 PivotField[] getRowFields()
          Gets the row fields.
 int getRowHeaderRowIndexAt(int rowIndex)
          Gets the row index in the row header table which has the data from the original table model at the specified rowIndex.
 CompoundKey[] getRowKeys()
          Get row key array.
 PivotDataModel.RowMerger getRowMerger()
          Gets the row merger.
 int getStatisticsType(Values rowValues, Values columnValues, PivotField dataField)
          Get the statistics layer.
 SummaryCalculator getSummaryCalculator()
          Gets the statistics calculator used to calculate all the statistics for the pivot data model.
 SummaryCalculatorFactory getSummaryCalculatorFactory()
          Gets the summary calculator factory which will create summary calculator to calculate all the statistics for the pivot data model.
 TableModel getTableModel()
          Gets the table model.
 int[] getUnassignedFieldIndices()
          Gets the model indices for the unassigned fields.
 PivotField[] getUnassignedFields()
          Gets the unassigned fields.
 Object getValueAt(PivotField field, Values rowKeys, Values columnKeys)
          Get the value to be compared.
protected  void handleFieldPropertyEvent(PropertyChangeEvent evt)
           
 void initialize()
          Initializes the PivotDataModel.
 boolean isAdjusting()
          Checks if the PivotDataModel is adjusting.
 boolean isAggregateMode()
          Checks if the pivot data model works in aggregate mode.
 boolean isAlwaysColumnDataFields()
          Checks if the data fields will always displayed on the column header area.
 boolean isAlwaysRowDataFields()
          Is the data field always displayed on the row header area.
 boolean isAutoUpdate()
          Checks if the pivot data will be automatically updated when the underlying table model data changes.
 boolean isCacheEnabled()
           
 boolean isCalculating()
          Returns if PivotValueProvider is calculating.
 boolean isColumnDataFields()
          Checks if the data field displayed on the column header area.
 boolean isRowDataFields()
          Is the data field displayed on the row header area.
 boolean isRunningCalculateSummary()
          Gets the flag indicating if the CalculatedPivotDataModel should calculate the summary values as running summary.
 boolean isSingleValueMode()
          The cells in the data table are actually summary of multiple rows in the original table model.
 boolean isSummaryLayer()
          Gets the flag indicating if it's a summary layer.
 boolean isSummaryMode()
          Checks if the pivot data model works in summary mode.
 void pivotValueProviderEventHandler(PivotValueProviderEvent event)
           
 void resetDataFields()
          Reset data fields based on the values in every PivotField.
 void setAdjusting(boolean adjusting)
          Sets the PivotDataModel to adjusting mode.
 void setAlwaysColumnDataFields(boolean alwaysColumnDataFields)
          Sets the flag whether the data fields will always be displayed on the column header area.
 void setAlwaysRowDataFields(boolean alwaysRowDataFields)
          Sets the flag whether the data fields will always be displayed on the row header area.
 void setAutoUpdate(boolean autoUpdate)
          Sets the flag if the pivot data will be automatically updated when the underlying table model data changes.
 void setCacheEnabled(boolean cacheEnabled)
           
 void setComputeAffectedCellOnUpdate(boolean computeAffectedCellOnUpdate)
          Set the flag indicating that if the PivotValueProviderEvent will contain the affected cells information on original data model change scenario.
 void setDataSource(PivotDataSource dataSource)
          Sets the data source.
 void setHideSingleDataField(boolean hideSingleDataField)
           
 void setOriginalTableModel(TableModel tableModel)
          Sets the original table model.
 void setPivotDataModel(IPivotDataModel pivotDataModel)
           
 void setPivotValueProvider(PivotValueProvider pivotValueProvider)
           
 void setRowMerger(PivotDataModel.RowMerger rowMerger)
          Sets the row merger.
 void setRunningCalculateSummary(boolean runningCalculateSummary)
          Sets the flag indicating if the CalculatedPivotDataModel should calculate the summary values as running summary.
 void setSingleValueMode(boolean singleValueMode)
          Sets the single value mode.
 void setSummaryCalculator(SummaryCalculator summaryCalculator)
          Sets the statistics calculator.
 void setSummaryCalculatorFactory(SummaryCalculatorFactory summaryCalculatorFactory)
          Sets the statistics calculator factory.
 void setSummaryLayer(boolean summaryLayer)
          Sets the flag indicating if it's a summary layer.
 void setSummaryMode(boolean summaryMode)
          Sets the flag for the summary mode.
 void tableChanged(TableModelEvent e)
          Handle the table model change event of the original table model.
 void updateFields()
           
 boolean verify()
          This method is for debugging purpose, not a public API.
 
Methods inherited from class com.jidesoft.pivot.PivotDataModel
addHiddenColumn, addHiddenColumn, addHiddenValues, addPivotValueProviderListener, addPrefixRowIndex, addPropertyChangeListener, addRowIndex, calculateStatistics, calculateStatistics, clearHiddenColumns, clearHiddenValues, collectValuesForCell, createDataTableModel, createDefaultPivotDataSource, createPivotDataCube, createPivotField, firePivotValueProviderChanged, firePivotValueProviderChanged, firePropertyChange, forceCalculate, getCellStyleProvider, getColumnAt, getColumnHeaderEditingProvider, getColumnHeaderTableModel, getCompoundKeyAt, getCornerTableModel, getDataAt, getDataEditingProvider, getDataTableModel, getFieldIndices, getHiddenColumns, getHiddenValues, getPivotValueProviderListeners, getPossibleValues, getPossibleValues, getRowAt, getRowHeaderEditingProvider, getRowHeaderTableModel, hasHiddenColumns, hasHiddenValues, invalidateColumnHeaderTableModel, invalidateCornerTableModel, invalidateDataTableModel, invalidateRowHeaderTableModel, isAllowEmptyColumnHeader, isAllowEmptyRowHeader, isAutoSortKeys, isCalculated, isColumnVisible, isComputeAffectedCellOnUpdate, isDisplayGrandTotalFirst, isDisplayGrandTotalFirstForColumn, isDisplayGrandTotalFirstForRow, isExpandByDefault, isHideExpandIconOnSingleRow, isHideRedundantSubtotal, isHideSingleDataField, isHideSummaryValues, isHighPerformanceMode, isKeepRowChildrenOnSummaryFilter, isLayoutDataFieldsFirst, isShowGrandTotalForColumn, isShowGrandTotalForRow, isShowSubtotalAsChild, isUseComparable, isValueImmutable, isValuesVisible, manageCompoundKeys, removeColumnKey, removeHiddenColumn, removeHiddenValues, removePivotValueProviderListener, removePropertyChangeListener, removeRowKey, setAllowEmptyColumnHeader, setAllowEmptyRowHeader, setAutoSortKeys, setCellStyleProvider, setColumnHeaderEditingProvider, setDataEditingProvider, setDisplayGrandTotalFirst, setDisplayGrandTotalFirstForColumn, setDisplayGrandTotalFirstForRow, setExpandByDefault, setHideExpandIconOnSingleRow, setHideRedundantSubtotal, setHideSummaryValues, setHighPerformanceMode, setKeepRowChildrenOnSummaryFilter, setLayoutDataFieldsFirst, setPivotFields, setRowHeaderEditingProvider, setShowGrandTotalForColumn, setShowGrandTotalForRow, setShowSubtotalAsChild, setUseComparable, setValueImmutable, shouldCalculateSummary, sortCompoundKeys, tableCellsUpdated, tableRowsDeleted, tableRowsInserted, tableRowsUpdated, updateFilters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jidesoft.pivot.IPivotDataModel
addHiddenColumn, addHiddenColumn, addHiddenValues, clearHiddenColumns, clearHiddenValues, getCellStyleProvider, getColumnHeaderEditingProvider, getColumnHeaderTableModel, getCornerTableModel, getDataAt, getDataEditingProvider, getDataTableModel, getHiddenColumns, getHiddenValues, getPossibleValues, getPossibleValues, getRowHeaderEditingProvider, getRowHeaderTableModel, hasHiddenColumns, hasHiddenValues, invalidateColumnHeaderTableModel, invalidateCornerTableModel, invalidateDataTableModel, invalidateRowHeaderTableModel, isAllowEmptyColumnHeader, isAllowEmptyRowHeader, isCalculated, isColumnVisible, isDisplayGrandTotalFirst, isDisplayGrandTotalFirstForColumn, isDisplayGrandTotalFirstForRow, isExpandByDefault, isHideRedundantSubtotal, isHideSingleDataField, isHideSummaryValues, isHighPerformanceMode, isKeepRowChildrenOnSummaryFilter, isLayoutDataFieldsFirst, isShowGrandTotalForColumn, isShowGrandTotalForRow, isShowSubtotalAsChild, isValuesVisible, removeHiddenColumn, removeHiddenValues, setAllowEmptyColumnHeader, setAllowEmptyRowHeader, setCellStyleProvider, setColumnHeaderEditingProvider, setDataEditingProvider, setDisplayGrandTotalFirst, setDisplayGrandTotalFirstForColumn, setDisplayGrandTotalFirstForRow, setExpandByDefault, setHideRedundantSubtotal, setHideSummaryValues, setHighPerformanceMode, setKeepRowChildrenOnSummaryFilter, setLayoutDataFieldsFirst, setRowHeaderEditingProvider, setShowGrandTotalForColumn, setShowGrandTotalForRow, setShowSubtotalAsChild
 

Constructor Detail

CalculatedPivotDataModel

public CalculatedPivotDataModel(TableModel tableModel)

CalculatedPivotDataModel

public CalculatedPivotDataModel(PivotDataSource dataSource)

CalculatedPivotDataModel

public CalculatedPivotDataModel(IPivotDataModel pivotDataModel)

CalculatedPivotDataModel

public CalculatedPivotDataModel(PivotValueProvider pivotValueProvider,
                                TableModel tableModel)
Method Detail

setPivotValueProvider

public void setPivotValueProvider(PivotValueProvider pivotValueProvider)

getPivotValueProvider

public PivotValueProvider getPivotValueProvider()

createPivotDataModel

protected IPivotDataModel createPivotDataModel(TableModel tableModel)

createPivotDataModel

protected IPivotDataModel createPivotDataModel(PivotDataSource dataSource)

getPivotDataModel

public Object getPivotDataModel()

setPivotDataModel

public void setPivotDataModel(IPivotDataModel pivotDataModel)

setOriginalTableModel

public void setOriginalTableModel(TableModel tableModel)
Description copied from class: PivotDataModel
Sets the original table model.

Overrides:
setOriginalTableModel in class PivotDataModel
Parameters:
tableModel - the new original table model.

initialize

public void initialize()
Description copied from class: PivotDataModel
Initializes the PivotDataModel. Whenever your original table model structured changed (column added, removed or changed), you need to call this method then PivotDataModel.calculate(). If only the data is changed, just PivotDataModel.calculate() is enough.

Specified by:
initialize in interface IPivotDataModel
Overrides:
initialize in class PivotDataModel

createPivotField

protected PivotField createPivotField(TableModel tableModel,
                                      int columnIndex)

tableChanged

public void tableChanged(TableModelEvent e)
Handle the table model change event of the original table model.

It will only be invoked in PivotValueProvider only scenario. In that scenario, CalculatedPivotDataModel only needs to handle the table structure change event to recreate fields. Assume PivotValueProvider will get events from table model itself.

It will only handle the table structure change event to initialize PivotField and trigger calculation. The reason is that, PivotValueProvider is supposed to handle the dynamic data change.

Specified by:
tableChanged in interface TableModelListener
Parameters:
e - the table model event

handleFieldPropertyEvent

protected void handleFieldPropertyEvent(PropertyChangeEvent evt)
Overrides:
handleFieldPropertyEvent in class PivotDataModel

getTableModel

public TableModel getTableModel()
Description copied from class: PivotDataModel
Gets the table model. This is the table model after filtering.

Please note, we introduced PivotDataSource concept in 2.2.2 release. With the help of PivotDataSource, PivotDataModel doesn't have to use TableModel as the data source. Although this method will still return the table model in the default case when the data source is the default TableModelPivotDataSource, it is not guaranteed. If you set your own PivotDataSource which doesn't depend on any table model, this getTableModel will return null.

Overrides:
getTableModel in class PivotDataModel
Returns:
the table model .

setDataSource

public void setDataSource(PivotDataSource dataSource)
Description copied from class: PivotDataModel
Sets the data source.

Specified by:
setDataSource in interface IPivotDataModel
Overrides:
setDataSource in class PivotDataModel
Parameters:
dataSource - the new data source.

getDataSource

public PivotDataSource getDataSource()
Description copied from class: PivotDataModel
Gets the data source.

Specified by:
getDataSource in interface IPivotDataModel
Overrides:
getDataSource in class PivotDataModel
Returns:
the data source.

getStatisticsType

public int getStatisticsType(Values rowValues,
                             Values columnValues,
                             PivotField dataField)
Description copied from interface: PivotValueProvider
Get the statistics layer. By default, it should return PivotConstants.STATISTICS_CALCULATION_DEFAULT. So that the PivotValueProvider itself will conduct the statistics. However, for running percentage or daily average, you probably need return other values so that CalculatedPivotDataModel would calculate the summary itself.

Specified by:
getStatisticsType in interface PivotValueProvider
Overrides:
getStatisticsType in class PivotDataModel
Parameters:
rowValues - the row values
columnValues - the column values
dataField - the data field
Returns:
the statistics layer.

getField

public PivotField getField(String name)
Description copied from class: PivotDataModel
Gets the PivotField by the name.

Specified by:
getField in interface IPivotDataModel
Overrides:
getField in class PivotDataModel
Parameters:
name - the field name
Returns:
the PivotField by the name.

getField

public PivotField getField(int index)
Description copied from class: PivotDataModel
Gets the PivotField by the index.

Specified by:
getField in interface IPivotDataModel
Overrides:
getField in class PivotDataModel
Parameters:
index - the field index
Returns:
the PivotField by the index.

getFields

public PivotField[] getFields()
Description copied from class: PivotDataModel
Gets all the PivotFields.

Specified by:
getFields in interface IPivotDataModel
Overrides:
getFields in class PivotDataModel
Returns:
all the PivotFields.

updateFields

public void updateFields()
Specified by:
updateFields in interface IPivotDataModel
Overrides:
updateFields in class PivotDataModel

isCalculating

public boolean isCalculating()
Description copied from interface: PivotValueProvider
Returns if PivotValueProvider is calculating.

Specified by:
isCalculating in interface PivotValueProvider
Overrides:
isCalculating in class PivotDataModel
Returns:
true if it is calculating. Otherwise false.

getPossibleValues

public Object[] getPossibleValues(PivotField field)
Description copied from interface: PivotValueProvider
Retrieve the possible values for the designated field.

In general, you need consider the current filtering to return possible values appropriately.

Specified by:
getPossibleValues in interface IPivotDataModel
Specified by:
getPossibleValues in interface PivotValueProvider
Overrides:
getPossibleValues in class PivotDataModel
Parameters:
field - the pivot field
Returns:
possible values array.

getRowFields

public PivotField[] getRowFields()
Description copied from class: PivotDataModel
Gets the row fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getRowFields in interface IPivotDataModel
Overrides:
getRowFields in class PivotDataModel
Returns:
the row fields.

getRowFieldIndices

public int[] getRowFieldIndices()
Description copied from class: PivotDataModel
Gets the model indices for the row fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getRowFieldIndices in interface IPivotDataModel
Overrides:
getRowFieldIndices in class PivotDataModel
Returns:
the row fields.

getColumnFields

public PivotField[] getColumnFields()
Description copied from class: PivotDataModel
Gets the column fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getColumnFields in interface IPivotDataModel
Overrides:
getColumnFields in class PivotDataModel
Returns:
the column fields.

getColumnFieldIndices

public int[] getColumnFieldIndices()
Description copied from class: PivotDataModel
Gets the model indices for the column fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getColumnFieldIndices in interface IPivotDataModel
Overrides:
getColumnFieldIndices in class PivotDataModel
Returns:
the column fields.

getDataFields

public PivotField[] getDataFields()
Description copied from class: PivotDataModel
Gets the data fields. it must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getDataFields in interface IPivotDataModel
Overrides:
getDataFields in class PivotDataModel
Returns:
the data fields.

resetDataFields

public void resetDataFields()
Description copied from interface: IPivotDataModel
Reset data fields based on the values in every PivotField. This method should only be invoked for protection purpose.

Specified by:
resetDataFields in interface IPivotDataModel
Overrides:
resetDataFields in class PivotDataModel

getDataFieldIndices

public int[] getDataFieldIndices()
Description copied from class: PivotDataModel
Gets the model indices for the data fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getDataFieldIndices in interface IPivotDataModel
Overrides:
getDataFieldIndices in class PivotDataModel
Returns:
the data fields.

getFilterFields

public PivotField[] getFilterFields()
Description copied from class: PivotDataModel
Gets the filter fields. it must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getFilterFields in interface IPivotDataModel
Overrides:
getFilterFields in class PivotDataModel
Returns:
the filter fields.

getFilterFieldIndices

public int[] getFilterFieldIndices()
Description copied from class: PivotDataModel
Gets the model indices for the filter fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getFilterFieldIndices in interface IPivotDataModel
Overrides:
getFilterFieldIndices in class PivotDataModel
Returns:
the filter fields.

getUnassignedFields

public PivotField[] getUnassignedFields()
Description copied from class: PivotDataModel
Gets the unassigned fields. it must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getUnassignedFields in interface IPivotDataModel
Overrides:
getUnassignedFields in class PivotDataModel
Returns:
the unassigned fields.

getUnassignedFieldIndices

public int[] getUnassignedFieldIndices()
Description copied from class: PivotDataModel
Gets the model indices for the unassigned fields. It must be called after PivotDataModel.calculate() is called. Otherwise, it will return null.

Specified by:
getUnassignedFieldIndices in interface IPivotDataModel
Overrides:
getUnassignedFieldIndices in class PivotDataModel
Returns:
the unassigned fields.

isAggregateMode

public boolean isAggregateMode()
Description copied from class: PivotDataModel
Checks if the pivot data model works in aggregate mode. Aggregate mode is only used by AggregateTableModel to show the actual cell values for the matched keys. By default, the actual values will not be displayed. Typically you should setSummaryMode(false).

Default is false.

Specified by:
isAggregateMode in interface IPivotDataModel
Overrides:
isAggregateMode in class PivotDataModel
Returns:
true or false.

createRowHeaderTableModel

protected HeaderTableModel createRowHeaderTableModel(CompoundKey[] keys)
Description copied from class: PivotDataModel
Creates the row header table model.

Overrides:
createRowHeaderTableModel in class PivotDataModel
Parameters:
keys - the row keys.
Returns:
the HeaderTableModel used for the row header table.

createColumnHeaderTableModel

protected HeaderTableModel createColumnHeaderTableModel(CompoundKey[] keys)
Description copied from class: PivotDataModel
Creates the column header table model.

Overrides:
createColumnHeaderTableModel in class PivotDataModel
Parameters:
keys - the column keys.
Returns:
the HeaderTableModel used for the column header table.

getRowKeys

public CompoundKey[] getRowKeys()
Description copied from interface: PivotValueProvider
Get row key array.

Specified by:
getRowKeys in interface PivotValueProvider
Overrides:
getRowKeys in class PivotDataModel
Returns:
the row key array.

getColumnKeys

public CompoundKey[] getColumnKeys()
Description copied from interface: PivotValueProvider
Get column key array.

Specified by:
getColumnKeys in interface PivotValueProvider
Overrides:
getColumnKeys in class PivotDataModel
Returns:
the column key array.

setRowMerger

public void setRowMerger(PivotDataModel.RowMerger rowMerger)
Description copied from class: PivotDataModel
Sets the row merger.

Overrides:
setRowMerger in class PivotDataModel
Parameters:
rowMerger - a new RowMerger
See Also:
PivotDataModel.RowMerger

getRowMerger

public PivotDataModel.RowMerger getRowMerger()
Description copied from class: PivotDataModel
Gets the row merger.

Overrides:
getRowMerger in class PivotDataModel
Returns:
the row merger.
See Also:
PivotDataModel.RowMerger

setHideSingleDataField

public void setHideSingleDataField(boolean hideSingleDataField)
Specified by:
setHideSingleDataField in interface IPivotDataModel
Overrides:
setHideSingleDataField in class PivotDataModel

setAlwaysRowDataFields

public void setAlwaysRowDataFields(boolean alwaysRowDataFields)
Description copied from class: PivotDataModel
Sets the flag whether the data fields will always be displayed on the row header area. By default, we might use row header area to display the data fields if there is no field in the row area.

Specified by:
setAlwaysRowDataFields in interface IPivotDataModel
Overrides:
setAlwaysRowDataFields in class PivotDataModel
Parameters:
alwaysRowDataFields - true or false.

isAlwaysRowDataFields

public boolean isAlwaysRowDataFields()
Description copied from class: PivotDataModel
Is the data field always displayed on the row header area. If this method returns true, isRowDataFields will always return true as long as isColumnDataFields returns false.

Specified by:
isAlwaysRowDataFields in interface IPivotDataModel
Overrides:
isAlwaysRowDataFields in class PivotDataModel
Returns:
true or false.

setAlwaysColumnDataFields

public void setAlwaysColumnDataFields(boolean alwaysColumnDataFields)
Description copied from class: PivotDataModel
Sets the flag whether the data fields will always be displayed on the column header area. By default, we might use row header area to display the data fields if there is no field in the row area.

Specified by:
setAlwaysColumnDataFields in interface IPivotDataModel
Overrides:
setAlwaysColumnDataFields in class PivotDataModel
Parameters:
alwaysColumnDataFields - true or false.

isAlwaysColumnDataFields

public boolean isAlwaysColumnDataFields()
Description copied from class: PivotDataModel
Checks if the data fields will always displayed on the column header area. If this method returns true, isColumnDataFields will always return true.

Specified by:
isAlwaysColumnDataFields in interface IPivotDataModel
Overrides:
isAlwaysColumnDataFields in class PivotDataModel
Returns:
true or false.

setSummaryCalculator

public void setSummaryCalculator(SummaryCalculator summaryCalculator)
Description copied from class: PivotDataModel
Sets the statistics calculator.

Specified by:
setSummaryCalculator in interface IPivotDataModel
Overrides:
setSummaryCalculator in class PivotDataModel
Parameters:
summaryCalculator - the summary calculator.

getSummaryCalculator

public SummaryCalculator getSummaryCalculator()
Description copied from class: PivotDataModel
Gets the statistics calculator used to calculate all the statistics for the pivot data model.

Specified by:
getSummaryCalculator in interface IPivotDataModel
Overrides:
getSummaryCalculator in class PivotDataModel
Returns:
the statistics calculator.

setSummaryCalculatorFactory

public void setSummaryCalculatorFactory(SummaryCalculatorFactory summaryCalculatorFactory)
Description copied from class: PivotDataModel
Sets the statistics calculator factory. We will use this factory to create SummaryCalculator if the calculation is running in a multiple thread environment. Otherwise we will use PivotDataModel.getSummaryCalculator() method to get the SummaryCalculator.

Specified by:
setSummaryCalculatorFactory in interface IPivotDataModel
Overrides:
setSummaryCalculatorFactory in class PivotDataModel
Parameters:
summaryCalculatorFactory - the summary calculator factory.

getSummaryCalculatorFactory

public SummaryCalculatorFactory getSummaryCalculatorFactory()
Description copied from class: PivotDataModel
Gets the summary calculator factory which will create summary calculator to calculate all the statistics for the pivot data model. Please note, this SummaryCalculatorFactory is only used when the PivotDataModel.calculateStatistics(PivotField, int, int, int, Object[]) method is called from a non-EDT. On EDT, we will use PivotDataModel.getSummaryCalculator() method to get the SummaryCalculator.

Specified by:
getSummaryCalculatorFactory in interface IPivotDataModel
Overrides:
getSummaryCalculatorFactory in class PivotDataModel
Returns:
the summary calculator factory.

setSummaryLayer

public void setSummaryLayer(boolean summaryLayer)
Description copied from interface: IPivotDataModel
Sets the flag indicating if it's a summary layer.

Specified by:
setSummaryLayer in interface IPivotDataModel
Overrides:
setSummaryLayer in class PivotDataModel
Parameters:
summaryLayer - the flag

isSummaryLayer

public boolean isSummaryLayer()
Description copied from interface: IPivotDataModel
Gets the flag indicating if it's a summary layer.

Specified by:
isSummaryLayer in interface IPivotDataModel
Overrides:
isSummaryLayer in class PivotDataModel
Returns:
true if it's a summary layer. Otherwise false.

calculate

public void calculate()
Description copied from class: PivotDataModel
Calculates the pivot data. Whenever you are done updating PivotField settings or the data in the original table model is changed, you should call this method to use the new settings or new data. If you call this method after the PivotDataModel has been set on PivotTablePane, you also need to call PivotTablePane.fieldsUpdated() method in order for the change to take effect.

Specified by:
calculate in interface IPivotDataModel
Overrides:
calculate in class PivotDataModel

isAutoUpdate

public boolean isAutoUpdate()
Description copied from class: PivotDataModel
Checks if the pivot data will be automatically updated when the underlying table model data changes.

Specified by:
isAutoUpdate in interface IPivotDataModel
Overrides:
isAutoUpdate in class PivotDataModel
Returns:
true or false.

setAutoUpdate

public void setAutoUpdate(boolean autoUpdate)
Description copied from class: PivotDataModel
Sets the flag if the pivot data will be automatically updated when the underlying table model data changes. By default, it is false because in most cases people use pivot data to analyze static data. If the data changes, you have to call PivotDataModel.calculate() method when the underlying table model data changes. However because the data inside pivot table is very complex, right now autoUpdate will only update correctly if the table model data change is cellUpdated event and rowUpdated event. If you add/remove rows or columns, you still have to call PivotDataModel.calculate() just like before.

Specified by:
setAutoUpdate in interface IPivotDataModel
Overrides:
setAutoUpdate in class PivotDataModel
Parameters:
autoUpdate - true or false.

isRowDataFields

public boolean isRowDataFields()
Description copied from class: PivotDataModel
Is the data field displayed on the row header area. It possibly returns true only if isColumnDataFields return false. Otherwise data fields will display on the column header area.

Specified by:
isRowDataFields in interface IPivotDataModel
Overrides:
isRowDataFields in class PivotDataModel
Returns:
true or false.

isColumnDataFields

public boolean isColumnDataFields()
Description copied from class: PivotDataModel
Checks if the data field displayed on the column header area.

Specified by:
isColumnDataFields in interface IPivotDataModel
Overrides:
isColumnDataFields in class PivotDataModel
Returns:
true or false.

isSingleValueMode

public boolean isSingleValueMode()
Description copied from class: PivotDataModel
The cells in the data table are actually summary of multiple rows in the original table model. For example, if the summary is SUM, we will display the sum of all the values of all the rows and display it in the cell of the data table. However In the single value mode, whenever there are two rows that maps to the same cell, we will delete the second row.

Specified by:
isSingleValueMode in interface IPivotDataModel
Specified by:
isSingleValueMode in interface PivotValueProvider
Overrides:
isSingleValueMode in class PivotDataModel
Returns:
true or false.

setSingleValueMode

public void setSingleValueMode(boolean singleValueMode)
Description copied from class: PivotDataModel
Sets the single value mode.

Specified by:
setSingleValueMode in interface IPivotDataModel
Specified by:
setSingleValueMode in interface PivotValueProvider
Overrides:
setSingleValueMode in class PivotDataModel
Parameters:
singleValueMode - true or false.

verify

public boolean verify()
Description copied from class: PivotDataModel
This method is for debugging purpose, not a public API. It will print out if there is any cell span errors in the row header and the column header table.

Specified by:
verify in interface IPivotDataModel
Overrides:
verify in class PivotDataModel

isCacheEnabled

public boolean isCacheEnabled()

setCacheEnabled

public void setCacheEnabled(boolean cacheEnabled)

pivotValueProviderEventHandler

public void pivotValueProviderEventHandler(PivotValueProviderEvent event)
Specified by:
pivotValueProviderEventHandler in interface PivotValueProviderListener

getDataAt

public List<Integer> getDataAt(CompoundKey rowKey,
                               CompoundKey columnKey)
Description copied from class: PivotDataModel
Gets the row index list that matches with the rowKey and columnKey.

Specified by:
getDataAt in interface IPivotDataModel
Overrides:
getDataAt in class PivotDataModel
Parameters:
rowKey - the row compound key
columnKey - the column compound key
Returns:
a list of integer which are row indexes to the data source that you can get using PivotDataModel.getDataSource().

isAdjusting

public boolean isAdjusting()
Description copied from class: PivotDataModel
Checks if the PivotDataModel is adjusting. If it is adjusting, other code should not call calculate() or update UI automatically when a property is changed. Right now, we used in PivotField.setSelectedPossibleValues(Object[]). By default, isAdjusting is false, so setSelectedPossibleValues will call calculate() and bothHeaderUpdated(). If isAdjusting is true, they will be not be called.

Specified by:
isAdjusting in interface IPivotDataModel
Overrides:
isAdjusting in class PivotDataModel
Returns:
true if adjusting. Otherwise false.

setAdjusting

public void setAdjusting(boolean adjusting)
Description copied from class: PivotDataModel
Sets the PivotDataModel to adjusting mode. If it is adjusting, PivotDataModel will not call calculate() and update the UI when something is changed. After you set adjusting to false, PivotDataModel will then calculate(). But you will be still be responsible to call the XxxUpdated() method on PivotTablePane to update the UI.

Specified by:
setAdjusting in interface IPivotDataModel
Overrides:
setAdjusting in class PivotDataModel
Parameters:
adjusting - true or false.

isSummaryMode

public boolean isSummaryMode()
Description copied from class: PivotDataModel
Checks if the pivot data model works in summary mode. Summary mode means instead of display the summary (such as sum, max, min, stddev etc statistics) of the values in the data table, it displays the first value that matches the key.

Default is true.

Specified by:
isSummaryMode in interface IPivotDataModel
Specified by:
isSummaryMode in interface PivotValueProvider
Overrides:
isSummaryMode in class PivotDataModel
Returns:
true or false.

setSummaryMode

public void setSummaryMode(boolean summaryMode)
Description copied from class: PivotDataModel
Sets the flag for the summary mode. Summary mode means instead of display the summary (such as sum, max, min, stddev etc statistics) of the values in the data table, it displays the first value that matches the key.

Specified by:
setSummaryMode in interface IPivotDataModel
Specified by:
setSummaryMode in interface PivotValueProvider
Overrides:
setSummaryMode in class PivotDataModel
Parameters:
summaryMode - true to set to summary mode. Otherwise false.
See Also:
PivotDataModel.isSummaryMode()

getRowHeaderRowIndexAt

public int getRowHeaderRowIndexAt(int rowIndex)
Description copied from class: PivotDataModel
Gets the row index in the row header table which has the data from the original table model at the specified rowIndex.

Specified by:
getRowHeaderRowIndexAt in interface IPivotDataModel
Overrides:
getRowHeaderRowIndexAt in class PivotDataModel
Parameters:
rowIndex - the row at the original table model.
Returns:
the row index as in the row header table.

getColumnHeaderColumnIndexAt

public int getColumnHeaderColumnIndexAt(int rowIndex)
Description copied from class: PivotDataModel
Gets the column index in the column header table which has the data from the original table model at the specified rowIndex.

Specified by:
getColumnHeaderColumnIndexAt in interface IPivotDataModel
Overrides:
getColumnHeaderColumnIndexAt in class PivotDataModel
Parameters:
rowIndex - the row at the original table model.
Returns:
the column index as in the column header table.

collectChildrenValues

@Deprecated
protected Values[] collectChildrenValues(Values parentValues,
                                                    boolean isRowValues,
                                                    int summaryType)
Deprecated. 


collectChildrenValues

protected Values[] collectChildrenValues(Values parentValues,
                                         boolean isRowValues,
                                         int summaryType,
                                         int statisticsType)
Collects the children value for calculation.

Parameters:
parentValues - the parent Values instance
isRowValues - if this is a row Values or column Values
summaryType - the summary type
statisticsType - the statistics type
Returns:
the children Values array.
Since:
3.4.4

collectValuesForCell

protected Object[] collectValuesForCell(PivotField field,
                                        Values rowKeys,
                                        Values columnKeys,
                                        int summaryType)
Overrides:
collectValuesForCell in class PivotDataModel

getValueAt

public Object getValueAt(PivotField field,
                         Values rowKeys,
                         Values columnKeys)
Description copied from interface: IPivotDataModel
Get the value to be compared.

Specified by:
getValueAt in interface IPivotDataModel
Specified by:
getValueAt in interface PivotValueProvider
Overrides:
getValueAt in class PivotDataModel
Parameters:
field - the data field
rowKeys - row value keys in the corresponding row header table
columnKeys - column value keys in the corresponding column header table
Returns:
the value from the cell.

calculateStatistics

protected Object calculateStatistics(RunningSummary runningSummary,
                                     Object[] objects)

setComputeAffectedCellOnUpdate

public void setComputeAffectedCellOnUpdate(boolean computeAffectedCellOnUpdate)
Set the flag indicating that if the PivotValueProviderEvent will contain the affected cells information on original data model change scenario.

By default, the flag is false. You could set it to true however it may hit the performance since we have to cache the values before and after value changed to get the affected cells.

This flag could only take effect when both isAutoUpdate() and isCacheEnabled() return true.

Overrides:
setComputeAffectedCellOnUpdate in class PivotDataModel
Parameters:
computeAffectedCellOnUpdate - the flag

isRunningCalculateSummary

public boolean isRunningCalculateSummary()
Gets the flag indicating if the CalculatedPivotDataModel should calculate the summary values as running summary.

Returns:
true if running summary should be used. Otherwise false.
See Also:
setRunningCalculateSummary(boolean)

setRunningCalculateSummary

public void setRunningCalculateSummary(boolean runningCalculateSummary)
Sets the flag indicating if the CalculatedPivotDataModel should calculate the summary values as running summary.

By default, the flag is true. You could change it to false to make the summary and grand total calculation behavior the same as that in PivotDataModel.

Parameters:
runningCalculateSummary - the flag

JIDE 3.5.15