Package org.jfree.data
Class XYDatasetTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.jfree.data.XYDatasetTableModel
- All Implemented Interfaces:
Serializable,EventListener,TableModel,DatasetChangeListener
public class XYDatasetTableModel extends AbstractTableModel implements TableModel, DatasetChangeListener
A READ-ONLY wrapper around an
XYDataset to convert it to a table
model for use in a JTable.
TO DO:
- implement proper naming for x axis (getColumnName)
- implement setValueAt to remove READ-ONLY constraint (not sure how)
- Author:
- Bryan Scott
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description XYDatasetTableModel()Default constructor.XYDatasetTableModel(XYDataset dataset)Creates a new table model based on the specified dataset. -
Method Summary
Modifier and Type Method Description voiddatasetChanged(DatasetChangeEvent datasetChangeEvent)Notify listeners that the underlying dataset has changed.intgetColumnCount()Gets the number of columns in the model.StringgetColumnName(int column)Returns the column name.intgetRowCount()Returns the number of rows.ObjectgetValueAt(int row, int column)Returns a value of the specified cell.booleanisCellEditable(int row, int column)Returns a flag indicating whether or not the specified cell is editable.voidsetModel(XYDataset dataset)Sets the model (dataset).voidsetValueAt(Object value, int row, int column)Updates theXYDatasetif allowed.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListenerMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, removeTableModelListener
-
Constructor Details
-
XYDatasetTableModel
public XYDatasetTableModel()Default constructor. -
XYDatasetTableModel
Creates a new table model based on the specified dataset.- Parameters:
dataset- the dataset.
-
-
Method Details
-
setModel
Sets the model (dataset).- Parameters:
dataset- the dataset.
-
getRowCount
public int getRowCount()Returns the number of rows.- Specified by:
getRowCountin interfaceTableModel- Returns:
- The row count.
-
getColumnCount
public int getColumnCount()Gets the number of columns in the model.- Specified by:
getColumnCountin interfaceTableModel- Returns:
- The number of columns in the model.
-
getColumnName
Returns the column name.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel- Parameters:
column- the column index.- Returns:
- The column name.
-
getValueAt
Returns a value of the specified cell. Column 0 is the X axis, Columns 1 and over are the Y axis- Specified by:
getValueAtin interfaceTableModel- Parameters:
row- the row number.column- the column number.- Returns:
- the value of the specified cell.
-
datasetChanged
Notify listeners that the underlying dataset has changed.- Specified by:
datasetChangedin interfaceDatasetChangeListener- Parameters:
datasetChangeEvent- the event- See Also:
DatasetChangeListener
-
isCellEditable
public boolean isCellEditable(int row, int column)Returns a flag indicating whether or not the specified cell is editable.- Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel- Parameters:
row- the row number.column- the column number.- Returns:
trueif the specified cell is editable.
-
setValueAt
Updates theXYDatasetif allowed.- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel- Parameters:
value- the new value.row- the row.column- the column.
-