NPE in hashtable constructor
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index 59d7b97..ec48d21 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5.1)
  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
@@ -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;
@@ -1327,6 +1328,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   public void updateAnnotation(boolean applyGlobalSettings)
   {
+    // TODO: this should be merged with other annotation update stuff - that sits on AlignViewport
     boolean updateCalcs = false;
     boolean conv = av.isShowGroupConservation();
     boolean cons = av.isShowGroupConsensus();
@@ -1343,40 +1345,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.setshowSequenceLogo(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();