JAL-1645 source formatting and organise imports
[jalview.git] / src / jalview / ext / jmol / JalviewJmolBinding.java
index ed0b950..b464c94 100644 (file)
@@ -63,11 +63,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
         implements JmolStatusListener, JmolSelectionListener,
         ComponentListener
 {
-  /*
-   * state flag used to check if the Jmol viewer's paint method can be called
-   */
-  private boolean finishedInit = false;
-
   boolean allChainsSelected = false;
 
   /*
@@ -236,10 +231,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public void superposeStructures(AlignmentI alignment, int refStructure,
           ColumnSelection hiddenCols)
   {
-    superposeStructures(new AlignmentI[]
-    { alignment }, new int[]
-    { refStructure }, new ColumnSelection[]
-    { hiddenCols });
+    superposeStructures(new AlignmentI[] { alignment },
+            new int[] { refStructure },
+            new ColumnSelection[] { hiddenCols });
   }
 
   /**
@@ -259,8 +253,17 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public void superposeStructures(AlignmentI[] _alignment,
           int[] _refStructure, ColumnSelection[] _hiddenCols)
   {
+    while (viewer.isScriptExecuting())
+    {
+      try
+      {
+        Thread.sleep(10);
+      } catch (InterruptedException i)
+      {
+      }
+      ;
+    }
     String[] files = getPdbFile();
-
     if (!waitForFileLoad(files))
     {
       return;
@@ -272,7 +275,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     String nSeconds = " ";
     if (files.length > 10)
     {
-      nSeconds = " 0.00001 ";
+      nSeconds = " 0.005 ";
     }
     else
     {
@@ -281,7 +284,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     }
     // see JAL-1345 - should really automatically turn off the animation for
     // large numbers of structures, but Jmol doesn't seem to allow that.
-    nSeconds = " ";
+    // nSeconds = " ";
     // union of all aligned positions are collected together.
     for (int a = 0; a < _alignment.length; a++)
     {
@@ -454,8 +457,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
                 + selectioncom.toString() + "); cartoons; ");
         // selcom.append("; ribbons; ");
         String cmdString = command.toString();
-        System.out
-.println("Superimpose command(s):\n" + cmdString);
+        System.out.println("Superimpose command(s):\n" + cmdString);
 
         evalStateCommand(cmdString);
       }
@@ -478,7 +480,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     jmolHistory(false);
     if (lastCommand == null || !lastCommand.equals(command))
     {
-      System.out.println(command);
       viewer.evalStringQuiet(command + "\n");
     }
     jmolHistory(true);
@@ -513,7 +514,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     }
     AlignmentI alignment = alignmentv.getAlignment();
 
-    for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(files, sr, fr, alignment))
+    for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(
+            files, sr, fr, alignment))
     {
       for (String cbyseq : cpdbbyseq.commands)
       {
@@ -533,10 +535,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
           String[] files, SequenceRenderer sr, FeatureRenderer fr,
           AlignmentI alignment)
   {
-    return JmolCommands
-            .getColourBySequenceCommand(getSsm(), files, getSequence(), sr,
-                    fr,
-                    alignment);
+    return JmolCommands.getColourBySequenceCommand(getSsm(), files,
+            getSequence(), sr, fr, alignment);
   }
 
   /**
@@ -589,8 +589,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     }
     // TODO: verify atomIndex is selecting correct model.
     // return new Color(viewer.getAtomArgb(atomIndex)); Jmol 12.2.4
-    int colour = viewer.ms.at[atomIndex]
-            .atomPropertyInt(T.color);
+    int colour = viewer.ms.at[atomIndex].atomPropertyInt(T.color);
     return new Color(colour);
   }
 
@@ -668,6 +667,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
           // applet path with docroot - discard as format won't match pdbfile
           mset[0] = m;
         }
+        _modelFileNameMap[0] = 0; // filename index for first model is always 0.
       }
       int j = 1;
       for (int i = 1; i < mset.length; i++)
@@ -887,8 +887,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
         pdbfilename = modelFileNames[_mp];
         if (pdbfilename == null)
         {
-          pdbfilename = new File(
-                  viewer.ms.getModelFileName(mnumber))
+          pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
                   .getAbsolutePath();
         }
 
@@ -943,7 +942,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     String mdlString = "";
     if ((p = strInfo.indexOf(":")) > -1)
     {
-      picked += strInfo.substring(p + 1, strInfo.indexOf("."));
+      picked += strInfo.substring(p, strInfo.indexOf("."));
     }
 
     if ((p = strInfo.indexOf("/")) > -1)
@@ -1131,8 +1130,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
         pdbfile = viewer.getData("" + (1 + _modelFileNameMap[modelnum])
                 + ".0", "PDB");
       }
-        // search pdbentries and sequences to find correct pdbentry for this
-        // model
+      // search pdbentries and sequences to find correct pdbentry for this
+      // model
       for (int pe = 0; pe < getPdbCount(); pe++)
       {
         boolean matches = false;
@@ -1217,7 +1216,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     // }
     if (!isLoadingFromArchive())
     {
-      viewer.evalStringQuiet("model 0; select backbone;restrict;cartoon;wireframe off;spacefill off");
+      viewer.evalStringQuiet("model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
     }
     // register ourselves as a listener and notify the gui that it needs to
     // update itself.
@@ -1402,16 +1401,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     return null;
   }
 
-  public boolean isFinishedInit()
-  {
-    return finishedInit;
-  }
-
-  public void setFinishedInit(boolean finishedInit)
-  {
-    this.finishedInit = finishedInit;
-  }
-
   /**
    * 
    */
@@ -1466,4 +1455,3 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     showConsole(false);
   }
 }
-