org.knime.base.node.io.tablecreator.table
Class SpreadsheetTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.knime.base.node.io.tablecreator.table.SpreadsheetTableModel
All Implemented Interfaces:
Serializable, TableModel

 class SpreadsheetTableModel
extends AbstractTableModel

The table model of a spreadsheet.

Author:
Heiko Hofer

Nested Class Summary
(package private) static class SpreadsheetTableModel.IntPair
          Class to encapsulate the row and column index of a cell in a table.
 
Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SpreadsheetTableModel()
          Create new instance.
 
Method Summary
 void addColProperties(Map<Integer,ColProperty> map)
          Adds {link ColProperty objects to this model.
 void addValues(Map<SpreadsheetTableModel.IntPair,Cell> tableValues)
          Add values to the table.
 void deleteColumns(int[] cols)
          Deletes the columns.
 void deleteRows(int[] rows)
          Delete rows.
 Class<?> getColumnClass(int columnIndex)
          
 int getColumnCount()
          
(package private)  int[] getColumnIndices()
          see getValues();
 String getColumnName(int columnIndex)
          
(package private)  SortedMap<Integer,ColProperty> getColumnProperties()
          Returns a mapping of column index to the {ColProperty} of the column.
 int getMaxColumn()
          Returns the maximal column index of the filled area
 int getMaxRow()
          Returns the maximal row index of the filled area
 int getRowCount()
          
(package private)  int[] getRowIndices()
          see getValues();
(package private)  Map<SpreadsheetTableModel.IntPair,Cell> getTableValues()
          Getter for the table values.
 Object getValueAt(int rowIndex, int columnIndex)
          
(package private)  String[] getValues()
          Use in combination with getRowIndices and getColumnIndices.
 void insertColumns(int[] cols)
          Add columns with default properties.
 void insertRows(int[] rows)
          Insert empty rows.
 boolean isCellEditable(int rowIndex, int columnIndex)
          
 void setColProperty(int colIdx, ColProperty colProperty)
           
 void setData(Map<Integer,ColProperty> columnProperties, int[] rowIndices, int[] columnIndices, String[] values)
          Replace the data of the table model by the given settings.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpreadsheetTableModel

public SpreadsheetTableModel()
Create new instance.

Method Detail

setData

public void setData(Map<Integer,ColProperty> columnProperties,
                    int[] rowIndices,
                    int[] columnIndices,
                    String[] values)
Replace the data of the table model by the given settings.

Parameters:
columnProperties - the properties of column
rowIndices - the row indices
columnIndices - the column indices
values - the values at the given row and column indices

getColumnProperties

SortedMap<Integer,ColProperty> getColumnProperties()
Returns a mapping of column index to the {ColProperty} of the column. The mapping must not exist for every column.

Returns:
a mapping of column index to the {ColProperty} of the column

getRowIndices

int[] getRowIndices()
see getValues();

Returns:
row indices populated with data

getColumnIndices

int[] getColumnIndices()
see getValues();

Returns:
column indices populated with data

getValues

String[] getValues()
Use in combination with getRowIndices and getColumnIndices. Together with this method you will three arrays which are a sparse representation of the tables data.

Returns:
the table data.

getColumnClass

public Class<?> getColumnClass(int columnIndex)

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getColumnCount

public int getColumnCount()


setColProperty

public void setColProperty(int colIdx,
                           ColProperty colProperty)
Parameters:
colIdx -
colProperty -

addColProperties

public void addColProperties(Map<Integer,ColProperty> map)
Adds {link ColProperty objects to this model.

Parameters:
map - {link ColProperty objects

getColumnName

public String getColumnName(int columnIndex)

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getRowCount

public int getRowCount()


getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)


isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

addValues

public void addValues(Map<SpreadsheetTableModel.IntPair,Cell> tableValues)
Add values to the table.

Parameters:
tableValues - the values and their position

deleteColumns

public void deleteColumns(int[] cols)
Deletes the columns.

Parameters:
cols - the indices of the columns to delete.

insertColumns

public void insertColumns(int[] cols)
Add columns with default properties.

Parameters:
cols - the indices to insert columns

deleteRows

public void deleteRows(int[] rows)
Delete rows.

Parameters:
rows - the indices of the rows to delete.

insertRows

public void insertRows(int[] rows)
Insert empty rows.

Parameters:
rows - the indices to insert empty rows.

getMaxRow

public int getMaxRow()
Returns the maximal row index of the filled area

Returns:
the maximal row index of the filled area

getMaxColumn

public int getMaxColumn()
Returns the maximal column index of the filled area

Returns:
the maximal column index of the filled area

getTableValues

Map<SpreadsheetTableModel.IntPair,Cell> getTableValues()
Getter for the table values.

Returns:
the table values


Copyright, 2003 - 2012. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.