+ * Get the residue colour at the given sequence position - as determined by
+ * the sequence group colour (if any), else the colour scheme, possibly
+ * overridden by a feature colour.
+ *
+ * @param seq
+ * @param position
+ * @param sr
+ * @param fr
+ * @return
+ */
+ protected static Color getResidueColour(final SequenceI seq,
+ int position, SequenceRenderer sr, FeatureRenderer fr)
+ {
+ Color col = sr.getResidueBoxColour(seq, position);
+
+ if (fr != null)
+ {
+ col = fr.findFeatureColour(col, seq, position);
+ }
+ return col;
+ }
+
+ /**
+ * Helper method to build the colour commands for one PDBfile.
+ *
+ * @param cset
+ * the list of commands to be added to
+ * @param colranges
+ * the map of colours to residue positions already determined
+ * @param fos
+ * file to write 'defattr' commands to
+ * @param setAttributes
+ * @throws IOException
+ */
+ protected static String buildColourCommands(
+ List<StructureMappingcommandSet> cset,
+ Map<String, StringBuilder> colranges,
+ FileOutputStream fos, StringBuilder setAttributes)
+ throws IOException
+ {
+ int colourId = 0;
+ String lastColour = null;
+ for (String colour : colranges.keySet())
+ {
+ lastColour = colour;
+ colourId++;
+ /*
+ * Using color command directly is slow for larger structures.
+ * setAttributes.append("color #" + colour + " " + colranges.get(colour)+
+ * ";");
+ */
+ setAttributes.append("color " + colour + " " + colranges.get(colour)
+ + ";");
+ final String atomSpec = new String(colranges.get(colour));
+ // setAttributes.append("setattr r jalviewclr " + colourId + " "
+ // + atomSpec + ";");
+ fos.write(("\t" + atomSpec + "\t" + colourId + "\n").getBytes());
+ }
+ return lastColour;
+ }
+
+ /**