Class DataRowModel

java.lang.Object
javax.swing.table.AbstractTableModel
org.opensourcephysics.display.DataRowModel
All Implemented Interfaces:
Serializable, TableModel

public class DataRowModel extends AbstractTableModel
BH 2020.03.30 note: DataRowTable is used in ThreeStateNuclearDecay, where it tracks the three nuclear states over time. The symptom in SwingJS was that it was taking an inordinant amount of time to append to the table and to scroll it, and there was a huge amount of activity just in adding a new row. The problem turned out to be calls to DataRowTable.refreshTable(), which was firing a full table rebuild -- basically a clean sweep of all rows and columns -- every time a row was added. The solution was to disambiguate the calls to refreshTable() as refreshTable(String type), allowing a more nuanced approach. In addition, that functionality, arising from DataRowModel, was moved into DataRowModel as refreshModel(String type). This solved the basic problem of too many, too full, updates. The second problem was that in SwingJS we don't necessarily have to repaint a cell if nothing has changed, particularly during scrolling. "Repainting" actually amounts to rebuilding the HTML5 structure of the table, leading to expensive restyling of the DOM. To avoid this, SwingJS was modified to allow for a null return from DataRowTable.getCellRenderer(row, column). The new method is getCellRendererOrNull(int row, int column, boolean isScrolling), which is called whenever JSTableUI does not absolutely have to recreate a cell from scratch -- during scrolling particularly.
Author:
hansonr and others
See Also:
  • Field Details

  • Constructor Details

    • DataRowModel

      public DataRowModel()
      Constructor DataRowModel
  • Method Details

    • setStride

      public void setStride(int stride)
      Sets the stride between rows.
      Parameters:
      tableModel -
      stride -
    • setMaxPoints

      public void setMaxPoints(int max)
      Sets the maximum number of rows the data can hold
    • clear

      public void clear()
      Clear the data
    • appendRow

      public void appendRow(Object obj) throws IllegalArgumentException
      Appends a row to this table.
      Parameters:
      obj - Object
      Throws:
      IllegalArgumentException
    • setRowNumberVisible

      public boolean setRowNumberVisible(boolean vis)
      Sets the display row number flag. Table displays row number.
      Parameters:
      vis - true<\code> if table display row number
      Returns:
      true if table display changed
    • setColumnNames

      public boolean setColumnNames(int column, String name)
      Sets the column names in this table.
      Parameters:
      column - the column index
      name -
      Returns:
      true if name changed or added
    • setFirstRowIndex

      public void setFirstRowIndex(int index)
      Sets the first row's index.
      Parameters:
      index -
    • getColumnCount

      public int getColumnCount()
      Gets the number of columns being shown.
      Returns:
      the column count
    • getColumnName

      public String getColumnName(int column)
      Gets the name of the specified column.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
      Parameters:
      column - the column index
      Returns:
      the column name
    • getRowCount

      public int getRowCount()
      Gets the number of rows.
      Returns:
      the row count
    • getValueAt

      public Object getValueAt(int row, int column)
      Gets the value at the given cell.
      Parameters:
      row - the row index
      column - the column index
      Returns:
      the value
    • mustPaint

      public boolean mustPaint(int row, int column)