todos & added simple method for other classes to monitor when fileUpdate events have...
authorjprocter <Jim Procter>
Wed, 8 Sep 2010 14:12:51 +0000 (14:12 +0000)
committerjprocter <Jim Procter>
Wed, 8 Sep 2010 14:12:51 +0000 (14:12 +0000)
src/jalview/ext/jmol/JalviewJmolBinding.java

index f27b533..2c34762 100644 (file)
@@ -373,6 +373,7 @@ public abstract class JalviewJmolBinding implements StructureListener,
       }
     }
     String[] selcom = new String[files.length];
+    int nmatched=0;
     // generate select statements to select regions to superimpose structures
     {
       for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
@@ -386,7 +387,9 @@ public abstract class JalviewJmolBinding implements StructureListener,
         {
           if (matched[r])
           {
-
+            if (pdbfnum==0) {
+              nmatched++;
+            }
             if (lpos != commonrpositions[pdbfnum][r] - 1)
             {
               // discontinuity
@@ -433,7 +436,8 @@ public abstract class JalviewJmolBinding implements StructureListener,
         }
       }
     }
-
+    // TODO: consider bailing if nmatched less than 4 because superposition not well defined.
+    // TODO: refactor superposable position search (above) from jmol selection construction (below)
     for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
     {
       if (pdbfnum == refStructure)
@@ -682,6 +686,10 @@ public abstract class JalviewJmolBinding implements StructureListener,
   // /StructureListener
   public synchronized String[] getPdbFile()
   {
+    if (viewer==null)
+    {
+      return new String[0];
+    }
     if (modelFileNames == null)
     {
 
@@ -1009,6 +1017,12 @@ public abstract class JalviewJmolBinding implements StructureListener,
     return false;
   }
 
+  // incremented every time a load notification is successfully handled - lightweight mechanism for other threads to detect when they can start referrring to new structures. 
+  private long loadNotifiesHandled=0;
+  public long getLoadNotifiesHandled()
+  {
+    return loadNotifiesHandled;
+  }
   public void notifyFileLoaded(String fullPathName, String fileName2,
           String modelName, String errorMsg, int modelParts)
   {
@@ -1182,6 +1196,7 @@ public abstract class JalviewJmolBinding implements StructureListener,
         fr.featuresAdded();
       }
       refreshGUI();
+      loadNotifiesHandled++;
     }
   }