Class UPGMA

java.lang.Object
  |
  +--Algorithm
        |
        +--UPGMA
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class UPGMA
extends Algorithm

This class implements UPGMA described in the package.


Field Summary
 
Fields inherited from class Algorithm
ansField, ansFrame, ansLabel, answer, count, display, infoArea, inputTable, interNode, interTable, maxLength, maxName, mini, minj, minLength, names, nodes, numOfNodes, numOfNodesLeft, okAnsButton, okQuesButton, phyTreesControls, popUpQues, quesFrame, quesLabel, question, random_i, random_j, roots, runType, treeDisplay
 
Constructor Summary
UPGMA(PTCControls inPhyTreesControls)
          Initializes specific GUI components used in the UPGMA algorithm.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Defines how to handle the actions of the OK buttons for the question and the answer windows in the UPGMA algorithm.
 java.lang.String buildAnswer()
          Generates the answers for the questions in the UPGMA algorithm.
 void calculateNewDistance()
          Implements the method in the Algorithm calss and defines how to calculate new distance matrix in the UPGMA algorithm.
 double findAndCalculate()
          Defines how to find the nodes to join and calculate branch lengths in the UPGMA algorithm.
 boolean findOne()
          Implements the method in the Algorithm class and indicates if one tree is found.
 void generateRandom_ij()
          Generates random numbers for pop up questions involved the new distance table in the UPGMA algorithm.
 double[][] getDistance()
          Gets the distance matrix used in the UPGMA algorithm.
 boolean init()
          Overrides the method in the Algorithm class and initializes specific data components used in the UPGMA algorithm.
 boolean isEnd()
          Implements the method in the Algorithm class and indicates if the algorithm terminates in the UPGMA algorithm.
 void join(double height)
          Defines how to join nodes in the UPGMA algorithm.
 void popUpQuestion()
          Generates pop up questions in the UPGMA algorithm.
 void process()
          Defines how to process in the UPGMA algorithm.
 void run()
          Implements the method in the Algorithm class and defines how to run the UPGMA algorithm.
 void trace()
          Implements the method in the Algorithm class and defines how to trace the UPGMA algorithm.
 void updateUI()
          Defines how to update the tree and the intermediate distance table in the UPGMA algorithm.
 
Methods inherited from class Algorithm
computeMaxName, computeMinMaxLength, constructAnsFrame, constructButton, constructQuesFrame, deleteNodes, findMin, getCount, getDisplay, getInterNode, getMaxLength, getMaxName, getMinLength, getNames, getNode, getNodes, getNumOfNodes, getNumOfNodesLeft, getRoots, randomInt, reset, setPopUpQues, setRoots, setRunType, setThreeFractionDigit, updateTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UPGMA

public UPGMA(PTCControls inPhyTreesControls)
Initializes specific GUI components used in the UPGMA algorithm.

Parameters:
inPhyTreesControls - the PTCControls object
Method Detail

getDistance

public double[][] getDistance()
Gets the distance matrix used in the UPGMA algorithm.

Returns:
the distance matrix used in the UPGMA algorithm

init

public boolean init()
Overrides the method in the Algorithm class and initializes specific data components used in the UPGMA algorithm.

Overrides:
init in class Algorithm
Returns:
true - the algorithm is properly initialized
false - input data is not right

trace

public void trace()
Implements the method in the Algorithm class and defines how to trace the UPGMA algorithm.

Specified by:
trace in class Algorithm

run

public void run()
Implements the method in the Algorithm class and defines how to run the UPGMA algorithm.

Specified by:
run in class Algorithm

process

public void process()
Defines how to process in the UPGMA algorithm.


findAndCalculate

public double findAndCalculate()
Defines how to find the nodes to join and calculate branch lengths in the UPGMA algorithm.

Returns:
the height of the tree

join

public void join(double height)
Defines how to join nodes in the UPGMA algorithm.


updateUI

public void updateUI()
Defines how to update the tree and the intermediate distance table in the UPGMA algorithm.


calculateNewDistance

public void calculateNewDistance()
Implements the method in the Algorithm calss and defines how to calculate new distance matrix in the UPGMA algorithm.

Specified by:
calculateNewDistance in class Algorithm

isEnd

public boolean isEnd()
Implements the method in the Algorithm class and indicates if the algorithm terminates in the UPGMA algorithm.

Specified by:
isEnd in class Algorithm
Returns:
true - the algorithm terminates
false - the algorithm does not terminate

findOne

public boolean findOne()
Implements the method in the Algorithm class and indicates if one tree is found.

Specified by:
findOne in class Algorithm
Returns:
false for the NJ algorithm

generateRandom_ij

public void generateRandom_ij()
Generates random numbers for pop up questions involved the new distance table in the UPGMA algorithm.


popUpQuestion

public void popUpQuestion()
Generates pop up questions in the UPGMA algorithm.


buildAnswer

public java.lang.String buildAnswer()
Generates the answers for the questions in the UPGMA algorithm.

Returns:
the answer

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Defines how to handle the actions of the OK buttons for the question and the answer windows in the UPGMA algorithm.

Parameters:
e - the ActionEvent object which is responsible for the action