X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FViewportRanges.java;h=b96ac2829e20f52ec0a435ea817078dbdcd5bfbc;hb=edeca22444e251f45ce730542b4dc2187bb95b63;hp=8c137b894a5ebe2389ca3a0c04304df4ec9c7d58;hpb=8f56b5317ff932c05d9a98cb43134ec69ddd1b36;p=jalview.git diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 8c137b8..b96ac28 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -112,7 +112,7 @@ public class ViewportRanges extends ViewportProperties * Set first residue visible in the viewport, and retain the current width. * Fires a property change event. * - * @param res + * @param res * residue position */ public void setStartRes(int res) @@ -262,38 +262,15 @@ public class ViewportRanges extends ViewportProperties private int[] updateStartEndSeq(int start, int end) { - if (end == 3 && this.endSeq == 14 || end == 13 && this.endSeq == 3) { - new NullPointerException().printStackTrace(System.out); - System.out.println("ViewportRange updateStartEndSeq " + start + " " + end + " " + Thread.currentThread()); - } +// if (end == 3 && this.endSeq == 14 || end == 13 && this.endSeq == 3) { +// new NullPointerException().printStackTrace(System.out); +// System.out.println("ViewportRange updateStartEndSeq " + start + " " + end + " " + Thread.currentThread()); +// } int oldstartseq = this.startSeq; - int visibleHeight = getVisibleAlignmentHeight(); - if (start > visibleHeight - 1) - { - startSeq = Math.max(visibleHeight - 1, 0); - } - else if (start < 0) - { - startSeq = 0; - } - else - { - startSeq = start; - } - int oldendseq = this.endSeq; - if (end >= visibleHeight) - { - endSeq = Math.max(visibleHeight - 1, 0); - } - else if (end < 0) - { - endSeq = 0; - } - else - { - endSeq = end; - } + int max = getVisibleAlignmentHeight() - 1; + startSeq = Math.max(0, Math.min(start, max)); + endSeq = Math.max(0, Math.min(end, max)); return new int[] { oldstartseq, oldendseq }; } @@ -408,21 +385,15 @@ public class ViewportRanges extends ViewportProperties */ public void setViewportStartAndWidth(int start, int w) { - int vpstart = start; - if (vpstart < 0) - { - vpstart = 0; - } - - /* - * if not wrapped, don't leave white space at the right margin - */ + int vpstart = Math.max(0, start); + if (!wrappedMode) { - if ((w <= getVisibleAlignmentWidth()) - && (vpstart + w - 1 > getVisibleAlignmentWidth() - 1)) + // if not wrapped, don't leave white space at the right margin + int maxStart = getVisibleAlignmentWidth() - w; + if (maxStart >= 0) { - vpstart = getVisibleAlignmentWidth() - w; + vpstart = Math.min(vpstart, maxStart); } } @@ -441,22 +412,15 @@ public class ViewportRanges extends ViewportProperties */ public void setViewportStartAndHeight(int start, int h) { - int vpstart = start; - - int visHeight = getVisibleAlignmentHeight(); - if (vpstart < 0) + int vpstart = Math.max(0, start); + int maxStart = getVisibleAlignmentHeight() - h; + if (maxStart > 0) { - vpstart = 0; + // can't start higher than vertical extent will allow + // (viewport height is less than the full alignment + // and we are running off the bottom) + vpstart = Math.min(vpstart, maxStart); } - else if (h <= visHeight && vpstart + h > visHeight) - // viewport height is less than the full alignment and we are running off - // the bottom - { - vpstart = visHeight - h; - } - // System.out.println("ViewportRanges setviewportStartAndHeight " + vpstart - // + " " + start + " " + h + " " + getVisibleAlignmentHeight()); - setStartEndSeq(vpstart, vpstart + h - 1); }