JAL-2851 Fix merge error breaking vertical scrolling
[jalview.git] / src / jalview / gui / SeqCanvas.java
index 8d9e537..95d672d 100755 (executable)
@@ -1266,8 +1266,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
           int endSeq)
   {
     // convert the cursorY into a position on the visible alignment
-    int cursor_ypos = av.getAlignment().getHiddenSequences()
-            .findIndexWithoutHiddenSeqs(cursorY);
+    int cursor_ypos = cursorY;
 
     // don't do work unless we have to
     if (cursor_ypos >= startSeq && cursor_ypos <= endSeq)
@@ -1281,52 +1280,56 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
       int cursor_xpos = av.getAlignment().getHiddenColumns()
               .findColumnPosition(cursorX);
 
-      if (av.getWrapAlignment())
+      if (av.getAlignment().getHiddenColumns().isVisible(cursorX))
       {
-        // 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())
+        if (av.getWrapAlignment())
         {
-          hgap += charHeight;
-        }
+          // 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;
+          int cWidth = (canvasWidth - labelWidthEast - labelWidthWest)
+                  / charWidth;
+          int cHeight = av.getAlignment().getHeight() * charHeight;
 
-        endx = startx + cWidth - 1;
-        int ypos = hgap; // vertical offset
+          endx = startx + cWidth - 1;
+          int ypos = hgap; // vertical offset
 
-        // iterate down the wrapped panels
-        while ((ypos <= canvasHeight) && (endx < cursor_xpos))
-        {
-          // update vertical offset
-          ypos += cHeight + getAnnotationHeight() + hgap;
+          // iterate down the wrapped panels
+          while ((ypos <= canvasHeight) && (endx < cursor_xpos))
+          {
+            // update vertical offset
+            ypos += cHeight + getAnnotationHeight() + hgap;
 
-          // update horizontal offset
-          startx += cWidth;
-          endx = startx + cWidth - 1;
+            // update horizontal offset
+            startx += cWidth;
+            endx = startx + cWidth - 1;
+          }
+          yoffset = ypos;
+          xoffset = labelWidthWest;
         }
-        yoffset = ypos;
-        xoffset = labelWidthWest;
-      }
 
-      // now check if cursor is within range for x values
-      if (cursor_xpos >= startx && cursor_xpos <= endx)
-      {
-        // get the character the cursor is drawn at
-        SequenceI seq = av.getAlignment().getSequenceAt(cursorY);
-        char s = seq.getCharAt(cursorX);
+        // now check if cursor is within range for x values
+        if (cursor_xpos >= startx && cursor_xpos <= endx)
+        {
+          // get the character the cursor is drawn at
+          SequenceI seq = av.getAlignment().getSequenceAt(cursorY);
+          char s = seq.getCharAt(cursorX);
 
-        seqRdr.drawCursor(g, s,
-                xoffset + (cursor_xpos - startx) * av.getCharWidth(),
-                yoffset + (cursor_ypos - startSeq) * av.getCharHeight());
+          seqRdr.drawCursor(g, s,
+                  xoffset + (cursor_xpos - startx) * av.getCharWidth(),
+                  yoffset + (cursor_ypos - startSeq) * av.getCharHeight());
+        }
       }
     }
   }
@@ -1780,31 +1783,15 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
       {
         scrollX = -range;
       }
-
-      // Both scrolling and resizing change viewport ranges: scrolling changes
-      // both start and end points, but resize only changes end values.
-      // Here we only want to fastpaint on a scroll, with resize using a normal
-      // paint, so scroll events are identified as changes to the horizontal or
-      // vertical start value.
-      if (eventName.equals(ViewportRanges.STARTRES))
-      {
-         if (av.getWrapAlignment())
-          {
-            fastPaintWrapped(scrollX);
-          }
-          else
-          {
-            fastPaint(scrollX, 0);
-          }
-      }
-      else if (eventName.equals(ViewportRanges.STARTSEQ))
-      {
-        // scroll
-        fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
-      }
-      else if (eventName.equals(ViewportRanges.STARTRESANDSEQ))
-      {
-        if (av.getWrapAlignment())
+    }
+    // Both scrolling and resizing change viewport ranges: scrolling changes
+    // both start and end points, but resize only changes end values.
+    // Here we only want to fastpaint on a scroll, with resize using a normal
+    // paint, so scroll events are identified as changes to the horizontal or
+    // vertical start value.
+    if (eventName.equals(ViewportRanges.STARTRES))
+    {
+      if (av.getWrapAlignment())
         {
           fastPaintWrapped(scrollX);
         }
@@ -1812,11 +1799,26 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
         {
           fastPaint(scrollX, 0);
         }
-        // bizarrely, we only need to scroll on the x value here as fastpaint
-        // copies the full height of the image anyway. Passing in the y value
-        // causes nasty repaint artefacts, which only disappear on a full
-        // repaint.
+    }
+    else if (eventName.equals(ViewportRanges.STARTSEQ))
+    {
+      // scroll
+      fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
+    }
+    else if (eventName.equals(ViewportRanges.STARTRESANDSEQ))
+    {
+      if (av.getWrapAlignment())
+      {
+        fastPaintWrapped(scrollX);
+      }
+      else
+      {
+        fastPaint(scrollX, 0);
       }
+      // bizarrely, we only need to scroll on the x value here as fastpaint
+      // copies the full height of the image anyway. Passing in the y value
+      // causes nasty repaint artefacts, which only disappear on a full
+      // repaint.
     }
   }
 
@@ -1833,7 +1835,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI
   {
     ViewportRanges ranges = av.getRanges();
 
-    if (Math.abs(scrollX) > ranges.getViewportWidth())
+    // if (Math.abs(scrollX) > ranges.getViewportWidth())
+    // JAL-2836, 2836 temporarily removed wrapped fastpaint for release 2.10.3
+    if (true)
     {
       /*
        * shift of more than one view width is