Class DataToolTable

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class DataToolTable extends DataTable
This is a DataTable that displays DataColumns and constructs HighlightableDatasets for a plot.
Version:
1.0
Author:
Douglas Brown
See Also:
  • Field Details

  • Constructor Details

    • DataToolTable

      public DataToolTable(DataToolTab tab)
      Constructs a DataToolTable for the specified DataTooltab.
      Parameters:
      tab -
  • Method Details

    • createTableModel

      protected DataTable.OSPDataTableModel createTableModel()
      Description copied from class: DataTable
      Overridden in DataToolTable in order to use its own implementation of OSPDataTableModel
      Overrides:
      createTableModel in class DataTable
      Returns:
    • updateRowSelection

      protected void updateRowSelection(int firstIndex, boolean isAdjusting)
      Description copied from class: DataTable
      Overridden in DataToolTable
      Overrides:
      updateRowSelection in class DataTable
    • doTableMousePressed

      protected void doTableMousePressed(MouseEvent e)
    • doHeaderMouseClicked

      protected void doHeaderMouseClicked(MouseEvent e)
    • createHeaderPopup

      protected void createHeaderPopup(int col)
    • dorepaint

      protected void dorepaint(int i)
    • getWorkingData

      protected org.opensourcephysics.tools.DataToolTable.WorkingDataset getWorkingData(String colName)
      Gets the working data for a specified column name. The working y-data is the named table column. The working x-data is the x (yellow) table column
      Parameters:
      colName - the name of the data column
      Returns:
      the working dataset
    • getWorkingData

      protected org.opensourcephysics.tools.DataToolTable.WorkingDataset getWorkingData()
      Gets the working data: first two data columns in x-y order
      Returns:
      the working dataset
    • removeWorkingData

      protected void removeWorkingData(String colName)
      Removes the working data for a specified column name.
      Parameters:
      colName - the name of the data column
    • deleteSelectedColumns

      protected void deleteSelectedColumns(boolean postEdit)
      Deletes the selected columns
      Parameters:
      postEdit - true to post an undoable edit
    • clearWorkingData

      protected void clearWorkingData()
      Clears the working data.
    • getDataset

      protected Dataset getDataset(String colName)
      Gets the source dataset associated with table column name.
      Parameters:
      colName - the column name
      Returns:
      the dataset
    • getSelectedData

      protected HighlightableDataset getSelectedData()
      Gets the selected data. The returned dataset consists of the selected rows in the first two columns of the table in x-y order. This also sets the highlights of the working data and populates the workingRows map.
      Returns:
      the data in the selected rows, or all data if no rows are selected
    • getSelectedColumnNames

      protected ArrayList<String> getSelectedColumnNames()
      Gets the selected column names.
      Returns:
      ArrayList of selected column names
    • setSelectedColumnNames

      protected void setSelectedColumnNames(Collection<String> names)
      Sets the selected column names.
      Parameters:
      names - Collection of column names to select
    • insertColumn

      protected void insertColumn(Dataset data, int col)
      Inserts a column dataset.
      Parameters:
      data - the dataset to insert
      col - the insertion view column number
    • deleteColumn

      protected Dataset deleteColumn(String colName)
      Deletes a column.
      Parameters:
      colName - the column name to delete
      Returns:
      the deleted dataset
    • insertCells

      protected HashMap<String,double[]> insertCells(int[] rows, HashMap<String,double[]> values)
      Inserts cells with values specified by column name. Existing cells are shifted down and other columns are padded with NaN at the end if needed.
      Parameters:
      rows - the model rows to insert
      values - HashMap of column name to double[] values
      Returns:
      HashMap of column name to double[] inserted values
    • deleteCells

      protected HashMap<String,double[]> deleteCells(int[] rows, HashMap<String,double[]> values)
      Deletes cells in a column. Remaining cells are shifted up.
      Parameters:
      rows - the model rows to delete
      values - HashMap of column name to (ignored) double[] values
      Returns:
      HashMap of column name to double[] deleted values
    • replaceCells

      protected HashMap<String,double[]> replaceCells(int[] rows, HashMap<String,double[]> values)
      Replaces cells.
      Parameters:
      rows - the model rows to replace in ascending order
      values - HashMap of column name to double[] new values
      Returns:
      HashMap of column name to double[] old values
    • insertRows

      protected HashMap<String,double[]> insertRows(int[] rows, HashMap<String,double[]> values)
      Inserts rows with values specified by column name. Unspecified values are set to NaN.
      Parameters:
      rows - the model rows to insert
      values - HashMap of column name to double[] values
      Returns:
      HashMap of column name to double[] inserted values
    • deleteRows

      protected HashMap<String,double[]> deleteRows(int[] rows)
      Deletes rows.
      Parameters:
      rows - the model rows to delete
      Returns:
      the deleted values
    • isEmptyRow

      protected boolean isEmptyRow(int row)
      Determines if a row is empty.
      Parameters:
      row - the model row number
      Returns:
      true if all datasets are NaN at row index
    • isEmptyCells

      protected boolean isEmptyCells(int row, ArrayList<String> columnNames)
      Determines if a row is empty.
      Parameters:
      row - the model row number
      columnNames - a list of column names
      Returns:
      true if all named columns are NaN at row index
    • getXColumn

      protected int getXColumn()
      Gets the x-axis view column.
      Returns:
      col the view column number
    • getYColumn

      protected int getYColumn()
      Gets the y-axis view column.
      Returns:
      col the view column number
    • replacePoints

      protected double[] replacePoints(Dataset dataset, int[] rows, double[] vals)
      Replaces points in a dataset.
      Parameters:
      dataset - the dataset
      rows - the rows to replace in ascending order
      vals - array of new y-values
      Returns:
      array of values replaced
    • insertPoints

      protected double[] insertPoints(Dataset dataset, int[] rows, double[] vals)
      Inserts points into a dataset.
      Parameters:
      dataset - the dataset
      rows - the rows to insert in ascending order
      vals - the corresponding y-values to insert
      Returns:
      array of values inserted
    • deletePoints

      protected double[] deletePoints(Dataset dataset, int[] rows)
      Deletes points from a dataset.
      Parameters:
      dataset - the dataset
      rows - the rows to remove in ascending order
      Returns:
      the removed y-values
    • trimEmptyRows

      protected boolean trimEmptyRows(int minSize)
      Trims empty rows from bottom of table up to a specified minimum.
      Parameters:
      minSize - the minimum row count to keep
      Returns:
      true if one or mmore rows were trimmed
    • clearSelectionIfEmptyEndRow

      protected void clearSelectionIfEmptyEndRow()
      Clears the selection if it consists of only an empty end row.
    • showDataBuilder

      protected void showDataBuilder()
      Displays the data builder.
    • renameColumn

      protected void renameColumn(String oldName, String newName)
      Renames a column.
      Parameters:
      oldName - the old name
      newName - the new name
    • refreshUndoItems

      protected void refreshUndoItems()
      Refreshes the undo and redo menu items.
    • refreshDataFunctions

      public void refreshDataFunctions()
      Refreshes the data functions.
    • selectAllCells

      public void selectAllCells()
      Selects all cells in the table.
    • clearSelection

      public void clearSelection()
      Deselects all selected columns and rows. Overrides JTable method.
      Overrides:
      clearSelection in class JTable
    • refreshTable

      public void refreshTable(int mode)
      Refreshes the data in the table. Overrides DataTable method.
      Overrides:
      refreshTable in class DataTable
    • getFormatDialog

      public DataTable.NumberFormatDialog getFormatDialog(String[] names, String[] selected)
      Description copied from class: DataTable
      Gets the format setter dialog.
      Overrides:
      getFormatDialog in class DataTable
      Parameters:
      names - the column name choices
      selected - the initially selected names
      Returns:
      the format setter dialog
    • getHiddenMarkers

      public String[] getHiddenMarkers()
      Gets the names of columns with visible markers.
      Returns:
      array of column names
    • hideMarkers

      public void hideMarkers(String[] hiddenColumns)
      Hides markers of named columns.
      Parameters:
      hiddenColumns - names of columns with hidden markers
    • setWorkingColumns

      public void setWorkingColumns(String xColName, String yColName)
      Sets the working columns by name.
      Parameters:
      xColName - the name of the horizontal axis variable
      yColName - the name of the vertical axis variable
    • setFont

      public void setFont(Font font)
      Overrides:
      setFont in class JComponent
    • getCellRenderer

      public TableCellRenderer getCellRenderer(int row, int col)
      Overrides DataTable getCellRenderer() method.
      Overrides:
      getCellRenderer in class DataTable
      Parameters:
      row - the row number
      col - the column number
      Returns:
      the cell editor
    • getCellEditor

      public TableCellEditor getCellEditor(int row, int col)
      Returns the editor for a cell specified by row and column.
      Overrides:
      getCellEditor in class JTable
      Parameters:
      row - the row number
      col - the column number
      Returns:
      the cell editor
    • isFitFittable

      public boolean isFitFittable(KnownFunction fit, boolean allowNone)
    • moveColumn

      public void moveColumn(String var, int col)