If no annotation exists
authoramwaterhouse <Andrew Waterhouse>
Thu, 17 Aug 2006 13:41:37 +0000 (13:41 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 17 Aug 2006 13:41:37 +0000 (13:41 +0000)
src/jalview/gui/AnnotationLabels.java

index 0788864..ceb736d 100755 (executable)
@@ -113,20 +113,23 @@ public class AnnotationLabels extends JPanel implements MouseListener,
       int height = 0;\r
       AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();\r
 \r
-      for (int i = 0; i < aa.length; i++)\r
+      if(aa!=null)\r
       {\r
-        if (!aa[i].visible)\r
+        for (int i = 0; i < aa.length; i++)\r
         {\r
-          continue;\r
-        }\r
+          if (!aa[i].visible)\r
+          {\r
+            continue;\r
+          }\r
 \r
-        height += aa[i].height;\r
+          height += aa[i].height;\r
 \r
-        if (y < height)\r
-        {\r
-          selectedRow = i;\r
+          if (y < height)\r
+          {\r
+            selectedRow = i;\r
 \r
-          break;\r
+            break;\r
+          }\r
         }\r
       }\r
     }\r
@@ -157,7 +160,8 @@ public class AnnotationLabels extends JPanel implements MouseListener,
 \r
             ap.av.alignment.addAnnotation(newAnnotation);\r
             ap.av.alignment.setAnnotationIndex(newAnnotation, 0);\r
-            dif = aa[aa.length - 1].height;\r
+            if (aa != null)\r
+              dif = aa[aa.length - 1].height;\r
         }\r
         else if (evt.getActionCommand().equals(HIDE))\r
         {\r
@@ -523,7 +527,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
         {\r
           g.drawImage(image, 2, 0 - scrollOffset, this);\r
         }\r
-        else if (dragEvent != null)\r
+        else if (dragEvent != null && aa!=null)\r
         {\r
           g.setColor(Color.lightGray);\r
           g.drawString(aa[selectedRow].label, dragEvent.getX(), dragEvent.getY() - scrollOffset);\r