X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FViewportRanges.java;fp=src%2Fjalview%2Fviewmodel%2FViewportRanges.java;h=10cf583d032a71f4aff9f29c44c44d56d3e8136d;hb=e54df488cd82761bfb0e9372aeae2acc5a1324d7;hp=7c6b7ab58dcee77f3a72396c4c18449910ef9632;hpb=171bb10b5fdc06925e47025829e6cede32b85b63;p=jalview.git diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 7c6b7ab..10cf583 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -563,14 +563,13 @@ public class ViewportRanges extends ViewportProperties /** * Answers the vertical scroll position (0..) to set, given the visible column - * that is at top left. Note that if called with the total visible width of - * the alignment, this gives the maximum cursor scroll value. + * that is at top left. * *
    * Example:
    *    viewport width 40 columns (0-39, 40-79, 80-119...)
    *    column 0 returns scroll position 0
-   *    columns 0-40 return scroll position 1
+   *    columns 1-40 return scroll position 1
    *    columns 41-80 return scroll position 2
    *    etc
    * 
@@ -587,8 +586,35 @@ public class ViewportRanges extends ViewportProperties * visible whole widths */ int scroll = topLeftColumn / w; + + /* + * add 1 for a part width if there is one + */ scroll += topLeftColumn % w > 0 ? 1 : 0; return scroll; } + + /** + * Answers the maximum wrapped vertical scroll value, given the column + * position (0..) to show at top left of the visible region. + * + * @param topLeftColumn + * @return + */ + public int getWrappedMaxScroll(int topLeftColumn) + { + int scrollPosition = getWrappedScrollPosition(topLeftColumn); + + /* + * how many more widths could be drawn after this one? + */ + int columnsRemaining = getVisibleAlignmentWidth() - topLeftColumn; + int width = getViewportWidth(); + int widthsRemaining = columnsRemaining / width + + (columnsRemaining % width > 0 ? 1 : 0) - 1; + int maxScroll = scrollPosition + widthsRemaining; + + return maxScroll; + } }