c.getBlue());
}
-
+ @Deprecated
public String[] colourBySequence(StructureSelectionManager ssm,
String[] files,
SequenceI[][] sequence, SequenceRenderer sr,
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import jalview.structure.AtomSpecModel;
import jalview.structure.StructureCommand;
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;
+ }
+
}
*/
package jalview.ext.rbvi.chimera;
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
import jalview.structure.StructureSelectionManager;
import jalview.util.ColorUtils;
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Routines for generating Chimera commands for Jalview/Chimera binding
*
return new StructureCommand("open " + file);
}
+ /**
+ * Overrides the default method to concatenate colour commands into one
+ */
+ @Override
+ public List<StructureCommandI> colourBySequence(
+ Map<Object, AtomSpecModel> colourMap)
+ {
+ List<StructureCommandI> commands = new ArrayList<>();
+ StringBuilder sb = new StringBuilder(colourMap.size() * 20);
+ boolean first = true;
+ for (Object key : colourMap.keySet())
+ {
+ Color colour = (Color) key;
+ final AtomSpecModel colourData = colourMap.get(colour);
+ StructureCommandI command = getColourCommand(colourData, colour);
+ if (!first)
+ {
+ sb.append(getCommandSeparator());
+ }
+ first = false;
+ sb.append(command.getCommand());
+ }
+
+ commands.add(new StructureCommand(sb.toString()));
+ return commands;
+ }
+
}
package jalview.structure;
-import jalview.api.AlignmentViewPanel;
-import jalview.datamodel.SequenceI;
-
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import jalview.api.AlignmentViewPanel;
+import jalview.datamodel.SequenceI;
+
/**
* A base class holding methods useful to all classes that implement commands
* for structure viewers
* Traverse the map of colours/models/chains/positions to construct a list of
* 'color' commands (one per distinct colour used). The format of each command
* is specific to the structure viewer.
+ * <p>
+ * The default implementation returns a single command containing one command
+ * per colour, concatenated.
*
* @param colourMap
* @return
public List<StructureCommandI> colourBySequence(
Map<Object, AtomSpecModel> colourMap)
{
- /*
- * default implementation creates one command per colour;
- * override to concatenate colour commands if wanted
- */
List<StructureCommandI> commands = new ArrayList<>();
+ StringBuilder sb = new StringBuilder(colourMap.size() * 20);
+ boolean first = true;
for (Object key : colourMap.keySet())
{
Color colour = (Color) key;
final AtomSpecModel colourData = colourMap.get(colour);
- commands.add(getColourCommand(colourData, colour));
+ StructureCommandI command = getColourCommand(colourData, colour);
+ if (!first)
+ {
+ sb.append(getCommandSeparator());
+ }
+ first = false;
+ sb.append(command.getCommand());
}
+ commands.add(new StructureCommand(sb.toString()));
return commands;
}