From: amwaterhouse Date: Thu, 17 Aug 2006 13:41:37 +0000 (+0000) Subject: If no annotation exists X-Git-Tag: Release_2_1~38 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0100493fd2817e63bc182ad4d7834cbf8fb5e612;p=jalview.git If no annotation exists --- diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 0788864..ceb736d 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -113,20 +113,23 @@ public class AnnotationLabels extends JPanel implements MouseListener, int height = 0; AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - for (int i = 0; i < aa.length; i++) + if(aa!=null) { - if (!aa[i].visible) + for (int i = 0; i < aa.length; i++) { - continue; - } + if (!aa[i].visible) + { + continue; + } - height += aa[i].height; + height += aa[i].height; - if (y < height) - { - selectedRow = i; + if (y < height) + { + selectedRow = i; - break; + break; + } } } } @@ -157,7 +160,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, ap.av.alignment.addAnnotation(newAnnotation); ap.av.alignment.setAnnotationIndex(newAnnotation, 0); - dif = aa[aa.length - 1].height; + if (aa != null) + dif = aa[aa.length - 1].height; } else if (evt.getActionCommand().equals(HIDE)) { @@ -523,7 +527,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { g.drawImage(image, 2, 0 - scrollOffset, this); } - else if (dragEvent != null) + else if (dragEvent != null && aa!=null) { g.setColor(Color.lightGray); g.drawString(aa[selectedRow].label, dragEvent.getX(), dragEvent.getY() - scrollOffset);