*/
package jalview.gui;
-import jalview.api.FeatureRenderer;
+import jalview.api.AlignViewportI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.schemes.ColourSchemeI;
+import jalview.renderer.ResidueShaderI;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.util.Comparison;
import java.awt.Color;
import java.awt.FontMetrics;
{
final static int CHAR_TO_UPPER = 'A' - 'a';
- AlignViewport av;
+ AlignViewportI av;
FontMetrics fm;
boolean forOverview = false;
/**
- * Creates a new SequenceRenderer object.
+ * Creates a new SequenceRenderer object
*
- * @param av
- * DOCUMENT ME!
+ * @param viewport
*/
- public SequenceRenderer(AlignViewport av)
+ public SequenceRenderer(AlignViewportI viewport)
{
- this.av = av;
+ this.av = viewport;
}
/**
// If EPS graphics, stringWidth will be a double, not an int
double dwidth = fm.getStringBounds("M", g).getWidth();
- monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth() && av
- .getCharWidth() == dwidth);
+ monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth()
+ && av.getCharWidth() == dwidth);
this.renderGaps = renderGaps;
}
- @Override
- public Color getResidueBoxColour(SequenceI seq, int i)
+ protected Color getResidueBoxColour(SequenceI seq, int i)
{
+ // rate limiting step when rendering overview for lots of groups
allGroups = av.getAlignment().findAllGroups(seq);
if (inCurrentSequenceGroup(i))
{
if (currentSequenceGroup.getDisplayBoxes())
{
- getBoxColour(currentSequenceGroup.cs, seq, i);
+ getBoxColour(currentSequenceGroup.getGroupColourScheme(), seq, i);
}
}
else if (av.getShowBoxes())
{
- getBoxColour(av.getGlobalColourScheme(), seq, i);
+ getBoxColour(av.getResidueShading(), seq, i);
}
return resBoxColour;
*
* @param seq
* @param position
- * @param fr
+ * @param finder
* @return
*/
@Override
public Color getResidueColour(final SequenceI seq, int position,
- FeatureRenderer fr)
+ FeatureColourFinder finder)
{
- // TODO replace 8 or so code duplications with calls to this method
- // (refactored as needed)
Color col = getResidueBoxColour(seq, position);
- if (fr != null)
+ if (finder != null)
{
- col = fr.findFeatureColour(col, seq, position);
+ col = finder.findFeatureColour(col, seq, position);
}
return col;
}
/**
* DOCUMENT ME!
*
- * @param cs
+ * @param shader
* DOCUMENT ME!
* @param seq
* DOCUMENT ME!
* @param i
* DOCUMENT ME!
*/
- void getBoxColour(ColourSchemeI cs, SequenceI seq, int i)
+ void getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
{
- if (cs != null)
+ if (shader.getColourScheme() != null)
{
- resBoxColour = cs.findColour(seq.getCharAt(i), i, seq);
+ resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
}
- else if (forOverview
- && !jalview.util.Comparison.isGap(seq.getCharAt(i)))
+ else if (forOverview && !Comparison.isGap(seq.getCharAt(i)))
{
resBoxColour = Color.lightGray;
}
drawBoxes(seq, start, end, y1);
- if (av.validCharWidth)
+ if (av.isValidCharWidth())
{
drawText(seq, start, end, y1);
}
int length = seq.getLength();
int curStart = -1;
- int curWidth = av.getCharWidth(), avWidth = av.getCharWidth(), avHeight = av
- .getCharHeight();
+ int curWidth = av.getCharWidth(), avWidth = av.getCharWidth(),
+ avHeight = av.getCharHeight();
Color tempColour = null;
{
if (currentSequenceGroup.getDisplayBoxes())
{
- getBoxColour(currentSequenceGroup.cs, seq, i);
+ getBoxColour(currentSequenceGroup.getGroupColourScheme(), seq,
+ i);
}
}
else if (av.getShowBoxes())
{
- getBoxColour(av.getGlobalColourScheme(), seq, i);
+ getBoxColour(av.getResidueShading(), seq, i);
}
-
}
if (resBoxColour != tempColour)
else
{
char gap = av.getGapCharacter();
- graphics.drawString(seq.getSequenceAsString(start, end + 1)
- .replace(gap, ' '), 0, y1);
+ graphics.drawString(
+ seq.getSequenceAsString(start, end + 1).replace(gap, ' '),
+ 0, y1);
}
}
else
boolean srep = av.isDisplayReferenceSeq();
boolean getboxColour = false;
boolean isarep = av.getAlignment().getSeqrep() == seq;
- boolean isgrep = currentSequenceGroup != null ? currentSequenceGroup
- .getSeqrep() == seq : false;
+ boolean isgrep = currentSequenceGroup != null
+ ? currentSequenceGroup.getSeqrep() == seq
+ : false;
char sr_c;
for (int i = start; i <= end; i++)
{
|| currentSequenceGroup.getColourText())
{
getboxColour = true;
- getBoxColour(currentSequenceGroup.cs, seq, i);
+ getBoxColour(currentSequenceGroup.getGroupColourScheme(), seq,
+ i);
if (currentSequenceGroup.getColourText())
{
if (currentSequenceGroup.thresholdTextColour > 0)
{
if (resBoxColour.getRed() + resBoxColour.getBlue()
- + resBoxColour.getGreen() < currentSequenceGroup.thresholdTextColour)
+ + resBoxColour
+ .getGreen() < currentSequenceGroup.thresholdTextColour)
{
graphics.setColor(currentSequenceGroup.textColour2);
}
if (av.getColourText())
{
getboxColour = true;
- getBoxColour(av.getGlobalColourScheme(), seq, i);
+ getBoxColour(av.getResidueShading(), seq, i);
if (av.getShowBoxes())
{
{
if (!getboxColour)
{
- getBoxColour(av.getGlobalColourScheme(), seq, i);
+ getBoxColour(av.getResidueShading(), seq, i);
}
if (resBoxColour.getRed() + resBoxColour.getBlue()
// currentSequenceGroup.getConsensus()
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)))
+ || 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);
+ && 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))
+ && (sequenceChar == conschar
+ || sequenceChar + CHAR_TO_UPPER == conschar))
{
sequenceChar = conservedChar;
}
* @param height
* DOCUMENT ME!
*/
- public void drawHighlightedText(SequenceI seq, int start, int end,
- int x1, int y1)
+ public void drawHighlightedText(SequenceI seq, int start, int end, int x1,
+ int y1)
{
int pady = av.getCharHeight() / 5;
int charOffset = 0;