X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=f36872ee11724358c02b5a46b5ad4372271073a5;hb=a4fca83856b96df2fe8701bb5cc14c8d1d0a6b09;hp=34cc78febab20e05262abdb28bebdc41e9bc2f99;hpb=9ca6b95ab67df6eaeea56765cc293133da436e76;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 34cc78f..f36872e 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -108,6 +108,8 @@ public class Alignment public SequenceI[] getSequencesArray() { + if (sequences==null) + return null; SequenceI[] reply = new SequenceI[sequences.size()]; for (int i = 0; i < sequences.size(); i++) { @@ -188,7 +190,7 @@ public class Alignment public void finalize() { if(getDataset()!=null) - getDataset().finalize(); + getDataset().removeAlignmentRef(); dataset = null; sequences = null; @@ -197,6 +199,16 @@ public class Alignment hiddenSequences = null; } + /** + * decrement the alignmentRefs counter by one and call finalize if it goes to zero. + */ + private void removeAlignmentRef() + { + if (--alignmentRefs==0) + { + finalize(); + } + } /** * DOCUMENT ME! @@ -460,17 +472,11 @@ public class Alignment return true; } - - /** - * DOCUMENT ME! - * - * @param aa DOCUMENT ME! + /* (non-Javadoc) + * @see jalview.datamodel.AlignmentI#deleteAnnotation(jalview.datamodel.AlignmentAnnotation) */ - public void deleteAnnotation(AlignmentAnnotation aa) + public boolean deleteAnnotation(AlignmentAnnotation aa) { - if(aa.sequenceRef!=null) - aa.sequenceRef.removeAlignmentAnnotation(aa); - int aSize = 1; if (annotations != null) @@ -480,25 +486,32 @@ public class Alignment if (aSize < 1) { - return; + return false; } AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1]; + boolean swap=false; int tIndex = 0; for (int i = 0; i < aSize; i++) { if (annotations[i] == aa) { + swap=true; continue; } - - temp[tIndex] = annotations[i]; - tIndex++; + if (tIndex