Merge branch 'develop' into feature/JAL-3390hideUnmappedStructure
[jalview.git] / src / jalview / ext / rbvi / chimera / ChimeraCommands.java
index 43cdeb1..a4f4cff 100644 (file)
@@ -36,6 +36,7 @@ import jalview.util.ColorUtils;
  * Routines for generating Chimera commands for Jalview/Chimera binding
  * 
  * @author JimP
+ * @see https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/framecommand.html
  * 
  */
 public class ChimeraCommands extends StructureCommandsBase
@@ -102,6 +103,7 @@ public class ChimeraCommands extends StructureCommandsBase
    * </pre>
    * 
    * @param featureMap
+   * @param binding
    * @return
    */
   @Override
@@ -221,41 +223,6 @@ public class ChimeraCommands extends StructureCommandsBase
   }
 
   @Override
-  public List<StructureCommandI> showChains(List<String> toShow)
-  {
-    /*
-     * Construct a chimera command like
-     * 
-     * ~display #*;~ribbon #*;ribbon :.A,:.B
-     */
-    StringBuilder cmd = new StringBuilder(64);
-    boolean first = true;
-    for (String chain : toShow)
-    {
-      String[] tokens = chain.split(":");
-      if (tokens.length == 2)
-      {
-        String showChainCmd = tokens[0] + ":." + tokens[1];
-        if (!first)
-        {
-          cmd.append(",");
-        }
-        cmd.append(showChainCmd);
-        first = false;
-      }
-    }
-
-    /*
-     * could append ";focus" to this command to resize the display to fill the
-     * window, but it looks more helpful not to (easier to relate chains to the
-     * whole)
-     */
-    final String command = "~display #*; ~ribbon #*; ribbon :"
-            + cmd.toString();
-    return Arrays.asList(new StructureCommand(command));
-  }
-
-  @Override
   public List<StructureCommandI> superposeStructures(AtomSpecModel ref,
           AtomSpecModel spec)
   {
@@ -424,6 +391,30 @@ public class ChimeraCommands extends StructureCommandsBase
   }
 
   @Override
+  public StructureCommandI showStructures(AtomSpecModel restrictTo)
+  {
+    if (restrictTo == null)
+    {
+      return new StructureCommand("ribbon");
+    }
+
+    String atomSpec = getAtomSpec(restrictTo, false);
+    String cmd = "ribbon " + atomSpec;
+    return new StructureCommand(cmd);
+  }
+
+  @Override
+  public StructureCommandI hideChain(String modelId, String chainId)
+  {
+    String cmd = "~ribbon #" + modelId + ":." + chainId;
+    return new StructureCommand(cmd);
+  }
+
+  @Override
+  public StructureCommandI hideAll()
+  {
+    return new StructureCommand("~display; ~ribbon");
+  }
   public StructureCommandI closeViewer()
   {
     return CLOSE_CHIMERA;