Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot
Class DefaultPivotTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.citra.pivot.DefaultPivotTableModel
All Implemented Interfaces:
PivotDataModelListener, PivotTableModel, Serializable, EventListener, TableModelListener, TableModel

public class DefaultPivotTableModel
extends AbstractTableModel
implements PivotTableModel, TableModelListener, PivotDataModelListener

DefaultPivotTableModel is the default PivotTableModel implementation. The models for the row and column header as well as the data area can be assigned with the corresponding set methods. Also, the model listens for table model events received from the row header model, as well as events from the data model, and configures itself accordingly.


Field Summary
protected  PivotColumnAdapter columnAdapter
          the column header's model
protected  PivotDataModel dataModel
          the data area's model
protected  PivotRowAdapter rowAdapter
          the row header's model
protected  boolean showColumnHeader
          whether to display the column header
protected  boolean showColumnSeparator
          whether to show the column separator
protected  boolean showRowHeader
          whether to display the row header
protected  boolean showRowSeparator
          whether to show the row separator
protected  boolean showSummary
          whether to show the summary cell
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DefaultPivotTableModel()
          Constructs a DefaultPivotTableModel.
DefaultPivotTableModel(PivotDataModel dataModel)
          Constructs a DefaultPivotTableModel.
 
Method Summary
protected  PivotDataModel createDefaultDataModel()
          Creates the default model for the data area.
 void dataChanged(ChangeEvent e)
          Notification that the data of a pivot data model has changed.
 void edgesChanged(ChangeEvent e)
          Notification that the edges (row and/or column header) of a pivot data model have changed.
 PivotColumnAdapter getColumnAdapter()
          Returns the model's column adapter.
 Class getColumnClass(int columnIndex)
          Returns Object.class regardless of columnIndex.
 Class getColumnClass(int row, int column)
          Determines the class of the model's cell at coordinates row and column.
 int getColumnCount()
          Returns the number of columns in the model.
 String getColumnName(int column)
          Returns a default name for the column using spreadsheet conventions: A, B, C, ...
 PivotDataModel getDataModel()
          Retrieves the pivot data model that contains the actual data, excluding the row and column header.
 PivotRowAdapter getRowAdapter()
          Returns the model's row adapter.
 int getRowCount()
          Returns the number of rows in the model.
 boolean getShowColumnHeader()
          Determines whether to display the column header.
 boolean getShowColumnSeparator()
          Determines whether to show the column separator.
 boolean getShowRowHeader()
          Determines whether to display the row header.
 boolean getShowRowSeparator()
          Determines whether to show the row separator.
 boolean getShowSummary()
          Determines whether to show the summary cell.
 Object getValueAt(int row, int column)
          Returns the value for the cell at columnIndex and rowIndex.
 void setColumnAdapter(PivotColumnAdapter adapter)
          Assigns the model for the pivot table's column header.
 void setDataModel(PivotDataModel dataModel)
          Assigns the model for the pivot table's data area.
 void setRowAdapter(PivotRowAdapter adapter)
          Assigns the model for the pivot table's row header.
 void setShowColumnHeader(boolean showColumnHeader)
          Determines whether to display the column header.
 void setShowColumnSeparator(boolean showColumnSeparator)
          Determines whether to show the column separator.
 void setShowRowHeader(boolean showRowHeader)
          Determines whether to display the row header.
 void setShowRowSeparator(boolean showRowSeparator)
          Determines whether to show the row separator.
 void setShowSummary(boolean showSummary)
          Determines whether to show the summary cell.
 void setValueAt(Object value, int rowIndex, int columnIndex)
          This empty implementation is provided so users don't have to implement this method if their data model is not editable.
 void tableChanged(TableModelEvent e)
          This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, 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, isCellEditable, removeTableModelListener
 

Field Detail

rowAdapter

protected PivotRowAdapter rowAdapter
the row header's model


columnAdapter

protected PivotColumnAdapter columnAdapter
the column header's model


dataModel

protected PivotDataModel dataModel
the data area's model


showRowSeparator

protected boolean showRowSeparator
whether to show the row separator


showColumnSeparator

protected boolean showColumnSeparator
whether to show the column separator


showSummary

protected boolean showSummary
whether to show the summary cell


showRowHeader

protected boolean showRowHeader
whether to display the row header


showColumnHeader

protected boolean showColumnHeader
whether to display the column header

Constructor Detail

DefaultPivotTableModel

public DefaultPivotTableModel()
Constructs a DefaultPivotTableModel.


DefaultPivotTableModel

public DefaultPivotTableModel(PivotDataModel dataModel)
Constructs a DefaultPivotTableModel.

Method Detail

createDefaultDataModel

protected PivotDataModel createDefaultDataModel()
Creates the default model for the data area. This is a DefaultPivotDataModel.

Returns:
the default model for the data

dataChanged

public void dataChanged(ChangeEvent e)
Notification that the data of a pivot data model has changed.

