JAL-3446 from applet; JAL-3374
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index 35ae242..01be3b5 100755 (executable)
@@ -1009,23 +1009,28 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     g.setColor(Color.white);
     g.fillRect(0, 0, visibleRect.width, visibleRect.height);
 
+    ViewportRanges ranges = av.getRanges();
+    
+    
+    
     if (image != null)
     {
        // BH 2018 optimizing generation of new Rectangle().
       if (fastPaint || (visibleRect.width != (clipBounds = g.getClipBounds(clipBounds)).width)
             || (visibleRect.height != clipBounds.height))
       {
-
-         
          g.drawImage(image, 0, 0, this);
         fastPaint = false;
         return;
       }
     }
-    imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes()
+    
+    imgWidth = (ranges.getEndRes() - ranges.getStartRes()
             + 1) * av.getCharWidth();
+    
     if (imgWidth < 1)
     {
+      fastPaint = false;
       return;
     }
     Graphics2D gg;
@@ -1068,8 +1073,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
         gg = (Graphics2D) image.getGraphics();
 
     }
-    
-    drawComponent(gg, av.getRanges().getStartRes(),
+   
+    drawComponent(gg, ranges.getStartRes(),
             av.getRanges().getEndRes() + 1);
     gg.dispose();
     imageFresh = false;
@@ -1077,11 +1082,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   }
 
   /**
-   * set true to enable redraw timing debug output on stderr
-   */
-  private final boolean debugRedraw = false;
-
-  /**
    * non-Thread safe repaint
    * 
    * @param horizontal
@@ -1101,6 +1101,11 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
     int sr = av.getRanges().getStartRes();
     int er = av.getRanges().getEndRes() + 1;
     int transX = 0;
+    
+    if (er == sr + 1) {
+      fastPaint = false;
+      return;
+    }
 
     Graphics2D gg = (Graphics2D) image.getGraphics();