JAL-2571 Corrected alignment width/height checks to visible only
[jalview.git] / src / jalview / viewmodel / ViewportRanges.java
index da39e36..56c1d39 100644 (file)
@@ -20,7 +20,6 @@
  */
 package jalview.viewmodel;
 
-import jalview.api.AlignViewportI;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 
@@ -122,9 +121,9 @@ public class ViewportRanges extends ViewportProperties
   public void setStartEndRes(int start, int end)
   {
     int oldstartres = this.startRes;
-    if (start > al.getWidth() - 1)
+    if (start > getVisibleAlignmentWidth() - 1)
     {
-      startRes = al.getWidth() - 1;
+      startRes = getVisibleAlignmentWidth() - 1;
     }
     else if (start < 0)
     {
@@ -164,9 +163,9 @@ public class ViewportRanges extends ViewportProperties
   {
     int startres = res;
     int width = getViewportWidth();
-    if (startres + width - 1 > al.getWidth() - 1)
+    if (startres + width - 1 > getVisibleAlignmentWidth() - 1)
     {
-      startres = al.getWidth() - width;
+      startres = getVisibleAlignmentWidth() - width;
     }
     setStartEndRes(startres - width + 1, startres);
   }
@@ -183,9 +182,9 @@ public class ViewportRanges extends ViewportProperties
   {
     int startseq = seq;
     int height = getViewportHeight();
-    if (startseq + height - 1 > al.getHeight() - 1)
+    if (startseq + height - 1 > getVisibleAlignmentHeight() - 1)
     {
-      startseq = al.getHeight() - height;
+      startseq = getVisibleAlignmentHeight() - height;
     }
     setStartEndSeq(startseq, startseq + height - 1);
   }
@@ -203,9 +202,9 @@ public class ViewportRanges extends ViewportProperties
   public void setStartEndSeq(int start, int end)
   {
     int oldstartseq = this.startSeq;
-    if (start > al.getHeight() - 1)
+    if (start > getVisibleAlignmentHeight() - 1)
     {
-      startSeq = al.getHeight() - 1;
+      startSeq = getVisibleAlignmentHeight() - 1;
     }
     else if (start < 0)
     {
@@ -217,9 +216,9 @@ public class ViewportRanges extends ViewportProperties
     }
 
     int oldendseq = this.endSeq;
-    if (end >= al.getHeight())
+    if (end >= getVisibleAlignmentHeight())
     {
-      endSeq = al.getHeight() - 1;
+      endSeq = getVisibleAlignmentHeight() - 1;
     }
     else if (end < 0)
     {
@@ -327,9 +326,9 @@ public class ViewportRanges extends ViewportProperties
     {
       vpstart = 0;
     }
-    else if (vpstart + w - 1 > al.getWidth() - 1)
+    else if (vpstart + w - 1 > getVisibleAlignmentWidth() - 1)
     {
-      vpstart = al.getWidth() - 1;
+      vpstart = getVisibleAlignmentWidth() - 1;
     }
     setStartEndRes(vpstart, vpstart + w - 1);
   }
@@ -351,9 +350,9 @@ public class ViewportRanges extends ViewportProperties
     {
       vpstart = 0;
     }
-    else if (vpstart + h - 1 > al.getHeight() - 1)
+    else if (vpstart + h - 1 > getVisibleAlignmentHeight() - 1)
     {
-      vpstart = al.getHeight() - h;
+      vpstart = getVisibleAlignmentHeight() - h;
     }
     setStartEndSeq(vpstart, vpstart + h - 1);
   }
@@ -399,7 +398,7 @@ public class ViewportRanges extends ViewportProperties
     }
     else
     {
-      if (endSeq >= al.getHeight() - 1)
+      if (endSeq >= getVisibleAlignmentHeight() - 1)
       {
         return false;
       }
@@ -430,7 +429,7 @@ public class ViewportRanges extends ViewportProperties
     }
     else
     {
-      if (endRes > al.getWidth() - 1)
+      if (endRes > getVisibleAlignmentWidth() - 1)
       {
         return false;
       }
@@ -463,11 +462,8 @@ public class ViewportRanges extends ViewportProperties
    *          x position in alignment
    * @param y
    *          y position in alignment
-   * @param av
-   *          viewport to be visible in. Here until hidden columns JAL-2388
-   *          merged, then use alignment to get hidden cols
    */
-  public void scrollToVisible(int x, int y, AlignViewportI av)
+  public void scrollToVisible(int x, int y)
   {
     while (y < startSeq)
     {