*/
private BufferedImage drawSelectionGroup()
{
- int verticalOffset = 0;
- if (av.getWrapAlignment())
- {
- verticalOffset = charHeight;
- if (av.getScaleAboveWrapped())
- {
- verticalOffset += charHeight;
- }
- }
-
- // get a new image of the correct size
+ // get a new image of the correct size
BufferedImage selectionImage = setupImage();
if (selectionImage == null)
// nothing to draw
return null;
}
+
+ // 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);
+ }
// set up drawing colour
Graphics2D g = (Graphics2D) selectionImage.getGraphics();
int startRes = av.getRanges().getStartRes();
// set x start and end positions of group
- int startx = (group.getStartRes() - startRes) * charWidth;
- int endx = (group.getEndRes() - startRes + 1) * charWidth;
+ int startx = (group.getStartRes() - startRes - horizontalOffset)
+ * charWidth;
+ int endx = (group.getEndRes() - startRes + 1 - horizontalOffset)
+ * charWidth;
int oldY = -1;
int i = 0;