From: hansonr Date: Thu, 18 Apr 2019 17:54:08 +0000 (-0500) Subject: Corrects incorrect calls to ViewportRanges.setEndSeq() X-Git-Tag: Release_2_11_4_0~45^2~18^2~143 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c0b77a767e71bffd8f55704f9a64f943f559e4f6;p=jalview.git Corrects incorrect calls to ViewportRanges.setEndSeq() This function has the limit of height - 1, not height. Also adds safety for start < 0 in ViewportRanges.setEndSeq(); --- diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index bad2383..2cf33ac 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -2071,7 +2071,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, seqs, 0, viewport.getAlignment().getWidth(), viewport.getAlignment())); - viewport.getRanges().setEndSeq(viewport.getAlignment().getHeight()); + viewport.getRanges().setEndSeq(viewport.getAlignment().getHeight() - 1); // BH + // 2019.04.18 viewport.getAlignment().getWidth(); viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index d10591e..2bead46 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -253,7 +253,7 @@ public class AlignViewport extends AlignmentViewport public void resetSeqLimits(int height) { - ranges.setEndSeq(height / getCharHeight()); + ranges.setEndSeq(height / getCharHeight() - 1); // BH 2019.04.18 } boolean centreColumnLabels; diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 77b8552..27a0f76 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2224,7 +2224,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { // propagate alignment changed. - viewport.getRanges().setEndSeq(alignment.getHeight()); + viewport.getRanges().setEndSeq(alignment.getHeight() - 1); if (annotationAdded) { // Duplicate sequence annotation in all views. diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 5ef2568..7d01222 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -743,7 +743,7 @@ public class AlignViewport extends AlignmentViewport } } - ranges.setEndSeq(getAlignment().getHeight()); + ranges.setEndSeq(getAlignment().getHeight() - 1); // BH 2019.04.18 firePropertyChange("alignment", null, getAlignment().getSequences()); } diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 6f817bb..4f671da 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -224,6 +224,7 @@ public class ViewportRanges extends ViewportProperties */ public void setStartEndSeq(int start, int end) { + // System.out.println("ViewportRange setStartEndSeq " + start + " " + end); int[] oldvalues = updateStartEndSeq(start, end); int oldstartseq = oldvalues[0]; int oldendseq = oldvalues[1]; @@ -285,12 +286,12 @@ public class ViewportRanges extends ViewportProperties * event. * * @param seq - * sequence position + * sequence position in the range [0, height) */ public void setEndSeq(int seq) { - int height = getViewportHeight(); - setStartEndSeq(seq - height + 1, seq); + // BH 2018.04.18 added safety for seq < 0; comment about not being >= height + setStartEndSeq(Math.max(0, seq + 1 - getViewportHeight()), seq); } /** @@ -425,17 +426,21 @@ public class ViewportRanges extends ViewportProperties public void setViewportStartAndHeight(int start, int h) { int vpstart = start; + + int visHeight = getVisibleAlignmentHeight(); if (vpstart < 0) { vpstart = 0; } - else if ((h <= getVisibleAlignmentHeight()) - && (vpstart + h - 1 > getVisibleAlignmentHeight() - 1)) + else if (h <= visHeight && vpstart + h > visHeight) // viewport height is less than the full alignment and we are running off // the bottom { - vpstart = getVisibleAlignmentHeight() - h; + vpstart = visHeight - h; } + // System.out.println("ViewportRanges setviewportStartAndHeight " + vpstart + // + " " + start + " " + h + " " + getVisibleAlignmentHeight()); + setStartEndSeq(vpstart, vpstart + h - 1); }