sr = new SequenceRenderer(av);
sr.graphics = nullFrame.getGraphics();
sr.renderGaps = false;
- sr.forOverview = true;
+ // sr.forOverview = true;
fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
}
setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
- or = new OverviewRenderer(sr, fr, od);
+ or = new OverviewRenderer(sr, fr, od, av.getAlignment(),
+ av.getResidueShading());
miniMe = nullFrame.createImage(od.getWidth(), od.getHeight());
offscreen = nullFrame.createImage(od.getWidth(), od.getHeight());
Graphics graphics;
- boolean forOverview = false;
-
public SequenceRenderer(AlignViewport av)
{
this.av = av;
{
resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
}
- else if (forOverview
- && !jalview.util.Comparison.isGap(seq.getCharAt(i)))
- {
- resBoxColour = Color.lightGray;
- }
else
{
resBoxColour = Color.white;
sr = new SequenceRenderer(av);
sr.renderGaps = false;
- sr.forOverview = true;
+ // sr.forOverview = true;
fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
}
{
miniMe = null;
- if (!av.getShowBoxes())
+ if (showSequenceFeatures)
{
- // boxes are not shown on main viewport
- or = new OverviewRenderer(sr, fr, od);
- miniMe = new BufferedImage(od.getWidth(), od.getHeight(),
- BufferedImage.TYPE_INT_RGB);
- miniMe.getGraphics().setColor(Color.WHITE);
- miniMe.getGraphics().fillRect(0, 0, od.getWidth(),
- od.getSequencesHeight());
+ fr.transferSettings(transferRenderer);
}
- else
- {
- if (showSequenceFeatures)
- {
- fr.transferSettings(transferRenderer);
- }
- setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
+ setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
- or = new OverviewRenderer(sr, fr, od);
- miniMe = or.draw(od.getRows(av.getAlignment()),
- od.getColumns(av.getAlignment()));
- }
+ or = new OverviewRenderer(sr, fr, od, av.getAlignment(),
+ av.getResidueShading());
+ miniMe = or.draw(od.getRows(av.getAlignment()),
+ od.getColumns(av.getAlignment()));
Graphics mg = miniMe.getGraphics();
import jalview.datamodel.SequenceI;
import jalview.renderer.ResidueShaderI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
-import jalview.util.Comparison;
import java.awt.Color;
import java.awt.FontMetrics;
boolean renderGaps = true;
- SequenceGroup currentSequenceGroup = null;
-
SequenceGroup[] allGroups = null;
Color resBoxColour;
boolean monospacedFont;
- boolean forOverview = false;
-
/**
* Creates a new SequenceRenderer object
*
// rate limiting step when rendering overview for lots of groups
allGroups = av.getAlignment().findAllGroups(seq);
- if (inCurrentSequenceGroup(i))
+ SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(i);
+ if (currentSequenceGroup != null)
{
if (currentSequenceGroup.getDisplayBoxes())
{
{
if (shader.getColourScheme() != null)
{
- if (forOverview && Comparison.isGap(seq.getCharAt(i))
- && !shader.getColourScheme().hasGapColour())
- {
- resBoxColour = Color.lightGray;
- }
- else
- {
- resBoxColour = shader.findColour(seq.getCharAt(i),
- i, seq);
- }
- }
- else if (forOverview && Comparison.isGap(seq.getCharAt(i)))
- {
- resBoxColour = Color.lightGray;
+ resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
}
else
{
if (i < length)
{
- if (inCurrentSequenceGroup(i))
+ SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(i);
+ if (currentSequenceGroup != null)
{
if (currentSequenceGroup.getDisplayBoxes())
{
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++)
{
continue;
}
- if (inCurrentSequenceGroup(i))
+ SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(i);
+ if (currentSequenceGroup != null)
{
if (!currentSequenceGroup.getDisplayText())
{
{
graphics.setColor(currentSequenceGroup.textColour);
}
+ boolean isgrep = currentSequenceGroup != null
+ ? currentSequenceGroup.getSeqrep() == seq : false;
if (!isarep && !isgrep
&& currentSequenceGroup.getShowNonconserved()) // todo
// optimize
*
* @return DOCUMENT ME!
*/
- boolean inCurrentSequenceGroup(int res)
+ SequenceGroup inCurrentSequenceGroup(int res)
{
if (allGroups == null)
{
- return false;
+ return null;
}
for (int i = 0; i < allGroups.length; i++)
if ((allGroups[i].getStartRes() <= res)
&& (allGroups[i].getEndRes() >= res))
{
- currentSequenceGroup = allGroups[i];
-
- return true;
+ return (allGroups[i]);
}
}
- return false;
+ return null;
}
/**
import jalview.api.AlignmentColsCollectionI;
import jalview.api.AlignmentRowsCollectionI;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
import jalview.renderer.seqfeatures.FeatureRenderer;
+import jalview.util.Comparison;
import jalview.viewmodel.OverviewDimensions;
import java.awt.Color;
// flag to indicate whether to halt drawing
private volatile boolean redraw = false;
+ // reference to alignment, needed to get sequence groups
+ private AlignmentI al;
+
+ private ResidueShaderI shader;
+
public OverviewRenderer(jalview.api.SequenceRenderer seqRenderer,
- FeatureRenderer fr, OverviewDimensions od)
+ FeatureRenderer fr, OverviewDimensions od, AlignmentI alignment,
+ ResidueShaderI resshader)
{
sr = seqRenderer;
finder = new FeatureColourFinder(fr);
+ al = alignment;
+ shader = resshader;
+
pixelsPerCol = od.getPixelsPerCol();
pixelsPerSeq = od.getPixelsPerSeq();
miniMe = new BufferedImage(od.getWidth(), od.getHeight(),
// get details of this alignment row
boolean hidden = rows.isHidden(alignmentRow);
SequenceI seq = rows.getSequence(alignmentRow);
+ // rate limiting step when rendering overview for lots of groups
+ SequenceGroup[] allGroups = al.findAllGroups(seq);
// calculate where this row extends to in pixels
int endRow = Math.min(Math.round((seqIndex + 1) * pixelsPerSeq) - 1,
if (pixelCol <= endCol)
{
// determine the colour based on the sequence and column position
- rgbcolor = getColumnColourFromSequence(seq,
+ rgbcolor = getColumnColourFromSequence(allGroups, seq,
hidden || cols.isHidden(alignmentCol), alignmentCol,
finder);
/*
* Find the colour of a sequence at a specified column position
*/
- private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq,
+ private int getColumnColourFromSequence(SequenceGroup[] allGroups,
+ jalview.datamodel.SequenceI seq,
boolean isHidden, int lastcol, FeatureColourFinder fcfinder)
{
Color color = Color.white;
if ((seq != null) && (seq.getLength() > lastcol))
{
- color = sr.getResidueColour(seq, lastcol, fcfinder);
+ color = getResidueColour(allGroups, seq, lastcol, fcfinder);
}
if (isHidden)
return color.getRGB();
}
+ private Color getResidueColour(SequenceGroup[] allGroups,
+ final SequenceI seq, int position,
+ FeatureColourFinder finder)
+ {
+ Color col = getResidueBoxColour(allGroups, seq, position);
+
+ if (finder != null)
+ {
+ col = finder.findFeatureColour(col, seq, position);
+ }
+ return col;
+ }
+
+ protected Color getResidueBoxColour(SequenceGroup[] allGroups,
+ SequenceI seq, int i)
+ {
+
+ ResidueShaderI currentShader;
+
+ SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(allGroups,
+ i);
+ if (currentSequenceGroup != null)
+ {
+ currentShader = currentSequenceGroup.getGroupColourScheme();
+ }
+ else
+ {
+ currentShader = shader;
+ }
+
+ return getBoxColour(currentShader, seq, i);
+ }
+
+ SequenceGroup inCurrentSequenceGroup(SequenceGroup[] allGroups, int res)
+ {
+ if (allGroups == null)
+ {
+ return null;
+ }
+
+ for (int i = 0; i < allGroups.length; i++)
+ {
+ if ((allGroups[i].getStartRes() <= res)
+ && (allGroups[i].getEndRes() >= res))
+ {
+ return (allGroups[i]);
+ }
+ }
+
+ return null;
+ }
+
+ Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
+ {
+ Color resBoxColour = Color.white;
+ char currentChar = seq.getCharAt(i);
+
+ if (shader.getColourScheme() != null)
+ {
+ if (Comparison.isGap(currentChar)
+ && !shader.getColourScheme().hasGapColour())
+ {
+ resBoxColour = Color.lightGray;
+ }
+ else
+ {
+ resBoxColour = shader.findColour(currentChar, i, seq);
+ }
+ }
+ else if (Comparison.isGap(currentChar))
+ {
+ resBoxColour = Color.lightGray;
+ }
+
+ return resBoxColour;
+ }
+
/**
* Draw the alignment annotation in the overview panel
*
assertEquals(Color.white, sr.getResidueBoxColour(seq, 2));
// set for overview
- sr.forOverview = true;
+ /* sr.forOverview = true;
assertEquals(Color.lightGray, sr.getResidueBoxColour(seq, 0));
- assertEquals(Color.white, sr.getResidueBoxColour(seq, 2));
+ assertEquals(Color.white, sr.getResidueBoxColour(seq, 2));*/
}
// TODO more tests for getResidueBoxColour covering groups, feature rendering,