From: kiramt Date: Tue, 14 Nov 2017 13:43:40 +0000 (+0000) Subject: JAL-2811 Made it work for hidden columns/seqs too X-Git-Tag: Release_2_10_3b1~28^2~2^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8fb1345b723e9104cab28c80b352a882e502b1ed;p=jalview.git JAL-2811 Made it work for hidden columns/seqs too --- 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(); } }