Class InputDistanceModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--InputModel
              |
              +--InputDistanceModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class InputDistanceModel
extends InputModel

This class is used to set the inpute distance table data in the distance based algorithms

See Also:
Serialized Form

Field Summary
 
Fields inherited from class InputModel
count, names
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
InputDistanceModel(int inCount, java.lang.String[] inNames)
          Constructs the empty table for users' input in the distance based algorithms.
InputDistanceModel(int inCount, java.lang.String[] inNames, java.lang.Object[][] inDistance)
          Constructs the data with specified values in the distance based algorithms.
 
Method Summary
 boolean checkInput(javax.swing.JFrame frame)
          Checks users' input data in the distance based algorithms
 int getColumnCount()
          Overrides the method in the TableModel class and returns the column count of the table.
 java.lang.String getColumnName(int columnIndex)
          Overrides the method in the TableModel class and returns the column names of the table.
 double[][] getDistance()
          Converts the users input to double array
 int getRowCount()
          Overrides the method in the TableModel class and returns the row count of the table.
 java.lang.Object getValueAt(int row, int col)
          Overrides the method in the TableModel class and returns the value of each table cell.
 boolean isCellEditable(int row, int col)
          Overrides the method in the InputModel class and sets if the cell can be edited.
 void saveInputToFile(java.lang.String fileName)
          Saves the input data to a file in the distance based algorithms
 void setDistance(java.lang.Object[][] inDistance)
          Sets the distance data in the distance based algorithms
 void setValueAt(java.lang.Object value, int row, int col)
          Overrides the method in the TableModel class and sets the table cell values.
 
Methods inherited from class InputModel
getCount, getNames, space
 
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
 

Constructor Detail

InputDistanceModel

public InputDistanceModel(int inCount,
                          java.lang.String[] inNames,
                          java.lang.Object[][] inDistance)
Constructs the data with specified values in the distance based algorithms.

Parameters:
inCount - the number of species in the distance based algorithms
inNames - the species's names in the distance based algorithms
inDistance - the distance in the distance based algorithms

InputDistanceModel

public InputDistanceModel(int inCount,
                          java.lang.String[] inNames)
Constructs the empty table for users' input in the distance based algorithms.

Parameters:
inCount - the number of species in the distance based algorithms
inNames - the species's names in the distance based algorithms
Method Detail

getColumnCount

public int getColumnCount()
Overrides the method in the TableModel class and returns the column count of the table.

Returns:
the column count of the table

getRowCount

public int getRowCount()
Overrides the method in the TableModel class and returns the row count of the table.

Returns:
the row count of the table

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Overrides the method in the TableModel class and returns the value of each table cell.

Parameters:
row - the row whose value is to be queried
col - the column whose value is to be queried
Returns:
the value Object at the specified cell

getColumnName

public java.lang.String getColumnName(int columnIndex)
Overrides the method in the TableModel class and returns the column names of the table.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of the column
Returns:
the name of the column

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Overrides the method in the TableModel class and sets the table cell values. Values other than A, C, G, T will not be accepted.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
value - the new value
row - the row whose value is to be changed
col - the column whose value is to be changed

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Overrides the method in the InputModel class and sets if the cell can be edited.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class InputModel
Parameters:
row - the row whose value to be queried
col - the column whose value to be queried

getDistance

public double[][] getDistance()
Converts the users input to double array

Returns:
the users input in double array

setDistance

public void setDistance(java.lang.Object[][] inDistance)
Sets the distance data in the distance based algorithms

Parameters:
inDistance - the distance data to be set

checkInput

public boolean checkInput(javax.swing.JFrame frame)
Checks users' input data in the distance based algorithms

Specified by:
checkInput in class InputModel
Returns:
true - if the data do not contain errors
false - if the data contain any errors

saveInputToFile

public void saveInputToFile(java.lang.String fileName)
Saves the input data to a file in the distance based algorithms

Specified by:
saveInputToFile in class InputModel
Parameters:
fileName - the name of the file to be saved