From 71a3cc0202bd8b731f01e5706372e9bae047d592 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 8 Jun 2022 13:10:42 +0100 Subject: [PATCH] JAL-4024 only render partially when new view overlaps with last rendered annotation panel view --- src/jalview/gui/AnnotationPanel.java | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 756e544..e9ef19c 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -1124,19 +1124,21 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, Graphics2D gg = (Graphics2D) image.getGraphics(); - gg.copyArea(0, 0, imgWidth, getHeight(), - -horizontal * av.getCharWidth(), 0); - - if (horizontal > 0) // scrollbar pulled right, image to the left - { - transX = (er - sr - horizontal) * av.getCharWidth(); - sr = er - horizontal; - } - else if (horizontal < 0) - { - er = sr - horizontal; + if (imgWidth>Math.abs(horizontal*av.getCharWidth())) { + //scroll is less than imgWidth away so can re-use buffered graphics + gg.copyArea(0, 0, imgWidth, getHeight(), + -horizontal * av.getCharWidth(), 0); + + if (horizontal > 0) // scrollbar pulled right, image to the left + { + transX = (er - sr - horizontal) * av.getCharWidth(); + sr = er - horizontal; + } + else if (horizontal < 0) + { + er = sr - horizontal; + } } - gg.translate(transX, 0); drawComponent(gg, sr, er); -- 1.7.10.2