X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=046f1e6cda95f029b3156180e2e2bb94ab037006;hb=3f12f4932226512316ec113e600695150431fd0a;hp=0e8fa170cda9091a4bf5ea8723a5dddac0665386;hpb=23c12388658b08e4bbda2ebfdad286d881689366;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 0e8fa17..046f1e6 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -504,14 +504,32 @@ public class SequenceGroup implements AnnotatedCollectionI } /** - * calculate residue conservation for group - but only if necessary. + * calculate residue conservation and colourschemes for group - but only if + * necessary. returns true if the calculation resulted in a visible change to + * group */ - public void recalcConservation() + public boolean recalcConservation() + { + return recalcConservation(false); + } + + /** + * calculate residue conservation for group - but only if necessary. returns + * true if the calculation resulted in a visible change to group + * + * @param defer + * when set, colourschemes for this group are not refreshed after + * recalculation + */ + public boolean recalcConservation(boolean defer) { if (cs == null && consensus == null && conservation == null) { - return; + return false; } + // TODO: try harder to detect changes in state in order to minimise + // recalculation effort + boolean upd = false; try { Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes, @@ -519,10 +537,12 @@ public class SequenceGroup implements AnnotatedCollectionI if (consensus != null) { _updateConsensusRow(cnsns, sequences.size()); + upd = true; } if (cs != null) { cs.setConsensus(cnsns); + upd = true; } if ((conservation != null) @@ -544,17 +564,25 @@ public class SequenceGroup implements AnnotatedCollectionI cs.setConservation(c); } } + // eager update - will cause a refresh of overview regardless + upd = true; } - if (cs != null) + if (cs != null && !defer) { + // TODO: JAL-2034 should cs.alignmentChanged modify return state cs.alignmentChanged(context != null ? context : this, null); + return true; + } + else + { + return upd; } } catch (java.lang.OutOfMemoryError err) { // TODO: catch OOM System.out.println("Out of memory loading groups: " + err); } - + return upd; } private void _updateConservationRow(Conservation c) @@ -894,6 +922,7 @@ public class SequenceGroup implements AnnotatedCollectionI /** * @return the representative sequence for this group */ + @Override public SequenceI getSeqrep() { return seqrep; @@ -906,6 +935,7 @@ public class SequenceGroup implements AnnotatedCollectionI * @param seqrep * the seqrep to set (null means no sequence representative) */ + @Override public void setSeqrep(SequenceI seqrep) { this.seqrep = seqrep; @@ -915,6 +945,7 @@ public class SequenceGroup implements AnnotatedCollectionI * * @return true if group has a sequence representative */ + @Override public boolean hasSeqrep() { return seqrep != null; @@ -1036,7 +1067,8 @@ public class SequenceGroup implements AnnotatedCollectionI /** * - * @return automatically calculated consensus row + * @return automatically calculated consensus row note: the row is a stub if a + * consensus calculation has not yet been performed on the group */ public AlignmentAnnotation getConsensus() {