JAL-4024 only render partially when new view overlaps with last rendered annotation... patch/JAL-4024_jumpScrollHang
authorJim Procter <j.procter@dundee.ac.uk>
Wed, 8 Jun 2022 12:10:42 +0000 (13:10 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Wed, 8 Jun 2022 12:10:42 +0000 (13:10 +0100)
src/jalview/gui/AnnotationPanel.java

index 756e544..e9ef19c 100755 (executable)
@@ -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);