JAL-2388 Unit tests and tidies
[jalview.git] / src / jalview / viewmodel / OverviewDimensions.java
index 60b4ee9..b34c85d 100644 (file)
@@ -91,7 +91,7 @@ public class OverviewDimensions
     {
       // wider
       width = MAX_WIDTH;
-      sequencesHeight = (int) (MAX_WIDTH / initialScale);
+      sequencesHeight = Math.round(MAX_WIDTH / initialScale);
       if (sequencesHeight < MIN_SEQ_HEIGHT)
       {
         sequencesHeight = MIN_SEQ_HEIGHT;
@@ -100,7 +100,7 @@ public class OverviewDimensions
     else
     {
       // taller
-      width = (int) (MAX_WIDTH * initialScale);
+      width = Math.round(MAX_WIDTH * initialScale);
       sequencesHeight = MAX_SEQ_HEIGHT;
 
       if (width < MIN_WIDTH)
@@ -173,7 +173,8 @@ public class OverviewDimensions
       // if last position was before the end of the alignment, need to update
       if ((scrollCol + vpwidth - 1) < visAlignWidth)
       {
-        visXAsRes = hiddenCols.findColumnNToLeft(vpwidth - 1, alwidth - 1);
+        visXAsRes = hiddenCols.findColumnPosition(hiddenCols
+                .findColumnNToLeft(vpwidth - 1, alwidth - 1));
       }
       else
       {
@@ -199,19 +200,16 @@ public class OverviewDimensions
     yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs
             .findIndexWithoutHiddenSeqs(yAsSeq));
 
-    // get where end seq should be by adding the viewport height on
-    int endSeq = yAsSeq + vpheight - 1;
-
     // check in case we went off the edge of the alignment
     int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
     int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
-    if (hiddenSeqs.findIndexWithoutHiddenSeqs(endSeq) > visAlignHeight)
+    if (visYAsRes + vpheight - 1 > visAlignHeight)
     {
       // went past the end of the alignment, adjust backwards
       if ((scrollRow + vpheight - 1) < visAlignHeight)
       {
-        visYAsRes = hiddenSeqs
-                .findIndexNAboveRow(vpheight - 1, alheight - 1);
+        visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs
+                .findIndexNAboveRow(vpheight - 1, alheight - 1));
       }
       else
       {
@@ -219,10 +217,9 @@ public class OverviewDimensions
       }
     }
 
-    // convert absolute positions back to visible alignment positions for
-    // viewport scrolling
+    // update scroll values
     scrollCol = visXAsRes;
-    scrollRow = visYAsRes; // hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
+    scrollRow = visYAsRes;
 
   }
 
@@ -278,7 +275,6 @@ public class OverviewDimensions
     g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
   }
 
-  // don't like this, scroll vals are separate from setting code
   public int getScrollCol()
   {
     return scrollCol;