X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;fp=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=93af6ec83f40402919d343286f881ef79a979c5e;hb=d043ce47fc710d3eb2629ba926a8a7417bd67d8c;hp=15adafc7a88938a4ed184aaa825e252a2d73ccee;hpb=49db0dff1da16c3355b43a41498c1fc93ef47e91;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 15adafc..93af6ec 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -734,6 +734,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, */ return; } + try { if (dragMode == DragMode.Resize) @@ -1006,7 +1007,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } private volatile boolean imageFresh = false; - private Rectangle visibleRect = new Rectangle(), clipBounds = new Rectangle(); @@ -1019,7 +1019,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, @Override public void paintComponent(Graphics g) { - // BH: note that this method is generally recommended to // call super.paintComponent(g). Otherwise, the children of this // component will not be rendered. That is not needed here @@ -1027,7 +1026,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // just a JPanel contained in a JViewPort. computeVisibleRect(visibleRect); - g.setColor(Color.white); g.fillRect(0, 0, visibleRect.width, visibleRect.height); @@ -1041,15 +1039,15 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, .getClipBounds(clipBounds)).width) || (visibleRect.height != clipBounds.height)) { - g.drawImage(image, 0, 0, this); + + + g.drawImage(image, 0, 0, this); fastPaint = false; return; } } - imgWidth = (ranges.getEndRes() - ranges.getStartRes() + 1) * av.getCharWidth(); - if (imgWidth < 1) { fastPaint = false; @@ -1097,8 +1095,9 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg = (Graphics2D) image.getGraphics(); } - - drawComponent(gg, ranges.getStartRes(), av.getRanges().getEndRes() + 1); + + drawComponent(gg, av.getRanges().getStartRes(), + av.getRanges().getEndRes() + 1); gg.dispose(); imageFresh = false; g.drawImage(image, 0, 0, this); @@ -1130,20 +1129,22 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, fastPaint = false; return; } - 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); @@ -1153,7 +1154,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg.translate(-transX, 0); gg.dispose(); - fastPaint = true; // Call repaint on alignment panel so that repaints from other alignment @@ -1272,7 +1272,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, private int[] bounds = new int[2]; private boolean allowFastPaint; - @Override public int[] getVisibleVRange() { @@ -1388,5 +1387,4 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { allowFastPaint = false; } - }