Class InputCharacterModel

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

public class InputCharacterModel
extends InputModel

This class is used to set the inpute character table data in the MP algorithm

See Also:
Serialized Form

Field Summary
 
Fields inherited from class InputModel
count, names
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
InputCharacterModel(int inCount, int inNumOfSites, java.lang.String[] inNames)
          Constructs the empty table for users' input in the MP algorithm.
InputCharacterModel(int inCount, int inNumOfSites, java.lang.String[] inNames, java.lang.Object[][] inCharacters)
          Constructs the data with specified values in the MP algorithm.
 
Method Summary
 boolean checkInput(javax.swing.JFrame frame)
          Checks users' input data in the MP algorithm.
 java.lang.String[][] getCharacters()
          Converts the users input to characters array.
 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.
 int getNumOfSites()
          Gets the number of the sites in the MP algorithm.
 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.
 void saveInputToFile(java.lang.String fileName)
          Saves the input data to a file in the MP algorithm.
 void setCharacters(java.lang.String[][] inCharacters)
          Sets the character data in the MP algorithm.
 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, isCellEditable, 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

InputCharacterModel

public InputCharacterModel(int inCount,
                           int inNumOfSites,
                           java.lang.String[] inNames,
                           java.lang.Object[][] inCharacters)
Constructs the data with specified values in the MP algorithm.

Parameters:
inCount - the number of species in the MP algorithm
inNumOfSites - the number of sites in the MP algorithm
inNames - the species's names in the MP algorithm
inCharacters - the characters in the MP algorithm

InputCharacterModel

public InputCharacterModel(int inCount,
                           int inNumOfSites,
                           java.lang.String[] inNames)
Constructs the empty table for users' input in the MP algorithm.

Parameters:
inCount - the number of species in the MP algorithm
inNumOfSites - the number of sites in the MP algorithm
inNames - the species's names in the MP algorithm
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

getCharacters

public java.lang.String[][] getCharacters()
Converts the users input to characters array.

Returns:
the users input in characters array

getNumOfSites

public int getNumOfSites()
Gets the number of the sites in the MP algorithm.

Returns:
the number of sites

setCharacters

public void setCharacters(java.lang.String[][] inCharacters)
Sets the character data in the MP algorithm.

Parameters:
inCharacters - the character data to be set

checkInput

public boolean checkInput(javax.swing.JFrame frame)
Checks users' input data in the MP algorithm.

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 MP algorithm.

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