Image for labels, stops flickering
authoramwaterhouse <Andrew Waterhouse>
Mon, 29 Jan 2007 17:41:31 +0000 (17:41 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 29 Jan 2007 17:41:31 +0000 (17:41 +0000)
src/jalview/appletgui/AnnotationLabels.java

index 5150867..48cea13 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.datamodel.*;
 public class AnnotationLabels\r
     extends Panel implements ActionListener, MouseListener, MouseMotionListener\r
 {\r
+  Image image;\r
   boolean active = false;\r
   AlignmentPanel ap;\r
   AlignViewport av;\r
@@ -232,9 +233,21 @@ public class AnnotationLabels
       }\r
     }\r
 \r
+    public void update(Graphics g)\r
+    {\r
+      paint(g);\r
+    }\r
+\r
   public void paint(Graphics g)\r
   {\r
-    drawComponent(g, getSize().width);\r
+    int w = getSize().width;\r
+    if (image == null || w != image.getWidth(this))\r
+    {\r
+      image = createImage(w, ap.annotationPanel.getSize().height);\r
+    }\r
+\r
+    drawComponent(image.getGraphics(), w);\r
+    g.drawImage(image,0,0,this);\r
   }\r
 \r
   public void drawComponent(Graphics g, int width)\r