Merge branch 'features/JAL-4071_visibleFeaturesCounter' into features/JAL-3417_sdppre...
[jalview.git] / src / jalview / structures / models / AAStructureBindingModel.java
index 9ecf630..906cb59 100644 (file)
@@ -20,8 +20,6 @@
  */
 package jalview.structures.models;
 
-import java.util.Locale;
-
 import java.awt.Color;
 import java.io.File;
 import java.io.IOException;
@@ -31,6 +29,7 @@ import java.util.BitSet;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javax.swing.SwingUtilities;
@@ -70,9 +69,9 @@ import jalview.util.MessageManager;
 
 /**
  * 
- * A base class to hold common function for 3D structure model binding.
- * Initial version created by refactoring JMol and Chimera binding models, but
- * other structure viewers could in principle be accommodated in future.
+ * A base class to hold common function for 3D structure model binding. Initial
+ * version created by refactoring JMol and Chimera binding models, but other
+ * structure viewers could in principle be accommodated in future.
  * 
  * @author gmcarstairs
  *
@@ -591,7 +590,6 @@ public abstract class AAStructureBindingModel
       }
     }
   }
-  
 
   @Override
   public abstract void highlightAtoms(List<AtomSpec> atoms);
@@ -925,8 +923,10 @@ public abstract class AAStructureBindingModel
        */
       // todo better way to ensure synchronous than setting getReply true!!
       executeCommands(commandGenerator.showBackbone(), true, null);
-      
-      AtomSpecType backbone = structures[refStructure].isRna ? AtomSpecType.PHOSPHATE : AtomSpecType.ALPHA;
+
+      AtomSpecType backbone = structures[refStructure].isRna
+              ? AtomSpecType.PHOSPHATE
+              : AtomSpecType.ALPHA;
       /*
        * superpose each (other) structure to the reference in turn
        */
@@ -941,7 +941,8 @@ public abstract class AAStructureBindingModel
           for (String reply : replies)
           {
             // return this error (Chimera only) to the user
-            if (reply.toLowerCase(Locale.ROOT).contains("unequal numbers of atoms"))
+            if (reply.toLowerCase(Locale.ROOT)
+                    .contains("unequal numbers of atoms"))
             {
               error += "; " + reply;
             }
@@ -1278,6 +1279,12 @@ public abstract class AAStructureBindingModel
   @Override
   public void updateColours(Object source)
   {
+    if (getViewer() == null)
+    {
+      // can happen if a viewer was not instantiated or cleaned up and is still
+      // registered - mostly during tests
+      return;
+    }
     AlignmentViewPanel ap = (AlignmentViewPanel) source;
     // ignore events from panels not used to colour this view
     if (!getViewer().isUsedForColourBy(ap))