de.unihalle.informatik.MiToBo.gui
Class MTBTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by javax.swing.table.DefaultTableModel
          extended by de.unihalle.informatik.MiToBo.gui.MTBTableModel
All Implemented Interfaces:
Serializable, TableModel
Direct Known Subclasses:
Mica2DTableModel

public class MTBTableModel
extends DefaultTableModel

Table model for MiToBo data tables.

The class implements a table model for data results in MiToBo. One main feature is the dynamic reallocation of memory when inserting new data. Objects of this class can be integrated in graphical user interfaces by using class MTBTableWindow.

Author:
moeller
See Also:
Serialized Form

Field Summary
protected  int cols
          Number of columns of the table.
protected  Object[][] data
          The data contained in the table.
protected  de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDTableWindow.TableModelDelimiter delimiter
          Delimiter to be used when exporting the model.
protected  Vector<String> headerStrings
          Header defines.
protected  int rows
          Number of rows of the table.
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
MTBTableModel(int r, int c)
          Default constructor.
MTBTableModel(int r, int c, Vector<String> headers)
          Constructor with given header strings.
 
Method Summary
 void clear()
          Deletes all(!)
 int getColumnCount()
           
 String getColumnName(int col)
           
 de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDTableWindow.TableModelDelimiter getDelimiter()
          Returns the currently chosen delimiter.
 int getRowCount()
           
 Object getValueAt(int row, int col)
           
 void insertData(Vector<Object[]> resultData)
          Appends a set of results to the table, i.e. adds a new row at the end.
 void saveTable(File file)
          Saves the contents of the table to given file, TSV format.
 void setColumnName(int col, String name)
          Sets the header of column to specified string.
 void setDelimiter(de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDTableWindow.TableModelDelimiter delim)
          Configure the delimiter to be used when exporting the table.
 void setValueAt(Object o, int row, int col)
           
 StringBuffer[] tableToString()
          Converts the contents of the table to a string array in CSV format (suitable for import in Excel).
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getDataVector, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rows

protected int rows
Number of rows of the table.


cols

protected int cols
Number of columns of the table.


data

protected Object[][] data
The data contained in the table.


delimiter

protected de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDTableWindow.TableModelDelimiter delimiter
Delimiter to be used when exporting the model.


headerStrings

protected Vector<String> headerStrings
Header defines.

Constructor Detail

MTBTableModel

public MTBTableModel(int r,
                     int c)
Default constructor.

Parameters:
r - Initial number of rows.
c - Initial number of columns.

MTBTableModel

public MTBTableModel(int r,
                     int c,
                     Vector<String> headers)
Constructor with given header strings.

Parameters:
r - Initial number of rows.
c - Initial number of cols.
headers - Header strings.
Method Detail

setDelimiter

public void setDelimiter(de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDTableWindow.TableModelDelimiter delim)
Configure the delimiter to be used when exporting the table.

Parameters:
delim - Delimiter type to use.

getDelimiter

public de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDTableWindow.TableModelDelimiter getDelimiter()
Returns the currently chosen delimiter.

Returns:
Delimiter for table export.

getColumnName

public String getColumnName(int col)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class DefaultTableModel

setColumnName

public void setColumnName(int col,
                          String name)
Sets the header of column to specified string.

Parameters:
col - Index of column.
name - New title string.

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel
Overrides:
getColumnCount in class DefaultTableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel
Overrides:
getRowCount in class DefaultTableModel

getValueAt

public Object getValueAt(int row,
                         int col)
Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class DefaultTableModel

setValueAt

public void setValueAt(Object o,
                       int row,
                       int col)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class DefaultTableModel

insertData

public void insertData(Vector<Object[]> resultData)
Appends a set of results to the table, i.e. adds a new row at the end.

Parameters:
resultData - Result data to be appended.

clear

public void clear()
Deletes all(!) data inside the table and resets size.


saveTable

public void saveTable(File file)
Saves the contents of the table to given file, TSV format.


tableToString

public StringBuffer[] tableToString()
Converts the contents of the table to a string array in CSV format (suitable for import in Excel).

For separating the columns the formerly configured delimiter is used, e.g., tabulators or just spaces.

Returns:
Array with contents of table (arranged line-wise).


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.