X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fphylogeny%2FPhylogenyNode.java;h=6b180ca14781cb51bce6731f434ea892e33a1b0f;hb=0fc3bc32fc5be907e3f91a780af68c6baff79db1;hp=651bbbcc03d8a43511804f0409d1baa6d26635c3;hpb=43b0ab9b36b3b5ad648d75ce11addff6b8142b3c;p=jalview.git diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java index 651bbbc..6b180ca 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java @@ -23,7 +23,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.phylogeny; @@ -47,38 +47,49 @@ import org.forester.util.ForesterUtil; * to unexpected behavior. * */ -public final class PhylogenyNode implements PhylogenyNodeI, Comparable { +public final class PhylogenyNode implements Comparable { - private static int _node_count = 0; - private byte _indicator; - private int _id; - private int _sum_ext_nodes; - private float _x; - private float _y; - private double _distance_parent = PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT; + private static long NODE_COUNT = 0; + private BranchData _branch_data; private boolean _collapse; - private PhylogenyNode _parent; - private PhylogenyNode _link; private ArrayList _descendants; + private double _distance_parent = PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT; + private long _id; + private byte _indicator; + private PhylogenyNode _link; private NodeData _node_data; - private BranchData _branch_data; + private PhylogenyNode _parent; + private int _sum_ext_nodes; + private float _x; private float _x_secondary; + private float _y; private float _y_secondary; /** * Default constructor for PhylogenyNode. */ public PhylogenyNode() { - // init(); setId( PhylogenyNode.getNodeCount() ); PhylogenyNode.increaseNodeCount(); setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!) } - public void removeConnections() { - _parent = null; - _link = null; - _descendants = null; + public PhylogenyNode( final String node_name ) { + setId( PhylogenyNode.getNodeCount() ); + PhylogenyNode.increaseNodeCount(); + setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!) + if ( node_name != null ) { + getNodeData().setNodeName( node_name ); + } + } + + private PhylogenyNode( final String nhx, + final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction, + final boolean replace_underscores ) throws NHXFormatException, PhyloXmlDataFormatException { + NHXParser.parseNHX( nhx, this, taxonomy_extraction, replace_underscores ); + setId( PhylogenyNode.getNodeCount() ); + PhylogenyNode.increaseNodeCount(); + setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!). } /** @@ -88,23 +99,32 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable 0.0 ) { + d += n._distance_parent; + } + n = n._parent; + } + return d; } @Override @@ -117,9 +137,6 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable getAllDescendants() { + return _descendants; + } + /** * Returns a List containing references to all external children of this * PhylogenyNode. @@ -268,10 +286,6 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable getAllDescendants() { - return _descendants; - } - final public int getNumberOfDescendants() { if ( _descendants == null ) { return 0; @@ -599,30 +595,6 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable(); - // _parent = null; //TODO not needed? - // _id = 0; //TODO not needed? - //initializeData(); //TODO not needed? - //} - /** - * Deletes data of this PhylogenyNode. Links to the other Nodes in the - * Phylogeny, the ID and the sum of external nodes are NOT deleted. Field - * "_link" (_link to Nodes in other Phylogeny) IS deleted. - * - * @see #getLink() (Last modified: 12/20/03) - */ - // final private void initializeData() { - // _indicator = 0; - // _x = 0; - // _y = 0; - // //_node_name = ""; - // _distance_parent = PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT; - // _collapse = false; - // _link = null; - // _branch_data = null; - // _node_data = null; - // } /** * Returns whether this PhylogenyNode should be drawn as collapsed. */ @@ -638,6 +610,10 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable