Merge remote-tracking branch 'origin/develop' into bug/JAL-2491
[jalview.git] / src / jalview / viewmodel / OverviewDimensionsHideHidden.java
index b03f9ac..9236151 100644 (file)
@@ -51,20 +51,20 @@ public class OverviewDimensionsHideHidden extends OverviewDimensions
     int xAsRes = Math.round((float) x * alwidth / width);
 
     // get viewport width in residues
-    int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
+    int vpwidth = ranges.getViewportWidth();
 
     if (xAsRes + vpwidth > alwidth)
     {
       // went past the end of the alignment, adjust backwards
 
       // if last position was before the end of the alignment, need to update
-      if ((scrollCol + vpwidth - 1) < alwidth)
+      if ((ranges.getEndRes() + vpwidth - 1) < alwidth)
       {
         xAsRes = alwidth - vpwidth;
       }
       else
       {
-        xAsRes = scrollCol;
+        xAsRes = ranges.getEndRes();
       }
     }
 
@@ -78,24 +78,24 @@ public class OverviewDimensionsHideHidden extends OverviewDimensions
 
     // get viewport height in sequences
     // add 1 because height includes both endSeq and startSeq
-    int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
+    int vpheight = ranges.getViewportHeight();
 
     if (yAsSeq + vpheight > alheight)
     {
       // went past the end of the alignment, adjust backwards
-      if ((scrollRow + vpheight - 1) < alheight)
+      if ((ranges.getEndSeq() + vpheight - 1) < alheight)
       {
         yAsSeq = alheight - vpheight;
       }
       else
       {
-        yAsSeq = scrollRow;
+        yAsSeq = ranges.getEndSeq();
       }
     }
 
-    // update scroll values
-    scrollCol = xAsRes;
-    scrollRow = yAsSeq;
+    // update viewport
+    ranges.setStartRes(xAsRes);
+    ranges.setStartSeq(yAsSeq);
 
   }