From: kiramt Date: Wed, 16 Aug 2017 14:51:55 +0000 (+0100) Subject: JAL-2665 Selecting on wrapped alignments X-Git-Tag: Release_2_10_3b1~140^2~15 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3dfe7249d7b369536e3e151c7e7b44c0d4d1458e;p=jalview.git JAL-2665 Selecting on wrapped alignments --- 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;