patches for # JAL-254 and JAL-548
authorjprocter <Jim Procter>
Tue, 1 Jun 2010 11:28:57 +0000 (11:28 +0000)
committerjprocter <Jim Procter>
Tue, 1 Jun 2010 11:28:57 +0000 (11:28 +0000)
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/Jalview2XML.java

index 59d7b97..09b7215 100755 (executable)
@@ -283,7 +283,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
       int start = r[0];
       int end = r[1];
-      // System.err.println("Seq : "+seqIndex+" Scroll to "+start+","+end); // DEBUG
+      // System.err.println("Seq : "+seqIndex+" Scroll to "+start+","+end); //
+      // DEBUG
       if (start < 0)
       {
         return false;
@@ -1343,40 +1344,46 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation();
     Hashtable oldrfs = new Hashtable();
-    for (int an = 0; an < aan.length; an++)
+    if (aan != null)
     {
-      if (aan[an].autoCalculated && aan[an].groupRef != null)
+      for (int an = 0; an < aan.length; an++)
       {
-        oldrfs.put(aan[an].groupRef, aan[an].groupRef);
-        av.alignment.deleteAnnotation(aan[an]);
-        aan[an] = null;
+        if (aan[an].autoCalculated && aan[an].groupRef != null)
+        {
+          oldrfs.put(aan[an].groupRef, aan[an].groupRef);
+          av.alignment.deleteAnnotation(aan[an]);
+          aan[an] = null;
+        }
       }
     }
     SequenceGroup sg;
-    for (int g = 0; g < gr.size(); g++)
+    if (gr != null)
     {
-      updateCalcs = false;
-      sg = (SequenceGroup) gr.elementAt(g);
-      if (applyGlobalSettings || !oldrfs.containsKey(sg))
-      {
-        // set defaults for this group's conservation/consensus
-        sg.setIncludeAllConsSymbols(showprf);
-        sg.setShowConsensusHistogram(showConsHist);
-      }
-      if (conv)
-      {
-        updateCalcs = true;
-        av.alignment.addAnnotation(sg.getConservationRow(), 0);
-      }
-      if (cons)
-      {
-        updateCalcs = true;
-        av.alignment.addAnnotation(sg.getConsensus(), 0);
-      }
-      // refresh the annotation rows
-      if (updateCalcs)
+      for (int g = 0; g < gr.size(); g++)
       {
-        sg.recalcConservation();
+        updateCalcs = false;
+        sg = (SequenceGroup) gr.elementAt(g);
+        if (applyGlobalSettings || !oldrfs.containsKey(sg))
+        {
+          // set defaults for this group's conservation/consensus
+          sg.setIncludeAllConsSymbols(showprf);
+          sg.setShowConsensusHistogram(showConsHist);
+        }
+        if (conv)
+        {
+          updateCalcs = true;
+          av.alignment.addAnnotation(sg.getConservationRow(), 0);
+        }
+        if (cons)
+        {
+          updateCalcs = true;
+          av.alignment.addAnnotation(sg.getConsensus(), 0);
+        }
+        // refresh the annotation rows
+        if (updateCalcs)
+        {
+          sg.recalcConservation();
+        }
       }
     }
     oldrfs.clear();
index 18bda61..bd46613 100755 (executable)
@@ -153,6 +153,8 @@ public class AnnotationLabels extends JPanel implements MouseListener,
           break;
         }
       }
+    } else {
+      selectedRow = -1;
     }
   }
 
@@ -429,7 +431,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
     if (SwingUtilities.isLeftMouseButton(evt))
     {
-      if (selectedRow < aa.length)
+      if (aa!=null && selectedRow < aa.length)
       {
         if (aa[selectedRow].groupRef != null)
         {
index 22977a9..4c40d2d 100755 (executable)
@@ -2942,10 +2942,10 @@ public class Jalview2XML
     }
 
     af.setMenusFromViewport(af.viewport);
-    af.alignPanel.updateAnnotation(false); // recompute any autoannotation
     // TODO: we don't need to do this if the viewport is aready visible.
     Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(), view
             .getHeight());
+    af.alignPanel.updateAnnotation(false); // recompute any autoannotation
     return af;
   }