JAL-1551 spotlessApply
[jalview.git] / src / jalview / datamodel / BinaryNode.java
index 7012d3b..5b55594 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -20,6 +20,8 @@
  */
 package jalview.datamodel;
 
+import java.awt.Color;
+
 /**
  * DOCUMENT ME!
  * 
@@ -38,9 +40,27 @@ public class BinaryNode
 
   BinaryNode parent;
 
-  /** DOCUMENT ME!! */
+  /** Bootstrap value */
   public int bootstrap;
 
+  /** DOCUMENT ME!! */
+  public double dist;
+
+  /** DOCUMENT ME!! */
+  public int count;
+
+  /** DOCUMENT ME!! */
+  public double height;
+
+  /** DOCUMENT ME!! */
+  public float ycount;
+
+  /** DOCUMENT ME!! */
+  public Color color = Color.black;
+
+  /** DOCUMENT ME!! */
+  public boolean dummy = false;
+
   /**
    * Creates a new BinaryNode object.
    */
@@ -48,6 +68,7 @@ public class BinaryNode
   {
     left = right = parent = null;
     bootstrap = 0;
+    dist = 0;
   }
 
   /**
@@ -60,13 +81,28 @@ public class BinaryNode
    * @param name
    *          DOCUMENT ME!
    */
-  public BinaryNode(Object element, BinaryNode parent, String name)
+  public BinaryNode(Object element, BinaryNode parent, String name,
+          double dist)
   {
+    this();
     this.element = element;
     this.parent = parent;
     this.name = name;
+    this.dist = dist;
+  }
+
+  public BinaryNode(Object element, BinaryNode parent, String name,
+          double dist, int bootstrap)
+  {
+    this(element, parent, name, dist);
+    this.bootstrap = bootstrap;
+  }
 
-    left = right = null;
+  public BinaryNode(Object val, BinaryNode parent, String name, double dist,
+          int bootstrap, boolean dummy)
+  {
+    this(val, parent, name, dist, bootstrap);
+    this.dummy = dummy;
   }
 
   /**
@@ -263,7 +299,8 @@ public class BinaryNode
    * 
    * set the display name
    * 
-   * @param new name
+   * @param new
+   *          name
    */
   public void setName(String name)
   {
@@ -299,4 +336,45 @@ public class BinaryNode
   {
     return bootstrap;
   }
+
+  /**
+   * @param dummy
+   *          true if node is created for the representation of polytomous trees
+   */
+  public boolean isDummy()
+  {
+    return dummy;
+  }
+
+  /**
+   * DOCUMENT ME!
+   * 
+   * @param newstate
+   *          DOCUMENT ME!
+   * 
+   * @return DOCUMENT ME!
+   */
+  public boolean setDummy(boolean newstate)
+  {
+    boolean oldstate = dummy;
+    dummy = newstate;
+
+    return oldstate;
+  }
+
+  /**
+   * ascends the tree but doesn't stop until a non-dummy node is discovered.
+   * 
+   */
+  public BinaryNode AscendTree()
+  {
+    BinaryNode c = this;
+
+    do
+    {
+      c = c.parent();
+    } while ((c != null) && c.dummy);
+
+    return c;
+  }
 }