Returns: true if HTML5 canvas is supported, false otherwise.
Parameters:
licenseURL
- the URL of the license fileParameters:
source
- molecule source in MDL molfile or null to apply an empty moleculeimageType
- output image data stream MIME type (default value is "image/png").optionalSettings
- JavaScript object that describes display settings.
The object contains key - value pairs.
Key | Type | Values | Default value | Notes |
---|---|---|---|---|
"carbonLabelVisible" | Boolean | {true, false} | false | does not apply in "BALLSTICK" displaymode |
"chiralFlagVisible" | Boolean | {true, false} | true | - |
"valenceErrorVisible" | Boolean | {true, false} | true | - |
"lonePairsVisible" | Boolean | {true, false} | false | show lone pairs if MRV source contains proper info or auto lone pair calculation is enabled |
"lonepaircalculationenabled" | Boolean | {true, false} | false | Set it to true to calculate lone pair on the current structure. |
"circledsign" | Boolean | {true, false} | false | Draw circle around positive and negative sign at charge or not. |
"atomIndicesVisible" | Boolean | {true, false} | false | - |
"atomMapsVisible" | Boolean | {true, false} | true | - |
"cpkColoring" | Boolean | {true, false} | true | - |
"displayMode" | String | {"WIREFRAME", "BALLSTICK", "STICK", "SPACEFILL"} | "WIREFRAME" | - |
"implicitHydrogen" | String | {"ALL", "OFF", "HETERO", "TERMINAL_AND_HETERO"} | "TERMINAL_AND_HETERO" | If "carbonLabelVisible" value is true, "HETERO" and "TERMINAL_AND_HETERO" values will be considered as "ALL". |
"backgroundColor" | String | css color | - | do not set this to leave it transparent (png) or white |
"zoomMode" | String | {"fit", "autoshrink"} | "fit" | "fit" will expand every molecule to the given size, "autoshrink" scales down large molecules only. |
"width" | Number | positive integer | 200 | - |
"height" | Number | positive integer | 200 | - |
{ 'carbonLabelVisible' : false, 'atomMapsVisible' : true, 'chiralFlagVisible' : true, 'valenceErrorVisible' : true, 'lonePairsVisible' : false, 'implicitHydrogen' : "TERMINAL_AND_HETERO", 'displayMode' : "WIREFRAME", 'backgroundColor' : "#ff00ff", 'width' : 300, 'height' : 350 }
Returns: image stream encoded as an image data URL if image width/height is greater than zero
Parameters:
source
- molecule source in MRV or null to apply an empty moleculeimagType
- output image data stream MIME type (default value is "image/png").optionalSettings
- JavaScript object that describes display settings.
The object contains key - value pairs.
Key | Type | Values | Default value | Notes |
---|---|---|---|---|
"carbonLabelVisible" | Boolean | {true, false} | false | does not apply in "BALLSTICK" displaymode |
"chiralFlagVisible" | Boolean | {true, false} | true | - |
"valenceErrorVisible" | Boolean | {true, false} | true | - |
"lonePairsVisible" | Boolean | {true, false} | false | show lone pairs if MRV source contains proper info or auto lone pair calculation is enabled |
"lonepaircalculationenabled" | Boolean | {true, false} | false | Set it to true to calculate lone pair on the current structure. |
"circledsign" | Boolean | {true, false} | false | Draw circle around positive and negative sign at charge or not. |
"atomIndicesVisible" | Boolean | {true, false} | false | - |
"atomMapsVisible" | Boolean | {true, false} | true | - |
"cpkColoring" | Boolean | {true, false} | true | - |
"displayMode" | String | {"WIREFRAME", "BALLSTICK", "STICK", "SPACEFILL"} | "WIREFRAME" | - |
"implicitHydrogen" | String | {"ALL", "OFF", "HETERO", "TERMINAL_AND_HETERO"} | "TERMINAL_AND_HETERO" | If "carbonLabelVisible" value is true, "HETERO" and "TERMINAL_AND_HETERO" values will be considered as "ALL". |
"backgroundColor" | String | css color | - | do not set this to leave it transparent (png) or white |
"zoomMode" | String | {"fit", "autoshrink"} | "fit" | "fit" will expand every molecule to the given size, "autoshrink" scales down large molecules only. |
"width" | Number | positive integer | 200 | - |
"height" | Number | positive integer | 200 | - |
{ "carbonLabelVisible" : false, "atomMapsVisible" : true, "chiralFlagVisible" : true, "valenceErrorVisible" : true, "lonePairsVisible" : false, "implicitHydrogen" : "TERMINAL_AND_HETERO", "displayMode" : "WIREFRAME", "backgroundColor" : "#ff00ff", "zoomMode" : autoshrink, "width" : 300, "height" : 350 }
Returns: image stream encoded as an image data URL if image width/height is greater than zero
Constructor with predefine parameters for the rendering.
Parameters:
params
- parameters enclosed into a JavaScript Objects.
imageType | the format of the generated image (image/png , image/jpeg , image/svg ) | "image/png" |
settings | display settings. Applies the same values than marvin.ImageExporter.mrvToDataUrl(String,String,JavaScriptObject). | { width: 200, height: 200 } |
inputFormat | predefine the format of the molecule source to be converted (or null to auto recognize) (If webservices are not specified, only "mol" and "mrv" are accepted, if it presents any format are accepted that molconverter service supports.) | null |
services | Optinally, you can specify webservice settings to inject molconverter and stereo calculation functionality. See marvin.Sketch.setServices(JavaScriptObject). | null |
Constructor with default parameters.
Parameters:
source
- the source of the molecule to render (the input format is determined by the creation of the ImageExporter instance).Returns: a Promise object
Creates a new editor widget and inserts it into the body of the current page.
Creates a new editor widget and inserts it into the specified DOM element.
Parameters:
id
- the ID of the DOM element whose child will be the editor widget.config
- initial parameters.Returns: map of display setting is wrapped into a JavaScript object.
Key | Type | Values | Default value | Notes |
---|---|---|---|---|
"carbonLabelVisible" | Boolean | {true, false} | false | does not apply in "BALLSTICK" displaymode |
"chiralFlagVisible" | Boolean | {true, false} | true | - |
"atomIndicesVisible" | Boolean | {true, false} | false | - |
"atomMapsVisible" | Boolean | {true, false} | true | - |
"cpkColoring" | Boolean | {true, false} | true | - |
"valenceErrorVisible" | Boolean | {true, false} | true | - |
"lonePairsVisible" | Boolean | {true, false} | false | - |
"displayMode" | String | {"WIREFRAME", "BALLSTICK", "STICK", "SPACEFILL"} | "WIREFRAME" | - |
"implicitHydrogen" | String | {"ALL", "OFF", "HETERO", "TERMINAL_AND_HETERO"} | "TERMINAL_AND_HETERO" | If "carbonLabelVisible" value is true, "HETERO" and "TERMINAL_AND_HETERO" values will be considered as "ALL". |
"backgroundColor" | String | css color | - | custom non-transparent color |
"circledsign" | Boolean | {true, false} | false | Draw circle around positive and negative sign at charge or not. |
{ "carbonLabelVisible" : false, "atomIndicesVisible" : false, "atomMapsVisible" : true, "chiralFlagVisible" : true, "valenceErrorVisible" : true, "lonePairsVisible" : false, "cpkColoring" : true, "implicitHydrogen" : "TERMINAL_AND_HETERO", "displayMode" : "WIREFRAME", "backgroundColor" : "#ffffff" }
Parameters:
jso
- map of display setting is wrapped into a JavaScript object.
Key | Type | Values | Default value | Notes |
---|---|---|---|---|
"carbonLabelVisible" | Boolean | {true, false} | false | does not apply in "BALLSTICK" displaymode |
"chiralFlagVisible" | Boolean | {true, false} | true | - |
"atomIndicesVisible" | Boolean | {true, false} | false | - |
"atomMapsVisible" | Boolean | {true, false} | true | - |
"cpkColoring" | Boolean | {true, false} | true | - |
"valenceErrorVisible" | Boolean | {true, false} | true | - |
"lonePairsVisible" | Boolean | {true, false} | false | - |
"displayMode" | String | {"WIREFRAME", "BALLSTICK", "STICK", "SPACEFILL"} | "WIREFRAME" | - |
"implicitHydrogen" | String | {"ALL", "OFF", "HETERO", "TERMINAL_AND_HETERO"} | "TERMINAL_AND_HETERO" | If "carbonLabelVisible" value is true, "HETERO" and "TERMINAL_AND_HETERO" values will be considered as "ALL". |
"backgroundColor" | String | css color | - | - |
"defaultTool" | String | {"rectangleSelection", "lassoSelection"} | "rectangleSelection" | set default tool |
"toolbars" | String | {"standard", "education", "reaction", "markush", "search", "basicSearch", "reporting"} | "standard" | to render toolbars by the given predefined layout |
"copyasmrv" | Boolean | {true, false} | false | To prefer MRV instead of MDL molfile format at copy |
"lonepaircalculationenabled" | Boolean | {true, false} | true | Enable automatic lone pair calculation |
"circledsign" | Boolean | {true, false} | false | Draw circle around positive and negative sign at charge or not. |
{ "carbonLabelVisible" : false, "atomIndicesVisible" : false, "atomMapsVisible" : true, "chiralFlagVisible" : true, "valenceErrorVisible" : true, "lonePairsVisible" : false, "cpkColoring" : true, "implicitHydrogen" : "TERMINAL_AND_HETERO", "displayMode" : "WIREFRAME", "backgroundColor" : "#ffffff", "defaultTool" : "lassoSelection", "toolbars": "standard" }
Returns: True if nothing on the canvas, else false.
Parameters:
format
- the input format getSupportedFormats() or null to recognize the format automatically.source
- the molecule sourceReturns: the Promise object
Returns: the JavaScript object.
webservices.js
for the list of supported services.Parameters:
jso
- map of services wrapped into a JavaScript object
{ "clean2dws" : <url of Clean2D webservice> "molconvertws" : <url of MolConvert webservice> "stereoinfows" : <url of CIP Stereo Info webservice> "reactionconvertws" : <url of Reaction converter webservice> "hydrogenizews" : <url of hydrogenize webservice> "automapperws" : <url of auto mapper webservice> }
Parameters:
jso
- attributes of button is wrapped into a JavaScript object. E.g.:
{ "name": "customButton", // JS String "image-url": "images/custom-button.png" // JS String "toolbar": "W" // JS String: "W" as West, "E" as East, "N" as North, "S" as South toolbar }
Parameters:
jso
- a JavaScript object that describes the template. It has to contains the following properties:
Name | Type | Description |
---|---|---|
structure | String | MRV source of the template structure |
name | String | title of the template button (optional, auto generated) |
icon | String | 24x24 pixel size icon for the button as base64 encoded data image (optional, auto generated) |
{ "structure": "<cml><MDocument><MChemicalStruct><molecule molID=\"m1\"><atomArray><atom id=\"a1\" elementType=\"C\" x2=\"-12.5625\" y2=\"6.539048685882614\"/><atom id=\"a2\" elementType=\"C\" x2=\"-13.808366329017026\" y2=\"5.633832087370612\"/><atom id=\"a3\" elementType=\"C\" x2=\"-13.332503911629807\" y2=\"4.169284647450719\"/><atom id=\"a4\" elementType=\"C\" x2=\"-11.792496088370193\" y2=\"4.169284647450719\"/><atom id=\"a5\" elementType=\"C\" x2=\"-11.316633670982972\" y2=\"5.633832087370612\"/></atomArray><bondArray><bond atomRefs2=\"a1 a2\" order=\"1\"/><bond atomRefs2=\"a1 a5\" order=\"1\"/><bond atomRefs2=\"a2 a3\" order=\"1\"/><bond atomRefs2=\"a3 a4\" order=\"1\"/><bond atomRefs2=\"a4 a5\" order=\"1\"/></bondArray></molecule></MChemicalStruct></MDocument></cml>", "name": "CycloPentane", "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABBElEQVRIie3UK08DQRiF4UdW1q4CfgISW7kSRYIrihBEJQkKi0OiCKJQSVAEtRJD0CgkqYGAIhjEzCYFlr1Mi+ubfMlezpyZPd/ssGTBHOPwP4z7uME9HnCNbFHmG3jCSbzv4TQ+G8xrfoBX5BXvcjziKMV4DQXu4nWT7rZB940tTDFqqe9F7RTbTeJLIdv1tquZYRDHXtSt5B0rCeYlq3iLXpWcYW+OCXajx5/kQtNSKTRs3Z7QrH6CeYZnNfGUTKTF1BhPyaZwLHSlUP1D/iIlpgwfWsRTMsFOhwmGuOqg7xxTIfSgNX28YF/4kp81nKkRPiXsvHOMhZ1RV2M1x8OSRr4A1pQ2FuhcylgAAAAASUVORK5CYII=" }
Returns: JavaScript object with indices of selected atoms and bonds. E.g.:
{ "atoms" : "1,2,3", "bonds" : "1-2,2-3" }
Parameters:
selection
- JavaScript object that describes atoms and bonds to select. E.g.:
{ "atoms" : "1,2,3", "bonds" : "1-2,2-3" }
Parameters:
jsoArray
- array of JavaScriptObject that describes highlight in the following format:
{ // give uids or indexes field (depend on how you would like to specify atoms/bonds to highlight) uids: { // string array with UIDs of atom atoms: [], // string array with UIDs of bond bonds: [] }, indexes: { // string array of indeces of atom atoms: [], // string array of pair of atom indeces to describe bond bonds: [] }, style: { // CSS color (rgb, rgba, hsl, hsla, hexa or web-safe color name) color: <string>, // value between 0.0 and 1.0 (default value is 1.0), if color has alpha value (rgb, rgba) this field is ignored. opacity: <number> // size of the patch that is relative to the selection patch, 1.0 means the same patch than the selection. size: <double> } }In the following example, there are two definitions, at the first one atoms and bonds are specified by UIDs, at the second atom indeces are used. In the first case, color contains alpha value, so the opacity property is needless in this case. At the second case, the pink color is defined and specified the desired opacity explicitly.
sketch.setHighlight( [ { uids: { atoms: ["e2ff0039baee12e2", "be3f1024c1f5e3f1"], bonds: ["3e1a21c74df9ae81"] }, style: { color: "rgba(20,230,50, 0.5)", size: 0.8 } }, { indexes: { atoms: ["1","2","3"], bonds: ["1-2","1-3"] }, style: { color: "pink", opacity: 0.6, size: 0.8 } } ] );
Parameters:
type
- the event type ("molchange" or "selectionchange")callback
- this function is performed after the specified event is invoked.Parameters:
type
- the event type (accept same types as on(String,function()))callback
- the reference of a previously attached event handler function to remove or null
to remove all event handlers for the specified event.Parameters:
format
- the output molecule format getSupportedFormats().options
- a JavaScript object that describes further options for export (optional).
hasUID
property. If it is true, export atom/bond UIDs as atom/bond properties (_mjs::uid
). Its default value is false.Returns: the Promise object
Parameters:
format
- the input format getSupportedFormats() or null to recognize the format automatically.source
- the molecule sourceReturns: the Promise object