The detailed description of atom coloring can be found in the Atom and bond set handling paragraph of the Developer's Guide.
This example introduces the atom coloring possibilities of the MarvinView applet with the help of atom sets.
The goal of the example is to define a sub-structure (cyclohexanol) of a molecule
with an atom set and color it using a custom color (blue).
The result of the example can be seen in the applet below:
To achive this, the following steps were done:
mview_param("setColoringEnabled", "true");
mview_param("atomSetColor1", "#0000ff");
mview_param("atomSet0.1", "6,7,8,9,10,11,12");
Atom sets are defined with a comma separated list of atom indices. The meaning of this parameter setting is: atoms of the molecule being in the cell number 0 having the atom indices that are included in the given list belong to the first atom set.
The atom indices are set to visible using the atomNumbersVisible parameter, though important to note, that indexing on the canvas starts from 1, while the indices in the atom set start from 0.
mview_param("atomNumbersVisible", "true");
Note that by coloring an atom the color of the connecting bonds are also affected.
The required HTML code is as follows:
<script LANGUAGE="JavaScript1.1" SRC="../../../marvin.js"></script> <script LANGUAGE="JavaScript1.1"> <!-- mview_begin("../../..", 300, 150); mview_param("rows", "1"); mview_param("cols", "1"); mview_param("cell0", "|../../../mols-2d/mol1.mol"); mview_param("atomNumbersVisible", "true"); mview_param("setColoringEnabled", "true"); mview_param("atomSetColor1", "#0000ff"); mview_param("atomSet0.1", "6,7,8,9,10,11,12"); mview_end(); //--> </script>