From ed87c8b39a1b48ef6bdf013106d8a667d559c4be Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 27 Apr 2016 16:36:28 +0100 Subject: [PATCH] JAL-192 show reference sequence position and residue in ruler --- src/jalview/gui/ScalePanel.java | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) 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); -- 1.7.10.2