java.lang.Object
javax.swing.table.AbstractTableModel
org.jfree.data.xy.XYDatasetTableModel
- All Implemented Interfaces:
Serializable
,EventListener
,TableModel
,DatasetChangeListener
public class XYDatasetTableModel
extends AbstractTableModel
implements TableModel, DatasetChangeListener
A READ-ONLY wrapper around a
TableXYDataset
to convert it to a
table model for use in a JTable. The first column of the table shows the
x-values, the remaining columns show the y-values for each series (series 0
appears in column 1, series 1 appears in column 2, etc).
TO DO:
- implement proper naming for x axis (getColumnName)
- implement setValueAt to remove READ-ONLY constraint (not sure how)
- See Also:
-
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorDescriptionDefault constructor.XYDatasetTableModel
(TableXYDataset dataset) Creates a new table model based on the specified dataset. -
Method Summary
Modifier and TypeMethodDescriptionvoid
datasetChanged
(DatasetChangeEvent event) Receives notification that the underlying dataset has changed.int
Gets the number of columns in the model.getColumnName
(int column) Returns the column name.int
Returns the number of rows.getValueAt
(int row, int column) Returns a value of the specified cell.boolean
isCellEditable
(int row, int column) Returns a flag indicating whether or not the specified cell is editable.void
setModel
(TableXYDataset dataset) Sets the model (dataset).void
setValueAt
(Object value, int row, int column) Updates theXYDataset
if allowed.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, 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, 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:
getRowCount
in interfaceTableModel
- Returns:
- The row count.
-
getColumnCount
public int getColumnCount()Gets the number of columns in the model.- Specified by:
getColumnCount
in interfaceTableModel
- Returns:
- The number of columns in the model.
-
getColumnName
Returns the column name.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in 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:
getValueAt
in interfaceTableModel
- Parameters:
row
- the row number.column
- the column number.- Returns:
- The value of the specified cell.
-
datasetChanged
Receives notification that the underlying dataset has changed.- Specified by:
datasetChanged
in interfaceDatasetChangeListener
- Parameters:
event
- the event- See Also:
-
isCellEditable
public boolean isCellEditable(int row, int column) Returns a flag indicating whether or not the specified cell is editable.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
row
- the row number.column
- the column number.- Returns:
true
if the specified cell is editable.
-
setValueAt
Updates theXYDataset
if allowed.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
value
- the new value.row
- the row.column
- the column.
-