public class TableCalculations
extends java.lang.Object
Contains calculations that will be performed on the table content. To add a calculation to a column you can use the API of this class or settings on the column definition. The following settings are supported:
You may also use the Calculation Decimal Precision setting to control the decimal precision of the calculation.
Note that when the table is changed or when the column definitions in the table is reloaded the calculations that you have added programmatically will be removed.
Modifier and Type | Method and Description |
---|---|
void |
addCalculation(Column column,
TableCalculation calc)
Adds a calculation to a column.
|
void |
addCalculationsFromColumns()
Add table calculations for columns based on the settings that have been
defined on the column.
|
TableCalculationResults |
calculate()
Calculate the results of all TableCalculations for the visible columns.
|
TableCalculationResults |
calculate(com.technia.tvc.commons.collections15.Predicate<Column> columnPredicate)
Calculate the results of all TableCalculations for the selected columns.
|
void |
clearCalculations()
Removes all table calculations from this table.
|
TableCalculation[] |
getCalculations()
Returns all table calculations.
|
TableCalculation[] |
getCalculations(Column column)
Get all table calculations on a particular column.
|
TableCalculation[] |
getCalculationsForColumns(com.technia.tvc.commons.collections15.Predicate<Column> columnPredicate)
Returns all table calculations assigned to the selected columns.
|
TableCalculation[] |
getCalculationsForVisibleColumns()
Returns all table calculations assigned to visible columns.
|
TableDataFilter |
getTableDataFilter()
Returns a filter that decides which
TableData instances to
include when calculating. |
boolean |
hasCalculation(Column column,
TableCalculation calc)
Check if a calculation has been associated with a particular column.
|
boolean |
hasCalculations()
Check if any table calculations exist on the table.
|
boolean |
hasCalculations(Column column)
Checks if one or more table calculations have been added to a column.
|
boolean |
hasCalculationsForColumns(com.technia.tvc.commons.collections15.Predicate<Column> columnPredicate)
Returns true if the table has any calculations for the columns accepted
by the predicate.
|
boolean |
hasCalculationsForVisibleColumns()
Checks if any table calculations are associated with the currently
visible columns.
|
void |
removeCalculation(Column column,
TableCalculation calc)
Remove a calculation from a column.
|
void |
setTableDataFilter(TableDataFilter filter)
Sets the filter that will be used to further filter the
TableData
instances that are included in the calculations. |
public TableDataFilter getTableDataFilter()
TableData
instances to
include when calculating. This filter will be used on top of existing
filters for visibility on the TableBean
. This can be used to for
example only include root nodes in a structure when calculating.TableData
.setTableDataFilter(TableDataFilter)
public void setTableDataFilter(TableDataFilter filter)
TableData
instances that are included in the calculations.filter
- The new filter.getTableDataFilter()
public TableCalculationResults calculate()
public TableCalculationResults calculate(com.technia.tvc.commons.collections15.Predicate<Column> columnPredicate)
columnPredicate
- A predicate that decides which columns to include.public TableCalculation[] getCalculations()
public TableCalculation[] getCalculationsForColumns(com.technia.tvc.commons.collections15.Predicate<Column> columnPredicate)
columnPredicate
- Selects columns.public TableCalculation[] getCalculationsForVisibleColumns()
public TableCalculation[] getCalculations(Column column)
column
- A column.public boolean hasCalculations()
public boolean hasCalculationsForColumns(com.technia.tvc.commons.collections15.Predicate<Column> columnPredicate)
columnPredicate
- A predecate that decides which columns to check.public boolean hasCalculationsForVisibleColumns()
public boolean hasCalculations(Column column)
column
- A column.public boolean hasCalculation(Column column, TableCalculation calc)
column
- A column.calc
- A calculation.public void addCalculation(Column column, TableCalculation calc)
column
- A column.calc
- The calculation to add to the column.java.lang.NullPointerException
- If any argument is null.public void addCalculationsFromColumns()
public void removeCalculation(Column column, TableCalculation calc)
column
- A column.calc
- The calculation that should be removed from the column.java.lang.NullPointerException
- If any argument is null.public void clearCalculations()
Copyright ? Technia AB. All Rights Reserved.