X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;fp=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=9b6c298048acf351f109e75e444cb6e78677fe18;hb=3dfe7249d7b369536e3e151c7e7b44c0d4d1458e;hp=558c1cab0cc336e3f730d8bc0622e443885c06a5;hpb=303c3ea0afc3b05d33ec82208ad6be239f1bd1f0;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 558c1ca..9b6c298 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1034,17 +1034,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI */ 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) @@ -1058,6 +1048,32 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // 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(); @@ -1077,8 +1093,10 @@ public class SeqCanvas extends JComponent implements ViewportListenerI 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;