UNPKG

smiles-drawer

Version:

A SMILES drawer and parser. Generate molecular structure depictions in pure JavaScript.

1,095 lines (811 loc) 153 kB
[![view on npm](http://img.shields.io/npm/v/example.svg)](https://www.npmjs.org/package/example) ## Classes <dl> <dt><a href="#ArrayHelper">ArrayHelper</a></dt> <dd><p>A static class containing helper functions for array-related tasks.</p> </dd> <dt><a href="#Atom">Atom</a></dt> <dd><p>A class representing an atom.</p> </dd> <dt><a href="#CanvasWrapper">CanvasWrapper</a></dt> <dd><p>A class wrapping a canvas element.</p> </dd> <dt><a href="#Drawer">Drawer</a></dt> <dd><p>The main class of the application representing the smiles drawer</p> </dd> <dt><a href="#Edge">Edge</a></dt> <dd><p>A class representing an edge.</p> </dd> <dt><a href="#Graph">Graph</a></dt> <dd><p>A class representing the molecular graph.</p> </dd> <dt><a href="#Line">Line</a></dt> <dd><p>A class representing a line.</p> </dd> <dt><a href="#MathHelper">MathHelper</a></dt> <dd><p>A static class containing helper functions for math-related tasks.</p> </dd> <dt><a href="#Ring">Ring</a></dt> <dd><p>A class representing a ring.</p> </dd> <dt><a href="#RingConnection">RingConnection</a></dt> <dd><p>A class representing a ring connection.</p> </dd> <dt><a href="#SSSR">SSSR</a></dt> <dd><p>A class encapsulating the functionality to find the smallest set of smallest rings in a graph.</p> </dd> <dt><a href="#Vector2">Vector2</a></dt> <dd><p>A class representing a 2D vector.</p> </dd> <dt><a href="#Vertex">Vertex</a></dt> <dd><p>A class representing a vertex.</p> </dd> </dl> <a name="ArrayHelper"></a> ## ArrayHelper A static class containing helper functions for array-related tasks. **Kind**: global class * [ArrayHelper](#ArrayHelper) * [.clone(arr)](#ArrayHelper.clone) ⇒ <code>\*</code> * [.equals(arrA, arrB)](#ArrayHelper.equals) ⇒ <code>Boolean</code> * [.print(arr)](#ArrayHelper.print) ⇒ <code>String</code> * [.each(arr, callback)](#ArrayHelper.each) * [.get(arr, property, value)](#ArrayHelper.get) ⇒ <code>\*</code> * [.contains(arr, options)](#ArrayHelper.contains) ⇒ <code>Boolean</code> * [.intersection(arrA, arrB)](#ArrayHelper.intersection) ⇒ <code>Array</code> * [.unique(arr)](#ArrayHelper.unique) ⇒ <code>Array</code> * [.count(arr, value)](#ArrayHelper.count) ⇒ <code>Number</code> * [.toggle(arr, value)](#ArrayHelper.toggle) ⇒ <code>Array</code> * [.remove(arr, value)](#ArrayHelper.remove) ⇒ <code>Array</code> * [.removeUnique(arr, value)](#ArrayHelper.removeUnique) ⇒ <code>Array</code> * [.removeAll(arrA, arrB)](#ArrayHelper.removeAll) ⇒ <code>Array</code> * [.merge(arrA, arrB)](#ArrayHelper.merge) ⇒ <code>Array</code> * [.containsAll(arrA, arrB)](#ArrayHelper.containsAll) ⇒ <code>Boolean</code> * [.sortByAtomicNumberDesc(arr)](#ArrayHelper.sortByAtomicNumberDesc) ⇒ <code>Array.&lt;Object&gt;</code> * [.deepCopy(arr)](#ArrayHelper.deepCopy) ⇒ <code>Array</code> <a name="ArrayHelper.clone"></a> ### ArrayHelper.clone(arr) ⇒ <code>\*</code> Clone an array or an object. If an object is passed, a shallow clone will be created. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>\*</code> - A clone of the array or object. | Param | Type | Description | | --- | --- | --- | | arr | <code>\*</code> | The array or object to be cloned. | <a name="ArrayHelper.equals"></a> ### ArrayHelper.equals(arrA, arrB) ⇒ <code>Boolean</code> Returns a boolean indicating whether or not the two arrays contain the same elements. Only supports 1d, non-nested arrays. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not the two arrays contain the same elements. | Param | Type | Description | | --- | --- | --- | | arrA | <code>Array</code> | An array. | | arrB | <code>Array</code> | An array. | <a name="ArrayHelper.print"></a> ### ArrayHelper.print(arr) ⇒ <code>String</code> Returns a string representation of an array. If the array contains objects with an id property, the id property is printed for each of the elements. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>String</code> - A string representation of the array. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array.&lt;Object&gt;</code> | An array. | | arr[].id | <code>\*</code> | If the array contains an object with the property 'id', the properties value is printed. Else, the array elements value is printend. | <a name="ArrayHelper.each"></a> ### ArrayHelper.each(arr, callback) Run a function for each element in the array. The element is supplied as an argument for the callback function **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | callback | <code>function</code> | The callback function that is called for each element. | <a name="ArrayHelper.get"></a> ### ArrayHelper.get(arr, property, value) ⇒ <code>\*</code> Return the array element from an array containing objects, where a property of the object is set to a given value. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>\*</code> - The array element matching the value. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | property | <code>String</code> &#124; <code>Number</code> | A property contained within an object in the array. | | value | <code>String</code> &#124; <code>Number</code> | The value of the property. | <a name="ArrayHelper.contains"></a> ### ArrayHelper.contains(arr, options) ⇒ <code>Boolean</code> Checks whether or not an array contains a given value. the options object passed as a second argument can contain three properties. value: The value to be searched for. property: The property that is to be searched for a given value. func: A function that is used as a callback to return either true or false in order to do a custom comparison. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Boolean</code> - A boolean whether or not the array contains a value. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | options | <code>Object</code> | See method description. | | options.value | <code>\*</code> | The value for which to check. | | [options.property] | <code>String</code> | The property on which to check. | | [options.func] | <code>function</code> | A custom property function. | <a name="ArrayHelper.intersection"></a> ### ArrayHelper.intersection(arrA, arrB) ⇒ <code>Array</code> Returns an array containing the intersection between two arrays. That is, values that are common to both arrays. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - The intersecting vlaues. | Param | Type | Description | | --- | --- | --- | | arrA | <code>Array</code> | An array. | | arrB | <code>Array</code> | An array. | <a name="ArrayHelper.unique"></a> ### ArrayHelper.unique(arr) ⇒ <code>Array</code> Returns an array of unique elements contained in an array. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - An array of unique elements contained within the array supplied as an argument. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | <a name="ArrayHelper.count"></a> ### ArrayHelper.count(arr, value) ⇒ <code>Number</code> Count the number of occurences of a value in an array. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Number</code> - The number of occurences of a value in the array. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | value | <code>\*</code> | A value to be counted. | <a name="ArrayHelper.toggle"></a> ### ArrayHelper.toggle(arr, value) ⇒ <code>Array</code> Toggles the value of an array. If a value is not contained in an array, the array returned will contain all the values of the original array including the value. If a value is contained in an array, the array returned will contain all the values of the original array excluding the value. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - The toggled array. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | value | <code>\*</code> | A value to be toggled. | <a name="ArrayHelper.remove"></a> ### ArrayHelper.remove(arr, value) ⇒ <code>Array</code> Remove a value from an array. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - A new array with the element with a given value removed. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | value | <code>\*</code> | A value to be removed. | <a name="ArrayHelper.removeUnique"></a> ### ArrayHelper.removeUnique(arr, value) ⇒ <code>Array</code> Remove a value from an array with unique values. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - An array with the element with a given value removed. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | An array. | | value | <code>\*</code> | A value to be removed. | <a name="ArrayHelper.removeAll"></a> ### ArrayHelper.removeAll(arrA, arrB) ⇒ <code>Array</code> Remove all elements contained in one array from another array. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - The filtered array. | Param | Type | Description | | --- | --- | --- | | arrA | <code>Array</code> | The array to be filtered. | | arrB | <code>Array</code> | The array containing elements that will be removed from the other array. | <a name="ArrayHelper.merge"></a> ### ArrayHelper.merge(arrA, arrB) ⇒ <code>Array</code> Merges two arrays and returns the result. The first array will be appended to the second array. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - The merged array. | Param | Type | Description | | --- | --- | --- | | arrA | <code>Array</code> | An array. | | arrB | <code>Array</code> | An array. | <a name="ArrayHelper.containsAll"></a> ### ArrayHelper.containsAll(arrA, arrB) ⇒ <code>Boolean</code> Checks whether or not an array contains all the elements of another array, without regard to the order. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not both array contain the same elements. | Param | Type | Description | | --- | --- | --- | | arrA | <code>Array</code> | An array. | | arrB | <code>Array</code> | An array. | <a name="ArrayHelper.sortByAtomicNumberDesc"></a> ### ArrayHelper.sortByAtomicNumberDesc(arr) ⇒ <code>Array.&lt;Object&gt;</code> Sort an array of atomic number information. Where the number is indicated as x, x.y, x.y.z, ... **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array.&lt;Object&gt;</code> - The array sorted by atomic number. Example of an array entry: { atomicNumber: 2, vertexId: 5 }. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array.&lt;Object&gt;</code> | An array of vertex ids with their associated atomic numbers. | | arr[].vertexId | <code>Number</code> | A vertex id. | | arr[].atomicNumber | <code>String</code> | The atomic number associated with the vertex id. | <a name="ArrayHelper.deepCopy"></a> ### ArrayHelper.deepCopy(arr) ⇒ <code>Array</code> Copies a an n-dimensional array. **Kind**: static method of <code>[ArrayHelper](#ArrayHelper)</code> **Returns**: <code>Array</code> - The copy. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array</code> | The array to be copied. | <a name="Atom"></a> ## Atom A class representing an atom. **Kind**: global class **Properties** | Name | Type | Description | | --- | --- | --- | | element | <code>String</code> | The element symbol of this atom. Single-letter symbols are always uppercase. Examples: H, C, F, Br, Si, ... | | drawExplicit | <code>Boolean</code> | A boolean indicating whether or not this atom is drawn explicitly (for example, a carbon atom). This overrides the default behaviour. | | ringbonds | <code>Array.&lt;Object&gt;</code> | An array containing the ringbond ids and bond types as specified in the original SMILE. | | branchBond | <code>String</code> | The branch bond as defined in the SMILES. | | ringbonds[].id | <code>Number</code> | The ringbond id as defined in the SMILES. | | ringbonds[].bondType | <code>String</code> | The bond type of the ringbond as defined in the SMILES. | | rings | <code>Array.&lt;Number&gt;</code> | The ids of rings which contain this atom. | | bondType | <code>String</code> | The bond type associated with this array. Examples: -, =, #, ... | | isBridge | <code>Boolean</code> | A boolean indicating whether or not this atom is part of a bridge in a bridged ring (contained by the largest ring). | | isBridgeNode | <code>Boolean</code> | A boolean indicating whether or not this atom is a bridge node (a member of the largest ring in a bridged ring which is connected to a bridge-atom). | | originalRings | <code>Array.&lt;Number&gt;</code> | Used to back up rings when they are replaced by a bridged ring. | | bridgedRing | <code>Number</code> | The id of the bridged ring if the atom is part of a bridged ring. | | anchoredRings | <code>Array.&lt;Number&gt;</code> | The ids of the rings that are anchored to this atom. The centers of anchored rings are translated when this atom is translated. | | bracket | <code>Object</code> | If this atom is defined as a bracket atom in the original SMILES, this object contains all the bracket information. Example: { hcount: {Number}, charge: ['--', '-', '+', '++'], isotope: {Number} }. | | plane | <code>Number</code> | Specifies on which "plane" the atoms is in stereochemical deptictions (-1 back, 0 middle, 1 front). | | attachedPseudoElements | <code>Array.&lt;Object&gt;</code> | A map with containing information for pseudo elements or concatinated elements. The key is comprised of the element symbol and the hydrogen count. | | attachedPseudoElement[].element | <code>String</code> | The element symbol. | | attachedPseudoElement[].count | <code>Number</code> | The number of occurences that match the key. | | attachedPseudoElement[].hyrogenCount | <code>Number</code> | The number of hydrogens attached to each atom matching the key. | | hasAttachedPseudoElements | <code>Boolean</code> | A boolean indicating whether or not this attom will be drawn with an attached pseudo element or concatinated elements. | | isDrawn | <code>Boolean</code> | A boolean indicating whether or not this atom is drawn. In contrast to drawExplicit, the bond is drawn neither. | | isConnectedToRing | <code>Boolean</code> | A boolean indicating whether or not this atom is directly connected (but not a member of) a ring. | | neighbouringElements | <code>Array.&lt;String&gt;</code> | An array containing the element symbols of neighbouring atoms. | | isPartOfAromaticRing | <code>Boolean</code> | A boolean indicating whether or not this atom is part of an explicitly defined aromatic ring. Example: c1ccccc1. | | bondCount | <code>Number</code> | The number of bonds in which this atom is participating. | | chirality | <code>String</code> | The chirality of this atom if it is a stereocenter (R or S). | | priority | <code>Number</code> | The priority of this atom acording to the CIP rules, where 0 is the highest priority. | | mainChain | <code>Boolean</code> | A boolean indicating whether or not this atom is part of the main chain (used for chirality). | | hydrogenDirection | <code>String</code> | The direction of the hydrogen, either up or down. Only for stereocenters with and explicit hydrogen. | | subtreeDepth | <code>Number</code> | The depth of the subtree coming from a stereocenter. | * [Atom](#Atom) * [new Atom(element, [bondType])](#new_Atom_new) * _instance_ * [.addNeighbouringElement(element)](#Atom+addNeighbouringElement) * [.attachPseudoElement(element, previousElement, [hydrogenCount], [charge])](#Atom+attachPseudoElement) * [.getAttachedPseudoElements()](#Atom+getAttachedPseudoElements) ⇒ <code>Object</code> * [.getAttachedPseudoElementsCount()](#Atom+getAttachedPseudoElementsCount) ⇒ <code>Number</code> * [.isHeteroAtom()](#Atom+isHeteroAtom) ⇒ <code>Boolean</code> * [.addAnchoredRing(ringId)](#Atom+addAnchoredRing) * [.getRingbondCount()](#Atom+getRingbondCount) ⇒ <code>Number</code> * [.backupRings()](#Atom+backupRings) * [.restoreRings()](#Atom+restoreRings) * [.haveCommonRingbond(atomA, atomB)](#Atom+haveCommonRingbond) ⇒ <code>Boolean</code> * [.neighbouringElementsEqual(arr)](#Atom+neighbouringElementsEqual) ⇒ <code>Boolean</code> * [.getAtomicNumber()](#Atom+getAtomicNumber) ⇒ <code>Number</code> * [.getMaxBonds()](#Atom+getMaxBonds) ⇒ <code>Number</code> * _static_ * [.maxBonds](#Atom.maxBonds) * [.atomicNumbers](#Atom.atomicNumbers) * [.mass](#Atom.mass) <a name="new_Atom_new"></a> ### new Atom(element, [bondType]) The constructor of the class Atom. | Param | Type | Default | Description | | --- | --- | --- | --- | | element | <code>String</code> | | The one-letter code of the element. | | [bondType] | <code>String</code> | <code>&#x27;-&#x27;</code> | The type of the bond associated with this atom. | <a name="Atom+addNeighbouringElement"></a> ### atom.addNeighbouringElement(element) Adds a neighbouring element to this atom. **Kind**: instance method of <code>[Atom](#Atom)</code> | Param | Type | Description | | --- | --- | --- | | element | <code>String</code> | A string representing an element. | <a name="Atom+attachPseudoElement"></a> ### atom.attachPseudoElement(element, previousElement, [hydrogenCount], [charge]) Attaches a pseudo element (e.g. Ac) to the atom. **Kind**: instance method of <code>[Atom](#Atom)</code> | Param | Type | Default | Description | | --- | --- | --- | --- | | element | <code>String</code> | | The element identifier (e.g. Br, C, ...). | | previousElement | <code>String</code> | | The element that is part of the main chain (not the terminals that are converted to the pseudo element or concatinated). | | [hydrogenCount] | <code>Number</code> | <code>0</code> | The number of hydrogens for the element. | | [charge] | <code>Number</code> | <code>0</code> | The charge for the element. | <a name="Atom+getAttachedPseudoElements"></a> ### atom.getAttachedPseudoElements() ⇒ <code>Object</code> Returns the attached pseudo elements sorted by hydrogen count (ascending). **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Object</code> - The sorted attached pseudo elements. <a name="Atom+getAttachedPseudoElementsCount"></a> ### atom.getAttachedPseudoElementsCount() ⇒ <code>Number</code> Returns the number of attached pseudo elements. **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Number</code> - The number of attached pseudo elements. <a name="Atom+isHeteroAtom"></a> ### atom.isHeteroAtom() ⇒ <code>Boolean</code> Returns whether this atom is a heteroatom (not C and not H). **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether this atom is a heteroatom. <a name="Atom+addAnchoredRing"></a> ### atom.addAnchoredRing(ringId) Defines this atom as the anchor for a ring. When doing repositionings of the vertices and the vertex associated with this atom is moved, the center of this ring is moved as well. **Kind**: instance method of <code>[Atom](#Atom)</code> | Param | Type | Description | | --- | --- | --- | | ringId | <code>Number</code> | A ring id. | <a name="Atom+getRingbondCount"></a> ### atom.getRingbondCount() ⇒ <code>Number</code> Returns the number of ringbonds (breaks in rings to generate the MST of the smiles) within this atom is connected to. **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Number</code> - The number of ringbonds this atom is connected to. <a name="Atom+backupRings"></a> ### atom.backupRings() Backs up the current rings. **Kind**: instance method of <code>[Atom](#Atom)</code> <a name="Atom+restoreRings"></a> ### atom.restoreRings() Restores the most recent backed up rings. **Kind**: instance method of <code>[Atom](#Atom)</code> <a name="Atom+haveCommonRingbond"></a> ### atom.haveCommonRingbond(atomA, atomB) ⇒ <code>Boolean</code> Checks whether or not two atoms share a common ringbond id. A ringbond is a break in a ring created when generating the spanning tree of a structure. **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not two atoms share a common ringbond. | Param | Type | Description | | --- | --- | --- | | atomA | <code>[Atom](#Atom)</code> | An atom. | | atomB | <code>[Atom](#Atom)</code> | An atom. | <a name="Atom+neighbouringElementsEqual"></a> ### atom.neighbouringElementsEqual(arr) ⇒ <code>Boolean</code> Check whether or not the neighbouring elements of this atom equal the supplied array. **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not the neighbours match the supplied array of elements. | Param | Type | Description | | --- | --- | --- | | arr | <code>Array.&lt;String&gt;</code> | An array containing all the elements that are neighbouring this atom. E.g. ['C', 'O', 'O', 'N'] | <a name="Atom+getAtomicNumber"></a> ### atom.getAtomicNumber() ⇒ <code>Number</code> Get the atomic number of this atom. **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Number</code> - The atomic number of this atom. <a name="Atom+getMaxBonds"></a> ### atom.getMaxBonds() ⇒ <code>Number</code> Get the maximum number of bonds for this atom. **Kind**: instance method of <code>[Atom](#Atom)</code> **Returns**: <code>Number</code> - The maximum number of bonds of this atom. <a name="Atom.maxBonds"></a> ### Atom.maxBonds A map mapping element symbols to their maximum bonds. **Kind**: static property of <code>[Atom](#Atom)</code> <a name="Atom.atomicNumbers"></a> ### Atom.atomicNumbers A map mapping element symbols to the atomic number. **Kind**: static property of <code>[Atom](#Atom)</code> <a name="Atom.mass"></a> ### Atom.mass A map mapping element symbols to the atomic mass. **Kind**: static property of <code>[Atom](#Atom)</code> <a name="CanvasWrapper"></a> ## CanvasWrapper A class wrapping a canvas element. **Kind**: global class **Properties** | Name | Type | Description | | --- | --- | --- | | canvas | <code>HTMLElement</code> | The HTML element for the canvas associated with this CanvasWrapper instance. | | ctx | <code>CanvasRenderingContext2D</code> | The CanvasRenderingContext2D of the canvas associated with this CanvasWrapper instance. | | colors | <code>Object</code> | The colors object as defined in the SmilesDrawer options. | | opts | <code>Object</code> | The SmilesDrawer options. | | drawingWidth | <code>Number</code> | The width of the canvas. | | drawingHeight | <code>Number</code> | The height of the canvas. | | offsetX | <code>Number</code> | The horizontal offset required for centering the drawing. | | offsetY | <code>Number</code> | The vertical offset required for centering the drawing. | | fontLarge | <code>Number</code> | The large font size in pt. | | fontSmall | <code>Number</code> | The small font size in pt. | * [CanvasWrapper](#CanvasWrapper) * [new CanvasWrapper(target, theme, options)](#new_CanvasWrapper_new) * [.updateSize(width, height)](#CanvasWrapper+updateSize) * [.setTheme(theme)](#CanvasWrapper+setTheme) * [.scale(vertices)](#CanvasWrapper+scale) * [.reset()](#CanvasWrapper+reset) * [.getColor(key)](#CanvasWrapper+getColor) ⇒ <code>String</code> * [.drawCircle(x, y, radius, color, [fill], [debug], [debugText])](#CanvasWrapper+drawCircle) * [.drawLine(line, [dashed], [alpha])](#CanvasWrapper+drawLine) * [.drawWedge(line, width)](#CanvasWrapper+drawWedge) * [.drawDashedWedge(line)](#CanvasWrapper+drawDashedWedge) * [.drawDebugText(x, y, text)](#CanvasWrapper+drawDebugText) * [.drawBall(x, y, elementName)](#CanvasWrapper+drawBall) * [.drawPoint(x, y, elementName)](#CanvasWrapper+drawPoint) * [.drawText(x, y, elementName, hydrogens, direction, isTerminal, charge, isotope, attachedPseudoElement)](#CanvasWrapper+drawText) * [.getChargeText(charge)](#CanvasWrapper+getChargeText) ⇒ <code>String</code> * [.drawDebugPoint(x, y, [debugText], [color])](#CanvasWrapper+drawDebugPoint) * [.drawAromaticityRing(ring)](#CanvasWrapper+drawAromaticityRing) * [.clear()](#CanvasWrapper+clear) <a name="new_CanvasWrapper_new"></a> ### new CanvasWrapper(target, theme, options) The constructor for the class CanvasWrapper. | Param | Type | Description | | --- | --- | --- | | target | <code>String</code> &#124; <code>HTMLElement</code> | The canvas id or the canvas HTMLElement. | | theme | <code>Object</code> | A theme from the smiles drawer options. | | options | <code>Object</code> | The smiles drawer options object. | <a name="CanvasWrapper+updateSize"></a> ### canvasWrapper.updateSize(width, height) Update the width and height of the canvas **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | | --- | --- | | width | <code>Number</code> | | height | <code>Number</code> | <a name="CanvasWrapper+setTheme"></a> ### canvasWrapper.setTheme(theme) Sets a provided theme. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | theme | <code>Object</code> | A theme from the smiles drawer options. | <a name="CanvasWrapper+scale"></a> ### canvasWrapper.scale(vertices) Scale the canvas based on vertex positions. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | vertices | <code>[Array.&lt;Vertex&gt;](#Vertex)</code> | An array of vertices containing the vertices associated with the current molecule. | <a name="CanvasWrapper+reset"></a> ### canvasWrapper.reset() Resets the transform of the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> <a name="CanvasWrapper+getColor"></a> ### canvasWrapper.getColor(key) ⇒ <code>String</code> Returns the hex code of a color associated with a key from the current theme. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> **Returns**: <code>String</code> - A color hex value. | Param | Type | Description | | --- | --- | --- | | key | <code>String</code> | The color key in the theme (e.g. C, N, BACKGROUND, ...). | <a name="CanvasWrapper+drawCircle"></a> ### canvasWrapper.drawCircle(x, y, radius, color, [fill], [debug], [debugText]) Draws a circle to a canvas context. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Default | Description | | --- | --- | --- | --- | | x | <code>Number</code> | | The x coordinate of the circles center. | | y | <code>Number</code> | | The y coordinate of the circles center. | | radius | <code>Number</code> | | The radius of the circle | | color | <code>String</code> | | A hex encoded color. | | [fill] | <code>Boolean</code> | <code>true</code> | Whether to fill or stroke the circle. | | [debug] | <code>Boolean</code> | <code>false</code> | Draw in debug mode. | | [debugText] | <code>String</code> | <code>&#x27;&#x27;</code> | A debug message. | <a name="CanvasWrapper+drawLine"></a> ### canvasWrapper.drawLine(line, [dashed], [alpha]) Draw a line to a canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Default | Description | | --- | --- | --- | --- | | line | <code>[Line](#Line)</code> | | A line. | | [dashed] | <code>Boolean</code> | <code>false</code> | Whether or not the line is dashed. | | [alpha] | <code>Number</code> | <code>1.0</code> | The alpha value of the color. | <a name="CanvasWrapper+drawWedge"></a> ### canvasWrapper.drawWedge(line, width) Draw a wedge on the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Default | Description | | --- | --- | --- | --- | | line | <code>[Line](#Line)</code> | | A line. | | width | <code>Number</code> | <code>1</code> | The wedge width. | <a name="CanvasWrapper+drawDashedWedge"></a> ### canvasWrapper.drawDashedWedge(line) Draw a dashed wedge on the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | line | <code>[Line](#Line)</code> | A line. | <a name="CanvasWrapper+drawDebugText"></a> ### canvasWrapper.drawDebugText(x, y, text) Draws a debug text message at a given position **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | x | <code>Number</code> | The x coordinate. | | y | <code>Number</code> | The y coordinate. | | text | <code>String</code> | The debug text. | <a name="CanvasWrapper+drawBall"></a> ### canvasWrapper.drawBall(x, y, elementName) Draw a ball to the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | x | <code>Number</code> | The x position of the text. | | y | <code>Number</code> | The y position of the text. | | elementName | <code>String</code> | The name of the element (single-letter). | <a name="CanvasWrapper+drawPoint"></a> ### canvasWrapper.drawPoint(x, y, elementName) Draw a point to the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | x | <code>Number</code> | The x position of the point. | | y | <code>Number</code> | The y position of the point. | | elementName | <code>String</code> | The name of the element (single-letter). | <a name="CanvasWrapper+drawText"></a> ### canvasWrapper.drawText(x, y, elementName, hydrogens, direction, isTerminal, charge, isotope, attachedPseudoElement) Draw a text to the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | x | <code>Number</code> | The x position of the text. | | y | <code>Number</code> | The y position of the text. | | elementName | <code>String</code> | The name of the element (single-letter). | | hydrogens | <code>Number</code> | The number of hydrogen atoms. | | direction | <code>String</code> | The direction of the text in relation to the associated vertex. | | isTerminal | <code>Boolean</code> | A boolean indicating whether or not the vertex is terminal. | | charge | <code>Number</code> | The charge of the atom. | | isotope | <code>Number</code> | The isotope number. | | attachedPseudoElement | <code>Object</code> | A map with containing information for pseudo elements or concatinated elements. The key is comprised of the element symbol and the hydrogen count. | | attachedPseudoElement.element | <code>String</code> | The element symbol. | | attachedPseudoElement.count | <code>Number</code> | The number of occurences that match the key. | | attachedPseudoElement.hyrogenCount | <code>Number</code> | The number of hydrogens attached to each atom matching the key. | <a name="CanvasWrapper+getChargeText"></a> ### canvasWrapper.getChargeText(charge) ⇒ <code>String</code> Translate the integer indicating the charge to the appropriate text. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> **Returns**: <code>String</code> - A string representing a charge. | Param | Type | Description | | --- | --- | --- | | charge | <code>Number</code> | The integer indicating the charge. | <a name="CanvasWrapper+drawDebugPoint"></a> ### canvasWrapper.drawDebugPoint(x, y, [debugText], [color]) Draws a dubug dot at a given coordinate and adds text. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Default | Description | | --- | --- | --- | --- | | x | <code>Number</code> | | The x coordinate. | | y | <code>Number</code> | | The y coordindate. | | [debugText] | <code>String</code> | <code>&#x27;&#x27;</code> | A string. | | [color] | <code>String</code> | <code>&#x27;#f00&#x27;</code> | A color in hex form. | <a name="CanvasWrapper+drawAromaticityRing"></a> ### canvasWrapper.drawAromaticityRing(ring) Draws a ring inside a provided ring, indicating aromaticity. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> | Param | Type | Description | | --- | --- | --- | | ring | <code>[Ring](#Ring)</code> | A ring. | <a name="CanvasWrapper+clear"></a> ### canvasWrapper.clear() Clear the canvas. **Kind**: instance method of <code>[CanvasWrapper](#CanvasWrapper)</code> <a name="Drawer"></a> ## Drawer The main class of the application representing the smiles drawer **Kind**: global class **Properties** | Name | Type | Description | | --- | --- | --- | | graph | <code>[Graph](#Graph)</code> | The graph associated with this SmilesDrawer.Drawer instance. | | ringIdCounter | <code>Number</code> | An internal counter to keep track of ring ids. | | ringConnectionIdCounter | <code>Number</code> | An internal counter to keep track of ring connection ids. | | canvasWrapper | <code>[CanvasWrapper](#CanvasWrapper)</code> | The CanvasWrapper associated with this SmilesDrawer.Drawer instance. | | totalOverlapScore | <code>Number</code> | The current internal total overlap score. | | defaultOptions | <code>Object</code> | The default options. | | opts | <code>Object</code> | The merged options. | | theme | <code>Object</code> | The current theme. | * [Drawer](#Drawer) * [new Drawer(options)](#new_Drawer_new) * [.extend()](#Drawer+extend) * [.draw(data, target, themeName, infoOnly)](#Drawer+draw) * [.edgeRingCount(edgeId)](#Drawer+edgeRingCount) ⇒ <code>Number</code> * [.getBridgedRings()](#Drawer+getBridgedRings) ⇒ <code>[Array.&lt;Ring&gt;](#Ring)</code> * [.getFusedRings()](#Drawer+getFusedRings) ⇒ <code>[Array.&lt;Ring&gt;](#Ring)</code> * [.getSpiros()](#Drawer+getSpiros) ⇒ <code>[Array.&lt;Ring&gt;](#Ring)</code> * [.printRingInfo()](#Drawer+printRingInfo) ⇒ <code>String</code> * [.rotateDrawing()](#Drawer+rotateDrawing) * [.getTotalOverlapScore()](#Drawer+getTotalOverlapScore) ⇒ <code>Number</code> * [.getRingCount()](#Drawer+getRingCount) ⇒ <code>Number</code> * [.hasBridgedRing()](#Drawer+hasBridgedRing) ⇒ <code>Boolean</code> * [.getHeavyAtomCount()](#Drawer+getHeavyAtomCount) ⇒ <code>Number</code> * [.getMolecularFormula()](#Drawer+getMolecularFormula) ⇒ <code>String</code> * [.getRingbondType(vertexA, vertexB)](#Drawer+getRingbondType) ⇒ <code>String</code> &#124; <code>null</code> * [.initRings()](#Drawer+initRings) * [.getBridgedRingRings(ringId)](#Drawer+getBridgedRingRings) ⇒ <code>Array.&lt;Number&gt;</code> * [.isPartOfBridgedRing(ringId)](#Drawer+isPartOfBridgedRing) ⇒ <code>Boolean</code> * [.createBridgedRing(ringIds, sourceVertexId)](#Drawer+createBridgedRing) ⇒ <code>[Ring](#Ring)</code> * [.areVerticesInSameRing(vertexA, vertexB)](#Drawer+areVerticesInSameRing) ⇒ <code>Boolean</code> * [.getCommonRings(vertexA, vertexB)](#Drawer+getCommonRings) ⇒ <code>Array.&lt;Number&gt;</code> * [.getLargestOrAromaticCommonRing(vertexA, vertexB)](#Drawer+getLargestOrAromaticCommonRing) ⇒ <code>[Ring](#Ring)</code> &#124; <code>null</code> * [.getVerticesAt(position, radius, excludeVertexId)](#Drawer+getVerticesAt) ⇒ <code>Array.&lt;Number&gt;</code> * [.getClosestVertex(vertex)](#Drawer+getClosestVertex) ⇒ <code>[Vertex](#Vertex)</code> * [.addRing(ring)](#Drawer+addRing) ⇒ <code>Number</code> * [.removeRing(ringId)](#Drawer+removeRing) * [.getRing(ringId)](#Drawer+getRing) ⇒ <code>[Ring](#Ring)</code> * [.addRingConnection(ringConnection)](#Drawer+addRingConnection) ⇒ <code>Number</code> * [.removeRingConnection(ringConnectionId)](#Drawer+removeRingConnection) * [.removeRingConnectionsBetween(vertexIdA, vertexIdB)](#Drawer+removeRingConnectionsBetween) * [.getRingConnection(id)](#Drawer+getRingConnection) ⇒ <code>[RingConnection](#RingConnection)</code> * [.getRingConnections(ringId, ringIds)](#Drawer+getRingConnections) ⇒ <code>Array.&lt;Number&gt;</code> * [.getOverlapScore()](#Drawer+getOverlapScore) ⇒ <code>Object</code> * [.chooseSide(vertexA, vertexB, sides)](#Drawer+chooseSide) ⇒ <code>Object</code> * [.setRingCenter(ring)](#Drawer+setRingCenter) * [.getSubringCenter(ring, vertex)](#Drawer+getSubringCenter) ⇒ <code>[Vector2](#Vector2)</code> * [.drawEdges(debug)](#Drawer+drawEdges) * [.drawEdge(edgeId, debug)](#Drawer+drawEdge) * [.drawVertices(debug)](#Drawer+drawVertices) * [.position()](#Drawer+position) * [.backupRingInformation()](#Drawer+backupRingInformation) * [.restoreRingInformation()](#Drawer+restoreRingInformation) * [.createRing(ring, [center], [startVertex], [previousVertex], [previousVertex])](#Drawer+createRing) * [.rotateSubtree(vertexId, parentVertexId, angle, center)](#Drawer+rotateSubtree) * [.getSubtreeOverlapScore(vertexId, parentVertexId, vertexOverlapScores)](#Drawer+getSubtreeOverlapScore) ⇒ <code>Object</code> * [.getCurrentCenterOfMass()](#Drawer+getCurrentCenterOfMass) ⇒ <code>[Vector2](#Vector2)</code> * [.getCurrentCenterOfMassInNeigbourhood(vec, [r])](#Drawer+getCurrentCenterOfMassInNeigbourhood) ⇒ <code>[Vector2](#Vector2)</code> * [.resolvePrimaryOverlaps()](#Drawer+resolvePrimaryOverlaps) * [.resolveSecondaryOverlaps(scores)](#Drawer+resolveSecondaryOverlaps) * [.getLastVertexWithAngle(vertexId)](#Drawer+getLastVertexWithAngle) ⇒ <code>[Vertex](#Vertex)</code> * [.createNextBond(vertex, [previousVertex], [angle], [originShortest], [skipPositioning])](#Drawer+createNextBond) * [.getCommonRingbondNeighbour(vertex)](#Drawer+getCommonRingbondNeighbour) ⇒ <code>Number</code> &#124; <code>null</code> * [.isPointInRing(vec)](#Drawer+isPointInRing) ⇒ <code>Boolean</code> * [.isEdgeInRing(edge)](#Drawer+isEdgeInRing) ⇒ <code>Boolean</code> * [.isEdgeRotatable(edge)](#Drawer+isEdgeRotatable) ⇒ <code>Boolean</code> * [.isRingAromatic(ring)](#Drawer+isRingAromatic) ⇒ <code>Boolean</code> * [.getEdgeNormals(edge)](#Drawer+getEdgeNormals) ⇒ <code>[Array.&lt;Vector2&gt;](#Vector2)</code> * [.getNonRingNeighbours(vertexId)](#Drawer+getNonRingNeighbours) ⇒ <code>[Array.&lt;Vertex&gt;](#Vertex)</code> * [.annotateStereochemistry()](#Drawer+annotateStereochemistry) * [.visitStereochemistry(vertexId, previousVertexId, visited, priority, maxDepth, depth)](#Drawer+visitStereochemistry) * [.initPseudoElements()](#Drawer+initPseudoElements) <a name="new_Drawer_new"></a> ### new Drawer(options) The constructor for the class SmilesDrawer. | Param | Type | Description | | --- | --- | --- | | options | <code>Object</code> | An object containing custom values for different options. It is merged with the default options. | <a name="Drawer+extend"></a> ### drawer.extend() A helper method to extend the default options with user supplied ones. **Kind**: instance method of <code>[Drawer](#Drawer)</code> <a name="Drawer+draw"></a> ### drawer.draw(data, target, themeName, infoOnly) Draws the parsed smiles data to a canvas element. **Kind**: instance method of <code>[Drawer](#Drawer)</code> | Param | Type | Default | Description | | --- | --- | --- | --- | | data | <code>Object</code> | | The tree returned by the smiles parser. | | target | <code>String</code> &#124; <code>HTMLElement</code> | | The id of the HTML canvas element the structure is drawn to - or the element itself. | | themeName | <code>String</code> | <code>&#x27;dark&#x27;</code> | The name of the theme to use. Built-in themes are 'light' and 'dark'. | | infoOnly | <code>Boolean</code> | <code>false</code> | Only output info on the molecule without drawing anything to the canvas. | <a name="Drawer+edgeRingCount"></a> ### drawer.edgeRingCount(edgeId) ⇒ <code>Number</code> Returns the number of rings this edge is a part of. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Number</code> - The number of rings the provided edge is part of. | Param | Type | Description | | --- | --- | --- | | edgeId | <code>Number</code> | The id of an edge. | <a name="Drawer+getBridgedRings"></a> ### drawer.getBridgedRings() ⇒ <code>[Array.&lt;Ring&gt;](#Ring)</code> Returns an array containing the bridged rings associated with this molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>[Array.&lt;Ring&gt;](#Ring)</code> - An array containing all bridged rings associated with this molecule. <a name="Drawer+getFusedRings"></a> ### drawer.getFusedRings() ⇒ <code>[Array.&lt;Ring&gt;](#Ring)</code> Returns an array containing all fused rings associated with this molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>[Array.&lt;Ring&gt;](#Ring)</code> - An array containing all fused rings associated with this molecule. <a name="Drawer+getSpiros"></a> ### drawer.getSpiros() ⇒ <code>[Array.&lt;Ring&gt;](#Ring)</code> Returns an array containing all spiros associated with this molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>[Array.&lt;Ring&gt;](#Ring)</code> - An array containing all spiros associated with this molecule. <a name="Drawer+printRingInfo"></a> ### drawer.printRingInfo() ⇒ <code>String</code> Returns a string containing a semicolon and new-line separated list of ring properties: Id; Members Count; Neighbours Count; IsSpiro; IsFused; IsBridged; Ring Count (subrings of bridged rings) **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>String</code> - A string as described in the method description. <a name="Drawer+rotateDrawing"></a> ### drawer.rotateDrawing() Rotates the drawing to make the widest dimension horizontal. **Kind**: instance method of <code>[Drawer](#Drawer)</code> <a name="Drawer+getTotalOverlapScore"></a> ### drawer.getTotalOverlapScore() ⇒ <code>Number</code> Returns the total overlap score of the current molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Number</code> - The overlap score. <a name="Drawer+getRingCount"></a> ### drawer.getRingCount() ⇒ <code>Number</code> Returns the ring count of the current molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Number</code> - The ring count. <a name="Drawer+hasBridgedRing"></a> ### drawer.hasBridgedRing() ⇒ <code>Boolean</code> Checks whether or not the current molecule a bridged ring. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not the current molecule a bridged ring. <a name="Drawer+getHeavyAtomCount"></a> ### drawer.getHeavyAtomCount() ⇒ <code>Number</code> Returns the number of heavy atoms (non-hydrogen) in the current molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Number</code> - The heavy atom count. <a name="Drawer+getMolecularFormula"></a> ### drawer.getMolecularFormula() ⇒ <code>String</code> Returns the molecular formula of the loaded molecule as a string. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>String</code> - The molecular formula. <a name="Drawer+getRingbondType"></a> ### drawer.getRingbondType(vertexA, vertexB) ⇒ <code>String</code> &#124; <code>null</code> Returns the type of the ringbond (e.g. '=' for a double bond). The ringbond represents the break in a ring introduced when creating the MST. If the two vertices supplied as arguments are not part of a common ringbond, the method returns null. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>String</code> &#124; <code>null</code> - Returns the ringbond type or null, if the two supplied vertices are not connected by a ringbond. | Param | Type | Description | | --- | --- | --- | | vertexA | <code>[Vertex](#Vertex)</code> | A vertex. | | vertexB | <code>[Vertex](#Vertex)</code> | A vertex. | <a name="Drawer+initRings"></a> ### drawer.initRings() Initializes rings and ringbonds for the current molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> <a name="Drawer+getBridgedRingRings"></a> ### drawer.getBridgedRingRings(ringId) ⇒ <code>Array.&lt;Number&gt;</code> Returns all rings connected by bridged bonds starting from the ring with the supplied ring id. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Array.&lt;Number&gt;</code> - An array containing all ring ids of rings part of a bridged ring system. | Param | Type | Description | | --- | --- | --- | | ringId | <code>Number</code> | A ring id. | <a name="Drawer+isPartOfBridgedRing"></a> ### drawer.isPartOfBridgedRing(ringId) ⇒ <code>Boolean</code> Checks whether or not a ring is part of a bridged ring. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not the supplied ring (by id) is part of a bridged ring system. | Param | Type | Description | | --- | --- | --- | | ringId | <code>Number</code> | A ring id. | <a name="Drawer+createBridgedRing"></a> ### drawer.createBridgedRing(ringIds, sourceVertexId) ⇒ <code>[Ring](#Ring)</code> Creates a bridged ring. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>[Ring](#Ring)</code> - The bridged ring. | Param | Type | Description | | --- | --- | --- | | ringIds | <code>Array.&lt;Number&gt;</code> | An array of ids of rings involved in the bridged ring. | | sourceVertexId | <code>Number</code> | The vertex id to start the bridged ring discovery from. | <a name="Drawer+areVerticesInSameRing"></a> ### drawer.areVerticesInSameRing(vertexA, vertexB) ⇒ <code>Boolean</code> Checks whether or not two vertices are in the same ring. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Boolean</code> - A boolean indicating whether or not the two vertices are in the same ring. | Param | Type | Description | | --- | --- | --- | | vertexA | <code>[Vertex](#Vertex)</code> | A vertex. | | vertexB | <code>[Vertex](#Vertex)</code> | A vertex. | <a name="Drawer+getCommonRings"></a> ### drawer.getCommonRings(vertexA, vertexB) ⇒ <code>Array.&lt;Number&gt;</code> Returns an array of ring ids shared by both vertices. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Array.&lt;Number&gt;</code> - An array of ids of rings shared by the two vertices. | Param | Type | Description | | --- | --- | --- | | vertexA | <code>[Vertex](#Vertex)</code> | A vertex. | | vertexB | <code>[Vertex](#Vertex)</code> | A vertex. | <a name="Drawer+getLargestOrAromaticCommonRing"></a> ### drawer.getLargestOrAromaticCommonRing(vertexA, vertexB) ⇒ <code>[Ring](#Ring)</code> &#124; <code>null</code> Returns the aromatic or largest ring shared by the two vertices. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>[Ring](#Ring)</code> &#124; <code>null</code> - If an aromatic common ring exists, that ring, else the largest (non-aromatic) ring, else null. | Param | Type | Description | | --- | --- | --- | | vertexA | <code>[Vertex](#Vertex)</code> | A vertex. | | vertexB | <code>[Vertex](#Vertex)</code> | A vertex. | <a name="Drawer+getVerticesAt"></a> ### drawer.getVerticesAt(position, radius, excludeVertexId) ⇒ <code>Array.&lt;Number&gt;</code> Returns an array of vertices positioned at a specified location. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Array.&lt;Number&gt;</code> - An array containing vertex ids in a given location. | Param | Type | Description | | --- | --- | --- | | position | <code>[Vector2](#Vector2)</code> | The position to search for vertices. | | radius | <code>Number</code> | The radius within to search. | | excludeVertexId | <code>Number</code> | A vertex id to be excluded from the search results. | <a name="Drawer+getClosestVertex"></a> ### drawer.getClosestVertex(vertex) ⇒ <code>[Vertex](#Vertex)</code> Returns the closest vertex (connected as well as unconnected). **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>[Vertex](#Vertex)</code> - The closest vertex. | Param | Type | Description | | --- | --- | --- | | vertex | <code>[Vertex](#Vertex)</code> | The vertex of which to find the closest other vertex. | <a name="Drawer+addRing"></a> ### drawer.addRing(ring) ⇒ <code>Number</code> Add a ring to this representation of a molecule. **Kind**: instance method of <code>[Drawer](#Drawer)</code> **Returns**: <code>Number</code> - The ring id of the new ring. | Param | Type | Description | | --- | --- | --- | | ring | <code>[Ring](#Ring)</code> | A new ring. | <a name="Drawer+removeRing"></a> ### drawer.removeRing(ringId) Removes a ring from the array of rings associate