X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FViewportRanges.java;h=c2bcf3f5b8539c5e96f9daf211f5d394f4638fa1;hb=52298f6987c5807b9f672e33f416dee9e14e1952;hp=56c1d39e789a7eb02e63252dfbdd5ca9b0bd1b38;hpb=2b2c9e1a88930585de0b5c205e4ae6f0174440d2;p=jalview.git diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 56c1d39..c2bcf3f 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -32,6 +32,14 @@ import jalview.datamodel.HiddenColumns; */ public class ViewportRanges extends ViewportProperties { + public static final String STARTRES = "startres"; + + public static final String ENDRES = "endres"; + + public static final String STARTSEQ = "startseq"; + + public static final String ENDSEQ = "endseq"; + // start residue of viewport private int startRes; @@ -123,7 +131,7 @@ public class ViewportRanges extends ViewportProperties int oldstartres = this.startRes; if (start > getVisibleAlignmentWidth() - 1) { - startRes = getVisibleAlignmentWidth() - 1; + startRes = Math.max(getVisibleAlignmentWidth() - 1, 0); } else if (start < 0) { @@ -139,17 +147,21 @@ public class ViewportRanges extends ViewportProperties { endRes = 0; } + else if (end > getVisibleAlignmentWidth() - 1) + { + endRes = Math.max(getVisibleAlignmentWidth() - 1, 0); + } else { endRes = end; } - changeSupport.firePropertyChange("startres", oldstartres, startRes); + changeSupport.firePropertyChange(STARTRES, oldstartres, startRes); if (oldstartres == startRes) { // event won't be fired if start positions are same // fire an event for the end positions in case they changed - changeSupport.firePropertyChange("endres", oldendres, endRes); + changeSupport.firePropertyChange(ENDRES, oldendres, endRes); } } @@ -204,7 +216,7 @@ public class ViewportRanges extends ViewportProperties int oldstartseq = this.startSeq; if (start > getVisibleAlignmentHeight() - 1) { - startSeq = getVisibleAlignmentHeight() - 1; + startSeq = Math.max(getVisibleAlignmentHeight() - 1, 0); } else if (start < 0) { @@ -218,7 +230,7 @@ public class ViewportRanges extends ViewportProperties int oldendseq = this.endSeq; if (end >= getVisibleAlignmentHeight()) { - endSeq = getVisibleAlignmentHeight() - 1; + endSeq = Math.max(getVisibleAlignmentHeight() - 1, 0); } else if (end < 0) { @@ -229,12 +241,12 @@ public class ViewportRanges extends ViewportProperties endSeq = end; } - changeSupport.firePropertyChange("startseq", oldstartseq, startSeq); + changeSupport.firePropertyChange(STARTSEQ, oldstartseq, startSeq); if (oldstartseq == startSeq) { // event won't be fired if start positions are the same // fire in case the end positions changed - changeSupport.firePropertyChange("endseq", oldendseq, endSeq); + changeSupport.firePropertyChange(ENDSEQ, oldendseq, endSeq); } } @@ -326,9 +338,12 @@ public class ViewportRanges extends ViewportProperties { vpstart = 0; } - else if (vpstart + w - 1 > getVisibleAlignmentWidth() - 1) + else if ((w <= getVisibleAlignmentWidth()) + && (vpstart + w - 1 > getVisibleAlignmentWidth() - 1)) + // viewport width is less than the full alignment and we are running off the + // RHS edge { - vpstart = getVisibleAlignmentWidth() - 1; + vpstart = getVisibleAlignmentWidth() - w; } setStartEndRes(vpstart, vpstart + w - 1); } @@ -350,7 +365,10 @@ public class ViewportRanges extends ViewportProperties { vpstart = 0; } - else if (vpstart + h - 1 > getVisibleAlignmentHeight() - 1) + else if ((h <= getVisibleAlignmentHeight()) + && (vpstart + h - 1 > getVisibleAlignmentHeight() - 1)) + // viewport height is less than the full alignment and we are running off + // the bottom { vpstart = getVisibleAlignmentHeight() - h; } @@ -429,7 +447,7 @@ public class ViewportRanges extends ViewportProperties } else { - if (endRes > getVisibleAlignmentWidth() - 1) + if (endRes >= getVisibleAlignmentWidth() - 1) { return false; }