|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel com.jidesoft.grid.JoinTableModel com.jidesoft.pivot.AggregateTableModel
public class AggregateTableModel
AggregateTableModel
takes any table models and aggregates the same values on the aggregated columns and
add expand/collapse icon or cell span to the cell on these aggregated rows.
DefaultGroupTableModel
except DefaultGroupTableModel is a kind of TreeTableModel,
v.s. AggregateTableModel is just a regular TableModel.
AggregateTableModel
used PivotDataModel
to do the aggregation. We tried to hide this
implementation detail from user as much as we can. But there is a getField(String)
method which exposes the
actual PivotField
to the user. You can use this PivotField
to add summary to the aggregated
column.
If you have a table model, you call AggregateTableModel(javax.swing.table.TableModel)
to create an
AggregateTableModel
. Then you call setAggregatedColumns(int[])
or {setAggregatedColumns(String[])
to aggregate the columns that have duplicated values. At last, you call aggregate()
. This call will make the AggregateTableModel
to be ready to be used by AggregateTable
.
Nested Class Summary | |
---|---|
protected class |
AggregateTableModel.AggregateTablePivotDataModel
The PivotDataModel for AggregateTable to use. |
Field Summary | |
---|---|
static String |
PROPERTY_AGGREGATED_COLUMNS_CHANGING
|
Fields inherited from class com.jidesoft.grid.JoinTableModel |
---|
_models |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Fields inherited from interface com.jidesoft.grid.MultiTableModel |
---|
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN |
Constructor Summary | |
---|---|
AggregateTableModel(TableModel model)
|
|
AggregateTableModel(TableModel model,
int[] aggregateColumnNames)
|
|
AggregateTableModel(TableModel model,
String[] aggregateColumnNames)
|
Method Summary | |
---|---|
void |
addAggregatedColumn(int column)
|
void |
addAggregatedColumn(int index,
int column)
|
void |
addIndexChangeListener(IndexChangeListener l)
Add IndexChangelistener. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. |
void |
aggregate()
Aggregates the table model. |
protected PivotDataModel |
createPivotDataModel(TableModel model)
Creates PivotDataModel and overrides calculate method to update the aggregate table model. |
protected void |
customizePivotDataModel(PivotDataModel pivotDataModel)
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Support for reporting bound property changes for Object properties. |
int |
getActualColumnAt(int column)
Gets actual column index in actual table model from the column index in AggregateTableModel. |
TableModel |
getActualModel()
Gets the underlying table model. |
int |
getActualModelColumnIndex(int columnModelIndex)
Gets the actual column index in the actual table model that is passed to the constructor of the AggregateTableModel. |
int |
getActualRowAt(int visualRow)
Gets the actual row index based on the visual row index. |
List<Integer> |
getActualRowsAt(int visualRow)
Gets the actual rows based on the visual row index. |
Integer[] |
getActualRowsAt(int visualRow,
int aggregatedColumnVisualIndex)
Gets the actual row indices based on the visual row index and the aggregated column index. |
int |
getAggregatedColumnCount()
Gets the number of aggregated column count. |
int[] |
getAggregatedColumns()
Gets the aggregated column indices. |
int[] |
getAggregatedColumnsInPivotFields()
Gets the aggregated column indices recorded in PivotField , which could be different
with getAggregatedColumns() if you just invoked setAggregatedColumns(int[]) and did not invoke
aggregate() yet. |
Class<?> |
getCellClassAt(int rowIndex,
int columnIndex)
Overrides to return the getCellClassAt from the underlying table models, of course, only when the underlying table model is ContextSensitiveTableModel. |
CellSpan |
getCellSpanAt(int rowIndex,
int columnIndex)
Overrides to return the CellSpan from the underlying table models, of course, only when the underlying table model is SpanModel and isCellSpanOn is true. |
CellStyle |
getCellStyleAt(int rowIndex,
int columnIndex)
Overrides to return the CellStyle from the underlying table models, of course, only when the underlying table model is StyleModel and isCellStyleOn is true. |
CellStyleProvider |
getCellStyleProvider()
|
Class<?> |
getColumnClass(int columnIndex)
Overrides to return the getColumnClass from the underlying table models. |
int |
getColumnCount()
Gets the total number of column count. |
Object |
getColumnIdentifier(int columnIndex)
Returns the identifier of the column in the model. |
String |
getColumnName(int columnIndex)
Overrides to return the getColumnName from the underlying table models. |
int |
getColumnType(int columnIndex)
Gets the column type in MultiTableModel. |
ConverterContext |
getConverterContextAt(int rowIndex,
int columnIndex)
Overrides to return the getConverterContextAt from the underlying table models, of course, only when the underlying table model is ContextSensitiveTableModel. |
EditorContext |
getEditorContextAt(int rowIndex,
int columnIndex)
Overrides to return the getEditorContextAt from the underlying table models, of course, only when the underlying table model is ContextSensitiveTableModel. |
PivotField |
getField(int columnIndex)
Gets the PivotField from the underlying PivotDataModel. |
PivotField |
getField(String name)
Gets the PivotField from the underlying PivotDataModel. |
int |
getGroupColumnAt(int index)
Gets the corresponding column index in its actual table model for the designated aggregated column. |
int |
getGroupColumnCount()
Gets the count of aggregated columns. |
Object |
getGroupColumnIdentifier(int groupColumnIndex)
Gets the identifier of the group column index. |
int |
getGroupColumnOrder(int index)
Gets the corresponding column order in its actual table model for the designated aggregated column. |
IndexChangeListener[] |
getIndexChangeListeners()
Returns an array of all the IndexChangeListener s |
int |
getMaximumAggregatedRows()
Gets the maximum number of aggregated rows. |
int |
getModelColumnIndex(int actualColumnIndex)
Gets the column index as in the AggregateTableModel. |
IPivotDataModel |
getPivotDataModel()
Gets the PivotDataModel. |
PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component. |
PropertyChangeListener[] |
getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property. |
int |
getRowAt(int actualRow)
Gets the view row index based on the actual row index. |
int |
getRowCount()
Gets the total number of row count. |
SummaryCalculator |
getSummaryCalculator()
Gets the statistics calculator used to calculate all the statistics for the pivot data model. |
int |
getTableIndex(int columnIndex)
Get the table index. |
Object |
getValueAt(int rowIndex,
int columnIndex)
Overrides to return the getValueAt from the underlying table models. |
int |
getVisualColumnAt(int actualColumn)
Gets the column index in AggregateTableModel from actual column index in actual table model. |
int |
getVisualRowAt(int actualRow)
Gets the visual row index representing the specified actual row. |
void |
groupAndRefresh()
Aggregates the table model. |
boolean |
groupColumnsFirst()
Gets the flag indicating if group columns should always be displayed at the begging when displayed. |
boolean |
hasAggregateColumns()
|
void |
hideColumn(int column)
|
boolean |
isAggregated()
Checks if the table model has been aggregated. |
boolean |
isCellSpanOn()
Overrides to return true if any of the underlying table models is SpanModel and the isCellSpanOn is true. |
boolean |
isCellStyleOn()
Overrides to return true if any of the underlying table models is StyleModel and the isCellStyleOn is true. |
boolean |
isColumnAggregated(int column)
Checks if the table model has been aggregated. |
boolean |
isColumnGroupable(int columnIndex)
Checks if the column is groupable or not. |
boolean |
isDisplayGroupColumns()
Always displays the grouped columns for AggregateTable. |
boolean |
isSettingAggregateColumns()
|
boolean |
isShowGrandTotal()
Gets the showSummary flag. |
boolean |
isShowSummary()
Gets the showSummary flag. |
boolean |
isShowSummaryOnly()
Gets the showSummaryOnly flag. |
boolean |
isSortAggregatedColumns()
Gets the flag if the aggregated columns should be sorted automatically |
boolean |
isSummaryMode()
Gets the summaryMode flag. |
void |
removeAggregatedColumn(int column)
|
void |
removeIndexChangeListener(IndexChangeListener l)
Remove IndexChangelistener. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. |
void |
setAggregatedColumns(int[] columns)
Sets the aggregated columns. |
void |
setAggregatedColumns(String[] columnNames)
Sets the aggregated columns. |
void |
setCellStyleProvider(CellStyleProvider cellStyleProvider)
|
void |
setGroupColumns(int[] columns,
int[] orders)
Sets the aggregated columns. |
void |
setMaximumAggregatedRows(int maximumAggregatedRows)
Sets the maximum number of aggregated rows. |
void |
setSettingAggregateColumns(boolean settingAggregateColumns)
|
void |
setShowGrandTotal(boolean show)
Sets showGrandTotal flag. |
void |
setShowSummary(boolean show)
Sets showSummary flag. |
void |
setShowSummaryOnly(boolean showSummaryOnly)
Sets showSummaryOnly flag. |
void |
setSortAggregatedColumns(boolean sorted)
Sets the flag if the aggregated columns should be sorted automatically. |
void |
setSummaryCalculator(SummaryCalculator summaryCalculator)
Sets the statistics calculator. |
void |
setSummaryMode(boolean show)
Sets summaryMode flag. |
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
Overrides to call setValueAt of the underlying table models to set the value. |
Methods inherited from class com.jidesoft.grid.JoinTableModel |
---|
addTableModel, addTableModel, getActualModel, getTableModel, getTableModelCount, isCellEditable, isNavigableAt, isNavigationOn, removeAllTableModels, removeTableModel |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, removeTableModelListener |
Field Detail |
---|
public static final String PROPERTY_AGGREGATED_COLUMNS_CHANGING
Constructor Detail |
---|
public AggregateTableModel(TableModel model)
public AggregateTableModel(TableModel model, String[] aggregateColumnNames)
public AggregateTableModel(TableModel model, int[] aggregateColumnNames)
Method Detail |
---|
protected PivotDataModel createPivotDataModel(TableModel model)
return new AggregateTablePivotDataModel(model);
model
- the table model
protected void customizePivotDataModel(PivotDataModel pivotDataModel)
public void setAggregatedColumns(int[] columns)
addAggregatedColumn(int)
Sets the aggregated columns. Nothing is changed at this point until aggregate()
is called.
columns
- the index of the columns to be aggregated.public void setAggregatedColumns(String[] columnNames)
addAggregatedColumn(int)
Nothing is changed at this point until aggregate()
is called.
columnNames
- the name of the columns to be aggregated.public void addAggregatedColumn(int index, int column)
public void addAggregatedColumn(int column)
public void removeAggregatedColumn(int column)
public void hideColumn(int column)
public boolean isAggregated()
public boolean isColumnAggregated(int column)
column
- the column index.
public void setShowSummary(boolean show)
show
- true or false.public boolean isShowSummary()
public void setSummaryMode(boolean show)
PivotDataModel.setSummaryMode(boolean)
.
show
- true or false.public boolean isSummaryMode()
public void setShowSummaryOnly(boolean showSummaryOnly)
showSummaryOnly
- true or false.public boolean isShowSummaryOnly()
public void setSortAggregatedColumns(boolean sorted)
sorted
- true or false.public boolean isSortAggregatedColumns()
public void setShowGrandTotal(boolean show)
show
- true or false.public boolean isShowGrandTotal()
public int getMaximumAggregatedRows()
public void setMaximumAggregatedRows(int maximumAggregatedRows)
maximumAggregatedRows
- the maximum number of aggregated rows.public PivotField getField(String name)
name
- the name of the field. It should be the column name.
public PivotField getField(int columnIndex)
columnIndex
- the column index.
public void aggregate()
public boolean hasAggregateColumns()
public int getGroupColumnCount()
getGroupColumnCount
in interface GroupModelProvider
public int getGroupColumnAt(int index)
getGroupColumnAt
in interface GroupModelProvider
index
- the aggregated column index
public final int getGroupColumnOrder(int index)
getGroupColumnOrder
in interface GroupModelProvider
index
- the aggregated column index
public void setGroupColumns(int[] columns, int[] orders)
setGroupColumns
in interface GroupModelProvider
columns
- the columns arrayorders
- no use for AggregateTableModelpublic void groupAndRefresh()
groupAndRefresh
in interface GroupModelProvider
public boolean isColumnGroupable(int columnIndex)
isColumnGroupable
in interface GroupModelProvider
columnIndex
- the column index
public final boolean isDisplayGroupColumns()
isDisplayGroupColumns
in interface GroupModelProvider
public boolean groupColumnsFirst()
GroupModelProvider
groupColumnsFirst
in interface GroupModelProvider
public Object getGroupColumnIdentifier(int groupColumnIndex)
GroupModelProvider
getGroupColumnIdentifier
in interface GroupModelProvider
groupColumnIndex
- the group column index
public int getAggregatedColumnCount()
public int[] getAggregatedColumnsInPivotFields()
PivotField
, which could be different
with getAggregatedColumns()
if you just invoked setAggregatedColumns(int[])
and did not invoke
aggregate()
yet.
public int[] getAggregatedColumns()
public CellStyleProvider getCellStyleProvider()
public void setCellStyleProvider(CellStyleProvider cellStyleProvider)
public CellStyle getCellStyleAt(int rowIndex, int columnIndex)
JoinTableModel
getCellStyleAt
in interface StyleModel
getCellStyleAt
in class JoinTableModel
rowIndex
- the row index.columnIndex
- the column index.
public boolean isCellStyleOn()
JoinTableModel
isCellStyleOn
in interface StyleModel
isCellStyleOn
in class JoinTableModel
public void setSummaryCalculator(SummaryCalculator summaryCalculator)
summaryCalculator
- the summary calculator.public SummaryCalculator getSummaryCalculator()
public int getActualModelColumnIndex(int columnModelIndex)
columnModelIndex
- the column index as in the AggregateTableModel.
public int getModelColumnIndex(int actualColumnIndex)
actualColumnIndex
- the actual model index as in the table model passed to the constructor of the
AggregateTableModel.
public Integer[] getActualRowsAt(int visualRow, int aggregatedColumnVisualIndex)
visualRow
- the visual row index.aggregatedColumnVisualIndex
- the visual column index of the aggregated column. It must be greater than 0
and less then the count of the aggregated columns.
public int getRowAt(int actualRow)
actualRow
- the row index in the actual table model
public int getActualRowAt(int visualRow)
getActualRowAt
in interface RowTableModelWrapper
visualRow
- the visual row index.
getActualRowsAt(int)
to find out all the rows.public int getVisualRowAt(int actualRow)
getVisualRowAt
in interface RowTableModelWrapper
actualRow
- the actual row index.
public List<Integer> getActualRowsAt(int visualRow)
visualRow
- the visual row index.
public IPivotDataModel getPivotDataModel()
public Object getColumnIdentifier(int columnIndex)
ColumnIdentifierTableModel
JideTable
uses this method to get the unique
identifier of this column.
getColumnIdentifier
in interface ColumnIdentifierTableModel
getColumnIdentifier
in class JoinTableModel
columnIndex
- the index of the column
public Class<?> getColumnClass(int columnIndex)
JoinTableModel
getColumnClass
in interface TableModel
getColumnClass
in class JoinTableModel
columnIndex
- the column index.
public String getColumnName(int columnIndex)
JoinTableModel
getColumnName
in interface TableModel
getColumnName
in class JoinTableModel
columnIndex
- the column index.
public int getColumnCount()
JoinTableModel
getColumnCount
in interface TableModel
getColumnCount
in class JoinTableModel
public int getRowCount()
JoinTableModel
getRowCount
in interface TableModel
getRowCount
in class JoinTableModel
public Object getValueAt(int rowIndex, int columnIndex)
JoinTableModel
getValueAt
in interface TableModel
getValueAt
in class JoinTableModel
rowIndex
- the row index.columnIndex
- the column index.
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
JoinTableModel
setValueAt
in interface TableModel
setValueAt
in class JoinTableModel
aValue
- the new value at the specified row and column index.rowIndex
- the row index.columnIndex
- the column index.public ConverterContext getConverterContextAt(int rowIndex, int columnIndex)
JoinTableModel
getConverterContextAt
in interface ContextSensitiveTableModel
getConverterContextAt
in class JoinTableModel
rowIndex
- the row index.columnIndex
- the column index.
public EditorContext getEditorContextAt(int rowIndex, int columnIndex)
JoinTableModel
getEditorContextAt
in interface ContextSensitiveTableModel
getEditorContextAt
in class JoinTableModel
rowIndex
- the row index.columnIndex
- the column index.
public Class<?> getCellClassAt(int rowIndex, int columnIndex)
JoinTableModel
getCellClassAt
in interface ContextSensitiveTableModel
getCellClassAt
in class JoinTableModel
rowIndex
- the row index.columnIndex
- the column index.
public CellSpan getCellSpanAt(int rowIndex, int columnIndex)
JoinTableModel
getCellSpanAt
in interface SpanModel
getCellSpanAt
in class JoinTableModel
rowIndex
- the row index.columnIndex
- the column index.
public boolean isCellSpanOn()
JoinTableModel
isCellSpanOn
in interface SpanModel
isCellSpanOn
in class JoinTableModel
public int getTableIndex(int columnIndex)
JoinTableModel
getTableIndex
in interface MultiTableModel
getTableIndex
in class JoinTableModel
columnIndex
- the column index.
public int getColumnType(int columnIndex)
JoinTableModel
getColumnType
in interface MultiTableModel
getColumnType
in class JoinTableModel
columnIndex
- the column index.
public TableModel getActualModel()
TableModelWrapper
getActualModel
in interface TableModelWrapper
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
propertyName
- the property whose value has changedoldValue
- the property's previous valuenewValue
- the property's new valuepublic void addPropertyChangeListener(PropertyChangeListener listener)
listener
- the PropertyChangeListener to be addedremovePropertyChangeListener(java.beans.PropertyChangeListener)
,
getPropertyChangeListeners()
,
addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- the PropertyChangeListener to be removedaddPropertyChangeListener(java.beans.PropertyChangeListener)
,
getPropertyChangeListeners()
,
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener
s or an empty array if no property change
listeners are currently registeredaddPropertyChangeListener(java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
,
PropertyChangeSupport.getPropertyChangeListeners()
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- one of the property names listed abovelistener
- the PropertyChangeListener to be addedremovePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
,
addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removedaddPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
propertyName
- the property name.
PropertyChangeListeners
associated with the named property or an empty array if
no listeners have been addedaddPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
getPropertyChangeListeners()
public boolean isSettingAggregateColumns()
public void setSettingAggregateColumns(boolean settingAggregateColumns)
public int getActualColumnAt(int column)
getActualColumnAt
in interface ColumnTableModelWrapper
column
- the column index in AggregateTableModel
public int getVisualColumnAt(int actualColumn)
getVisualColumnAt
in interface ColumnTableModelWrapper
actualColumn
- the actual column index in actual table model
public void addIndexChangeListener(IndexChangeListener l)
IndexChangeEventGenerator
addIndexChangeListener
in interface IndexChangeEventGenerator
l
- the listenerpublic void removeIndexChangeListener(IndexChangeListener l)
IndexChangeEventGenerator
removeIndexChangeListener
in interface IndexChangeEventGenerator
l
- the listenerpublic IndexChangeListener[] getIndexChangeListeners()
IndexChangeEventGenerator
IndexChangeListener
s
getIndexChangeListeners
in interface IndexChangeEventGenerator
IndexChangeListener
s added or an empty array if no listeners have been addedIndexChangeEventGenerator.addIndexChangeListener(com.jidesoft.grid.IndexChangeListener)
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |