Customizing Structure Templates

By default, MarvinSketch contains 12 template groups, as described in the Developer's Guide.

The Generic and My Templates groups automatically appear on the Advanced Templates toolbar for easier access.

In this example, the My Templates group contains one molecule: benzene.

The goal of this example is to customize the template structures of MarvinSketch in the following way:

  • Generic and Rings template groups are set to visible on the toolbar

  • Two wedge bonds are defined in the Extra Templates group, which will also be visible on the toolbar

  • A new template group, Conformers is defined consisting of 6 structures

The result of this customization can be seen on the picture below. The Conformers and My Templates template groups are not visible on the toolbar in this case.

images/download/attachments/45331359/sketch_templates.png

The code below is taken from SketchTemplates.java, where the structure templates are customized using the setParams method of the MSketchPane class. Currently this is the only way of defining template groups.
In the example, the characters * and : are used as delimiters.

    sketchPane.  setParams  (        UserSettings.TOOLBAR_TEMPLATES+  "0=*Generic*chemaxon/marvin/templates/generic.t  \n  "  +        UserSettings.TOOLBAR_TEMPLATES+  "1=*Rings*chemaxon/marvin/templates/rings.t  \n  "  +        UserSettings.EXTRA_TEMPLATES+  "=chemaxon/marvin/templates/wedgebonds.t  \n  "  +        UserSettings.TEMPLATES+  "11=:Conformers:chemaxon/marvin/templates/conformers.t  \n  "  );

images/download/attachments/45331359/sketch_templates2.png

In this example we have used the wedgebonds.t. and conformers.t. compressed SDfiles. Note that currently template files can only be in SDfiles or compressed SDfiles formats with .t extension.

The same example is available as an applet example, showing the usage and effect of using these parameters in applets.