Specified by:
dataChanged in interface PivotDataModelListener
Parameters:
e - the event that triggers the notification

edgesChanged

public void edgesChanged(ChangeEvent e)
Notification that the edges (row and/or column header) of a pivot data model have changed.

Specified by:
edgesChanged in interface PivotDataModelListener
Parameters:
e - the event that triggers the notification

getColumnAdapter

public PivotColumnAdapter getColumnAdapter()
Returns the model's column adapter. This is the model of the table's column header.

Specified by:
getColumnAdapter in interface PivotTableModel
Returns:
the column header's model

getColumnClass

public Class getColumnClass(int columnIndex)
Returns Object.class regardless of columnIndex.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
columnIndex - the column being queried
Returns:
the Object.class

getColumnClass

public Class getColumnClass(int row,
                            int column)
Determines the class of the model's cell at coordinates row and column.

Specified by:
getColumnClass in interface PivotTableModel
Parameters:
row - the cell's row index
column - the cell's column index
Returns:
the class for the specified cell

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. A JTable uses this method to determine how many columns it should create and display by default.

Specified by:
getColumnCount in interface TableModel
Returns:
the number of columns in the model
See Also:
TableModel.getRowCount()

getColumnName

public String getColumnName(int column)
Returns a default name for the column using spreadsheet conventions: A, B, C, ... Z, AA, AB, etc. If column cannot be found, returns an empty string.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - the column being queried
Returns:
a string containing the default name of column

getDataModel

public PivotDataModel getDataModel()
Retrieves the pivot data model that contains the actual data, excluding the row and column header.

Specified by:
getDataModel in interface PivotTableModel
Returns:
the data model

getRowAdapter

public PivotRowAdapter getRowAdapter()
Returns the model's row adapter. This is the model of the table's row header.

Specified by:
getRowAdapter in interface PivotTableModel
Returns:
the row header's table model

getRowCount

public int getRowCount()
Returns the number of rows in the model. A JTable uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.

Specified by:
getRowCount in interface TableModel
Returns:
the number of rows in the model
See Also:
TableModel.getColumnCount()

getShowColumnHeader

public boolean getShowColumnHeader()
Determines whether to display the column header.

Returns:
true if the column header is displayed, false otherwise

getShowColumnSeparator

public boolean getShowColumnSeparator()
Determines whether to show the column separator.

Returns:
true if the column separator is shown, false otherwise

getShowRowHeader

public boolean getShowRowHeader()
Determines whether to display the row header.

Returns:
true if the row header is displayed, false otherwise

getShowRowSeparator

public boolean getShowRowSeparator()
Determines whether to show the row separator.

Returns:
true if the row separator is shown, false otherwise

getShowSummary

public boolean getShowSummary()
Determines whether to show the summary cell.

Returns:
true if the summary cell is shown, false otherwise

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface TableModel
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the value Object at the specified cell

setColumnAdapter

public void setColumnAdapter(PivotColumnAdapter adapter)
Assigns the model for the pivot table's column header. This will trigger a table structure changed event.

Parameters:
adapter - the model to assign for the column header

setDataModel

public void setDataModel(PivotDataModel dataModel)
Assigns the model for the pivot table's data area. This will trigger a table structure changed event.

Parameters:
dataModel - the model to assign for the data area

setRowAdapter

public void setRowAdapter(PivotRowAdapter adapter)
Assigns the model for the pivot table's row header. This will trigger a table structure changed event.

Parameters:
adapter - the model to assign for the row header

setShowColumnHeader

public void setShowColumnHeader(boolean showColumnHeader)
Determines whether to display the column header.

Parameters:
showColumnHeader - true if the column header is displayed, false otherwise

setShowColumnSeparator

public void setShowColumnSeparator(boolean showColumnSeparator)
Determines whether to show the column separator.

Parameters:
showColumnSeparator - true if the column separator is shown, false otherwise

setShowRowHeader

public void setShowRowHeader(boolean showRowHeader)
Determines whether to display the row header.

Parameters:
showRowHeader - true if the row header is displayed, false otherwise

setShowRowSeparator

public void setShowRowSeparator(boolean showRowSeparator)
Determines whether to show the row separator.

Parameters:
showRowSeparator - true if the row separator is shown, false otherwise

setShowSummary

public void setShowSummary(boolean showSummary)
Determines whether to show the summary cell.

Parameters:
showSummary - true if the summary cell is shown, false otherwise

setValueAt

public void setValueAt(Object value,
                       int rowIndex,
                       int columnIndex)
Description copied from class: javax.swing.table.AbstractTableModel
This empty implementation is provided so users don't have to implement this method if their data model is not editable.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
value - value to assign to cell
rowIndex - row of cell
columnIndex - column of cell
See Also:
TableModel.getValueAt(int, int), TableModel.isCellEditable(int, int)

tableChanged

public void tableChanged(TableModelEvent e)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.

Specified by:
tableChanged in interface TableModelListener

Copyright © 2011 Citra Technologies. All Rights Reserved.