X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=e9ef19c03eee53a7f83cdfd88541c743b1c7627c;hp=756e544c8815178a4cdf2fce07d92b84bced5306;hb=71a3cc0202bd8b731f01e5706372e9bae047d592;hpb=11346f873e4ecb2d191499fd1d52b8de07a65bf3 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);