JAL-192 show reference sequence position and residue in ruler
authorJim Procter <jprocter@issues.jalview.org>
Wed, 27 Apr 2016 15:36:28 +0000 (16:36 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 27 Apr 2016 15:36:28 +0000 (16:36 +0100)
src/jalview/gui/ScalePanel.java

index 3ab681c..61f1b36 100755 (executable)
@@ -503,14 +503,45 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
     }
 
     String string;
-    int maxX = 0;
-
+    boolean isrgap = false;
+    char rc;
+    int maxX = 0, refN, iadj;
+    SequenceI refSeq = av.getAlignment().getSeqrep();
+    int refSp = -1, refEp = -1;
+    if (refSeq != null)
+    {
+      refSp = refSeq.findIndex(refSeq.getStart()) - 1;
+      refEp = refSeq.findIndex(refSeq.getEnd()) - 1;
+    }
+    // todo: add a 'reference origin column' to set column number relative to
     for (int i = scalestartx; i < endx; i += 5)
     {
       if ((i % 10) == 0)
       {
-        string = String.valueOf(av.getColumnSelection()
-                .adjustForHiddenColumns(i));
+        iadj = av.getColumnSelection().adjustForHiddenColumns(i) - 1;
+        if (refSeq == null)
+        {
+          string = String.valueOf(iadj);
+        }
+        else
+        {
+          refN = refSeq.findPosition(iadj);
+          // TODO show bounds if position is a gap
+          // - ie L--R -> "1L|2R" for
+          // marker
+          if (iadj < refSp)
+          {
+            string = String.valueOf(iadj - refSp);
+          }
+          else if (iadj > refEp)
+          {
+            string = "+" + String.valueOf(iadj - refEp);
+          }
+          else
+          {
+            string = String.valueOf(refN) + refSeq.getCharAt(iadj);
+          }
+        }
         if ((i - startx - 1) * avCharWidth > maxX)
         {
           gg.drawString(string, (i - startx - 1) * avCharWidth, y);