ChemWriter

ChemWriter 2

Drawing Properties

ChemWriter supports several user-definable drawing properties. These properties enable fine-grained control over the appearance of drawn structures in both the Editor and Painter components. This system is designed to ensure that chemical structures are rendered in a readable manner regardless of display size.

Most numerical drawing properties are measurements relative to a structure's median bond length. For example, setting a lineWidth of 0.1 tells ChemWriter to display bond line widths at 10% the length of a bond. The only exception is deviceBondLength, which is measured relative to device units (e.g., pixels).

Available Drawing Properties

lineWidth

The width of bond lines relative to the median bond length.

lineOffset

The distance between parallel multiple bond lines relative to the median bond length.

atomLabelHeight

The height of a capital letter in an atom label relative to the median bond height.

hoverRadius

The radius around which atom labels and bond midpoints will be detected as hovered on mouse over events, relative to the median bond height.

deviceBondLength

The bond length in device units (e.g., pixels).

disableImplicitHydrogenCount

An array of element symbols to exclude from implicit hydrogen checking. For example: ['Sn', 'Se'].

Setting and Querying Drawing Properties

Drawing properties can be set in two ways. The most common way will be to pass a params object to either the loadEditor or loadPainter functions. For example, a Painter's lineWidth property can be set to 0.05 at startup with:

var painter = chemwriter.loadPainter('my-painter', {
  licensePath: '/path/to/licenseFile',
  lineWidth: 0.05
});
 

The other way to set a drawing property is to invoke a JavaScript function. To simplify the API, ChemWriter uses the camelized name of the property in the function name, prepended with either 'get' or 'set'. For example, changing the line width of a running Editor instance to 0.05 can be accomplished with:

// var editor = ...

editor.setLineWidth(0.05);
editor.getLineWidth(); // returns 0.05