JAL-3404 explicit getModelForPdbFile lookup
[jalview.git] / src / jalview / ext / jmol / JalviewJmolBinding.java
index 972f093..2645980 100644 (file)
@@ -28,7 +28,6 @@ import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.ext.rbvi.chimera.AtomSpecModel;
-import jalview.ext.rbvi.chimera.StructureCommands;
 import jalview.gui.IProgressIndicator;
 import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
@@ -38,6 +37,7 @@ import jalview.structure.AtomSpec;
 import jalview.structure.StructureSelectionManager;
 import jalview.structures.models.AAStructureBindingModel;
 import jalview.util.MessageManager;
+import jalview.util.StructureCommands;
 
 import java.awt.Color;
 import java.awt.Container;
@@ -59,7 +59,6 @@ import org.jmol.api.JmolSelectionListener;
 import org.jmol.api.JmolStatusListener;
 import org.jmol.api.JmolViewer;
 import org.jmol.c.CBK;
-import org.jmol.script.T;
 import org.jmol.viewer.Viewer;
 
 public abstract class JalviewJmolBinding extends AAStructureBindingModel
@@ -486,8 +485,13 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
    * @param commands
    */
   @Override
-  protected void colourBySequence(final String[] commands)
+  protected void colourBySequence(AlignmentViewPanel viewPanel)
   {
+    Map<Object, AtomSpecModel> map = StructureCommands.buildColoursMap(this,
+            viewPanel);
+
+    String[] commands = JmolCommands.getColourBySequenceCommand(map);
+
     if (colourby != null)
     {
       colourby.interrupt();
@@ -508,20 +512,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   }
 
   /**
-   * @param files
-   * @param viewPanel
-   * @return
-   */
-  @Override
-  protected String[] getColourBySequenceCommands(
-          String[] files, AlignmentViewPanel viewPanel)
-  {
-    Map<Object, AtomSpecModel> map = StructureCommands.buildColoursMap(this, viewPanel);
-
-    return JmolCommands.getColourBySequenceCommand(map);
-  }
-
-  /**
    * @param command
    */
   protected void executeWhenReady(String command)
@@ -567,19 +557,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     return null;
   }
 
-  public Color getColour(int atomIndex, int pdbResNum, String chain,
-          String pdbfile)
-  {
-    if (getModelNum(pdbfile) < 0)
-    {
-      return null;
-    }
-    // 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);
-    return new Color(colour);
-  }
-
   /**
    * instruct the Jalview binding to update the pdbentries vector if necessary
    * prior to matching the jmol view's contents to the list of structure files
@@ -614,7 +591,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   @Override
   public synchronized String[] getStructureFiles()
   {
-    List<String> mset = new ArrayList<>();
     if (viewer == null)
     {
       return new String[0];
@@ -622,6 +598,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
     if (modelFileNames == null)
     {
+      List<String> mset = new ArrayList<>();
       int modelCount = viewer.ms.mc;
       String filePath = null;
       for (int i = 0; i < modelCount; ++i)
@@ -1473,4 +1450,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
      */
     viewer.evalString("zoom 0");
   }
+
+  @Override
+  public int getModelForPdbFile(String fileName, int fileIndex)
+  {
+    return fileIndex;
+  }
 }