From: kiramt Date: Mon, 13 Nov 2017 16:42:20 +0000 (+0000) Subject: JAl-2811 Working for wrapped panels too X-Git-Tag: Release_2_10_3b1~28^2~2^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2f0ad8e5b9b1fbb89be632d19ba1ff78d34b9399;p=jalview.git JAl-2811 Working for wrapped panels too --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index bd2862a..2d040a3 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1275,8 +1275,48 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // define our cursor image BufferedImage cursorImage = null; + int yoffset = 0; + int xoffset = 0; + int startx = startRes; + int endx = endRes; + if (av.getWrapAlignment()) + { + // work out the correct offsets for the cursor + int charHeight = av.getCharHeight(); + int charWidth = av.getCharWidth(); + int canvasWidth = getWidth(); + int canvasHeight = getHeight(); + + // height gap above each panel + int hgap = charHeight; + if (av.getScaleAboveWrapped()) + { + hgap += charHeight; + } + + int cWidth = (canvasWidth - labelWidthEast - labelWidthWest) + / charWidth; + int cHeight = av.getAlignment().getHeight() * charHeight; + + endx = startx + cWidth - 1; + int ypos = hgap; // vertical offset + + // iterate down the wrapped panels + while ((ypos <= canvasHeight) && (endx < cursorX)) + { + // update vertical offset + ypos += cHeight + getAnnotationHeight() + hgap; + + // update horizontal offset + startx += cWidth; + endx = startx + cWidth - 1; + } + yoffset = ypos; + xoffset = labelWidthWest; + } + if (av.cursorMode && cursorY >= startSeq && cursorY <= endSeq - && cursorX >= startRes && cursorX <= endRes) + && cursorX >= startx && cursorX <= endx) { // get a new image of the correct size cursorImage = setupImage(); @@ -1286,29 +1326,16 @@ public class SeqCanvas extends JComponent implements ViewportListenerI SequenceI seq = av.getAlignment().getSequenceAt(cursorY); char s = seq.getCharAt(cursorX); - int offset = 0; - if (av.getWrapAlignment()) - { - // work out the correct offset for the cursor - offset = wrappedSpaceAboveAlignment; - int currentWidth = 0; - while ((currentWidth < wrappedVisibleWidths) - && (currentWidth < cursorX)) - { - offset += wrappedRepeatHeightPx; - currentWidth++; - } - } - seqRdr.drawCursor(g, s, - (cursorX - startRes) * av.getCharWidth(), - offset + ((cursorY - startSeq) * av.getCharHeight())); + xoffset + (cursorX - startx) * av.getCharWidth(), + yoffset + (cursorY - startSeq) * av.getCharHeight()); g.dispose(); } return cursorImage; } + /* * Set up graphics for selection group */