JAL-147 improved wrapped scrolling (including Overview) with
[jalview.git] / src / jalview / appletgui / SeqPanel.java
index 5bebe28..e4e3640 100644 (file)
@@ -616,6 +616,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     int res = 0;
     int x = evt.getX();
 
+    int startRes = av.getRanges().getStartRes();
     if (av.getWrapAlignment())
     {
 
@@ -639,14 +640,15 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       }
 
       wrappedBlock = y / cHeight;
-      wrappedBlock += av.getRanges().getStartRes() / cwidth;
-
+      wrappedBlock += startRes / cwidth;
+      int startOffset = startRes % cwidth; // in case start is scrolled right
+                                           // from 0
       res = wrappedBlock * cwidth
-              + Math.min(cwidth - 1, x / av.getCharWidth());
+              + Math.min(cwidth - 1, startOffset + x / av.getCharWidth());
     }
     else
     {
-      res = (x / av.getCharWidth()) + av.getRanges().getStartRes();
+      res = (x / av.getCharWidth()) + startRes;
     }
 
     if (av.hasHiddenColumns())