JAL-192 patch for off-by one and pathological case (hide inserted regions + set refer...
authorJim Procter <jprocter@issues.jalview.org>
Thu, 5 May 2016 13:25:30 +0000 (14:25 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 5 May 2016 13:25:30 +0000 (14:25 +0100)
src/jalview/datamodel/ColumnSelection.java
src/jalview/gui/ScalePanel.java
test/jalview/datamodel/ColumnSelectionTest.java

index e3a8472..6fd76b2 100644 (file)
@@ -600,7 +600,7 @@ public class ColumnSelection
    * Return absolute column index for a visible column index
    * 
    * @param column
-   *          int column index in alignment view
+   *          int column index in alignment view (count from zero)
    * @return alignment column index for column
    */
   public int adjustForHiddenColumns(int column)
index aedb157..194066e 100755 (executable)
@@ -529,10 +529,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
     {
       if (((i - refSp) % 10) == 0)
       {
-        iadj = av.getColumnSelection().adjustForHiddenColumns(i) - 1;
+        iadj = av.getColumnSelection().adjustForHiddenColumns(i - 1);
         if (refSeq == null)
         {
-          string = String.valueOf(iadj + 1);
+          string = String.valueOf(iadj);
         }
         else
         {
index 63f80b2..86e7949 100644 (file)
@@ -155,6 +155,21 @@ public class ColumnSelectionTest
 
   }
 
+  @Test(groups={"Functional"})
+  public void testLocateVisibleBoundsPathologicals()
+  {
+    // test some pathological cases we missed
+    AlignmentI al = new Alignment(new SequenceI[] { new Sequence("refseqGaptest","KTDVTI----------NFI-----G----L")});
+    ColumnSelection cs = new ColumnSelection();
+    cs.hideInsertionsFor(al.getSequenceAt(0));
+    assertEquals(
+            "G",
+            ""
+                    + al.getSequenceAt(0).getCharAt(
+                            cs.adjustForHiddenColumns(9)));
+
+
+  }
   @Test(groups = { "Functional" })
   public void testHideColumns()
   {