From af9772ad2e3c28a8f075ace5c97ec1f863f96726 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 6 May 2016 15:29:14 +0100 Subject: [PATCH] JAL-192 JAL-2099 reuse refactored scale code for wrapped view --- src/jalview/gui/SeqCanvas.java | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 0f24b4b..2f7cd76 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -122,24 +122,26 @@ public class SeqCanvas extends JComponent private void drawNorthScale(Graphics g, int startx, int endx, int ypos) { updateViewport(); - int scalestartx = startx - (startx % 10) + 10; - - g.setColor(Color.black); - // NORTH SCALE - for (int i = scalestartx; i < endx; i += 10) + for (Object[] mark : jalview.renderer.ScaleRenderer.calculateMarks(av, + startx, endx)) { - int value = i; - if (av.hasHiddenColumns()) + int mpos = ((Integer) mark[1]).intValue(); // (i - startx - 1) + if (mpos < 0) { - value = av.getColumnSelection().adjustForHiddenColumns(value); + continue; } + String mstring = (String) mark[2]; - g.drawString(String.valueOf(value), (i - startx - 1) * charWidth, - ypos - (charHeight / 2)); - - g.drawLine(((i - startx - 1) * charWidth) + (charWidth / 2), - (ypos + 2) - (charHeight / 2), ((i - startx - 1) * charWidth) - + (charWidth / 2), ypos - 2); + if (Boolean.valueOf((Boolean) mark[0])) + { + if (mstring != null) + { + g.drawString(mstring, mpos * charWidth, ypos - (charHeight / 2)); + } + g.drawLine((mpos * charWidth) + (charWidth / 2), (ypos + 2) + - (charHeight / 2), (mpos * charWidth) + (charWidth / 2), + ypos - 2); + } } } -- 1.7.10.2