Package org.jfree.data.xy
Class XYDatasetTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.jfree.data.xy.XYDatasetTableModel
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,javax.swing.table.TableModel,DatasetChangeListener
public class XYDatasetTableModel extends javax.swing.table.AbstractTableModel implements javax.swing.table.TableModel, DatasetChangeListener
A READ-ONLY wrapper around aTableXYDatasetto 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) TableXYDatasetmodelThe dataset.
-
Constructor Summary
Constructors Constructor Description XYDatasetTableModel()Default constructor.XYDatasetTableModel(TableXYDataset dataset)Creates a new table model based on the specified dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddatasetChanged(DatasetChangeEvent event)Receives notification that the underlying dataset has changed.intgetColumnCount()Gets the number of columns in the model.java.lang.StringgetColumnName(int column)Returns the column name.intgetRowCount()Returns the number of rows.java.lang.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(TableXYDataset dataset)Sets the model (dataset).voidsetValueAt(java.lang.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, removeTableModelListener
-
-
-
-
Field Detail
-
model
TableXYDataset model
The dataset.
-
-
Constructor Detail
-
XYDatasetTableModel
public XYDatasetTableModel()
Default constructor.
-
XYDatasetTableModel
public XYDatasetTableModel(TableXYDataset dataset)
Creates a new table model based on the specified dataset.- Parameters:
dataset- the dataset.
-
-
Method Detail
-
setModel
public void setModel(TableXYDataset dataset)
Sets the model (dataset).- Parameters:
dataset- the dataset.
-
getRowCount
public int getRowCount()
Returns the number of rows.- Specified by:
getRowCountin interfacejavax.swing.table.TableModel- Returns:
- The row count.
-
getColumnCount
public int getColumnCount()
Gets the number of columns in the model.- Specified by:
getColumnCountin interfacejavax.swing.table.TableModel- Returns:
- The number of columns in the model.
-
getColumnName
public java.lang.String getColumnName(int column)
Returns the column name.- Specified by:
getColumnNamein interfacejavax.swing.table.TableModel- Overrides:
getColumnNamein classjavax.swing.table.AbstractTableModel- Parameters:
column- the column index.- Returns:
- The column name.
-
getValueAt
public java.lang.Object getValueAt(int row, int column)Returns a value of the specified cell. Column 0 is the X axis, Columns 1 and over are the Y axis- Specified by:
getValueAtin interfacejavax.swing.table.TableModel- Parameters:
row- the row number.column- the column number.- Returns:
- The value of the specified cell.
-
datasetChanged
public void datasetChanged(DatasetChangeEvent event)
Receives notification that the underlying dataset has changed.- Specified by:
datasetChangedin interfaceDatasetChangeListener- Parameters:
event- 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 interfacejavax.swing.table.TableModel- Overrides:
isCellEditablein classjavax.swing.table.AbstractTableModel- Parameters:
row- the row number.column- the column number.- Returns:
trueif the specified cell is editable.
-
setValueAt
public void setValueAt(java.lang.Object value, int row, int column)Updates theXYDatasetif allowed.- Specified by:
setValueAtin interfacejavax.swing.table.TableModel- Overrides:
setValueAtin classjavax.swing.table.AbstractTableModel- Parameters:
value- the new value.row- the row.column- the column.
-
-