Formatting
[jalview.git] / src / jalview / datamodel / BinaryNode.java
index 850730b..a7e8254 100755 (executable)
-/*
-* Jalview - A Sequence Alignment Editor and Viewer
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
-*
-* This program 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 2
-* of the License, or (at your option) any later version.
-*
-* This program 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 this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
-*/\r
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
 package jalview.datamodel;\r
 \r
-public class BinaryNode {\r
-    Object element;\r
-    String name;\r
-    BinaryNode left;\r
-    BinaryNode right;\r
-    BinaryNode parent;\r
-    public int bootstrap;\r
-\r
-    public BinaryNode() {\r
-        left = right = parent = null;\r
-        bootstrap = 0;\r
-    }\r
+/**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @author $author$\r
+ * @version $Revision$\r
+ */\r
+public class BinaryNode\r
+{\r
+  Object element;\r
+  String name;\r
+  BinaryNode left;\r
+  BinaryNode right;\r
+  BinaryNode parent;\r
 \r
-    public BinaryNode(Object element, BinaryNode parent, String name) {\r
-        this.element = element;\r
-        this.parent = parent;\r
-        this.name = name;\r
+  /** DOCUMENT ME!! */\r
+  public int bootstrap;\r
 \r
-        left = right = null;\r
-    }\r
+  /**\r
+   * Creates a new BinaryNode object.\r
+   */\r
+  public BinaryNode()\r
+  {\r
+    left = right = parent = null;\r
+    bootstrap = 0;\r
+  }\r
 \r
-    public Object element() {\r
-        return element;\r
-    }\r
+  /**\r
+   * Creates a new BinaryNode object.\r
+   *\r
+   * @param element DOCUMENT ME!\r
+   * @param parent DOCUMENT ME!\r
+   * @param name DOCUMENT ME!\r
+   */\r
+  public BinaryNode(Object element, BinaryNode parent, String name)\r
+  {\r
+    this.element = element;\r
+    this.parent = parent;\r
+    this.name = name;\r
 \r
-    public Object setElement(Object v) {\r
-        return element = v;\r
-    }\r
+    left = right = null;\r
+  }\r
 \r
-    public BinaryNode left() {\r
-        return left;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public Object element()\r
+  {\r
+    return element;\r
+  }\r
 \r
-    public BinaryNode setLeft(BinaryNode n) {\r
-        return left = n;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param v DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public Object setElement(Object v)\r
+  {\r
+    return element = v;\r
+  }\r
 \r
-    public BinaryNode right() {\r
-        return right;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public BinaryNode left()\r
+  {\r
+    return left;\r
+  }\r
 \r
-    public BinaryNode setRight(BinaryNode n) {\r
-        return right = n;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param n DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public BinaryNode setLeft(BinaryNode n)\r
+  {\r
+    return left = n;\r
+  }\r
 \r
-    public BinaryNode parent() {\r
-        return parent;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public BinaryNode right()\r
+  {\r
+    return right;\r
+  }\r
 \r
-    public BinaryNode setParent(BinaryNode n) {\r
-        return parent = n;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param n DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public BinaryNode setRight(BinaryNode n)\r
+  {\r
+    return right = n;\r
+  }\r
 \r
-    public boolean isLeaf() {\r
-        return (left == null) && (right == null);\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public BinaryNode parent()\r
+  {\r
+    return parent;\r
+  }\r
 \r
-    /**
- * attaches FIRST and SECOND node arguments as the LEFT and RIGHT children of this node (removing any old references)
- * a null parameter DOES NOT mean that the pointer to the corresponding child node is set to  NULL - you  should use
- * setChild(null), or detach() for this.
- *
- */\r
-    public void SetChildren(BinaryNode leftchild, BinaryNode rightchild) {\r
-        if (leftchild != null) {\r
-            this.setLeft(leftchild);\r
-            leftchild.detach();\r
-            leftchild.setParent(this);\r
-        }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param n DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public BinaryNode setParent(BinaryNode n)\r
+  {\r
+    return parent = n;\r
+  }\r
 \r
-        if (rightchild != null) {\r
-            this.setRight(rightchild);\r
-            rightchild.detach();\r
-            rightchild.setParent(this);\r
-        }\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public boolean isLeaf()\r
+  {\r
+    return (left == null) && (right == null);\r
+  }\r
 \r
-    /**
- * Detaches the node from the binary tree, along with all its child nodes.
- * @return BinaryNode The detached node.
- */\r
-    public BinaryNode detach() {\r
-        if (this.parent != null) {\r
-            if (this.parent.left == this) {\r
-                this.parent.left = null;\r
-            } else {\r
-                if (this.parent.right == this) {\r
-                    this.parent.right = null;\r
-                }\r
-            }\r
-        }\r
+  /**\r
+   * attaches FIRST and SECOND node arguments as the LEFT and RIGHT children of this node (removing any old references)\r
+   * a null parameter DOES NOT mean that the pointer to the corresponding child node is set to  NULL - you  should use\r
+   * setChild(null), or detach() for this.\r
+   *\r
+   */\r
+  public void SetChildren(BinaryNode leftchild, BinaryNode rightchild)\r
+  {\r
+    if (leftchild != null)\r
+    {\r
+      this.setLeft(leftchild);\r
+      leftchild.detach();\r
+      leftchild.setParent(this);\r
+    }\r
 \r
-        this.parent = null;\r
+    if (rightchild != null)\r
+    {\r
+      this.setRight(rightchild);\r
+      rightchild.detach();\r
+      rightchild.setParent(this);\r
+    }\r
+  }\r
 \r
-        return this;\r
+  /**\r
+   * Detaches the node from the binary tree, along with all its child nodes.\r
+   * @return BinaryNode The detached node.\r
+   */\r
+  public BinaryNode detach()\r
+  {\r
+    if (this.parent != null)\r
+    {\r
+      if (this.parent.left == this)\r
+      {\r
+        this.parent.left = null;\r
+      }\r
+      else\r
+      {\r
+        if (this.parent.right == this)\r
+        {\r
+          this.parent.right = null;\r
+        }\r
+      }\r
     }\r
 \r
-    /**
- * Traverses up through the tree until a node with a free leftchild is discovered.
- * @return BinaryNode
- */\r
-    public BinaryNode ascendLeft() {\r
-        BinaryNode c = this;\r
+    this.parent = null;\r
 \r
-        do {\r
-            c = c.parent();\r
-        } while ((c != null) && (c.left() != null) && !c.left().isLeaf());\r
+    return this;\r
+  }\r
 \r
-        return c;\r
+  /**\r
+   * Traverses up through the tree until a node with a free leftchild is discovered.\r
+   * @return BinaryNode\r
+   */\r
+  public BinaryNode ascendLeft()\r
+  {\r
+    BinaryNode c = this;\r
+\r
+    do\r
+    {\r
+      c = c.parent();\r
     }\r
+    while ( (c != null) && (c.left() != null) && !c.left().isLeaf());\r
 \r
-    /**
- * Traverses up through the tree until a node with a free rightchild is discovered.
- * Jalview builds trees by descent on the left, so this may be unused.
- * @return BinaryNode
- */\r
-    public BinaryNode ascendRight() {\r
-        BinaryNode c = this;\r
+    return c;\r
+  }\r
 \r
-        do {\r
-            c = c.parent();\r
-        } while ((c != null) && (c.right() != null) && !c.right().isLeaf());\r
+  /**\r
+   * Traverses up through the tree until a node with a free rightchild is discovered.\r
+   * Jalview builds trees by descent on the left, so this may be unused.\r
+   * @return BinaryNode\r
+   */\r
+  public BinaryNode ascendRight()\r
+  {\r
+    BinaryNode c = this;\r
 \r
-        return c;\r
+    do\r
+    {\r
+      c = c.parent();\r
     }\r
+    while ( (c != null) && (c.right() != null) && !c.right().isLeaf());\r
 \r
-    public void setName(String name) {\r
-        this.name = name;\r
-    }\r
+    return c;\r
+  }\r
 \r
-    public String getName() {\r
-        return this.name;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param name DOCUMENT ME!\r
+   */\r
+  public void setName(String name)\r
+  {\r
+    this.name = name;\r
+  }\r
 \r
-    public void setBootstrap(int boot) {\r
-        this.bootstrap = boot;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public String getName()\r
+  {\r
+    return this.name;\r
+  }\r
 \r
-    public int getBootstrap() {\r
-        return bootstrap;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param boot DOCUMENT ME!\r
+   */\r
+  public void setBootstrap(int boot)\r
+  {\r
+    this.bootstrap = boot;\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public int getBootstrap()\r
+  {\r
+    return bootstrap;\r
+  }\r
 }\r