From: Jim Procter Date: Wed, 27 Apr 2016 15:36:28 +0000 (+0100) Subject: JAL-192 show reference sequence position and residue in ruler X-Git-Tag: Release_2_10_0~235^2~2^2~1^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ed87c8b39a1b48ef6bdf013106d8a667d559c4be;p=jalview.git JAL-192 show reference sequence position and residue in ruler --- diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 3ab681c..61f1b36 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -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);