From 28a00b99bbd8f25fd894d5941149f2e1a45ed0f2 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 21 Apr 2011 13:17:07 +0000 Subject: [PATCH] allow an alignment annotation row to be removed and re-inserted without losing any of its sequence or group associations (JAL-784) --- src/jalview/datamodel/Alignment.java | 9 ++++++++- src/jalview/datamodel/AlignmentI.java | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 42559c6..4e279d3 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -652,6 +652,11 @@ public class Alignment implements AlignmentI */ public boolean deleteAnnotation(AlignmentAnnotation aa) { + return deleteAnnotation(aa, true); + } + + public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook) + { int aSize = 1; if (annotations != null) @@ -683,7 +688,9 @@ public class Alignment implements AlignmentI if (swap) { annotations = temp; - unhookAnnotation(aa); + if (unhook) { + unhookAnnotation(aa); + } } return swap; } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 8b947eb..2e0903d 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -204,7 +204,7 @@ public interface AlignmentI /** * Deletes a specific AlignmentAnnotation from the alignment, and removes its - * reference from any SequenceI object's annotation if and only if aa is + * reference from any SequenceI or SequenceGroup object's annotation if and only if aa is * contained within the alignment's annotation vector. Otherwise, it will do * nothing. * @@ -215,6 +215,20 @@ public interface AlignmentI public boolean deleteAnnotation(AlignmentAnnotation aa); /** + * Deletes a specific AlignmentAnnotation from the alignment, and optionally removes any + * reference from any SequenceI or SequenceGroup object's annotation if and only if aa is + * contained within the alignment's annotation vector. Otherwise, it will do + * nothing. + * + * @param aa + * the annotation to delete + * @param unhook + * flag indicating if any references should be removed from annotation - use this if you intend to add the annotation back into the alignment + * @return true if annotation was deleted from this alignment. + */ + public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook); + + /** * Get the annotation associated with this alignment (this can be null if no * annotation has ever been created on the alignment) * -- 1.7.10.2