X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FBinaryNode.java;h=da636138752e0fb575dd1c4ee7b2ea99d35b6a69;hb=d1f6cf53b29322601c621da9a6b3cb09dd28235e;hp=cefbc227a694ba66e58ca056df0577f30f8e71d0;hpb=99c58ee0ae2a848f982552e53feaf6d5cb9925e5;p=jalview.git diff --git a/src/jalview/datamodel/BinaryNode.java b/src/jalview/datamodel/BinaryNode.java index cefbc22..da63613 100755 --- a/src/jalview/datamodel/BinaryNode.java +++ b/src/jalview/datamodel/BinaryNode.java @@ -1,40 +1,56 @@ /* -* 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 -*/ - + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 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 + */ package jalview.datamodel; +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class BinaryNode { - Object element; String name; BinaryNode left; BinaryNode right; BinaryNode parent; + + /** DOCUMENT ME!! */ public int bootstrap; + /** + * Creates a new BinaryNode object. + */ public BinaryNode() { left = right = parent = null; bootstrap = 0; } + /** + * Creates a new BinaryNode object. + * + * @param element DOCUMENT ME! + * @param parent DOCUMENT ME! + * @param name DOCUMENT ME! + */ public BinaryNode(Object element, BinaryNode parent, String name) { this.element = element; @@ -44,46 +60,99 @@ public class BinaryNode left = right = null; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public Object element() { return element; } + /** + * DOCUMENT ME! + * + * @param v DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public Object setElement(Object v) { return element = v; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public BinaryNode left() { return left; } + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public BinaryNode setLeft(BinaryNode n) { return left = n; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public BinaryNode right() { return right; } + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public BinaryNode setRight(BinaryNode n) { return right = n; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public BinaryNode parent() { return parent; } + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public BinaryNode setParent(BinaryNode n) { return parent = n; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public boolean isLeaf() { return (left == null) && (right == null); @@ -102,8 +171,8 @@ public class BinaryNode this.setLeft(leftchild); leftchild.detach(); leftchild.setParent(this); - } + if (rightchild != null) { this.setRight(rightchild); @@ -118,7 +187,8 @@ public class BinaryNode */ public BinaryNode detach() { - if (this.parent!=null) { + if (this.parent != null) + { if (this.parent.left == this) { this.parent.left = null; @@ -131,49 +201,82 @@ public class BinaryNode } } } + this.parent = null; + return this; } + /** * Traverses up through the tree until a node with a free leftchild is discovered. * @return BinaryNode */ - public BinaryNode ascendLeft() { + public BinaryNode ascendLeft() + { BinaryNode c = this; - do { + + do + { c = c.parent(); - } while (c!=null && c.left()!=null && !c.left().isLeaf()); + } + while ( (c != null) && (c.left() != null) && !c.left().isLeaf()); + return c; } + /** * 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 */ - public BinaryNode ascendRight() { + public BinaryNode ascendRight() + { BinaryNode c = this; - do { + + do + { c = c.parent(); - } while (c!=null && c.right()!=null && !c.right().isLeaf()); + } + while ( (c != null) && (c.right() != null) && !c.right().isLeaf()); + return c; } - + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + */ public void setName(String name) { this.name = name; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getName() { return this.name; } + /** + * DOCUMENT ME! + * + * @param boot DOCUMENT ME! + */ public void setBootstrap(int boot) { this.bootstrap = boot; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int getBootstrap() { return bootstrap;