JAL-4134 - brutal hack to build a tree clustering columns of PAE Matrix
[jalview.git] / src / jalview / analysis / TreeModel.java
index 703702a..1725adc 100644 (file)
@@ -51,7 +51,7 @@ public class TreeModel
 
   int noseqs;
 
-  SequenceNode top;
+  BinaryNode top;
 
   double maxDistValue;
 
@@ -59,7 +59,7 @@ public class TreeModel
 
   int ycount;
 
-  Vector<SequenceNode> node;
+  Vector<BinaryNode> node;
 
   boolean hasDistances = true; // normal case for jalview trees
 
@@ -81,7 +81,7 @@ public class TreeModel
   public TreeModel(SequenceI[] seqs, AlignmentView odata,
           NewickFile treefile)
   {
-    this(seqs, treefile.getTree(), treefile.HasDistances(),
+    this(seqs, (SequenceNode) treefile.getTree(), treefile.HasDistances(),
             treefile.HasBootstrap(), treefile.HasRootDistance());
     seqData = odata;
 
@@ -129,7 +129,7 @@ public class TreeModel
   {
     SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
 
-    Vector<SequenceNode> leaves = findLeaves(top);
+    Vector<BinaryNode> leaves = findLeaves(top);
 
     int i = 0;
     int namesleft = seqs.length;
@@ -141,7 +141,8 @@ public class TreeModel
     // int countOne2Many = 0;
     while (i < leaves.size())
     {
-      j = leaves.elementAt(i++);
+      // TODO - decide if we get rid of the polymorphism here ?
+      j = (SequenceNode)leaves.elementAt(i++);
       realnam = j.getName();
       nam = null;
 
@@ -206,7 +207,7 @@ public class TreeModel
    */
   public void updatePlaceHolders(List<SequenceI> list)
   {
-    Vector<SequenceNode> leaves = findLeaves(top);
+    Vector<BinaryNode> leaves = findLeaves(top);
 
     int sz = leaves.size();
     SequenceIdMatcher seqmatcher = null;
@@ -214,7 +215,7 @@ public class TreeModel
 
     while (i < sz)
     {
-      SequenceNode leaf = leaves.elementAt(i++);
+      SequenceNode leaf = (SequenceNode) leaves.elementAt(i++);
 
       if (list.contains(leaf.element()))
       {
@@ -289,15 +290,15 @@ public class TreeModel
   /**
    * Search for leaf nodes below (or at) the given node
    * 
-   * @param nd
+   * @param top2
    *          root node to search from
    * 
    * @return
    */
-  public Vector<SequenceNode> findLeaves(SequenceNode nd)
+  public Vector<BinaryNode> findLeaves(BinaryNode top2)
   {
-    Vector<SequenceNode> leaves = new Vector<SequenceNode>();
-    findLeaves(nd, leaves);
+    Vector<BinaryNode> leaves = new Vector<BinaryNode>();
+    findLeaves(top2, leaves);
     return leaves;
   }
 
@@ -311,8 +312,8 @@ public class TreeModel
    * 
    * @return Vector of leaf nodes on binary tree
    */
-  Vector<SequenceNode> findLeaves(SequenceNode nd,
-          Vector<SequenceNode> leaves)
+  Vector<BinaryNode> findLeaves(BinaryNode nd,
+          Vector<BinaryNode> leaves)
   {
     if (nd == null)
     {
@@ -388,14 +389,14 @@ public class TreeModel
    * @param threshold
    * @see #getGroups()
    */
-  public List<SequenceNode> groupNodes(float threshold)
+  public List<BinaryNode> groupNodes(float threshold)
   {
-    List<SequenceNode> groups = new ArrayList<SequenceNode>();
+    List<BinaryNode> groups = new ArrayList<BinaryNode>();
     _groupNodes(groups, getTopNode(), threshold);
     return groups;
   }
 
-  protected void _groupNodes(List<SequenceNode> groups, SequenceNode nd,
+  protected void _groupNodes(List<BinaryNode> groups, BinaryNode nd,
           float threshold)
   {
     if (nd == null)
@@ -630,7 +631,7 @@ public class TreeModel
    * 
    * @return DOCUMENT ME!
    */
-  public SequenceNode getTopNode()
+  public BinaryNode getTopNode()
   {
     return top;
   }
@@ -665,7 +666,7 @@ public class TreeModel
    */
   public void applyToNodes(NodeTransformI nodeTransformI)
   {
-    for (Enumeration<SequenceNode> nodes = node.elements(); nodes
+    for (Enumeration<BinaryNode> nodes = node.elements(); nodes
             .hasMoreElements(); nodeTransformI
                     .transform(nodes.nextElement()))
     {