Atom and bond-set handling
Format styles (journal styles)
You can get more advanced display format for the molecule by applying journal styles. Format styles in Marvin include the setting of the following attributes:- type of atom font,
- scale of atom font,
- color of atoms and atom labels,
- thickness of bonds,
- color of bonds.
You can create an atom- or bond-set in Marvin to specify an atom-font/atom-color and bond-thickness/bond-color. The colors, fonts, thickness values are stored in a lookup table of MDocument.
The following code example will change the format of some atoms and bonds in a 11 atom - long chain:
//import a simple chain
Molecule mol = MolImporter.importMol("CCNCCCCCNCC");
//create a document to register color, font, size in the lookup table
MDocument mdoc = new MDocument(mol);
//define two colors
Color green = new Color(0, 255, 0);
Color blue = new Color(0, 0, 255);
MFont font = new MFont("Helvetica", MFont.BOLD, 20 );
To create a new color/font setting for a set of atom you have to register the
color and font in the lookup table the following way:
//specify a new atom-style by setting color and font of the 1. atom set
//set the coloring mode
mdoc.setAtomSetColorMode(1, MDocument.SETCOLOR_SPECIFIED);
//set the color of the 1. atom-set
mdoc.setAtomSetRGB(1, green.getRGB());
//set the font of the 1. atom-set
mdoc.setAtomSetFont(1, font);
To create a new color/thickness setting for a set of bonds you have to register the
color and the thickness in the lookup table the following way:
//specify a new bond-style by setting color and thickness of the 2. atom set
//set the coloring mode
mdoc.setBondSetColorMode(2, MDocument.SETCOLOR_SPECIFIED);
//set the color of the 2. bond-set
mdoc.setBondSetRGB(2, blue.getRGB());
//set the thickness of the 2. bond-set
mdoc.setBondSetThickness(2, 0.2);
You can create an atom-set in Marvin the following way:
//set the color and font of the 2. and 8. atoms in the molecule
//by adding these atoms to the 1. atom set.
mol.getAtom(2).setSetSeq(1);
mol.getAtom(8).setSetSeq(1);
You can create a bond-set in Marvin the following way:
//set the color and thickness of 4. bond in the molecule
//by adding this bond to the 2. atom set.
The result of atom and bond set coloring example is shown on the picture:

The atom- and bond-set coloring is available using the
atomSetColor, bondSetColor applet and beans parameters.
Do you have a question? Would you like to learn more? Please browse among the related topics on our support forum or search the website. If you want to suggest modifications or improvements to our documentation email our support directly!
