From 0100493fd2817e63bc182ad4d7834cbf8fb5e612 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 17 Aug 2006 13:41:37 +0000 Subject: [PATCH] If no annotation exists --- src/jalview/gui/AnnotationLabels.java | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) 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); -- 1.7.10.2