JAL-192 patch for off-by one and pathological case (hide inserted regions + set refer...
[jalview.git] / src / jalview / gui / ScalePanel.java
index f266d36..194066e 100755 (executable)
@@ -494,7 +494,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
     int scalestartx = (startx / 10) * 10;
 
     SequenceI refSeq = av.getAlignment().getSeqrep();
-    int refSp = 0, refEp = -1;
+    int refSp = 0, refEp = -1, refStart = 0, refEnd = -1, refStartI = 0, refEndI = -1;
     if (refSeq != null)
     {
       // find bounds and set origin appopriately
@@ -504,6 +504,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
 
       refSp = refbounds[0];
       refEp = refbounds[1];
+      refStart = refbounds[2];
+      refEnd = refbounds[3];
+      refStartI = refbounds[4];
+      refEndI = refbounds[5];
       scalestartx = refSp + ((scalestartx - refSp) / 10) * 10;
     }
 
@@ -525,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
         {
@@ -536,13 +540,13 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
           // TODO show bounds if position is a gap
           // - ie L--R -> "1L|2R" for
           // marker
-          if (iadj < refSp)
+          if (iadj < refStartI)
           {
-            string = String.valueOf(iadj - refSp);
+            string = String.valueOf(iadj - refStartI);
           }
-          else if (iadj > refEp)
+          else if (iadj > refEndI)
           {
-            string = "+" + String.valueOf(iadj - refEp);
+            string = "+" + String.valueOf(iadj - refEndI);
           }
           else
           {