X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=821136fa448053f3bcf9a0c327dc787aee04efcf;hb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;hp=bf54c667b4177c3f7341bb26de413e671b1e705f;hpb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index bf54c66..821136f 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -24,6 +24,9 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.SearchResults; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.renderer.ScaleRenderer; +import jalview.renderer.ScaleRenderer.ScaleMark; +import jalview.viewmodel.AlignmentViewport; import java.awt.Color; import java.awt.FontMetrics; @@ -72,7 +75,7 @@ public class SeqCanvas extends Panel avcharWidth = av.getCharWidth(); } - public AlignViewport getViewport() + public AlignmentViewport getViewport() { return av; } @@ -89,26 +92,29 @@ public class SeqCanvas extends Panel private void drawNorthScale(Graphics g, int startx, int endx, int ypos) { - int scalestartx = startx - startx % 10 + 10; - + updateViewport(); g.setColor(Color.black); - - // NORTH SCALE - for (int i = scalestartx; i < endx; i += 10) + for (ScaleMark mark : new ScaleRenderer().calculateMarks(av, startx, + endx)) { - int value = i; - if (av.hasHiddenColumns()) + int mpos = mark.column; // (i - startx - 1) + if (mpos < 0) { - value = av.getColumnSelection().adjustForHiddenColumns(value); + continue; } + String mstring = mark.text; - g.drawString(String.valueOf(value), (i - startx - 1) * avcharWidth, - ypos - (avcharHeight / 2)); - - g.drawLine(((i - startx - 1) * avcharWidth) + (avcharWidth / 2), - (ypos + 2) - (avcharHeight / 2), - ((i - startx - 1) * avcharWidth) + (avcharWidth / 2), - ypos - 2); + if (mark.major) + { + if (mstring != null) + { + g.drawString(mstring, mpos * avcharWidth, ypos + - (avcharHeight / 2)); + } + g.drawLine((mpos * avcharWidth) + (avcharWidth / 2), (ypos + 2) + - (avcharHeight / 2), (mpos * avcharWidth) + + (avcharWidth / 2), ypos - 2); + } } } @@ -275,6 +281,7 @@ public class SeqCanvas extends Panel * at 0). NOTE 1: The av limits are set in setFont in this class and in the * adjustment listener in SeqPanel when the scrollbars move. */ + @Override public void update(Graphics g) { paint(g); @@ -472,11 +479,10 @@ public class SeqCanvas extends Panel continue; } - gg.fillPolygon(new int[] - { res * avcharWidth - avcharHeight / 4, + gg.fillPolygon(new int[] { res * avcharWidth - avcharHeight / 4, res * avcharWidth + avcharHeight / 4, res * avcharWidth }, - new int[] - { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), + new int[] { ypos - (avcharHeight / 2), + ypos - (avcharHeight / 2), ypos - (avcharHeight / 2) + 8 }, 3); } @@ -528,11 +534,9 @@ public class SeqCanvas extends Panel } private void drawPanel(Graphics g1, int startRes, int endRes, - int startSeq, - int endSeq, int offset) + int startSeq, int endSeq, int offset) { - if (!av.hasHiddenColumns()) { draw(g1, startRes, endRes, startSeq, endSeq, offset); @@ -575,10 +579,17 @@ public class SeqCanvas extends Panel g1.translate(-screenY * avcharWidth, 0); screenY += blockEnd - blockStart + 1; blockStart = hideEnd + 1; + + if (screenY > (endRes - startRes)) + { + // already rendered last block + return; + } } } if (screenY <= (endRes - startRes)) { + // remaining visible region to render blockEnd = blockStart + (endRes - startRes) - screenY; g1.translate(screenY * avcharWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); @@ -826,8 +837,7 @@ public class SeqCanvas extends Panel break; } - group = av.getAlignment().getGroups() - .get(groupIndex); + group = av.getAlignment().getGroups().get(groupIndex); } while (groupIndex < av.getAlignment().getGroups().size()); }