From: gmungoc Date: Wed, 21 Jun 2017 08:37:34 +0000 (+0100) Subject: JAL-2524 don't render up to a hidden marker beyond the visible region X-Git-Tag: Release_2_10_3b1~199 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=334ef687768a011b7b179641ed37bb53c5c342c6;p=jalview.git JAL-2524 don't render up to a hidden marker beyond the visible region --- diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 46a908e..538f1d2 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -552,8 +552,8 @@ public class SeqCanvas extends Panel implements ViewportListenerI return annotations.adjustPanelHeight(); } - private void drawPanel(Graphics g1, int startRes, int endRes, - int startSeq, int endSeq, int offset) + private void drawPanel(Graphics g1, final int startRes, final int endRes, + final int startSeq, final int endSeq, final int offset) { if (!av.hasHiddenColumns()) @@ -562,8 +562,8 @@ public class SeqCanvas extends Panel implements ViewportListenerI } else { - int screenY = 0; + final int screenYMax = endRes - startRes; int blockStart = startRes; int blockEnd = endRes; @@ -581,13 +581,22 @@ public class SeqCanvas extends Panel implements ViewportListenerI continue; } - blockEnd = hideStart - 1; + /* + * draw up to just before the next hidden region, or the end of + * the visible region, whichever comes first + */ + blockEnd = Math.min(hideStart - 1, blockStart + screenYMax + - screenY); g1.translate(screenY * avcharWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); - if (av.getShowHiddenMarkers()) + /* + * draw the downline of the hidden column marker (ScalePanel draws the + * triangle on top) if we reached it + */ + if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1) { g1.setColor(Color.blue); g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1, @@ -600,14 +609,14 @@ public class SeqCanvas extends Panel implements ViewportListenerI screenY += blockEnd - blockStart + 1; blockStart = hideEnd + 1; - if (screenY > (endRes - startRes)) + if (screenY > screenYMax) { // already rendered last block return; } } } - if (screenY <= (endRes - startRes)) + if (screenY <= screenYMax) { // remaining visible region to render blockEnd = blockStart + (endRes - startRes) - screenY; diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 0e5e1b8..a74db48 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -637,28 +637,30 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } /** - * DOCUMENT ME! + * Draws the visible region of the alignment on the graphics context. If there + * are hidden column markers in the visible region, then each sub-region + * between the markers is drawn separately, followed by the hidden column + * marker. * * @param g1 - * DOCUMENT ME! * @param startRes - * DOCUMENT ME! + * offset of the first column in the visible region (0..) * @param endRes - * DOCUMENT ME! + * offset of the last column in the visible region (0..) * @param startSeq - * DOCUMENT ME! + * offset of the first sequence in the visible region (0..) * @param endSeq - * DOCUMENT ME! - * @param offset - * DOCUMENT ME! + * offset of the last sequence in the visible region (0..) + * @param yOffset + * vertical offset at which to draw (for wrapped alignments) */ - public void drawPanel(Graphics g1, int startRes, int endRes, - int startSeq, int endSeq, int offset) + public void drawPanel(Graphics g1, final int startRes, final int endRes, + final int startSeq, final int endSeq, final int yOffset) { updateViewport(); if (!av.hasHiddenColumns()) { - draw(g1, startRes, endRes, startSeq, endSeq, offset); + draw(g1, startRes, endRes, startSeq, endSeq, yOffset); } else { @@ -666,6 +668,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI .getHiddenRegions(); int screenY = 0; + final int screenYMax = endRes - startRes; int blockStart = startRes; int blockEnd = endRes; @@ -680,38 +683,47 @@ public class SeqCanvas extends JComponent implements ViewportListenerI continue; } - blockEnd = hideStart - 1; + /* + * draw up to just before the next hidden region, or the end of + * the visible region, whichever comes first + */ + blockEnd = Math.min(hideStart - 1, blockStart + screenYMax + - screenY); g1.translate(screenY * charWidth, 0); - draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); + draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset); - if (av.getShowHiddenMarkers()) + /* + * draw the downline of the hidden column marker (ScalePanel draws the + * triangle on top) if we reached it + */ + if (av.getShowHiddenMarkers() && blockEnd == hideStart - 1) { g1.setColor(Color.blue); g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1, - 0 + offset, (blockEnd - blockStart + 1) * charWidth - 1, - (endSeq - startSeq + 1) * charHeight + offset); + 0 + yOffset, (blockEnd - blockStart + 1) * charWidth - 1, + (endSeq - startSeq + 1) * charHeight + yOffset); } g1.translate(-screenY * charWidth, 0); screenY += blockEnd - blockStart + 1; blockStart = hideEnd + 1; - if (screenY > (endRes - startRes)) + if (screenY > screenYMax) { // already rendered last block return; } } - if (screenY <= (endRes - startRes)) + if (screenY <= screenYMax) { // remaining visible region to render - blockEnd = blockStart + (endRes - startRes) - screenY; + blockEnd = blockStart + screenYMax - screenY; g1.translate(screenY * charWidth, 0); - draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); + draw(g1, blockStart, blockEnd, startSeq, endSeq, yOffset); g1.translate(-screenY * charWidth, 0); } @@ -719,8 +731,21 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } - // int startRes, int endRes, int startSeq, int endSeq, int x, int y, - // int x1, int x2, int y1, int y2, int startx, int starty, + /** + * Draws a region of the visible alignment + * + * @param g1 + * @param startRes + * offset of the first column in the visible region (0..) + * @param endRes + * offset of the last column in the visible region (0..) + * @param startSeq + * offset of the first sequence in the visible region (0..) + * @param endSeq + * offset of the last sequence in the visible region (0..) + * @param yOffset + * vertical offset at which to draw (for wrapped alignments) + */ private void draw(Graphics g, int startRes, int endRes, int startSeq, int endSeq, int offset) {