computecolumn
Class TableAddFunctionColumn

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended bytableoperations.TableMap
          extended bycomputecolumn.TableAddFunctionColumn
All Implemented Interfaces:
EventListener, Serializable, TableModel, TableModelListener

public class TableAddFunctionColumn
extends TableMap

A Table to calculate a new column given a function and two column indexes. It Extends TableMap so it can be saved in a file.

Author:
Julien Robert
See Also:
Serialized Form

Field Summary
private  int fromColumn1
           
private  int fromColumn2
           
private  String fromFunction
           
 
Fields inherited from class tableoperations.TableMap
model
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableAddFunctionColumn(TableModel model, int column1, int column2, String function)
          Creates a new TableAddFunctionColumn given a model and two columns to compute with the function.
 
Method Summary
static double calculateWithFunction(String function, double a, double b)
          Computes the given function on both operands a and b.
 Class getColumnClass(int aColumn)
           
 int getColumnCount()
           
 String getColumnName(int aColumn)
           
 Object getValueAt(int aRow, int aColumn)
           
 boolean isCellEditable(int row, int column)
           
 void setValueAt(Object aValue, int aRow, int aColumn)
           
 
Methods inherited from class tableoperations.TableMap
getModel, getRowCount, setModel, tableChanged, writeToFileAsCsv
 
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
 

Field Detail

fromColumn1

private int fromColumn1

fromColumn2

private int fromColumn2

fromFunction

private String fromFunction
Constructor Detail

TableAddFunctionColumn

public TableAddFunctionColumn(TableModel model,
                              int column1,
                              int column2,
                              String function)
Creates a new TableAddFunctionColumn given a model and two columns to compute with the function.

Parameters:
model - the model TableModel
column1 - the index of the first column to compute from.
column2 - the index of the second column to compute from.
function - the string specifying the function to use.
Method Detail

calculateWithFunction

public static double calculateWithFunction(String function,
                                           double a,
                                           double b)
Computes the given function on both operands a and b.

Parameters:
function - the string which specifies the function to use
a - the first operand
b - the second operand
Returns:
the result of the function calculated with both operands

getColumnClass

public Class getColumnClass(int aColumn)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class TableMap
See Also:
TableModel.getColumnClass(int)

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel
Overrides:
getColumnCount in class TableMap
See Also:
TableModel.getColumnCount()

getColumnName

public String getColumnName(int aColumn)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class TableMap
See Also:
TableModel.getColumnName(int)

getValueAt

public Object getValueAt(int aRow,
                         int aColumn)
Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class TableMap
See Also:
TableModel.getValueAt(int, int)

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class TableMap
See Also:
TableModel.isCellEditable(int, int)

setValueAt

public void setValueAt(Object aValue,
                       int aRow,
                       int aColumn)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class TableMap
See Also:
TableModel.setValueAt(java.lang.Object, int, int)