X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FViewportRanges.java;fp=src%2Fjalview%2Fviewmodel%2FViewportRanges.java;h=36e598f6d24c44fa5de747632c51099e5b1c8e53;hb=682503a8ef93a72d63431a2818bd550623cd2918;hp=f290ae78f0e14cbe4e42d0e904d1ee8622cb719d;hpb=eceeb384e2117b35c85a0abdf69a6ddaafd66b6e;p=jalview.git diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index f290ae7..36e598f 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -577,4 +577,35 @@ public class ViewportRanges extends ViewportProperties { wrappedMode = wrapped; } + + /** + * 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. + * + *
+   * 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 41-80 return scroll position 2
+   *    etc
+   * 
+ * + * @param topLeftColumn + * (0..) + * @return + */ + public int getWrappedScrollPosition(final int topLeftColumn) + { + int w = getViewportWidth(); + + /* + * visible whole widths + */ + int scroll = topLeftColumn / w; + scroll += topLeftColumn % w > 0 ? 1 : 0; + + return scroll; + } }