+ /*
+ * Draw a selection group over a wrapped alignment
+ */
+ private void drawWrappedSelection(Graphics2D g, SequenceGroup group,
+ int canvasWidth,
+ int canvasHeight, int startRes)
+ {
+ int charHeight = av.getCharHeight();
+ int charWidth = av.getCharWidth();
+
+ // height gap above each panel
+ int hgap = charHeight;
+ if (av.getScaleAboveWrapped())
+ {
+ hgap += charHeight;
+ }
+
+ int cWidth = (canvasWidth - labelWidthEast - labelWidthWest)
+ / charWidth;
+ int cHeight = av.getAlignment().getHeight() * charHeight;
+
+ int startx = startRes;
+ int endx;
+ int ypos = hgap; // vertical offset
+ int maxwidth = av.getAlignment().getWidth();
+
+ if (av.hasHiddenColumns())
+ {
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth);
+ }
+
+ // chop the wrapped alignment extent up into panel-sized blocks and treat
+ // each block as if it were a block from an unwrapped alignment
+ while ((ypos <= canvasHeight) && (startx < maxwidth))
+ {
+ // set end value to be start + width, or maxwidth, whichever is smaller
+ endx = startx + cWidth - 1;
+
+ if (endx > maxwidth)
+ {
+ endx = maxwidth;
+ }
+
+ g.translate(labelWidthWest, 0);
+
+ drawUnwrappedSelection(g, group, startx, endx, 0,
+ av.getAlignment().getHeight() - 1,
+ ypos);
+
+ g.translate(-labelWidthWest, 0);
+
+ // update vertical offset
+ ypos += cHeight + getAnnotationHeight() + hgap;
+
+ // update horizontal offset
+ startx += cWidth;
+ }
+ }
+