Make sure annots are alignment width
[jalview.git] / src / jalview / gui / AlignFrame.java
index 61c6672..58650cb 100755 (executable)
@@ -142,7 +142,7 @@ public class AlignFrame
    }
 
    setMenusFromViewport(viewport);
-
+   buildSortByAnnotationScoresMenu();
    if (viewport.wrapAlignment)
    {
      wrapMenuItem_actionPerformed(null);
@@ -1592,6 +1592,7 @@ public class AlignFrame
        if (annotationAdded)
        {
          alignPanel.annotationPanel.adjustPanelHeight();
+         buildSortByAnnotationScoresMenu();
        }
        viewport.firePropertyChange("alignment", null, alignment.getSequences());
      } else {
@@ -3087,12 +3088,17 @@ public class AlignFrame
       sortByAnnotScore.removeAll();
       // almost certainly a quicker way to do this - but we keep it simple
       Hashtable scoreSorts=new Hashtable();
-      AlignmentAnnotation aann[] = viewport.alignment.getAlignmentAnnotation();
-      for (int i=0;i<aann.length; i++)
+      AlignmentAnnotation aann[];
+      Enumeration sq = viewport.alignment.getSequences().elements();
+      while (sq.hasMoreElements())
       {
-        if (aann[i].hasScore() && aann[i].sequenceRef!=null)
+        aann = ((SequenceI) sq.nextElement()).getAnnotation();
+        for (int i=0;aann!=null && i<aann.length; i++)
         {
-          scoreSorts.put(aann[i].label, aann[i].label);
+          if (aann[i].hasScore() && aann[i].sequenceRef!=null)
+          {
+            scoreSorts.put(aann[i].label, aann[i].label);
+          }
         }
       }
       Enumeration labels = scoreSorts.keys();
@@ -3674,6 +3680,7 @@ public void drop(DropTargetDropEvent evt)
       {
         // (isAnnotation)
         alignPanel.adjustAnnotationHeight();
+        buildSortByAnnotationScoresMenu();
       }
 
     }