+ * @param cs
+ */
+ public void colourByJalviewColourScheme(ColourSchemeI cs)
+ {
+ colourBySequence = false;
+
+ if (cs == null || !cs.isSimple())
+ {
+ return;
+ }
+
+ /*
+ * build a map of {Residue3LetterCode, Color}
+ */
+ Map<String, Color> colours = new HashMap<>();
+ List<String> residues = ResidueProperties.getResidues(isNucleotide(),
+ false);
+ for (String resName : residues)
+ {
+ char res = resName.length() == 3
+ ? ResidueProperties.getSingleCharacterCode(resName)
+ : resName.charAt(0);
+ Color colour = cs.findColour(res, 0, null, null, 0f);
+ colours.put(resName, colour);
+ }
+
+ /*
+ * pass to the command constructor, and send the command
+ */
+ String cmd = commandGenerator.colourByResidues(colours);
+ executeCommand(cmd, false, COLOURING_STRUCTURES);
+ }
+
+ public void setBackgroundColour(Color col)
+ {
+ String cmd = commandGenerator.setBackgroundColour(col);
+ executeCommand(cmd, false, null);
+ }
+
+ /**
+ * Sends one command to the structure viewer. If {@code getReply} is true, the
+ * command is sent synchronously, otherwise in a deferred thread.
+ * <p>
+ * If a progress message is supplied, this is displayed before command
+ * execution, and removed afterwards.
+ *
+ * @param cmd
+ * @param getReply
+ * @param msg
+ * @return
+ */
+ private List<String> executeCommand(String cmd, boolean getReply,
+ String msg)
+ {
+ if (getReply)
+ {
+ return executeSynchronous(cmd, msg, getReply);
+ }
+ else
+ {
+ executeAsynchronous(cmd, msg);
+ return null;
+ }
+ }
+
+ /**
+ * Sends the command in the current thread. If a message is supplied, this is
+ * shown before the thread is started, and removed when it completes. May
+ * return a reply to the command if requested.