Class DataTableImpl

  extended by javax.swing.table.AbstractTableModel
      extended by tenua.simulator.DataTableImpl
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, DataTable

public class DataTableImpl
extends javax.swing.table.AbstractTableModel
implements DataTable

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.
It is intended to be used as:
      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).
It also supports setting a "hidden" flag that makes the cell uneditable. Column names are unique. Adding a column whose name already exists erases that column.

Thread safety

This class is the interface between the GUI, which runs on the Swing event thread, and the calculating part of the program, which may run on many threads. To ensure that all reads and writes are current, the writer methods only execute on the Swing event thread (they use SwingUtilities.invokeLater). Readers wait until all pending writers are done.
The thread-safe writers are: The thread-safe readers are: