phenote.matrix.model
Class MatrixController

java.lang.Object
  extended by phenote.matrix.model.MatrixController

public class MatrixController
extends java.lang.Object


Constructor Summary
MatrixController()
          Creates a new matrix controller
 
Method Summary
 void buildColumns()
          Traverses the character list and extracts the entity, quality, and additional entity from each one.
 void buildMatrix()
          Gets the current list of characters and calls methods to build the rows and columns of the matrix
 void buildRows()
          Traverses the character list and extracts the valid taxon from each one.
 java.lang.String getColumnHeader(int index)
           
 java.util.ArrayList<MatrixColumn> getColumns()
           
 int getNumColumns()
           
 int getNumRows()
           
 java.util.ArrayList<MatrixRow> getRows()
           
 java.lang.Object getValueAt(int rowIndex, int colIndex)
          This method iterates through each character in the main data list and checks to see if it is a valid character for the given row and given column in the matrix.
 void initializeVars()
          Creates new instances of all instance variables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixController

public MatrixController()
Creates a new matrix controller

Method Detail

initializeVars

public void initializeVars()
Creates new instances of all instance variables


buildMatrix

public void buildMatrix()
                 throws CharFieldException
Gets the current list of characters and calls methods to build the rows and columns of the matrix

Throws:
CharFieldException

buildRows

public void buildRows()
Traverses the character list and extracts the valid taxon from each one. Each taxon is made into a PhenotypeMatrixRow object, and that object is put into a Set, assuring that there will be no duplicates. Once the set is complete, each element of the set is added to an ArrayList. (This was done to maintain compatibility with other parts of the code that expected the rows to be stored in an ArrayList; it probably could be refactored to use the Set and eliminate the ArrayList entirely.)


buildColumns

public void buildColumns()
Traverses the character list and extracts the entity, quality, and additional entity from each one. The resulting tuple is made into a PhenotypeMatrixColumn object, and that object is put into a Set, assuring that there will be no duplicates. Once the set is complete, each element of the set is added to an ArrayList. (This was done to maintain compatibility with other parts of the code that expected the columns to be stored in an ArrayList; it probably could be refactored to use the Set and eliminate the ArrayList entirely.)


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int colIndex)
This method iterates through each character in the main data list and checks to see if it is a valid character for the given row and given column in the matrix. Once it finds a match, it uses the getValue() method from PhenotypeMatrixColumn class to create a new PhenotypeMatrixCell object, and returns it.

Parameters:
rowIndex - the number of the row being requested
colIndex - the number of the column being requested
Returns:
an Object (actually the PhenotypeMatrixCell) representing the contents of the matrix at the requested location

getColumnHeader

public java.lang.String getColumnHeader(int index)
Parameters:
index - the index of the column whose header is being requested
Returns:
a String representing the name of the requested column

getNumRows

public int getNumRows()
Returns:
the number of rows in the current matrix

getNumColumns

public int getNumColumns()
Returns:
the number of columns in the current matrix

getRows

public java.util.ArrayList<MatrixRow> getRows()
Returns:
an ArrayList describing the rows of the matrix

getColumns

public java.util.ArrayList<MatrixColumn> getColumns()
Returns:
an ArrayList describing the columns of the matrix