else
{
// package into blocks of visible columns
- // Graphics2D g = (Graphics2D) selectionImage.getGraphics();
- // Graphics g1 = selectionImage.getGraphics();
-
int screenY = 0;
int blockStart = startRes;
int blockEnd = endRes;
g.translate(screenY * charWidth, 0);
drawSelectionGroupPart(g, group,
blockStart, blockEnd, startSeq, endSeq);
-
+
g.translate(-screenY * charWidth, 0);
}
}
horizontalOffset = (slice * cWidth);
}
- int visWidth = av.getRanges().getViewportWidth() * charWidth;
-
- // set x start and end positions of group
- int startx = (group.getStartRes() - startRes - horizontalOffset)
- * charWidth;
- int endx = (group.getEndRes() - startRes + 1 - horizontalOffset)
- * charWidth;
+ int visWidth = (endRes - startRes + 1) * charWidth;
int oldY = -1;
int i = 0;
int top = -1;
int bottom = -1;
- // get sequences to determine y positions of group
- for (i = startSeq; i <= endSeq; ++i)
+ int sx = -1;
+ int sy = -1;
+ int ex = -1;
+
+ // position of start residue of group relative to startRes, in pixels
+ sx = (group.getStartRes() - startRes - horizontalOffset) * charWidth;
+
+ // width of group in pixels
+ ex = (((group.getEndRes() + 1) - group.getStartRes() - horizontalOffset)
+ * charWidth) - 1;
+
+ for (i = startSeq; i <= endSeq; i++)
{
- int sy = verticalOffset + (i - startSeq) * charHeight;
+ sy = verticalOffset + (i - startSeq) * charHeight;
- if (group.getSequences(null)
- .contains(av.getAlignment().getSequenceAt(i)))
+ if (sx + ex < 0 || sx > visWidth)
+ {
+ continue;
+ }
+
+ if ((sx <= (endRes - startRes) * charWidth)
+ && group.getSequences(null)
+ .contains(av.getAlignment().getSequenceAt(i)))
{
if ((bottom == -1) && !group.getSequences(null)
.contains(av.getAlignment().getSequenceAt(i + 1)))
{
// if start position is visible, draw vertical line to left of
// group
- if (startx >= 0 && startx < visWidth * charWidth)
+ if (sx >= 0 && sx < visWidth)
{
- g.drawLine(startx, oldY, startx, sy);
+ g.drawLine(sx, oldY, sx, sy);
}
// if end position is visible, draw vertical line to right of
// group
- if (endx <= visWidth * charWidth)
+ if (sx + ex < visWidth)
+ {
+ g.drawLine(sx + ex, oldY, sx + ex, sy);
+ }
+
+ if (sx < 0)
{
- g.drawLine(endx, oldY, endx, sy);
+ ex += sx;
+ sx = 0;
}
- if (endx > visWidth * charWidth)
+ if (sx + ex > visWidth)
{
- endx = visWidth * charWidth;
+ ex = visWidth;
+ }
+
+ else if (sx + ex >= (endRes - startRes + 1) * charWidth)
+ {
+ ex = (endRes - startRes + 1) * charWidth;
}
// draw horizontal line at top of group
if (top != -1)
{
- g.drawLine(startx, top, endx, top);
+ g.drawLine(sx, top, sx + ex, top);
top = -1;
}
// draw horizontal line at bottom of group
if (bottom != -1)
{
- g.drawLine(startx, bottom, endx, bottom);
+ g.drawLine(sx, bottom, sx + ex, bottom);
bottom = -1;
}
}
}
}
+
if (inGroup)
{
- int sy = verticalOffset + (i - startSeq) * charHeight;
- if (startx >= 0 && startx < visWidth)
+ sy = verticalOffset + ((i - startSeq) * charHeight);
+ if (sx >= 0 && sx < visWidth)
{
- g.drawLine(startx, oldY, startx, sy);
+ g.drawLine(sx, oldY, sx, sy);
}
- if (endx < visWidth)
+ if (sx + ex < visWidth)
{
- g.drawLine(endx, oldY, endx, sy);
+ g.drawLine(sx + ex, oldY, sx + ex, sy);
}
- if (endx > visWidth)
+ if (sx < 0)
+ {
+ ex += sx;
+ sx = 0;
+ }
+
+ if (sx + ex > visWidth)
+ {
+ ex = visWidth;
+ }
+ else if (sx + ex >= (endRes - startRes + 1) * charWidth)
{
- endx = visWidth;
+ ex = (endRes - startRes + 1) * charWidth;
}
if (top != -1)
{
- g.drawLine(startx, top, endx, top);
+ g.drawLine(sx, top, sx + ex, top);
top = -1;
}
if (bottom != -1)
{
- g.drawLine(startx, bottom - 1, endx, bottom - 1);
+ g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);
bottom = -1;
}