return annotations.adjustPanelHeight();
}
- private void drawPanel(Graphics g1, int startRes, int endRes,
- int startSeq, int endSeq, int offset)
+ private void drawPanel(Graphics g1, final int startRes, final int endRes,
+ final int startSeq, final int endSeq, final int offset)
{
if (!av.hasHiddenColumns())
}
else
{
-
int screenY = 0;
+ final int screenYMax = endRes - startRes;
int blockStart = startRes;
int blockEnd = endRes;
continue;
}
- blockEnd = hideStart - 1;
+ /*
+ * draw up to just before the next hidden region, or the end of
+ * the visible region, whichever comes first
+ */
+ blockEnd = Math.min(hideStart - 1, blockStart + screenYMax
+ - screenY);
g1.translate(screenY * avcharWidth, 0);
draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
- if (av.getShowHiddenMarkers())
+ /*
+ * draw the downline of the hidden column marker (ScalePanel draws the
+ * triangle on top) if we reached it
+ */
+ if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1)
{
g1.setColor(Color.blue);
g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1,
screenY += blockEnd - blockStart + 1;
blockStart = hideEnd + 1;
- if (screenY > (endRes - startRes))
+ if (screenY > screenYMax)
{
// already rendered last block
return;
}
}
}
- if (screenY <= (endRes - startRes))
+ if (screenY <= screenYMax)
{
// remaining visible region to render
blockEnd = blockStart + (endRes - startRes) - screenY;
}
/**
- * DOCUMENT ME!
+ * Draws the visible region of the alignment on the graphics context. If there
+ * are hidden column markers in the visible region, then each sub-region
+ * between the markers is drawn separately, followed by the hidden column
+ * marker.
*
* @param g1
- * DOCUMENT ME!
* @param startRes
- * DOCUMENT ME!
+ * offset of the first column in the visible region (0..)
* @param endRes
- * DOCUMENT ME!
+ * offset of the last column in the visible region (0..)
* @param startSeq
- * DOCUMENT ME!
+ * offset of the first sequence in the visible region (0..)
* @param endSeq
- * DOCUMENT ME!
- * @param offset
- * DOCUMENT ME!
+ * offset of the last sequence in the visible region (0..)
+ * @param yOffset
+ * vertical offset at which to draw (for wrapped alignments)
*/
- public void drawPanel(Graphics g1, int startRes, int endRes,
- int startSeq, int endSeq, int offset)
+ public void drawPanel(Graphics g1, final int startRes, final int endRes,
+ final int startSeq, final int endSeq, final int yOffset)
{
updateViewport();
if (!av.hasHiddenColumns())
{
- draw(g1, startRes, endRes, startSeq, endSeq, offset);
+ draw(g1, startRes, endRes, startSeq, endSeq, yOffset);
}
else
{
.getHiddenRegions();
int screenY = 0;
+ final int screenYMax = endRes - startRes;
int blockStart = startRes;
int blockEnd = endRes;
continue;
}
- blockEnd = hideStart - 1;
+ /*
+ * draw up to just before the next hidden region, or the end of
+ * the visible region, whichever comes first
+ */
+ blockEnd = Math.min(hideStart - 1, blockStart + screenYMax
+ - screenY);
g1.translate(screenY * charWidth, 0);
- draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
+ draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset);
- if (av.getShowHiddenMarkers())
+ /*
+ * draw the downline of the hidden column marker (ScalePanel draws the
+ * triangle on top) if we reached it
+ */
+ if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1)
{
g1.setColor(Color.blue);
g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1,
- 0 + offset, (blockEnd - blockStart + 1) * charWidth - 1,
- (endSeq - startSeq + 1) * charHeight + offset);
+ 0 + yOffset, (blockEnd - blockStart + 1) * charWidth - 1,
+ (endSeq - startSeq + 1) * charHeight + yOffset);
}
g1.translate(-screenY * charWidth, 0);
screenY += blockEnd - blockStart + 1;
blockStart = hideEnd + 1;
- if (screenY > (endRes - startRes))
+ if (screenY > screenYMax)
{
// already rendered last block
return;
}
}
- if (screenY <= (endRes - startRes))
+ if (screenY <= screenYMax)
{
// remaining visible region to render
- blockEnd = blockStart + (endRes - startRes) - screenY;
+ blockEnd = blockStart + screenYMax - screenY;
g1.translate(screenY * charWidth, 0);
- draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
+ draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset);
g1.translate(-screenY * charWidth, 0);
}
}
- // int startRes, int endRes, int startSeq, int endSeq, int x, int y,
- // int x1, int x2, int y1, int y2, int startx, int starty,
+ /**
+ * Draws a region of the visible alignment
+ *
+ * @param g1
+ * @param startRes
+ * offset of the first column in the visible region (0..)
+ * @param endRes
+ * offset of the last column in the visible region (0..)
+ * @param startSeq
+ * offset of the first sequence in the visible region (0..)
+ * @param endSeq
+ * offset of the last sequence in the visible region (0..)
+ * @param yOffset
+ * vertical offset at which to draw (for wrapped alignments)
+ */
private void draw(Graphics g, int startRes, int endRes, int startSeq,
int endSeq, int offset)
{