From: Jim Procter Date: Fri, 29 Apr 2016 09:44:30 +0000 (+0100) Subject: JAL-192 scale origin relative to start of reference sequence, & deal gracefully with... X-Git-Tag: Release_2_10_0~235^2~1^2^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e224b72118c12cd77ae96f0f8d86c123e0416dc7;p=jalview.git JAL-192 scale origin relative to start of reference sequence, & deal gracefully with reference sequence being completely hidden --- diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 7c8a1d7..e595e65 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -492,31 +492,38 @@ public class ScalePanel extends JPanel implements MouseMotionListener, gg.setColor(Color.black); int scalestartx = (startx / 10) * 10; + + SequenceI refSeq = av.getAlignment().getSeqrep(); + int refSp = 0, refEp = -1; + if (refSeq != null) + { + // find bounds and set origin appopriately + // locate first visible position for this sequence + int[] refbounds = av.getColumnSelection() + .locateVisibleBoundsOfSequence(refSeq); + + refSp = refbounds[0] - 1; + refEp = refbounds[1] - 1; + scalestartx = refSp + ((scalestartx - refSp) / 10) * 10; + } + + int widthx = 1 + endx - startx; FontMetrics fm = gg.getFontMetrics(av.getFont()); int y = avCharHeight - fm.getDescent(); - if ((scalestartx % 10) == 0) + if (refSeq == null && scalestartx % 10 == 0) { scalestartx += 5; } String string; - 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) + if (((i - refSp) % 10) == 0) { iadj = av.getColumnSelection().adjustForHiddenColumns(i) - 1; if (refSeq == null)