Make sure fontmetrics is not null
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index aeb0b9a..bc14d66 100755 (executable)
@@ -148,6 +148,8 @@ public class AnnotationPanel extends JPanel implements MouseListener,
         if (activeRow == -1)\r
         {\r
             AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
+            if(aa==null)\r
+              return;\r
 \r
             for (int j = 0; j < aa.length; j++)\r
             {\r
@@ -178,6 +180,8 @@ public class AnnotationPanel extends JPanel implements MouseListener,
         if (activeRow == -1)\r
         {\r
             AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
+            if(aa==null)\r
+              return;\r
 \r
             for (int j = 0; j < aa.length; j++)\r
             {\r
@@ -526,7 +530,7 @@ public class AnnotationPanel extends JPanel implements MouseListener,
       g.setColor(Color.white);\r
       g.fillRect(0, 0, getWidth(), getHeight());\r
 \r
-      if (fastPaint)\r
+      if (fastPaint && image!=null)\r
       {\r
         g.drawImage(image, 0, 0, this);\r
         fastPaint = false;\r
@@ -604,6 +608,12 @@ public class AnnotationPanel extends JPanel implements MouseListener,
      */\r
     public void drawComponent(Graphics2D g, int startRes, int endRes)\r
     {\r
+      if (fm == null)\r
+        fm = g.getFontMetrics();\r
+\r
+               if(fm==null)\r
+                       fm = g.getFontMetrics();\r
+\r
         g.setColor(Color.white);\r
         g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());\r
 \r