From 303c3ea0afc3b05d33ec82208ad6be239f1bd1f0 Mon Sep 17 00:00:00 2001 From: kiramt Date: Wed, 16 Aug 2017 14:25:03 +0100 Subject: [PATCH] JAL-2556 start to account for wrapped alignments --- src/jalview/gui/SeqCanvas.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index e999e78..558c1ca 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -936,8 +936,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI if (sx < 0) { - // ex += sx; - // sx = 0; + ex += sx; + sx = 0; } if (sx + ex > visWidth) @@ -1034,6 +1034,16 @@ 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 BufferedImage selectionImage = setupImage(); @@ -1051,6 +1061,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // set up drawing colour Graphics2D g = (Graphics2D) selectionImage.getGraphics(); + g.translate(LABEL_WEST, 0); // set background to transparent g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f)); g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight()); @@ -1079,7 +1090,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int startSeq = av.getRanges().getStartSeq(); for (i = startSeq; i <= av.getRanges().getEndSeq(); ++i) { - int sy = (i - startSeq) * charHeight; + int sy = verticalOffset + (i - startSeq) * charHeight; if (group.getSequences(null) .contains(av.getAlignment().getSequenceAt(i))) @@ -1145,7 +1156,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } if (inGroup) { - int sy = (i - startSeq) * charHeight; + int sy = verticalOffset + (i - startSeq) * charHeight; if (startx >= 0 && startx < visWidth) { g.drawLine(startx, oldY, startx, sy); @@ -1175,7 +1186,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI inGroup = false; } - + g.translate(-LABEL_WEST, 0); return selectionImage; } -- 1.7.10.2