From: kiramt Date: Tue, 14 Mar 2017 16:41:33 +0000 (+0000) Subject: JAL-2439 Fixes to out-by-one sequence indexing in gui classes X-Git-Tag: Release_2_10_2~3^2~92^2~41 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5edb685cf52a607834a82c10cb4dd9c139e31dde;p=jalview.git JAL-2439 Fixes to out-by-one sequence indexing in gui classes --- diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index af7e9cd..dd7c8fa 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -823,7 +823,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { av.setStartSeq(offy); av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height - / av.getCharHeight()); + / av.getCharHeight() - 1); } } diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 8f8ed35..18281d9 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -117,7 +117,7 @@ public class IdCanvas extends Panel } else { - transY = imgHeight - vertical * av.getCharHeight(); + transY = imgHeight - ((vertical + 1) * av.getCharHeight()); } } else if (vertical < 0) @@ -264,7 +264,7 @@ public class IdCanvas extends Panel { // Now draw the id strings SequenceI seq; - for (int i = starty; i < endy; i++) + for (int i = starty; i <= endy; i++) { seq = av.getAlignment().getSequenceAt(i); diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index fd74c4a..cd5aa74 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -252,7 +252,7 @@ public class SeqCanvas extends Panel } else { - transY = imgHeight - vertical * avcharHeight; + transY = imgHeight - ((vertical + 1) * avcharHeight); } } else if (vertical < 0) @@ -613,7 +613,7 @@ public class SeqCanvas extends Panel // / First draw the sequences // /////////////////////////// - for (int i = startSeq; i < endSeq; i++) + for (int i = startSeq; i <= endSeq; i++) { nextSeq = av.getAlignment().getSequenceAt(i); @@ -697,7 +697,7 @@ public class SeqCanvas extends Panel int bottom = -1; int alHeight = av.getAlignment().getHeight() - 1; - for (i = startSeq; i < endSeq; i++) + for (i = startSeq; i <= endSeq; i++) { sx = (group.getStartRes() - startRes) * avcharWidth; sy = offset + ((i - startSeq) * avcharHeight); diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 552d166..631638f 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -801,7 +801,8 @@ public class AlignmentPanel extends GAlignmentPanel implements { av.setStartSeq(offy); av.setEndSeq(offy - + (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight())); + + (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight()) + - 1); } } diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index c753cae..11bb14b 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -175,10 +175,10 @@ public class IdCanvas extends JPanel } else { - transY = imgHeight - (vertical * av.getCharHeight()); + transY = imgHeight - ((vertical + 1) * av.getCharHeight()); } } - else if (vertical < 0) + else if (vertical < 0) // scroll up { es = ss - vertical; @@ -354,7 +354,7 @@ public class IdCanvas extends JPanel SequenceI sequence; // Now draw the id strings - for (int i = starty; i < endy; i++) + for (int i = starty; i <= endy; i++) { sequence = av.getAlignment().getSequenceAt(i); diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 54d2be7..226e0df 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -306,7 +306,7 @@ public class SeqCanvas extends JComponent } else { - transY = imgHeight - (vertical * charHeight); + transY = imgHeight - ((vertical + 1) * charHeight); } } else if (vertical < 0) @@ -719,7 +719,7 @@ public class SeqCanvas extends JComponent // / First draw the sequences // /////////////////////////// - for (int i = startSeq; i < endSeq; i++) + for (int i = startSeq; i <= endSeq; i++) { nextSeq = av.getAlignment().getSequenceAt(i); if (nextSeq == null) @@ -803,7 +803,7 @@ public class SeqCanvas extends JComponent int top = -1; int bottom = -1; - for (i = startSeq; i < endSeq; i++) + for (i = startSeq; i <= endSeq; i++) { sx = (group.getStartRes() - startRes) * charWidth; sy = offset + ((i - startSeq) * charHeight);