|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
tenua.simulator.DataTableImpl
public class DataTableImpl
A two-dimensional TableModel. Contains only double data, with an extra column of "X values" that can be put into a row header panel in a JScrollPane as:
DataTable model = new DataTable();
JTable mainTable = new JTable(model);
JScrollPane pane = new JScrollPane(mainTable);
JTable rowHeaders = new JTable(model.getRowHeaderModel());
pane.setRowHeaderView(new JPanel(new BorderLayout()).add (rowHeaders));
The trick with putting the rowHeaders into its own panel seems to be the
only way I can get it to size correctly.
model.addColumn("first");
model.addColumn("second");
col1 = model.getColumnNumber("first");
double x = 10; y = 50;
model.setY (x, col1, y);
where x is a double representing the x value. You can use
the TableModel methods of setValueAt (row, col, new Double (y))
if you know the exact row you want to set, or the thread-safe versions
like setY (row, col, y).
setYAt
getXAt
getYAt
setY (x, -1, any-value) inserts a row with X-value x and no
data in any of the columns.
| Constructor Summary | |
|---|---|
DataTableImpl()
Creates a new instance of DataTable |
|
| Method Summary | |
|---|---|
void |
addColumn(java.lang.String name)
Adds a column or erases it if it already exists |
DoubleBean |
doubleBean(double x,
int c)
Creates a DoubleBean that reflects a given data point |
int |
findColumn(java.lang.String name)
|
java.lang.Class |
getColumnClass(int c)
|
int |
getColumnCount()
|
java.lang.String |
getColumnName(int c)
|
int |
getColumnNumber(java.lang.String name)
Find the column index for a given column. |
double |
getCount(int c)
returns the number of data points in a column |
double |
getHighestX(int c)
returns the highest x value for which a column has data |
double |
getLowestX(int c)
returns the lowest x value for which a column has data |
double |
getNextX(int c,
double x)
returns the next x value for which a column has data |
double |
getNthX(int c,
int n)
returns the nth x value for which data exists in a column. |
int |
getRowCount()
|
javax.swing.table.TableModel |
getRowHeaderModel()
|
java.lang.Object |
getValueAt(int r,
int c)
|
double |
getXAt(int r)
return the x value of a given row |
double |
getY(double x,
int c)
return the y value of a given x value and column. |
double |
getYAt(int r,
int c)
return the y value of a given row and column |
boolean |
isCellEditable(int r,
int c)
|
boolean |
isHidden(int c)
Checks whether a given column is hidden |
void |
purgeRows()
Removes all blank rows |
void |
removeColumn(int c)
Removes a column |
void |
setColumnName(int c,
java.lang.String name)
|
void |
setHidden(int c,
boolean hide)
Sets the hidden state for a column |
void |
setValueAt(java.lang.Object o,
int r,
int c)
|
void |
setY(double x,
int c,
double y)
Set the y value of a given x-value and column. |
void |
setYAt(int r,
int c,
double y)
Set the y value of a given row and column. |
java.lang.String |
toString()
a string representation of this table |
java.lang.String |
toString(int[] cols)
a string representation of a subset of this table. |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DataTableImpl()
| Method Detail |
|---|
public int findColumn(java.lang.String name)
findColumn in class javax.swing.table.AbstractTableModelpublic java.lang.Class getColumnClass(int c)
getColumnClass in interface javax.swing.table.TableModelgetColumnClass in class javax.swing.table.AbstractTableModelpublic int getColumnCount()
getColumnCount in interface javax.swing.table.TableModelpublic java.lang.String getColumnName(int c)
getColumnName in interface javax.swing.table.TableModelgetColumnName in class javax.swing.table.AbstractTableModelpublic int getRowCount()
getRowCount in interface javax.swing.table.TableModelpublic javax.swing.table.TableModel getRowHeaderModel()
public java.lang.Object getValueAt(int r,
int c)
getValueAt in interface javax.swing.table.TableModel
public boolean isCellEditable(int r,
int c)
isCellEditable in interface javax.swing.table.TableModelisCellEditable in class javax.swing.table.AbstractTableModel
public void setColumnName(int c,
java.lang.String name)
public void setValueAt(java.lang.Object o,
int r,
int c)
setValueAt in interface javax.swing.table.TableModelsetValueAt in class javax.swing.table.AbstractTableModelpublic java.lang.String toString()
toString in class java.lang.Objectpublic double getXAt(int r)
r - the row number
java.lang.ArrayIndexOutOfBoundsException - if the row does not exist
public double getYAt(int r,
int c)
r - the row numberc - the column number (column -1 is the X-value)
java.lang.InterruptedException - if the routine is interrupted
before it gets a chance to read the data
java.lang.ArrayIndexOutOfBoundsException - if the row or column do not exist
public double getY(double x,
int c)
DataTable
x - the X-valuec - the column number (column -1 is the X-value)
public double getLowestX(int c)
DataTable
getLowestX in interface DataTablec - the column to search
public double getHighestX(int c)
DataTable
getHighestX in interface DataTablec - the column to search
public double getNthX(int c,
int n)
DataTable
c - the column to searchn - which x value to return
public double getNextX(int c,
double x)
DataTable
c - the column to searchx - the previous x value
public double getCount(int c)
DataTable
c - the column to search
public int getColumnNumber(java.lang.String name)
DataTable
getColumnNumber in interface DataTablename - the column name to look forpublic DoubleBean doubleBean(double x, int c)
DoubleBean that reflects a given data point
x - the x valuec - the column
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist
public boolean isHidden(int c)
throws java.lang.InterruptedException
c - the column to check
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist
java.lang.InterruptedExceptionpublic java.lang.String toString(int[] cols)
cols - the indices of the columns to select
java.lang.ArrayIndexOutOfBoundsException - if the columns do not exist
public void setYAt(int r,
int c,
double y)
r - the row numberc - the column numbery - the new value
java.lang.ArrayIndexOutOfBoundsException - if the row or column do not exist
public void setY(double x,
int c,
double y)
DataTable
x - the x valuec - the column numbery - the new valuepublic void addColumn(java.lang.String name)
DataTable
name - the name of the new columnpublic void purgeRows()
public void removeColumn(int c)
c - the column to remove
public void setHidden(int c,
boolean hide)
c - the columnhidden - true to hide, false to show and edit.
java.lang.ArrayIndexOutOfBoundsException - if the row or column do not exist
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||