JAL-147 unit tests added, unused setEndRes removed
[jalview.git] / src / jalview / viewmodel / ViewportRanges.java
index 36e598f..36ed984 100644 (file)
@@ -135,9 +135,10 @@ public class ViewportRanges extends ViewportProperties
     /*
      * if not wrapped, don't leave white space at the right margin
      */
-    if (!wrappedMode && (start > getVisibleAlignmentWidth() - 1))
+    int lastColumn = getVisibleAlignmentWidth() - 1;
+    if (!wrappedMode && (start > lastColumn))
     {
-      startRes = Math.max(getVisibleAlignmentWidth() - 1, 0);
+      startRes = Math.max(lastColumn, 0);
     }
     else if (start < 0)
     {
@@ -153,9 +154,9 @@ public class ViewportRanges extends ViewportProperties
     {
       endRes = 0;
     }
-    else if (!wrappedMode && (end > getVisibleAlignmentWidth() - 1))
+    else if (!wrappedMode && (end > lastColumn))
     {
-      endRes = Math.max(getVisibleAlignmentWidth() - 1, 0);
+      endRes = Math.max(lastColumn, 0);
     }
     else
     {
@@ -172,30 +173,6 @@ public class ViewportRanges extends ViewportProperties
   }
 
   /**
-   * Set last residue visible in the viewport. Fires a property change event.
-   * 
-   * @param res
-   *          residue position
-   */
-  public void setEndRes(int res)
-  {
-    int startres = res;
-    int width = getViewportWidth();
-
-    /*
-     * if not wrapped, don't leave white space at the right margin
-     */
-    if (!wrappedMode)
-    {
-      if (startres + width - 1 > getVisibleAlignmentWidth() - 1)
-      {
-        startres = getVisibleAlignmentWidth() - width;
-      }
-    }
-    setStartEndRes(startres - width + 1, startres);
-  }
-
-  /**
    * Set the first sequence visible in the viewport, maintaining the height. If
    * the viewport would extend past the last sequence, sets the viewport so it
    * sits at the bottom of the alignment. Fires a property change event.
@@ -227,9 +204,10 @@ public class ViewportRanges extends ViewportProperties
   public void setStartEndSeq(int start, int end)
   {
     int oldstartseq = this.startSeq;
-    if (start > getVisibleAlignmentHeight() - 1)
+    int visibleHeight = getVisibleAlignmentHeight();
+    if (start > visibleHeight - 1)
     {
-      startSeq = Math.max(getVisibleAlignmentHeight() - 1, 0);
+      startSeq = Math.max(visibleHeight - 1, 0);
     }
     else if (start < 0)
     {
@@ -241,9 +219,9 @@ public class ViewportRanges extends ViewportProperties
     }
 
     int oldendseq = this.endSeq;
-    if (end >= getVisibleAlignmentHeight())
+    if (end >= visibleHeight)
     {
-      endSeq = Math.max(getVisibleAlignmentHeight() - 1, 0);
+      endSeq = Math.max(visibleHeight - 1, 0);
     }
     else if (end < 0)
     {