JAL-3551 concatenate colour by sequence commands for all except PyMOL
[jalview.git] / src / jalview / ext / pymol / PymolCommands.java
index 115efa1..e4f9f5f 100644 (file)
@@ -3,6 +3,7 @@ package jalview.ext.pymol;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import jalview.structure.AtomSpecModel;
 import jalview.structure.StructureCommand;
@@ -209,4 +210,27 @@ public class PymolCommands extends StructureCommandsBase
     return new StructureCommand("load", file);
   }
 
+  /**
+   * Overrides the default implementation (which generates concatenated
+   * commands) to generate one per colour (because the XML-RPC interface to
+   * PyMOL only accepts one command at a time)
+   * 
+   * @param colourMap
+   * @return
+   */
+  @Override
+  public List<StructureCommandI> colourBySequence(
+          Map<Object, AtomSpecModel> colourMap)
+  {
+    List<StructureCommandI> commands = new ArrayList<>();
+    for (Object key : colourMap.keySet())
+    {
+      Color colour = (Color) key;
+      final AtomSpecModel colourData = colourMap.get(colour);
+      commands.add(getColourCommand(colourData, colour));
+    }
+  
+    return commands;
+  }
+
 }