From e37b8c622b4d0a46d3dd170e3cd130bca39ee468 Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Wed, 20 Jun 2012 05:06:20 +0000 Subject: [PATCH] subtree deletion changed --- forester/java/src/org/forester/phylogeny/Phylogeny.java | 9 ++++----- forester/java/src/org/forester/phylogeny/PhylogenyNode.java | 8 ++++++++ forester/java/src/org/forester/util/ForesterConstants.java | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/forester/java/src/org/forester/phylogeny/Phylogeny.java b/forester/java/src/org/forester/phylogeny/Phylogeny.java index f3b6c5f..44851b2 100644 --- a/forester/java/src/org/forester/phylogeny/Phylogeny.java +++ b/forester/java/src/org/forester/phylogeny/Phylogeny.java @@ -221,14 +221,13 @@ public class Phylogeny { * @param remove_us the parent node of the subtree to be deleted */ public void deleteSubtree( final PhylogenyNode remove_us, final boolean collapse_resulting_node_with_one_desc ) { - if ( isEmpty() ) { + if ( isEmpty() || ( remove_us.isRoot() && getNumberOfExternalNodes() != 1 ) ) { return; } - if ( remove_us.isRoot() ) { + if ( remove_us.isRoot() && getNumberOfExternalNodes() == 1 ) { init(); - return; } - if ( !collapse_resulting_node_with_one_desc ) { + else if ( !collapse_resulting_node_with_one_desc ) { remove_us.getParent().removeChildNode( remove_us ); } else { @@ -269,7 +268,7 @@ public class Phylogeny { } } } - remove_us.setParent( null ); + remove_us.reset(); setIdHash( null ); externalNodesHaveChanged(); } diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java index 4045537..8dedcd2 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java @@ -70,6 +70,14 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable