in progress...
[jalview.git] / forester / java / src / org / forester / phylogeny / PhylogenyNode.java
index d37cc3b..25b33d7 100644 (file)
@@ -248,10 +248,7 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
         }
     }
 
-    final public List<PhylogenyNode> getAllDescendants() {
-        return _descendants;
-    }
-
     /**
      * Returns a List containing references to all external children of this
      * PhylogenyNode.
@@ -468,12 +465,12 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
 
     public final PhylogenyNode getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() {
         //TODO work on me ~~
-        if ( isInternal() && !isCollapse() ) {
-            throw new UnsupportedOperationException( "attempt to get next external node of an uncollapsed internal node" );
-        }
         if ( isRoot() ) {
             return null;
         }
+        if ( isInternal() && !isCollapse() ) {
+            throw new UnsupportedOperationException( "attempt to get next external node of an uncollapsed internal node" );
+        }
         if ( getParent().isCollapse() ) {
             throw new UnsupportedOperationException( "attempt to get next external node of node with a collapsed parent" );
         }
@@ -515,6 +512,10 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
         }
         return _node_data;
     }
+    
+    public final boolean isHasNodeData() {
+        return ( !( _node_data == null || _node_data.isEmpty() ) );
+    }
 
     final public int getNumberOfDescendants() {
         if ( _descendants == null ) {
@@ -613,9 +614,10 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
 
     /**
      * Returns whether this PhylogenyNode should be drawn as collapsed.
+     * Root can not be collapsed.
      */
     final public boolean isCollapse() {
-        return _collapse;
+        return _collapse && _parent != null;
     }
 
     /**
@@ -636,10 +638,7 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
      * @return true if this PhylogenyNode is external, false otherwise
      */
     final public boolean isExternal() {
-        if ( _descendants == null ) {
-            return true;
-        }
-        return ( getNumberOfDescendants() < 1 );
+        return ( _descendants == null ) || ( _descendants.size() == 0 );
     }
 
     final public boolean isFirstChildNode() {
@@ -784,14 +783,14 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
     }
 
     /**
-     * Inserts PhylogenyNode n at the specified position i into the list of
+     * Inserts PhylogenyNode node at the specified position i into the list of
      * child nodes. This does not allow null slots in the list of child nodes:
-     * If i is larger than the number of child nodes, n is just added to the
-     * list, not place at index i.
+     * If i is larger than the number of child nodes, node is just added to the
+     * list, not placed at index i.
      *
      * @param i
      *            the index of position where to add the child
-     * @param n
+     * @param node
      *            the PhylogenyNode to add
      */
     final public void setChildNode( final int i, final PhylogenyNode node ) {
@@ -1022,10 +1021,6 @@ public final class PhylogenyNode implements Comparable<PhylogenyNode> {
                 sb.append( getNodeData().getSequence().getAccession().toString() );
                 sb.append( " " );
             }
-            if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getMolecularSequence() ) ) {
-                sb.append( getNodeData().getSequence().getMolecularSequence() );
-                sb.append( " " );
-            }
         }
         if ( sb.length() <= 1 ) {
             sb.append( "[" );