*/
package jalview.gui;
+import jalview.api.ColorI;
import jalview.api.FeatureRenderer;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.schemes.Colour;
import jalview.schemes.ColourSchemeI;
+import jalview.util.ColorUtils;
import java.awt.Color;
import java.awt.FontMetrics;
}
@Override
- public Color getResidueBoxColour(SequenceI seq, int i)
+ public ColorI getResidueBoxColour(SequenceI seq, int i)
{
allGroups = av.getAlignment().findAllGroups(seq);
getBoxColour(av.getGlobalColourScheme(), seq, i);
}
- return resBoxColour;
+ return new Colour(resBoxColour);
}
/**
* @return
*/
@Override
- public Color getResidueColour(final SequenceI seq, int position,
+ public ColorI getResidueColour(final SequenceI seq, int position,
FeatureRenderer fr)
{
// TODO replace 8 or so code duplications with calls to this method
// (refactored as needed)
- Color col = getResidueBoxColour(seq, position);
+ ColorI col = getResidueBoxColour(seq, position);
if (fr != null)
{
int y1)
{
if (seq == null)
- {
+ {
return; // fix for racecondition
}
int i = start;
{
end = seq.getLength() - 1;
}
- graphics.setColor(av.getTextColour());
+ graphics.setColor(ColorUtils.getColor(av.getTextColour()));
if (monospacedFont && av.getShowText() && allGroups.length == 0
&& !av.getColourText() && av.getThresholdTextColour() == 0)
{
boolean srep = av.isDisplayReferenceSeq();
boolean getboxColour = false;
+ boolean isarep = av.getAlignment().getSeqrep() == seq;
+ boolean isgrep = currentSequenceGroup != null ? currentSequenceGroup
+ .getSeqrep() == seq : false;
+ char sr_c;
for (int i = start; i <= end; i++)
{
- graphics.setColor(av.getTextColour());
+
+ graphics.setColor(ColorUtils.getColor(av.getTextColour()));
getboxColour = false;
s = seq.getCharAt(i);
+
if (!renderGaps && jalview.util.Comparison.isGap(s))
{
continue;
if (resBoxColour.getRed() + resBoxColour.getBlue()
+ resBoxColour.getGreen() < currentSequenceGroup.thresholdTextColour)
{
- graphics.setColor(currentSequenceGroup.textColour2);
+ graphics.setColor(ColorUtils.getColor(currentSequenceGroup.textColour2));
}
}
}
else
{
- graphics.setColor(currentSequenceGroup.textColour);
+ graphics.setColor(ColorUtils.getColor(currentSequenceGroup.textColour));
}
- if (currentSequenceGroup.getShowNonconserved()) // todo optimize
+ if (!isarep && !isgrep
+ && currentSequenceGroup.getShowNonconserved()) // todo
+ // optimize
{
// todo - use sequence group consensus
- s = getDisplayChar(srep, i, s,
- '.');
+ s = getDisplayChar(srep, i, s, '.', currentSequenceGroup);
}
if (resBoxColour.getRed() + resBoxColour.getBlue()
+ resBoxColour.getGreen() < av.getThresholdTextColour())
{
- graphics.setColor(av.getTextColour2());
+ graphics.setColor(ColorUtils.getColor(av.getTextColour2()));
}
}
- if (av.getShowUnconserved())
+ if (!isarep && av.getShowUnconserved())
{
- s = getDisplayChar(srep, i, s,
- '.');
+ s = getDisplayChar(srep, i, s, '.', currentSequenceGroup);
}
charOffset = (av.getCharWidth() - fm.charWidth(s)) / 2;
graphics.drawString(String.valueOf(s),
- charOffset + av.getCharWidth()
- * (i - start), y1);
+ charOffset + av.getCharWidth() * (i - start), y1);
}
}
* @return
*/
private char getDisplayChar(final boolean usesrep, int position,
- char sequenceChar, char conservedChar)
+ 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 (conschar != '-'
+ char conschar = (usesrep) ? (currentGroup == null ? av.getAlignment()
+ .getSeqrep().getCharAt(position)
+ : (currentGroup.getSeqrep() != null ? currentGroup.getSeqrep()
+ .getCharAt(position) : av.getAlignment().getSeqrep()
+ .getCharAt(position)))
+ : (currentGroup != null && currentGroup.getConsensus() != null) ? 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))
{
sequenceChar = conservedChar;