}
- // int startRes, int endRes, int startSeq, int endSeq, int x, int y,
- // int x1, int x2, int y1, int y2, int startx, int starty,
private void draw(Graphics g, int startRes, int endRes, int startSeq,
int endSeq, int offset)
{
sx = (group.getStartRes() - startRes) * charWidth;
sy = offset + ((i - startSeq) * charHeight);
// width of group in pixels
- ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) - 1;
+ ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth)
+ - 1;
if (sx + ex < 0 || sx > visWidth)
{
{
ex = visWidth;
}
-
else if (sx + ex >= (endRes - startRes + 1) * charWidth)
{
ex = (endRes - startRes + 1) * charWidth;
// nothing to draw
return null;
}
-
- /*if (!av.getWrapAlignment())
- {
- LABEL_EAST = 0;
- LABEL_WEST = 0;
- }*/
// set up drawing colour
Graphics2D g = (Graphics2D) selectionImage.getGraphics();
blockEnd = hideStart - 1;
g.translate(screenY * charWidth, 0);
-
drawSelectionGroupPart(g, group,
blockStart, blockEnd, startSeq, endSeq, offset);
g.translate(-screenY * charWidth, 0);
}
}
- // g.translate(-LABEL_WEST, 0);
}
/*
int startRes, int endRes, int startSeq, int endSeq,
int verticalOffset)
{
- // set up values in case the alignment is wrapped
- /*int verticalOffset = 0;
- int horizontalOffset = 0;
- if (av.getWrapAlignment())
- {
- int hgap = charHeight;
- if (av.getScaleAboveWrapped())
- {
- hgap += charHeight;
- }
-
- // get the start res of the group and work out the offsets for it in the wrapped alignment
- int groupstart = group.getStartRes();
- int cWidth = (getWidth() - LABEL_EAST - LABEL_WEST) / charWidth;
-
- // group is in which slice of alignment? res position / width in residues
- int slice = groupstart / cWidth;
- // vertical offset is increased by slice number * number of sequences * height of each sequence
- verticalOffset = slice * (av.getAlignment().getHeight() * charHeight
- + getAnnotationHeight() + hgap) + hgap;
-
- // horizontal offset is number of residues to subtract from group residue
- // position
- horizontalOffset = (slice * cWidth);
- }*/
-
int visWidth = (endRes - startRes + 1) * charWidth;
int oldY = -1;
int sx = -1;
int sy = -1;
- int ex = -1;
-
- // position of start residue of group relative to startRes, in pixels
- sx = (group.getStartRes() - startRes) * charWidth;
-
- // width of group in pixels
- ex = (((group.getEndRes() + 1) - group.getStartRes())
- * charWidth) - 1;
+ int xwidth = -1;
for (i = startSeq; i <= endSeq; i++)
{
+ // position of start residue of group relative to startRes, in pixels
+ sx = (group.getStartRes() - startRes) * charWidth;
+
+ // width of group in pixels
+ xwidth = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth)
+ - 1;
+
sy = verticalOffset + (i - startSeq) * charHeight;
- if (sx + ex < 0 || sx > visWidth)
+ if (sx + xwidth < 0 || sx > visWidth)
{
continue;
}
// if end position is visible, draw vertical line to right of
// group
- if (sx + ex < visWidth)
+ if (sx + xwidth < visWidth)
{
- g.drawLine(sx + ex, oldY, sx + ex, sy);
+ g.drawLine(sx + xwidth, oldY, sx + xwidth, sy);
}
if (sx < 0)
{
- ex += sx;
+ xwidth += sx;
sx = 0;
}
- if (sx + ex > visWidth)
- {
- ex = visWidth;
- }
-
- else if (sx + ex >= (endRes - startRes + 1) * charWidth)
+ if (sx + xwidth >= (endRes - startRes + 1) * charWidth)
{
- ex = (endRes - startRes + 1) * charWidth;
+ xwidth = (endRes - startRes + 1) * charWidth - sx;
}
-
+
// draw horizontal line at top of group
if (top != -1)
{
- g.drawLine(sx, top, sx + ex, top);
+ g.drawLine(sx, top, sx + xwidth, top);
top = -1;
}
// draw horizontal line at bottom of group
if (bottom != -1)
{
- g.drawLine(sx, bottom, sx + ex, bottom);
+ g.drawLine(sx, bottom, sx + xwidth, bottom);
bottom = -1;
}
g.drawLine(sx, oldY, sx, sy);
}
- if (sx + ex < visWidth)
+ if (sx + xwidth < visWidth)
{
- g.drawLine(sx + ex, oldY, sx + ex, sy);
+ g.drawLine(sx + xwidth, oldY, sx + xwidth, sy);
}
if (sx < 0)
{
- ex += sx;
+ xwidth += sx;
sx = 0;
}
- if (sx + ex > visWidth)
+ if (sx + xwidth > visWidth)
{
- ex = visWidth;
+ xwidth = visWidth;
}
- else if (sx + ex >= (endRes - startRes + 1) * charWidth)
+ else if (sx + xwidth >= (endRes - startRes + 1) * charWidth)
{
- ex = (endRes - startRes + 1) * charWidth;
+ xwidth = (endRes - startRes + 1) * charWidth;
}
if (top != -1)
{
- g.drawLine(sx, top, sx + ex, top);
+ g.drawLine(sx, top, sx + xwidth, top);
top = -1;
}
if (bottom != -1)
{
- g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);
+ g.drawLine(sx, bottom - 1, sx + xwidth, bottom - 1);
bottom = -1;
}