JAL-2388 Moving some alignment panel logic into overview (in progress)
[jalview.git] / src / jalview / viewmodel / OverviewDimensions.java
index 4a2dd29..4af4175 100644 (file)
@@ -138,19 +138,11 @@ public class OverviewDimensions
     {
       x = 0;
     }
-    else if (x >= width)
-    {
-      x = alwidth - 1;
-    }
 
     if (y < 0)
     {
       y = 0;
     }
-    else if (y >= sequencesHeight)
-    {
-      y = alheight - 1;
-    }
 
     //
     // Convert x value to residue position
@@ -178,13 +170,14 @@ public class OverviewDimensions
     int endRes = xAsRes + vpwidth - 1;
 
     // check in case we went off the edge of the alignment
-    if (endRes > alwidth)
+    int visAlignWidth = hiddenCols.findColumnPosition(alwidth);
+    if (endRes > visAlignWidth - 1)
     {
       // went past the end of the alignment, adjust backwards
-      endRes = alwidth;
+      endRes = visAlignWidth - 1;
       // recalc xAsRes backwards from endRes
       // add 1 because width includes xAsRes
-      xAsRes = endRes - vpwidth + 1;
+      xAsRes = hiddenCols.adjustForHiddenColumns(endRes - vpwidth + 1);
     }
 
     //
@@ -209,10 +202,11 @@ public class OverviewDimensions
     int endSeq = yAsSeq + vpheight - 1;
 
     // check in case we went off the edge of the alignment
-    if (endSeq > alheight)
+    int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
+    if (hiddenSeqs.findIndexWithoutHiddenSeqs(endSeq) > visAlignHeight - 1)
     {
       // went past the end of the alignment, adjust backwards
-      endSeq = alheight;
+      endSeq = visAlignHeight - 1;
       // recalc yAsSeq backwards from endSeq
       yAsSeq = endSeq - vpheight + 1;
     }