public class DefaultChartModel extends AbstractTableModel implements ChartModel
ChartModel
that also implements
the Swing TableModel
interface. The labels of the chart values
in this chart model provide the names of the columns for the table model.
Therefore, each data sample in the chart model represents one row in the
table model, and each chart value in the chart definition represents one
column in the table model. This model can thus be used to simultaneously
drive a ChartView
and a JTable
, effectively
providing both a graphical and a spreadsheet view of the same underlying
data.Modifier and Type | Field and Description |
---|---|
private Chart |
chart |
private Vector |
data |
private EventListenerList |
listeners |
listenerList
Constructor and Description |
---|
DefaultChartModel(Chart chart)
Construct a new
DefaultChartModel for the specified chart
definition. |
Modifier and Type | Method and Description |
---|---|
void |
addChartModelListener(ChartModelListener listener)
Add a
ChartModelListener to this model's list of listeners. |
void |
addDataSample(DataSample ds)
Add a data sample to this model.
|
void |
clear()
Remove all data samples from this model.
|
protected void |
fireChartDataChanged()
Fire a chart data changed event.
|
int |
getColumnCount()
Get the number of columns in the table model.
|
String |
getColumnName(int col)
Get the name of the specified column in the table model.
|
DataSample |
getDataSample(int index)
Get the data sample at the specified index.
|
int |
getDataSampleCount()
Get the number of data samples in this model.
|
Enumeration |
getDataSamples()
Get all of the data samples in this model.
|
int |
getRowCount()
Get the number of rows in the table model.
|
Object |
getValueAt(int row,
int col)
Get the value at the specified row and column in the table model.
|
boolean |
isCellEditable(int row,
int col)
Determine if the given cell is editable.
|
void |
removeChartModelListener(ChartModelListener listener)
Remove a
ChartModelListener from this model's list of
listeners. |
void |
removeDataSample(int index)
Remove the data sample at the specified index from this model.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
private EventListenerList listeners
public DefaultChartModel(Chart chart)
DefaultChartModel
for the specified chart
definition.chart
- The chart definition.public int getRowCount()
getRowCount
in interface TableModel
public int getColumnCount()
getColumnCount
in interface TableModel
public String getColumnName(int col)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
col
- The column.public boolean isCellEditable(int row, int col)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
row
- The row.col
- The Column.true
if the cell is editable, false
otherwise. This implementation always returns false
.public void addChartModelListener(ChartModelListener listener)
ChartModelListener
to this model's list of listeners.addChartModelListener
in interface ChartModel
listener
- The listener to add.public void removeChartModelListener(ChartModelListener listener)
ChartModelListener
from this model's list of
listeners.removeChartModelListener
in interface ChartModel
listener
- The listener to remove.protected void fireChartDataChanged()
public void addDataSample(DataSample ds)
addDataSample
in interface ChartModel
ds
- The data sample to add.public int getDataSampleCount()
getDataSampleCount
in interface ChartModel
public Enumeration getDataSamples()
getDataSamples
in interface ChartModel
Enumeration
of the DataSample
objects in this model.public DataSample getDataSample(int index)
getDataSample
in interface ChartModel
index
- The index of the desired data sample.DataSample
at the specified index, or
null
if there is no data sample at that index.public void removeDataSample(int index)
removeDataSample
in interface ChartModel
index
- The index of the data sample to remove.public void clear()
clear
in interface ChartModel
public Object getValueAt(int row, int col)
getValueAt
in interface TableModel
row
- The row.col
- The column.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses