From: Jim Procter Date: Thu, 7 Apr 2016 16:58:45 +0000 (+0100) Subject: JAL-1722 fix: don’t draw visible regions outside viewport view X-Git-Tag: Release_2_10_0~268^2^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8e828522d5642db3c70c0909e0b44244f9ec2605;p=jalview.git JAL-1722 fix: don’t draw visible regions outside viewport view --- diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index ce70597..024fdc7 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -276,6 +276,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); @@ -573,10 +574,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); diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 5706fe7..0f24b4b 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -335,6 +335,7 @@ public class SeqCanvas extends JComponent */ // Set this to false to force a full panel paint + @Override public void paintComponent(Graphics g) { updateViewport(); @@ -682,10 +683,17 @@ public class SeqCanvas extends JComponent g1.translate(-screenY * charWidth, 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 * charWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);