JAL-4134 - refactor tree calculation code to work with binaryNode base type.
[jalview.git] / src / jalview / analysis / AverageDistanceTree.java
index 9bf6742..760962e 100644 (file)
@@ -1,8 +1,28 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.analysis;
 
 import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
-import jalview.datamodel.SequenceNode;
+import jalview.datamodel.BinaryNode;
 import jalview.viewmodel.AlignmentViewport;
 
 /**
@@ -93,25 +113,25 @@ public class AverageDistanceTree extends TreeBuilder
    * {@inheritDoc}
    */
   @Override
-  protected void findNewDistances(SequenceNode nodei, SequenceNode nodej,
+  protected void findNewDistances(BinaryNode nodei, BinaryNode nodej,
           double dist)
   {
     double ih = 0;
     double jh = 0;
 
-    SequenceNode sni = nodei;
-    SequenceNode snj = nodej;
+    BinaryNode sni = nodei;
+    BinaryNode snj = nodej;
 
     while (sni != null)
     {
       ih = ih + sni.dist;
-      sni = (SequenceNode) sni.left();
+      sni = (BinaryNode) sni.left();
     }
 
     while (snj != null)
     {
       jh = jh + snj.dist;
-      snj = (SequenceNode) snj.left();
+      snj = (BinaryNode) snj.left();
     }
 
     nodei.dist = ((dist / 2) - ih);