From 8fb1345b723e9104cab28c80b352a882e502b1ed Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 14 Nov 2017 13:43:40 +0000 Subject: [PATCH] JAL-2811 Made it work for hidden columns/seqs too --- src/jalview/gui/SeqCanvas.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 394a0b6..4aa7851 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1275,13 +1275,22 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // define our cursor image BufferedImage cursorImage = null; + // convert the cursorY into a position on the visible alignment + int cursor_ypos = av.getAlignment().getHiddenColumns() + .findColumnPosition(cursorY); + // don't do work unless we have to - if (av.cursorMode && cursorY >= startSeq && cursorY <= endSeq) + if (av.cursorMode && cursor_ypos >= startSeq && cursor_ypos <= endSeq) { int yoffset = 0; int xoffset = 0; int startx = startRes; int endx = endRes; + + // convert the cursorX into a position on the visible alignment + int cursor_xpos = av.getAlignment().getHiddenColumns() + .findColumnPosition(cursorX); + if (av.getWrapAlignment()) { // work out the correct offsets for the cursor @@ -1305,7 +1314,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int ypos = hgap; // vertical offset // iterate down the wrapped panels - while ((ypos <= canvasHeight) && (endx < cursorX)) + while ((ypos <= canvasHeight) && (endx < cursor_xpos)) { // update vertical offset ypos += cHeight + getAnnotationHeight() + hgap; @@ -1319,7 +1328,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } // now check if cursor is within range for x values - if (cursorX >= startx && cursorX <= endx) + if (cursor_xpos >= startx && cursor_xpos <= endx) { // get a new image of the correct size cursorImage = setupImage(); @@ -1330,8 +1339,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI char s = seq.getCharAt(cursorX); seqRdr.drawCursor(g, s, - xoffset + (cursorX - startx) * av.getCharWidth(), - yoffset + (cursorY - startSeq) * av.getCharHeight()); + xoffset + (cursor_xpos - startx) * av.getCharWidth(), + yoffset + (cursor_ypos - startSeq) * av.getCharHeight()); g.dispose(); } } -- 1.7.10.2