X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSequenceRenderer.java;h=790d87580d247ae8fb1ab5aa84773864253da48a;hb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;hp=0470f8349077c7156c71bdb952a14f96242b652f;hpb=a90e2fe3cc3b779521a81cf8de410936f3a777c1;p=jalview.git diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index 0470f83..790d875 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -32,6 +32,8 @@ import java.awt.Graphics; public class SequenceRenderer implements jalview.api.SequenceRenderer { + final static int CHAR_TO_UPPER = 'A' - 'a'; + AlignViewport av; FontMetrics fm; @@ -67,6 +69,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer this.renderGaps = renderGaps; } + @Override public Color getResidueBoxColour(SequenceI seq, int i) { allGroups = av.getAlignment().findAllGroups(seq); @@ -256,7 +259,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } if (currentSequenceGroup.getShowNonconserved()) { - s = getDisplayChar(srep, i, s, '.'); + s = getDisplayChar(srep, i, s, '.', currentSequenceGroup); } } else @@ -280,7 +283,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } if (av.getShowUnconserved()) { - s = getDisplayChar(srep, i, s, '.'); + s = getDisplayChar(srep, i, s, '.', null); } } @@ -312,20 +315,43 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } - private char getDisplayChar(final boolean usesrep, int position, char s, - char c) + /** + * Returns 'conservedChar' to represent the given position if the sequence + * character at that position is equal to the consensus (ignoring case), else + * returns the sequence character + * + * @param usesrep + * @param position + * @param sequenceChar + * @param conservedChar + * @return + */ + private char getDisplayChar(final boolean usesrep, int position, + char sequenceChar, char conservedChar, SequenceGroup currentGroup) { // TODO - use currentSequenceGroup rather than alignment // currentSequenceGroup.getConsensus() - char conschar = (usesrep) ? av.getAlignment().getSeqrep() - .getCharAt(position) - : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter - .charAt(0); - if (!jalview.util.Comparison.isGap(conschar) && s == conschar) + char conschar = (usesrep) ? (currentGroup == null + || position < currentGroup.getStartRes() + || position > currentGroup.getEndRes() ? av.getAlignment() + .getSeqrep().getCharAt(position) + : (currentGroup.getSeqrep() != null ? currentGroup.getSeqrep() + .getCharAt(position) : av.getAlignment().getSeqrep() + .getCharAt(position))) + : (currentGroup != null && currentGroup.getConsensus() != null + && position >= currentGroup.getStartRes() + && position <= currentGroup.getEndRes() && currentGroup + .getConsensus().annotations.length > position) ? currentGroup + .getConsensus().annotations[position].displayCharacter + .charAt(0) + : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter + .charAt(0); + if (!jalview.util.Comparison.isGap(conschar) + && (sequenceChar == conschar || sequenceChar + CHAR_TO_UPPER == conschar)) { - s = c; + sequenceChar = conservedChar; } - return s; + return sequenceChar; } boolean inCurrentSequenceGroup(int res)