public class TabularPivotModel extends AbstractPivotModel implements PivotModelExt, PivotModelExt.SortCtrl
Modifier and Type | Class and Description |
---|---|
protected static class |
TabularPivotModel.CalculatorContextSpace |
protected static interface |
TabularPivotModel.RawDataRunner |
PivotModelExt.SortCtrl
Modifier and Type | Field and Description |
---|---|
protected TabularPivotModel.CalculatorContextSpace |
_space |
protected static int |
_STD_CAL_TYPE_SIZE |
protected static Comparator<PivotHeaderNode> |
NODE_COMPARATOR |
Constructor and Description |
---|
TabularPivotModel(Iterable<? extends List<?>> data,
List<String> columns)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addSupportedCalculator(ContextualCalculator<?> cal)
Register a custom
Calculator supported in this model. |
protected ContextualCalculator<?> |
cast(Calculator calc) |
protected TabularPivotField |
cast(PivotField field) |
protected SimplePivotHeaderNode |
cast(PivotHeaderNode node) |
void |
clearAllFields(boolean complete)
Remove all pivot fields from column, row, and data.
|
void |
clearSupportedCalculators()
Clear all registered custom
Calculator supported in this model. |
protected ContextualCalculator<?> |
getCalculator(SimplePivotHeaderNode rowNode,
int rowCalIndex,
SimplePivotHeaderNode colNode,
int colCalIndex,
int dataIndex) |
protected CalculatorContextSignature |
getCalculatorContextSignature()
Override this method to intervene the required signature for preparing
source space.
|
TabularPivotField[] |
getColumnFields() |
PivotHeaderTree |
getColumnHeaderTree()
Return the header tree of columns.
|
TabularPivotField[] |
getDataFields() |
TabularPivotField |
getField(String fieldName)
Returns the pivot field from the specified field name, if any.
|
TabularPivotField[] |
getFields()
Return a list of all fields in the model.
|
TabularPivotField[] |
getFields(PivotField.Type type)
Return a list of pivot fields of the given type.
|
Iterable<? extends List<?>> |
getRawData()
Return the raw data collection.
|
TabularPivotField[] |
getRowFields() |
PivotHeaderTree |
getRowHeaderTree()
Return the header tree of rows.
|
int |
getSourceDataIndex(PivotField field)
Return the index of raw data columns the field corresponds to.
|
Calculator[] |
getSupportedCalculators()
Return a list of supported Calculators as options of Summary and Subtotals.
|
Number |
getValue(PivotHeaderNode rowNode,
int rowCalIndex,
PivotHeaderNode colNode,
int colCalIndex,
int dataIndex)
Get the calculated data summary at specific cell position.
|
protected void |
iterateRawData(SimplePivotHeaderTree colTree,
SimplePivotHeaderTree rowTree,
TabularPivotModel.RawDataRunner runner)
Override this method to provide a different implementation of raw data
iteration.
|
void |
removeField(PivotField field)
Remove the field from column, row, or data.
|
void |
removeField(String fieldName)
Remove first field with given name from column, row, or data.
|
void |
removeSupportedCalculator(ContextualCalculator<?> cal)
Unregister a custom
Calculator supported in this model. |
void |
setFieldKeyComparator(PivotField field,
Comparator<Object> comparator)
Set a comparator on a pivot field for node ordering
|
void |
setFieldKeyComparator(String fieldName,
Comparator<Object> comparator)
Set a comparator on a pivot field for node ordering.
|
void |
setFieldKeyOrder(PivotField field,
boolean ascending)
Set the node ordering of the field.
|
void |
setFieldKeyOrder(String fieldName,
boolean ascending)
Set the ordering of keys on a field.
|
void |
setFieldSubtotals(PivotField field,
Calculator[] subtotals)
Set the subtotals on a field.
|
void |
setFieldSubtotals(String fieldName,
Calculator[] subtotals)
Sets the subtotal calculators on a field, or null to show no subtotal.
|
void |
setFieldSummary(PivotField field,
Calculator summary)
Set the summary on a field.
|
void |
setFieldSummary(String fieldName,
Calculator summary)
Sets the summary calculator on a field, or null to use the default one.
|
void |
setFieldType(PivotField field,
PivotField.Type type)
Change the type of a pivot field.
|
void |
setFieldType(PivotField field,
PivotField.Type type,
int index)
Change the type of a pivot field and insert it at the given level (in
case of COLUMN or ROW) or display position (in case of DATA).
|
void |
setFieldType(String fieldName,
PivotField.Type type)
Change the type of a pivot field.
|
protected boolean |
shallReloadSourceSpace(CalculatorContextSignature current,
CalculatorContextSignature required)
Override this method to determine whether to reload source space more
aggressively than default setting.
|
protected void |
sortColumnTree(SimplePivotHeaderTree colTree)
Override this method to change the default node sorting in the column tree.
|
protected void |
sortRowTree(SimplePivotHeaderTree rowTree)
Override this method to change the default node sorting in the row tree.
|
protected void |
sortTrees()
Deprecated.
As of release 2.3.0, replaced by
sortRowTree(SimplePivotHeaderTree) and sortColumnTree(SimplePivotHeaderTree) |
protected void |
updateContextSpace() |
void |
updateRawData()
Force to update the cached result in the model by rescanning the raw data.
|
addPivotDataListener, fireEvent, removePivotDataListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPivotDataListener, removePivotDataListener
protected final TabularPivotModel.CalculatorContextSpace _space
protected static final int _STD_CAL_TYPE_SIZE
protected static final Comparator<PivotHeaderNode> NODE_COMPARATOR
public void setFieldType(String fieldName, PivotField.Type type)
fieldName
- name of the fieldPivotField.Type
public void setFieldType(PivotField field, PivotField.Type type, int index)
PivotModelExt
setFieldType
in interface PivotModelExt
index
- the tree level or display positionPivotField.Type
public void setFieldType(PivotField field, PivotField.Type type)
PivotModelExt
setFieldType
in interface PivotModelExt
PivotField.Type
public int getSourceDataIndex(PivotField field)
public final TabularPivotField[] getRowFields()
public final TabularPivotField[] getColumnFields()
public final TabularPivotField[] getDataFields()
public TabularPivotField[] getFields(PivotField.Type type)
PivotModel
getFields
in interface PivotModel
PivotField
,
PivotField.Type
public TabularPivotField[] getFields()
PivotModel
getFields
in interface PivotModel
public TabularPivotField getField(String fieldName)
Note: it only returns the first one matching with the field name.
public void removeField(String fieldName)
PivotField.Type
public void removeField(PivotField field)
PivotField.Type
public void clearAllFields(boolean complete)
complete
- true to additionally remove custom summary, subtotals
and group handlersPivotField.Type
public void setFieldKeyOrder(String fieldName, boolean ascending)
public void setFieldKeyOrder(PivotField field, boolean ascending)
PivotModelExt.SortCtrl
setFieldKeyOrder
in interface PivotModelExt.SortCtrl
public void setFieldKeyComparator(String fieldName, Comparator<Object> comparator)
fieldName
- the field on which the comparator appliescomparator
- a comparator to sort field keyspublic void setFieldKeyComparator(PivotField field, Comparator<Object> comparator)
PivotModelExt.SortCtrl
setFieldKeyComparator
in interface PivotModelExt.SortCtrl
comparator
- a comparator to sort field keyspublic void updateRawData()
iterateRawData(SimplePivotHeaderTree, SimplePivotHeaderTree, RawDataRunner)
and hence trigger an iteration over the raw data.public Calculator[] getSupportedCalculators()
PivotModelExt
getSupportedCalculators
in interface PivotModelExt
public void addSupportedCalculator(ContextualCalculator<?> cal)
Calculator
supported in this model. This will
be reflected in getSupportedCalculators()
and hence are aware
by PivotFieldControl
.public void removeSupportedCalculator(ContextualCalculator<?> cal)
Calculator
supported in this model. This will
be reflected in getSupportedCalculators()
and hence are aware
by PivotFieldControl
.public void clearSupportedCalculators()
Calculator
supported in this model.
This will be reflected in getSupportedCalculators()
and hence
are aware by PivotFieldControl
. This does not affect built-in
calculators.public void setFieldSummary(String fieldName, Calculator summary)
public void setFieldSummary(PivotField field, Calculator summary)
PivotModelExt
setFieldSummary
in interface PivotModelExt
public void setFieldSubtotals(String fieldName, Calculator[] subtotals)
public void setFieldSubtotals(PivotField field, Calculator[] subtotals)
PivotModelExt
setFieldSubtotals
in interface PivotModelExt
protected final void updateContextSpace()
protected void sortRowTree(SimplePivotHeaderTree rowTree)
SimplePivotHeaderTree.sort(Comparator)
by providing a customrowTree
- the header tree to be sortedprotected void sortColumnTree(SimplePivotHeaderTree colTree)
SimplePivotHeaderTree.sort(Comparator)
by providing a customcolTree
- the header tree to be sorted@Deprecated protected void sortTrees()
sortRowTree(SimplePivotHeaderTree)
and sortColumnTree(SimplePivotHeaderTree)
protected void iterateRawData(SimplePivotHeaderTree colTree, SimplePivotHeaderTree rowTree, TabularPivotModel.RawDataRunner runner)
public Number getValue(PivotHeaderNode rowNode, int rowCalIndex, PivotHeaderNode colNode, int colCalIndex, int dataIndex)
PivotModel
getValue
in interface PivotModel
rowNode
- row node, root node means grand totalrowCalIndex
- row subtotal calculator index, -1 if not subtotalcolNode
- column node, root node means grand totalcolCalIndex
- column subtotal calculator index, -1 if not subtotaldataIndex
- index of data fieldsprotected final ContextualCalculator<?> getCalculator(SimplePivotHeaderNode rowNode, int rowCalIndex, SimplePivotHeaderNode colNode, int colCalIndex, int dataIndex)
public PivotHeaderTree getColumnHeaderTree()
PivotModel
getColumnHeaderTree
in interface PivotModel
PivotHeaderTree
public PivotHeaderTree getRowHeaderTree()
PivotModel
getRowHeaderTree
in interface PivotModel
PivotHeaderTree
protected CalculatorContextSignature getCalculatorContextSignature()
protected boolean shallReloadSourceSpace(CalculatorContextSignature current, CalculatorContextSignature required)
current
- the current source space signaturerequired
- the new required signatureprotected TabularPivotField cast(PivotField field)
protected SimplePivotHeaderNode cast(PivotHeaderNode node)
protected ContextualCalculator<?> cast(Calculator calc)
Copyright © 2017. All rights reserved.