X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=6b797d79a939a5c50af6b41e05916e96956185e5;hb=9e926ac4305fd9dff38b6e079e55b4f50664d544;hp=06cdec48bdff0ad6e88166a700a239ce70fe228d;hpb=9a72e919f5f39f03f62d384a907ade3e279d884e;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 06cdec4..6b797d7 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -30,6 +30,7 @@ import java.awt.Color; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -517,10 +518,9 @@ public class SequenceGroup implements AnnotatedCollectionI { if (s != null && !sequences.contains(s)) { - List before = sequences; sequences.add(s); - changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, - sequences); + changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, + sequences.size() - 1, sequences.size()); } if (recalc) @@ -645,8 +645,10 @@ public class SequenceGroup implements AnnotatedCollectionI conservation.description = "Conservation for group " + getName() + " less than " + consPercGaps + "% gaps"; // preserve width if already set - int aWidth = (conservation.annotations != null) ? (endRes < conservation.annotations.length ? conservation.annotations.length - : endRes + 1) + int aWidth = (conservation.annotations != null) + ? (endRes < conservation.annotations.length + ? conservation.annotations.length + : endRes + 1) : endRes + 1; conservation.annotations = null; conservation.annotations = new Annotation[aWidth]; // should be alignment @@ -666,8 +668,10 @@ public class SequenceGroup implements AnnotatedCollectionI consensus.description = "Percent Identity"; consensusData = cnsns; // preserve width if already set - int aWidth = (consensus.annotations != null) ? (endRes < consensus.annotations.length ? consensus.annotations.length - : endRes + 1) + int aWidth = (consensus.annotations != null) + ? (endRes < consensus.annotations.length + ? consensus.annotations.length + : endRes + 1) : endRes + 1; consensus.annotations = null; consensus.annotations = new Annotation[aWidth]; // should be alignment width @@ -713,10 +717,9 @@ public class SequenceGroup implements AnnotatedCollectionI { synchronized (sequences) { - List before = sequences; sequences.remove(s); - changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, - sequences); + changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, + sequences.size() + 1, sequences.size()); if (recalc) { @@ -1314,38 +1317,16 @@ public class SequenceGroup implements AnnotatedCollectionI @Override public Iterable findAnnotation(String calcId) { - List aa = new ArrayList<>(); - if (calcId == null) - { - return aa; - } - for (AlignmentAnnotation a : getAlignmentAnnotation()) - { - if (calcId.equals(a.getCalcId())) - { - aa.add(a); - } - } - return aa; + return AlignmentAnnotation.findAnnotation( + Arrays.asList(getAlignmentAnnotation()), calcId); } @Override public Iterable findAnnotations(SequenceI seq, String calcId, String label) { - ArrayList aa = new ArrayList<>(); - for (AlignmentAnnotation ann : getAlignmentAnnotation()) - { - if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId() - .equals(calcId))) - && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq)) - && (label == null || (ann.label != null && ann.label - .equals(label)))) - { - aa.add(ann); - } - } - return aa; + return AlignmentAnnotation.findAnnotations( + Arrays.asList(getAlignmentAnnotation()), seq, calcId, label); } /** @@ -1356,17 +1337,8 @@ public class SequenceGroup implements AnnotatedCollectionI */ public boolean hasAnnotation(String calcId) { - if (calcId != null && !"".equals(calcId)) - { - for (AlignmentAnnotation a : getAlignmentAnnotation()) - { - if (a.getCalcId() == calcId) - { - return true; - } - } - } - return false; + return AlignmentAnnotation + .hasAnnotation(Arrays.asList(getAlignmentAnnotation()), calcId); } /** @@ -1376,10 +1348,10 @@ public class SequenceGroup implements AnnotatedCollectionI { synchronized (sequences) { - List before = sequences; + int before = sequences.size(); sequences.clear(); changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, - sequences); + sequences.size()); } } @@ -1467,7 +1439,8 @@ public class SequenceGroup implements AnnotatedCollectionI @Override public boolean isNucleotide() { - if (context != null) { + if (context != null) + { return context.isNucleotide(); } return false;