import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.renderer.seqfeatures.FeatureRenderer;
import jalview.viewmodel.OverviewDimensions;
import java.awt.Color;
// raw number of pixels to allocate to each row
private float pixelsPerSeq;
+ // flag to indicate whether to halt drawing
+ private volatile boolean redraw = false;
+
public OverviewRenderer(jalview.api.SequenceRenderer seqRenderer,
- FeatureColourFinder colfinder, OverviewDimensions od)
+ FeatureRenderer fr, OverviewDimensions od)
{
sr = seqRenderer;
- finder = colfinder;
+ finder = new FeatureColourFinder(fr);
pixelsPerCol = od.getPixelsPerCol();
pixelsPerSeq = od.getPixelsPerSeq();
int rgbcolor = Color.white.getRGB();
int seqIndex = 0;
int pixelRow = 0;
+
for (int alignmentRow : rows)
{
+ if (redraw)
+ {
+ break;
+ }
+
// get details of this alignment row
boolean hidden = rows.isHidden(alignmentRow);
SequenceI seq = rows.getSequence(alignmentRow);
int pixelCol = 0;
for (int alignmentCol : cols)
{
+ if (redraw)
+ {
+ break;
+ }
+
// calculate where this column extends to in pixels
- int endCol = Math.min(
- Math.round((colIndex + 1) * pixelsPerCol) - 1,
+ int endCol = Math.min(Math.round((colIndex + 1) * pixelsPerCol) - 1,
miniMe.getWidth() - 1);
- // determine the colour based on the sequence and column position
- rgbcolor = getColumnColourFromSequence(seq,
- hidden || cols.isHidden(alignmentCol), alignmentCol, finder);
-
- // fill in the appropriate number of pixels
- for (int row = pixelRow; row <= endRow; ++row)
+ // don't do expensive colour determination if we're not going to use it
+ // NB this is important to avoid performance issues in the overview
+ // panel
+ if (pixelCol <= endCol)
{
- for (int col = pixelCol; col <= endCol; ++col)
+ // determine the colour based on the sequence and column position
+ rgbcolor = getColumnColourFromSequence(seq,
+ hidden || cols.isHidden(alignmentCol), alignmentCol,
+ finder);
+
+ // fill in the appropriate number of pixels
+ for (int row = pixelRow; row <= endRow; ++row)
{
- miniMe.setRGB(col, row, rgbcolor);
+ for (int col = pixelCol; col <= endCol; ++col)
+ {
+ miniMe.setRGB(col, row, rgbcolor);
+ }
}
- }
- pixelCol = endCol + 1;
+ pixelCol = endCol + 1;
+ }
colIndex++;
}
pixelRow = endRow + 1;
int pixelCol = 0;
for (int alignmentCol : cols)
{
+ if (redraw)
+ {
+ break;
+ }
if (alignmentCol >= annotations.length)
{
break; // no more annotations to draw here
}
else
{
- int endCol = Math.min(
- Math.round((colIndex + 1) * pixelsPerCol) - 1,
+ int endCol = Math.min(Math.round((colIndex + 1) * pixelsPerCol) - 1,
miniMe.getWidth() - 1);
if (annotations[alignmentCol] != null)
g.setColor(annotations[alignmentCol].colour);
}
- height = (int) ((annotations[alignmentCol].value / anno.graphMax) * y);
+ height = (int) ((annotations[alignmentCol].value / anno.graphMax)
+ * y);
if (height > y)
{
height = y;
}
}
}
+
+ public void setRedraw(boolean b)
+ {
+ synchronized (this)
+ {
+ redraw = b;
+ }
+ }
}