API
Hierarchy
- package ChemDoodle
- package extensions
- package featureDetection
- package iChemLabs
- package informatics
- class BondDeducer
- class HydrogenDeducer
- class Splitter
- class StructureBuilder
- class _Counter
- class FrerejacqueNumberCounter
- class NumberOfMoleculesCounter
- class _RingFinder
- class SSSRFinder
- class EulerFacetFinder
- package io
- package file
- package png
- class JCAMPInterpreter
- class MOLInterpreter
- class XYZInterpreter
- class PDBInterpreter
- class CIFInterpreter
- package math
- package monitor
- package structures
- class _Canvas
- class ViewerCanvas
- class HyperlinkCanvas
- class TransformCanvas
- class MolGrabberCanvas
- class FileCanvas
- class _AnimatorCanvas
- class RotatorCanvas
- class SlideshowCanvas
- class _Canvas3D
- class ViewerCanvas3D
- class TransformCanvas3D
- class MolGrabberCanvas3D
- class RotatorCanvas3D
- class MovieCanvas3D
- class _SpectrumCanvas
- class ObserverCanvas
- class OverlayCanvas
- class PerspectiveCanvas
- class SeekerCanvas
- class PeriodicTableCanvas
- class _Layout
- class SimpleReactionLayout
Documentation
ChemDoodle
this package is the root for all contents of the ChemDoodle Web Components library. It contains access to all packages, canvases and layouts as well as shortcut functions for common tasks.
- static Array ELEMENT: a hashmap for elemental data where the element’s symbol is the key and the corresponding Element data structure is the value
- static Array RESIDUE: a hashmap for residue data where the residue’s symbol is the key and the corresponding Residue data structure is the value
- static Array SYMBOLS: a numbered Array containing all element symbols, where the index is the element’s atomic number – 1 (index starts at 0 for hydrogen)
- static Function getVersion(): returns the version of the ChemDoodle Web Components library; changing this value in source is not recommended
- static Function readCIF(String content, Number xSuper, Number ySuper, Number zSuper): shortcut method to read a CIF file and return the corresponding Molecule without instantiating a CIFInterpreter; the three optional integers specify the supercell dimensions, by default they are all 1, so reading a file without specifying these parameters will produce just the unit cell. In addition to reading atoms from CIF files, this interpreter will also produce a unit cell and other objects relevant to the display of periodic information
returns Molecule - static Function readJCAMP(String content): shortcut method to read a IUPAC JCAMP-DX file and return the corresponding Spectrum without instantiating a JCAMPInterpreter; this shortcut method will automatically convert HZ to PPM
returns Spectrum - static Function readMOL(String content, Number multiplier): shortcut method to read a MDL MOLFile and return the corresponding Molecule without instantiating a MOLInterpreter; the optional multiplier variable will override the default_anstromsPerBondLength variable, set it to 1 for 3D scenes in Ängstroms
returns Molecule - static Function readPDB(String content, Number multiplier): shortcut method to read a RCSB PDB file and return the corresponding Molecule without instantiating a PDBInterpreter; the optional multiplier variable will override the default_anstromsPerBondLength variable, set it to 1 for 3D scenes in Ängstroms. In addition to reading atoms from PDB files, this interpreter will also read residue data and generate ribbons and cartoons for that data
returns Molecule - static Function readXYZ(String content): shortcut method to read a XYZ file and return the corresponding Molecule without instantiating a XYZInterpreter
returns Molecule - static Function writeMOL(Molecule mol): shortcut method to write an MDL MOLFile given an input Molecule without instantiating a MOLInterpreter
returns String
ChemDoodle._Canvas
is the parent class for all ChemDoodle Web Component Canvases, it should not be instantiated. Its basic functionality allows for molecules to be drawn and loaded. This class also hosts the system for handling user input events from the mouse and the keyboard. This class should be extended for custom canvases.
constructor = new Function _Canvas()
- String id: the HTML id of the associated HTML element
- Integer width: the width the associated HTML element
- Integer height: the height of the associated HTML element
- VisualSpecifications specs: the visual specifications that define how content should be painted
- Molecule molecule: the molecule associated with this canvas
- String emptyMessage: the message to be displayed if the molecule is null. If this variable is null, no message is displayed if the molecule is null
- Image image: the background image, overrides the VisualSpecification backgroundColor property; if null, no image is drawn
- Boolean inGesture: keeps track of mobile gestures and is true if there is currently a mobile gesture being executed through this Canvas
- Function center(): centers the loaded molecule in the canvas
- Function create(String id, Integer width, Integer height): this function places the canvas in the HTML page and is called in every constructor of the children classes. The id is the HTML id of the canvas element, with width and height its dimensions
- Function getMolecule(): returns the Molecule currently associated with the canvas
returns Molecule - Function loadMolecule(Molecule mol): loads the given Molecule, mol, and checks it
- Function prehandleEvent(Event e): conditions the user input event and sets a new variable in the Event object named p that contains the coordinates of the event in the canvas
- Function repaint(): repaints the canvas
- Function resize(Integer width, Integer height): resizes the canvas to the input width and height parameters, this is done efficiently and is the prefered way to resize Canvas objects; this function will automatically recenter content and perform the necessary functions to update rendering
- Function setBackgroundImage(String url): sets the background image to the image specified by the url parameter
- optional abstract Function afterLoadMolecule(): additional function to be called after the Molecule is loaded
- optional abstract Function drawChildExtras(Context ctx): draws extra graphics on top of the base graphics, override this for your custom canvases
- optional abstract Function subCreate(): additional function to be called during create(), such that child classes can do additional setup before returning to the child constructor
- //Mobile Touch Events and Gestures
- optional abstract Function dbltap(Event e): receives the double tap event for mobile devices, override this for your custom canvases, forwards to dblclick if not implemented, if neither dbltap or dblclick are implemented, then the event is forwarded to touchstart or mousedown
- optional abstract Function gesturechange(Event e): receives the gesture move event for mobile devices, override this for your custom canvases
- optional abstract Function gestureend(Event e): receives the touch end event for mobile devices, override this for your custom canvases
- optional abstract Function gesturestart(Event e): receives the gesture start event for mobile devices, override this for your custom canvases
- optional abstract Function multitouchmove(Event e, Number numFingers): receives an event for mobile devices where multiple fingers are moving on the screen, override this for your custom canvases, the center of the fingers is provided in the Event, the number of fingers touching the screen is also sent to the handler
- optional abstract Function tap(Event e): receives the tap event for mobile devices (quickly touchstart then touchend), override this for your custom canvases, forwards to click if not implemented
- optional abstract Function touchend(Event e): receives the touch end event for mobile devices, override this for your custom canvases, forwards to mouseup if not implemented
- optional abstract Function touchhold(Event e): receives the touch hold event for mobile devices, override this for your custom canvases; will fire if the user touches down and does not lift or move for 1 second
- optional abstract Function touchmove(Event e): receives the touch move event for mobile devices, override this for your custom canvases, forwards to drag if not implemented
- optional abstract Function touchstart(Event e): receives the touch start event for mobile devices, override this for your custom canvases, forwards to mousedown if not implemented
- //Mouse Events
- optional abstract Function click(Event e): receives the mouse click event, override this for your custom canvases
- optional abstract Function dblclick(Event e): receives the mouse double click event, override this for your custom canvases
- optional abstract Function drag(Event e): receives the mouse drag event, override this for your custom canvases
- optional abstract Function middleclick(Event e): receives the mouse middle click event, override this for your custom canvases
- optional abstract Function middlemousedown(Event e): receives the mouse middle mouse down event, override this for your custom canvases
- optional abstract Function middlemouseup(Event e): receives the mouse middle mouse up event, override this for your custom canvases
- optional abstract Function mousedown(Event e): receives the mouse down event, override this for your custom canvases
- optional abstract Function mousemove(Event e): receives the mouse move event, override this for your custom canvases
- optional abstract Function mouseout(Event e): receives the mouse out event, override this for your custom canvases
- optional abstract Function mouseover(Event e): receives the mouse over event, override this for your custom canvases
- optional abstract Function mouseup(Event e): receives the mouse up event, override this for your custom canvases
- optional abstract Function mousewheel(Event e, Number delta): receives the mouse wheel event, override this for your custom canvases; delta is the amount the wheel has spun
- optional abstract Function rightclick(Event e): receives the mouse right click event, override this for your custom canvases
- optional abstract Function rightmousedown(Event e): receives the mouse right mouse down event, override this for your custom canvases
- optional abstract Function rightmouseup(Event e): receives the mouse right mouse up event, override this for your custom canvases
- //Keyboard Events
- optional abstract Function keydown(Event e): receives the key down event, override this for your custom canvases
- optional abstract Function keypress(Event e): receives the key press event, override this for your custom canvases
- optional abstract Function keyup(Event e): receives the key up event, override this for your custom canvases
ChemDoodle.ViewerCanvas
is a child of the Canvas class and provides a basic canvas for simply displaying a static styled structural drawing
constructor = new Function ViewerCanvas(String id, Integer width, Integer height)
prototype = _Canvas
ChemDoodle.HyperlinkCanvas
is a child of the Canvas class and provides a basic button-like canvas: it responds to mouse overs and executes a link or action when clicked on
constructor = new Function HyperlinkCanvas(String id, Integer width, Integer height, String urlOrFunction)
prototype = _Canvas
- String urlOrFunction: this is the url to be directed to when clicked, this can also be a function object and the function will be executed when clicked
- String color: the color of the mouse over highlight
Default Value: blue
Unit: color - Number size: the width of the mouse over highlight
Default Value: 2
Unit: pixels - Boolean openInNewWindow: if true and urlOrFunction is a url, then the url will be opened in a new window instead of changing the current page
Default Value: false
Unit: true/false - Image hoverImage: if this is initialized, then the mouse over will display an image instead of a hyperlink-like decoration
- Event e: keeps track of the last event
- Function setHoverImage(String url): sets the canvas’s hover image to the image url specified
- override Function click(Event e): performs the mouse click action
- override Function drawChildExtras(Context ctx): draws extra graphics on top of the base graphics
- override Function mouseout(Event e): performs the mouse out action
- override Function mouseover(Event e): performs the mouse over action, currently not called
ChemDoodle.TransformCanvas
is a child of the Canvas class and provides a basic canvas for users to transform (translate [alt+drag], rotate [drag], scale [mousewheel]) molecules with
constructor = new Function TransformCanvas(String id, Integer width, Integer height)
prototype = _Canvas
- Point lastPoint: keeps track of the last mouse position
- Boolean rotate3D: will rotate in 3 dimensions if true, will only rotate around the z axis if false
Default Value: false - Number rotationMultMod: multiplication modifier for the rotation calculations, larger numbers correspond to faster rotations
Default Value: 1.3 - Number lastPinchScale: keeps track of the last pinch scale from a mobile gesture
- Number lastGestureRotate: keeps track of the last rotation magnitude from a mobile gesture
- override Function dblclick(Event e): performs the double-click action, which centers the molecule
- override Function drag(Event e): performs the mouse drag action
- override Function gesturechange(Event e): handles any pinch and rotate gestures from mobile devices which will scale and rotate the molecule
- override Function gestureend(Event e): resets the gesture tracking variables and ends the gesture
- override Function mousedown(Event e): performs the mouse down action
- override Function mousewheel(Event e, Number delta): performs the mouse wheel action
ChemDoodle.MolGrabberCanvas
is a child of the Canvas class and provides a basic canvas for users to search databases with.
constructor = new Function MolGrabberCanvas(String id, Integer width, Integer height)
prototype = _Canvas
- Function search(): uses iChemLabs cloud services to contact the database with query term as defined in the form and then updates the Canvas after receiving the molecule data
- Function setSearchTerm(String term): automatically searches for and loads the input search term
ChemDoodle.FileCanvas
is a child of the Canvas class and provides a basic canvas for users to load molecule from their computer with. The action is the server side script to be called that loads the file into a hidden frame. After the asynchronous call is finished, the correct function is called to load the molecule into the canvas with the associated id
constructor = new Function FileCanvas(String id, Integer width, Integer height, String String, String urlOrFunction, String color, Number size)
prototype = _Canvas
ChemDoodle._AnimatorCanvas
is a child of the Canvas class and is the parent class for all animated ChemDoodle Web Component Canvases, it should not be instantiated. It provides an extendable framework for creating animations. This class should be extended for custom animated canvases.
constructor = new Function _AnimatorCanvas()
prototype = _Canvas
- Timer handle: a handle on the current Timer so it can be started and stopped
- Number timeout: the default refresh rate
Default Value: 33 (~30fps)
Unit: ms - Number lastTime: keeps track of the last time the nextFrame() function was called
- Function isRunning(): returns true if the animation is currently running
returns Boolean
Unit: true/false - Function startAnimation(): initializes the animation
- Function stopAnimation(): terminates the animation
- abstract Function nextFrame(Number delta): called by the timer, in the frequency specified by the interval timeout, this must be overridden for your custom canvases, repaints the canvas after each call; this class keeps track of the time between calls and passes that value to this function for accurate animations
ChemDoodle.RotatorCanvas
is a child of the AnimatorCanvas class and provides a basic canvas for displaying molecular rotation animations
constructor = new Function RotatorCanvas(String id, Integer width, Integer height, String String, Boolean rotate3D)
- Boolean rotate3D: the animation will rotate in 3 dimensions if true, will only rotate around the z axis if false
Default Value: false - Number xIncrement: the x rotation increment
Default Value: Math.PI/15
Unit: radians/sec - Number yIncrement: the y rotation increment
Default Value: Math.PI/15
Unit: radians/sec - Number zIncrement: the z rotation increment
Default Value: Math.PI/15
Unit: radians/sec - override Function dblclick(Event e): catches double click events and toggles the animation
- override Function nextFrame(Number delta): updates the state during the rotation animation
ChemDoodle.SlideshowCanvas
is a child of the AnimatorCanvas class and provides a basic canvas for displaying transitions between several molecular structures
constructor = new Function SlideshowCanvas(String id, Integer width, Integer height)
- Array molecules: the molecular structures to be displayed in the order they are to be displayed in, this should not be empty
- Integer curIndex: keeps track of the current index in molecules
- Number timeout: this parameter is inherited from AnimatorCanvas, but it is set to a larger value
Default Value: 5000
Unit: ms - Number alpha: keeps track of the current alpha during the transition
- Timer innerHandle: holds on to the second inner Timer for performing the transition, so it can be started and stopped
- Integer phase: keeps track of the current phase (different types of animations) during the transition
- Function addMolecule(Molecule molecule): adds a molecule to the slideshow
- Function breakInnerHandle(): completes the second phase of the animation and the molecule switch
- override Function drawChildExtras(Context ctx): draws extra graphics on top of the base graphics
- override Function nextFrame(Number delta): updates the state during the rotation
ChemDoodle._Canvas3D
is the parent class for all 3D ChemDoodle Web Component Canvases, it should not be instantiated. Its basic functionality allows for molecules to be rendered in a 3D scene and loaded. This class should be extended for custom 3D canvases.
constructor = new Function _Canvas3D()
prototype = _Canvas
- mat4 rotationMatrix: the rotation matrix to be applied before rendering the 3D scene
Default Value: mat4.identity([])
Unit: 4×4 matrix - mat4 translationMatrix: the translation matrix to be applied before rendering the 3D scene
Default Value: mat4.identity([])
Unit: 4×4 matrix - Point lastPoint: the last point in the canvas’s space that the user initiated a mouseDown event
- Number maxDimension: keeps track of the max dimension to aid in determining the magnitude of scaling
- Function displayMessage(): controls what the Canvas3D displays if WebGL is unavailable
- Function setViewDistance(Number distance): helper method to move the camera the input distance away from the center of the scene; distance is in Angstroms
- Function setupScene(): creates the 3D scene
- override Function afterLoadMolecule(): helper method to reset the scene if a gl parameter has been altered
- override Function center(): centers the molecule in 3D around the origin
- override Function drag(Event e): performs the mouse drag action
- override Function mousedown(Event e): performs the mouse down action
- override Function mousewheel(Event e): performs the mouse scroll action
- override Function repaint(): renders the 3D scene
- override Function rightmousedown(Event e): performs the mouse right click action
- override Function subCreate(): sets up GLContext, alerts viewer to warning if GLContext cannot be created; initializes shaders and scene
ChemDoodle.ViewerCanvas3D
is a child of the Canvas3D class and provides a basic canvas for simply displaying a static 3D scene of a molecule
constructor = new Function ViewerCanvas3D(String id, Integer width, Integer height)
prototype = _Canvas
- override Function drag(): set to null to ignore this gesture
- override Function mousedown(): set to null to ignore this gesture
- override Function mousewheel(): set to null to ignore this gesture
- override Function rightmousedown(): set to null to ignore this gesture
ChemDoodle.TransformCanvas3D
is a child of the Canvas3D class and provides a basic canvas for users to transform (translate [alt+drag], rotate [drag], scale [mousewheel]) molecules with in a 3D scene
constructor = new Function TransformCanvas3D(String id, Integer width, Integer height)
prototype = _Canvas
ChemDoodle.MolGrabberCanvas3D
is a child of the Canvas3D class and provides a basic 3D canvas for users to search databases with. The content may then be transformed just as in the Transformer3D canvas.
constructor = new Function MolGrabberCanvas3D(String id, Integer width, Integer height)
- Function search(): uses iChemLabs cloud services to contact the database with query term as defined in the form and then updates the Canvas3D after receiving the molecule data
- Function setSearchTerm(String term): automatically searches for and loads the input search term
ChemDoodle.RotatorCanvas3D
is a child of the Canvas3D class and provides a basic canvas for displaying molecular rotation animations in a 3D scene, also doubly inherits methods from the AnimatorCanvas class
constructor = new Function RotatorCanvas3D(String id, Integer width, Integer height)
- Timer handle: a handle on the current Timer so it can be started and stopped
- Number timeout: the default refresh rate
Default Value: 33 (~30fps)
Unit: ms - Number xIncrement: the x rotation increment
Default Value: Math.PI/15
Unit: radians/sec - Number yIncrement: the y rotation increment
Default Value: Math.PI/15
Unit: radians/sec - Number zIncrement: the z rotation increment
Default Value: Math.PI/15
Unit: radians/sec - Function isRunning(): returns true if the animation is currently running
returns Boolean
Unit: true/false - Function startAnimation(): initializes the animation
- Function stopAnimation(): terminates the animation
- override Function dblclick(Event e): catches double click events and toggles the animation
- override Function drag(): set to null to ignore this gesture
- override Function mousedown(): set to null to ignore this gesture
- override Function mousewheel(): set to null to ignore this gesture
- override Function nextFrame(Number delta): updates the state during the rotation animation
- override Function rightmousedown(): set to null to ignore this gesture
ChemDoodle.MovieCanvas3D
is a child of the Canvas3D class and provides a basic canvas for displaying movies of molecules in a 3D scene, also doubly inherits methods from the AnimatorCanvas class
constructor = new Function MovieCanvas3D(String id, Integer width, Integer height)
- static Number PLAY_ONCE: specifies that movie will play once to the end and stop
- static Number PLAY_LOOP: specifies that movie will play continuously, restarting from the first frame once it reaches the end
- static Number PLAY_SPRING: specifies that movie will play continuously, springing back and forth between the first and last frames
- Array molecules: the molecular structures, with each entry representing a frame to be displayed in the order they are to be displayed in, this should not be empty; you should fill this array before the _Canvas.loadMolecule() function is called so all the data is properly setup
- Timer handle: a handle on the current Timer so it can be started and stopped
- Number timeout: the default refresh rate
Default Value: 50 (~20fps)
Unit: ms - Number playMode: set to specify how the movie playback will proceed
Default Value: PLAY_SPRING
Unit: MovieCanvas3D.PLAY_* - Boolean reverse: used internally to allow the spring playback method to function
- Number frameNumber: keeps track of the next frame number
- Function isRunning(): returns true if the animation is currently running
returns Boolean
Unit: true/false - Function startAnimation(): initializes the animation
- Function stopAnimation(): terminates the animation
- override Function center(): centers all of the frames in the molecules array
- override Function dblclick(Event e): catches double click events and toggles the animation
- override Function nextFrame(Number delta): updates the state during the rotation animation
ChemDoodle._SpectrumCanvas
is a child of the Canvas class and is the parent class for all Spectrum ChemDoodle Web Component Canvases, it should not be instantiated. This canvas is specifically suited for displaying graphics of spectra.
constructor = new Function _SpectrumCanvas()
prototype = _Canvas
- Spectrum spectrum: the Spectrum data structure that this Canvas displays
- Function getSpectrum(): returns the Spectrum belonging to this SpectrumCanvas
returns Spectrum - Function loadSpectrum(): loads the spectrum and then repaints
- override Function repaint(): paints the spectrum
ChemDoodle.ObserverCanvas
is a child of the SpectrumCanvas class and provides a basic canvas for simply displaying a static styled spectrum drawing
constructor = new Function ObserverCanvas(String id, Integer width, Integer height)
prototype = _SpectrumCanvas
ChemDoodle.OverlayCanvas
is a child of the SpectrumCanvas class and provides an basic canvas for viewing several spectra superimposed over each other
constructor = new Function OverlayCanvas(String id, Integer width, Integer height)
prototype = _SpectrumCanvas
- Array overlaySpectra: the additional spectra to be overlaid on the main spectrum
Default Value: Array - Function addSpectrum(Spectrum spectrum): adds a spectrum to the canvas; it is recommended that this function is used over directly populating the overlaySpectra array, as this function will first set the main spectrum if it isn’t set
- override Function innerRepaint(Context ctx): draws extra graphics on top of the base graphics
ChemDoodle.PerspectiveCanvas
is a child of the SpectrumCanvas class and provides an interactive canvas for zooming in on peaks in spectra
constructor = new Function PerspectiveCanvas(String id, Integer width, Integer height)
prototype = _SpectrumCanvas
- Point dragRange: keeps track of the x-coordinates for the start and end of the drag event
- Boolean rescaleYAxisOnZoom: determines whether the y-axis will rescale upon a zoom
Default Value: true
Unit: true/false - Number lastPinchScale: keeps track of the last pinch scale from a mobile gesture
- override Function dblclick(Event e): performs the double-click action, which fits the entire spectrum to the canvas
- override Function drag(Event e): performs the mouse drag action, which will zoom in on the spectrum; if the shift key is held, then the spectrum will be translated
- override Function drawChildExtras(Context ctx): draws extra graphics on top of the base graphics
- override Function gesturechange(Event e): handles any pinch gestures from mobile devices which will scale the spectrum
- override Function mousedown(Event e): performs the mouse down action
- override Function mouseup(Event e): performs the mouse up action
- override Function mousewheel(Event e, Number delta): performs the mouse wheel action
ChemDoodle.SeekerCanvas
is a child of the SpectrumCanvas class and provides an interactive canvas for viewing internal coordinates in spectra
constructor = new Function SeekerCanvas(String id, Integer width, Integer height, Integer seekType)
prototype = _SpectrumCanvas
- static String SEEK_POINTER: seeks the pointer location
- static String SEEK_PLOT: seeks closest plot coordinate by the x coordinate of the pointer location
- static String SEEK_PEAK: seeks closest peak coordinate by the x coordinate of the pointer location
- String seekType: seek method for the canvas, must be one of the SEEK constants
Default Value: SEEK_POINTER - Point p: keeps track of the last point from the user
- override Function innerRepaint(Context ctx): draws extra graphics on top of the base graphics
- override Function mousemove(Event e): performs the mouse move action
- override Function mouseout(Event e): performs the mouse out action
- override Function touchend(Event e): performs the touch end action
- override Function touchmove(Event e): performs the touch move action
- override Function touchstart(Event e): performs the touch start action
ChemDoodle.PeriodicTableCanvas
is a child of the Canvas class and displays a periodic table of elements. As with all components, it is completely customizable and interactive.
constructor = new Function PeriodicTableCanvas(String id, Integer cellDimension)
prototype = _Canvas
- Number padding: the padding between the sides of the component and the table
Default Value: 5
Unit: pixels - Number cellDimension: the width and height of each cell in the periodic table, 20 by default, but also specified in the constructor
Default Value: 20
Unit: pixels - PeriodicCell hovered: the currently hovered cell, or null if there is no cell hovered
- PeriodicCell selected: the currently selected cell, or null if there is no cell selected
- Function drawCell(Context ctx, VisualSpecifications specs, PeriodicCell cell): draws the provided cell to the canvas that owns the Context using the given VisualSpecifications, override this function to change the rendering of the table
- Function getHoveredElement(): returns the Element object corresponding to the cell that is currently hovered by the mouse pointer, and returns null if no cell is hovered
returns Element - override Function click(Event e): catches double click events and selects a cell
- override Function getMolecule(): set to null to ignore this function from the _Canvas class
- override Function mousemove(Event e): catches mouse move events and hovers a cell
- override Function mouseout(Event e): catches mouse out events and sets the hovered cell to null
- override Function repaint(): paints the periodic table
- override Function setMolecule(): set to null to ignore this function from the _Canvas class
- override Function setupTable(): sets up the table and all the table cells, this function is called by the constructor, but can be called after changing the constructor defaults to re-layout the table
ChemDoodle._Layout
is the parent class for all ChemDoodle Web Component Layouts, it should not be instantiated. It provides minimal, but essential, inherited functionality to aid in creating child classes that can organize complex layouts of Canvas objects and other HTML elements. This class should be extended for custom layouts.
constructor = new Function _Layout()
- VisualSpecifications specs: the visual specifications that define how content should be painted. All contained Canvas objects will inherit this VisualSpecifications object.
- String name: the name of the layout; this value will also identify contained canvases.
- Function create(String name): Sets up the component in the constructor. Essentially this just registers the unique name for the layout. This should be called as the last function in all constructors for classes that extend Layout.
- Function layout(): lays out the component on the webpage. This method should not be overriden, instead set the layout rules in the innerLayout() function of the child class, which is called by this method.
- abstract Function innerLayout(): this method is defined by all child classes of Layout. This method should define the html to layout the component and write it to the HTML document.
ChemDoodle.SimpleReactionLayout
is a child of the Layout class and allows the building and displaying of simple single reactions.
constructor = new Function SimpleReactionLayout(String name)
prototype = _Layout
- Array reactants: an array holding the reactant molecules
- Array products: an array holding the product molecules
- String arrow: any HTML content to represent the arrow between the reactants and products
Default Value: →
Unit: HTML - String textAbove: any HTML content to represent the text to be displayed above the reaction arrow, if null, then nothing is displayed above the arrow.
Default Value: null
Unit: HTML - String textBelow: any HTML content to represent the text to be displayed below the reaction arrow, if null, then nothing is displayed below the arrow.
Default Value: null
Unit: HTML - String plus: any HTML content to represent the plus symbol placed between multiple reactants or products
Default Value: +
Unit: HTML - Function addProduct(Molecule product): add the input Molecule to the end of the products Array.
- Function addReactant(Molecule reactant): add the input Molecule to the end of the reactants Array.
- override Function innerLayout(): lays out the reactant and products canvases in a HTML table with HTML elements in between to show the reaction decorations.
ChemDoodle.extensions
this package contains helper functions for classes that the ChemDoodle Web Components library doesn’t own.
- static Function contextHashTo(Context ctx, Number xs, Number ys, Number xt, Number yt, Number width, Number spacing): hashes from the first set of coordinates to the second set of coordinates given an input Context, line width and hash spacing
- static Function stringStartsWith(String str, String match): returns true and only true if the input String str starts with the String match
returns Boolean - static Function vec3AngleFrom(vec3 v1, vec3 v2): returns the angle between the two input vec3 objects
returns Number
ChemDoodle.featureDetection
this package contains several convenience methods to check for support of verious HTML5 features that the ChemDoodle Web Components library uses.
- static Function supports_canvas(): returns a boolean corresponding to the browser’s support for the HTML5 <canvas> tag
returns Boolean - static Function supports_canvas_text(): returns a boolean corresponding to the browser’s support for HTML5 <canvas> text rendering
returns Boolean - static Function supports_gesture(): returns a boolean corresponding to the browser’s support for gesture events; this is useful for determining if the current browser can support pinching and zooming, and to resort to ChemDoodle’s handlers if necessary
returns Boolean - static Function supports_touch(): returns a boolean corresponding to the browser’s support for touch events; this is useful for determining if the current browser is on a mobile platform
returns Boolean - static Function supports_webgl(): returns a boolean corresponding to the browser’s support for WebGL
returns Boolean - static Function supports_xhr2(): this method checks the browser’s support for XMLHttpRequest Level 2 functionality
returns Boolean
ChemDoodle.iChemLabs
this package connects to iChemLabs cloud services through AJAX XMLHttpRequest Level 2 for complete access to the entire ChemDoodle Java API. Additional functionality is provided on request. View our support options for details.
- static String SERVER_URL: the url to call for AJAX services
- static Boolean asynchronous: this value will determine if calls to AJAX services are synchronous or not
Default Value: true
Unit: true/false - static Function contactServer(String call, Object content, Function callback, Function errorback): the core function for contacting our server; this function takes parameters specific to our server protocol, is able to communicate the protocol and then returns the appropriate response to the callback function; this should never be manually called, use the other functions in this package instead; the errorback function is optional, and if provided and any error occurs, the errorback function will be called
- static Function generateImage(Molecule mol, String ext, Function callback, Function errorback): generates an image file of the input Molecule in any of the chemical formats that ChemDoodle understands (specified by the ext parameter); returns a link to the callback function that is the url of the file on our server that can then be downloaded
- static Function getMoleculeFromContent(String content, String format, Function callback, Function errorback): generates a molecule data structure from the input content string, specifying the correct format of the content by the extension of its filetype
- static Function getMoleculeFromDatabase(String database, String query, Function callback, Number dimension, Function errorback): contacts one of our partner databases to retrieve a structure for the input query; the dimension parameter is optional and determines if 2D or 3D coordinates are returned; allowed databases are ‘chemexper’, ‘chemspider’ and ‘pubchem’
- static Function getOptimizedPDBStructure(String id, Boolean withAtoms, Function callback, Function errorback): given an input PDB id, will return the atom, bond and ribbon data for the corresponding structure; a Molecule object is returned to the callback function. If the withAtoms parameter is false, atoms and bonds will not be returned, only ribbon data will be returned; this is useful if you want to speed up rendering. Loading PDB files through this method is several magnitudes faster than by loading and parsing the data from a variable in Javascript.
- static Function getZeoliteFromIZA(String iza, Function callback, Number xSuper, Number ySuper, Number zSuper, Function errorback): given an IZA code, the read zeolite, in a Molecule data structure, will be returned as a parameter to the callback function; the three number parameters are the supercell dimensions, and if not specified, will default to 1
- static Function isGraphIsomorphism(Molecule arrow, Molecule target, Function callback, Function errorback): this function will determine if the arrow molecule is a graph isomorphism of the target molecule, with the boolean value being returned as a parameter to the callback function
- static Function isSubgraphIsomorphism(Molecule arrow, Molecule target, Function callback, Function errorback): this function will determine if the arrow molecule is a subgraph isomorphism of the target molecule, with the boolean value being returned as a parameter to the callback function
- static Function kekulize(Molecule mol, Function callback, Function errorback): provided with an input Molecule, this function will kekulize either the entire single bond system, or just the resonance bonds into a valid kekule structure where pi delocalization is maximized; the kekulized copy structure will be returned as a parameter to the callback function
- static Function optimize(Molecule mol, Number dimension, Function callback, Function errorback): optimizes the input Molecule’s coordinates given a dimension (2 or 3), the callback function is called after the coordinates have been updated so you can repaint the canvas or do other necessary updates; if the dimension is 2, then nothing is sent to the callback function, the original Molecule’s coordinates are updated, if the dimension is 3, then a new molecule is sent to the callback function
- static Function readIUPACName(String iupac, Function callback, Function errorback): given an IUPAC name, the corresponding molecule will be returned as a parameter to the callback function
- static Function readSMILES(String smiles, Function callback, Function errorback): reads the input SMILES string and returns the corresponding Molecule to the callback function
- static Function saveFile(Molecule mol, String ext, Function callback, Function errorback): saves the input Molecule in any of the chemical formats that ChemDoodle understands (specified by the ext parameter); returns a link to the callback function that is the url of the file on our server that can then be downloaded
- static Function simulate13CNMR(Molecule mol, Function callback, Function errorback): simulates the 13C NMR spectrum for the input molecule, the resulting Spectrum object is sent to the callback function
- static Function simulate1HNMR(Molecule mol, Function callback, Function errorback): simulates the 1H NMR spectrum for the input molecule, the resulting Spectrum object is sent to the callback function
- static Function simulateMassParentPeak(Molecule mol, Function callback, Function errorback): simulates the parent peak in a mass spectrum for the input molecule (isotopic distribution), the resulting Spectrum object is sent to the callback function
- static Function writeSMILES(Molecule mol, Function callback, Function errorback): outputs the input Molecule to a SMILES string that is sent to the callback function
ChemDoodle.informatics
this package hosts all classes that perform cheminformatics algorithms.
- static Function getPointsPerAngstrom(): returns the pixel/Ängstrom ratio that is currently defined by the default ChemDoodle settings
returns Number
Unit: pixels/Ängstrom
ChemDoodle.informatics.BondDeducer
is a class for analyzing bonds based on 3D coordinates
- Number margin: the amount of flexibility in calculating bonds; the larger the number, the more bonds found
Default Value: 1.1
Unit: bond lengths - Function deduceCovalentBonds(Molecule molecule, Number customPointsPerAngstrom): deduces covalent bonds for the input molecule and appends them to the molecule‘s bonds array. Uses the covalent radii data provided in atomicData. The customPointsPerAngstrom parameters allows you to change the value from that specified by default.
ChemDoodle.informatics.HydrogenDeducer
is a class for manipulating hydrogens
- Function removeHydrogens(Molecule molecule): removes all hydrogens and bonds attached to them from the given molecule
ChemDoodle.informatics.Splitter
is a class for splitting a Molecule data structure composed of discrete graphs into individual discrete Molecule objects
- Function split(Molecule molecule): returns an array consisting of each discrete graph data structure in the input molecule, as individual discrete Molecule objects
returns Array
ChemDoodle.informatics.StructureBuilder
is a class for copying and creating molecular structures
- Function copy(Molecule molecule): returns a new Molecule object that is a copy of the input Molecule
returns Molecule
ChemDoodle.informatics._Counter
is an interface for calculating integer descriptors given a Molecule object. It should not be instantiated. To obtain a value from a Counter, use the following command where mol is a Molecule object and ChildOfCounter is a child of the Counter class: new ChildOfCounter(mol).value
- Number value: the result of the Counter algorithm
- Molecule molecule: holds the Molecule object being analyzed by the child derivative
- Function setMolecule(Molecule molecule): sets the molecule and performs the descriptor calculation. Should be called as the last method in all child constructors.
- abstract Function innerCalculate(Molecule molecule): this method is defined by all child classes of Counter. This method should calculate the descriptor value given the Molecule stored.
ChemDoodle.informatics.FrerejacqueNumberCounter
is a child of the Counter class and calculates the Frèrejacque Number, which is the SSSR count.
constructor = new Function FrerejacqueNumberCounter(Molecule molecule)
prototype = _Counter
- override Function innerCalculate(Molecule molecule): calculates the Frèrejacque Number. This should never be manually called as it is called by the constructor after setup.
ChemDoodle.informatics.NumberOfMoleculesCounter
is a child of the Counter class and calculates the real number of molecules in a Molecule object, which can hold disjoint graphs.
constructor = new Function NumberOfMoleculesCounter(Molecule molecule)
prototype = _Counter
- override Function innerCalculate(Molecule molecule): calculates the number of molecules. This should never be manually called as it is called by the constructor after setup.
ChemDoodle.informatics._RingFinder
is an interface for ring perception algorithms. It should not be instantiated. Contains helper methods for ring perception and for storing rings. So to obtain a ring set, use the following command where mol is a Molecule object and ChildOfRingFinder is a child of the RingFinder class: new ChildOfRingFinder(mol).rings
- Array atoms: all atoms that will be analyzed during ring perception are stored here, set by RingFinder.reduce()
- Array bonds: all bonds that will be analyzed during ring perception are stored here, set by RingFinder.reduce()
- Array rings: this array holds all the perceived rings
- Function fuse(): a helper method to find the bonds that belong to the perceived rings if only the atoms are specified.
- Function reduce(Molecule molecule): reduces this input molecule graph to discard most non-ring atons and all lone atoms to speed up runtimes, sets the atoms and bonds Arrays to the reduced graph.
- Function setMolecule(Molecule molecule): sets the molecule and performs the ring perception. Should be called as the last method in all child constructors.
- abstract Function innerGetRings(Molecule molecule): this method is defined by all child classes of RingFinder. This method should find rings based on the reduced atoms and bonds Arrays and then place perceived rings in the rings Array.
ChemDoodle.informatics.SSSRFinder
perceives the Smallest Set of Smallest Rings (SSSR) as defined by Plotkin. The SSSR set is not unique. This is not a child of the RingFinder class, as it uses the EulerFacetRingFinder class to perceive rings, and the SSSR is retrieved from that result. It works identically to a RingFinder derivative.
constructor = new Function SSSRFinder(Molecule molecule)
- Array rings: this array holds all the perceived rings
ChemDoodle.informatics.EulerFacetFinder
is a child of the RingFinder class and perceives a set of rings that defines all Euler facets in a molecule using an algorithm developed by Kevin Theisen. This ring set is thorough, unique and adequately describes rings as a 3D representation of a 2D drawing.
constructor = new Function EulerFacetFinder(Molecule molecule)
prototype = _RingFinder
- Number fingerBreak: is a cutoff for the size of rings to be found. Defines the length of a ring path which is half of a ring. So a value of 5 specifies that only 8 membered rings and smaller should be perceived. Use this setting to improve performance.
Default Value: 5 - override Function innerGetRings(Molecule molecule): implements the algorithm to find the Euler facet ring set. This should never be manually called as it is called by the constructor after setup.
ChemDoodle.io
this package contains various classes and tools for converting chemical data between formats.
- static Function fromJSONDummy(Object content): recover a Molecule from JSON format
returns Molecule - static Function toJSONDummy(Molecule mol): convert a Molecule to a consise Object that represents the chemical data for use in JSON protocol
returns Object
ChemDoodle.io.JCAMPInterpreter
reads IUPAC JCAMP-DX files
constructor = new Function JCAMPInterpreter()
- Boolean convertHZ2PPM: if true, and the file being read is a NMR spectrum in HZ, then the interpreter will automatically convert the x-axis into PPM
Default Value: false
Unit: true/false - Function read(String content): reads the JCAMP file content and returns the corresponding Spectrum
returns Spectrum
ChemDoodle.io.MOLInterpreter
reads and writes MDL MOLFiles (v2000)
constructor = new Function MOLInterpreter()
- Function read(String content, Number multiplier): reads MOLFile content and returns the corresponding molecule; the optional multiplier variable will override the default_anstromsPerBondLength variable, set it to 1 for 3D scenes in Angstroms
returns Molecule - Function write(Molecule molecule): writes and returns a String containing the MOLFile of the given molecule
returns String
ChemDoodle.io.XYZInterpreter
reads XYZ files
constructor = new Function XYZInterpreter()
- Molecule deduceCovalentBonds: if true, the XYZInterpreter will also calculate covalent bonds for input atoms
Default Value: true
Unit: true/false - Function read(String content): reads XYZ file content and returns the corresponding molecule
returns Molecule
ChemDoodle.io.PDBInterpreter
reads RCSB PDB files
constructor = new Function PDBInterpreter()
- Molecule deduceResidueBonds: if true, the PDBInterpreter deduce bonds between residue atoms
Default Value: false
Unit: true/false - Molecule calculateRibbonDistances: if true, the PDBInterpreter will also calculate distances for all protein and nucleic acid atoms to the closest ligand atoms for use in display. If no ligand atoms are present, then all atoms will be given a measured distance of 0
Default Value: false
Unit: true/false - Function read(String content, Number multiplier): reads the PDB file content and returns the corresponding Molecule; the optional multiplier variable will override the default_anstromsPerBondLength variable, set it to 1 for 3D scenes in Angstroms
returns Molecule
ChemDoodle.io.CIFInterpreter
reads Crystallographic Information Files (CIF)
constructor = new Function CIFInterpreter()
- Function read(String content, Number xSuper, Number ySuper, Number zSuper): reads a CIF file and returns the corresponding Molecule without instantiating a CIFInterpreter; the three optional integers specify the supercell dimensions, by default they are all 1, so reading a file without specifying these parameters will produce just the unit cell. In addition to reading atoms from CIF files, this interpreter will also produce a unit cell and other objects relevant to the display of periodic information
returns Molecule
ChemDoodle.io.file
this package deals with files.
- static Function content(String url, Function callback): retrieves the content of a file given an input url; the content is sent to the callback function provided; note that this function uses AJAX, so it will only work for files local to the same origin calling it, unless the server supports XHR2
ChemDoodle.io.png
this package generates png images from canvases.
- static Function create(_Canvas canvas): creates a PNG image from the input Canvas object and opens it in a new window
ChemDoodle.math
this package contains various methematical algorithms.
- static Function angleBetweenLargest(Object data): returns an object with two parameters (angle, largest); angle points between the largest gap of the input Array of angles in radians, largest is the value of the angle between the bonds of the largest gap in radians
returns Number - static Function calculateDistanceInterior(Point to, Point from, Object r): returns the distance of a line inscribed in a rectangle, given that the line has only 1 endpoint in the rectangle; the rectangle is a object with self-explanatory parameters x, y, w, and h
returns Number - static Function distanceFromPointToLineInclusive(Point p, Point l1, Point l2): returns the shortest (tangent) distance from the input Point to the line with endpoints defined by the last two input Points. This works by rotating the frame such that the line starts at the origin and points up along the x-axis, and the absolute value of the rotated input Point x-coordinate is returned. If the input Point’s y-coordinate is not between the endpoints, inclusively, a value of -1 is returned.
returns Number - static Function getRGB(String hex, Number mutliplier): returns a 3 membered Array of Numbers corresponding to the RGB magnitudes of the input hex string and multiplied by the input multiplier
returns Array - static Function intersectLines(Number x1, Number y1, Number x2, Number y2, Number x3, Number y3, Number x4, Number y4): returns the intersection of two non-parallel line segments, if they intersect
returns Point - static Function isBetween(Number x, Number left, Number right): returns true if the first input parameter is between the last two input parameters, inclusively
returns Boolean
ChemDoodle.monitor
this package keeps track of user input on the current page, such as the Canvas that is focused and what modifier keys are pressed on the keyboard
- static Boolean SHIFT: keeps track of whether the shift key is held down
- static Boolean ALT: keeps track of whether the alt key is held down
- static Boolean META: keeps track of whether the operating system specific meta key is held down (CTRL on Windows/Linux, CMD on Mac)
- static _Canvas CANVAS_OVER: keeps track of the canvas that the mouse is currently over. This is null if the mouse is over no canvas
- static _Canvas CANVAS_DRAGGING: keeps track of the canvas that the mouse is currently dragging from. This is null if no Canvas is currently being dragged from
ChemDoodle.structures
this package hosts all data structures provided by the ChemDoodle Web Components library.
ChemDoodle.structures.Element
is data structure for holding information about an element. This is a private class that cannot be instantiated, however, the Elements in the ELEMENT array can be extended.
constructor = new Function Element(String symbol, String name, Number atomicNumber)
- String symbol: the symbol of the element
- String name: the name of the element
- Number atomicNumber: the atomic number of the element
- Number covalentRadius: the covalent radius of the element
- Number vdWRadius: the van der Waals radius of the element
- String jmolColor: the Jmol color of the element
- String pymolColor: the PyMOL color of the element; all colors are the same as the Jmol set except: H, C, N, O, F, S
- Number mass: the integer value for the mass of the most abundant isotope of the element
- Number valency: the maximum valency for an element, or 0 if unknown
ChemDoodle.structures.Residue
is data structure for holding information about residue types. This is a private class that cannot be instantiated, however, the Residues in the RESIDUE array can be extended.
constructor = new Function Residue(String symbol, String name, Number atomicNumber)
- String symbol: the symbol of the residue
- String name: the name of the residue
- Boolean polar: just for amino acids, true if polar, false if non-polar
- String aminoColor: the color of the residue in the “amino” color set
- String shapelyColor: the color of the residue in the “shapely” color set
ChemDoodle.structures.PeriodicCell
is data structure for holding information about a single cell in the periodic table for the PeriodicTableCanvas. This is a private class that cannot be instantiated.
constructor = new Function PeriodicCell(Element element, Number x, Number y, Number dimension)
- Element element: the corresponding element
- Number x: the x coordinate of the top-left corner of the cell
- Number y: the y coordinate of the top-left corner of the cell
- Number dimension: the width and height of the square cell
ChemDoodle.structures.VisualSpecifications
The VisualSpecifications structure contains all the variables that define how all objects are drawn on the canvas. The variables are categorized into Canvas, Atom (atoms_), Bond (bonds_) and Spectrum (plots_) settings. All of these visual specifications are set by the defaults when a Canvas is constructed. The default variables are defined by the global ChemDoodle variable and have the same names as the member variables, except that they are preceded by ChemDoodle.default_. Change the default settings to enforce visual specifications on entire webpages.
constructor = new Function VisualSpecifications(Number x, Number y)
- //Canvas Specifications
- String backgroundColor: background color of the canvas, set this to null to create a see-through canvas
Default Value: white
Unit: color - Number scale: scale of the canvas, set this after the molecule has been loaded, then repaint the canvas
Default Value: 1
Unit: %/100 - Number rotateAngle: rotation angle of the canvas
Default Value: 0
Unit: radians - Number bondLength_2D: length of the bonds, set the default_ before using an interpreter to read your file; for 2D depiction
Default Value: 20
Unit: pixels - Number angstromsPerBondLength: number of Angstroms per bond length
Default Value: 1.25
Unit: Å/bond length - Array lightDirection_3D: the direction the lighting points in 3D scenes
Default Value: [-.1, -.1, -1]
Unit: vector - String lightDiffuseColor_3D: the diffusive light color in 3D scenes
Default Value: ‘#FFFFFF’
Unit: color - String lightSpecularColor_3D: the specular light color in 3D scenes
Default Value: ‘#FFFFFF’
Unit: color - Boolean projectionPerspective_3D: if true, a perspective projection will be used, if false, an orthographic projection will be used
Default Value: true
Unit: true/false - Number projectionPerspectiveVerticalFieldOfView_3D: the field of view angle for the perspective projection matrix in 3D scenes
Default Value: 45
Unit: degrees - Number projectionOrthoWidth_3D: the width of the orthographic projection matrix in 3D scenes
Default Value: 40
Unit: Angstroms - Number projectionWidthHeightRatio_3D: the width/height ratio for the projection matrix in 3D scenes; this setting is automatically handled by the canvas given its dimensions, but can be overridden if preferred (if the value is null, then this setting is ignored), this should be width/height of your canvas to keep the aspect ratio square
Unit: ratio - Number projectionFrontCulling_3D: the near camera cutoff distance in 3D scenes
Default Value: 0.1
Unit: Angstroms - Number projectionBackCulling_3D: the far camera cutoff distance in 3D scenes
Default Value: 10000
Unit: Angstroms - //Atom Specifications
- Boolean atoms_display: draw the atoms
Default Value: true
Unit: true/false - String atoms_color: atom color
Default Value: #000000
Unit: color - Number atoms_font_size_2D: atom text font size for 2D depiction
Default Value: 12
Unit: points - Array atoms_font_families_2D: the atom text font families, families cascade through the array if not found on the users computer; for 2D depiction
Default Value: [Helvetica, Arial, Dialog]
Unit: Array<String> - Boolean atoms_font_bold_2D: atom text will be bold
Default Value: false
Unit: true/false - Boolean atoms_font_italic_2D: atom text will be italicized
Default Value: false
Unit: true/false - Boolean atoms_circles_2D: draw atoms as circles, text is not drawn; for 2D depiction
Default Value: false
Unit: true/false - Number atoms_circleDiameter_2D: diameter of atom circles for 2D depiction
Default Value: 10
Unit: pixels - Number atoms_circleBorderWidth_2D: width of atom circle borders for 2D depiction
Default Value: 1
Unit: pixels - Boolean atoms_useJMOLColors: use Jmol colors for atoms
Default Value: false
Unit: true/false - Boolean atoms_usePYMOLColors: use PyMOL colors for atoms, will default to Jmol if that specification is also true
Default Value: false
Unit: true/false - Boolean atoms_implicitHydrogens_2D: render implicit hydrogens on all labels that are visible
Default Value: true
Unit: true/false - Boolean atoms_displayTerminalCarbonLabels_2D: show labels for terminal carbons
Default Value: false
Unit: true/false - Boolean atoms_showHiddenCarbons_2D: show hidden carbons that are located between two nearly parallel bonds of the same bond order
Default Value: true
Unit: true/false - Boolean atoms_displayAllCarbonLabels_2D: show all carbon labels
Default Value: false
Unit: true/false - Number atoms_lonePairDistance_2D: distance between the lone pairs and the atom
Default Value: 8
Unit: pixels - Number atoms_lonePairSpread_2D: distance between the electrons in lone pairs
Default Value: 4
Unit: pixels - Number atoms_lonePairDiameter_2D: diameter of the dots representing electrons in lone pairs
Default Value: 1
Unit: pixels - Number atoms_resolution_3D: the resolution of the sphere vertex buffer used to render atoms in 3D scenes
Default Value: 60
Unit: positive integer - Number atoms_sphereDiameter_3D: the diameter of atoms in 3D scenes (for ball and stick and wireframe type representations); atoms_useVDWDiameters_3D overrides this property
Default Value: 0.8
Unit: Angstroms - Boolean atoms_useVDWDiameters_3D: use van der Waals diameters for atoms
Default Value: false
Unit: true/false - Number atoms_vdwMultiplier_3D: a multiplier for VDW radii
Default Value: 1
Unit: %/100 - String atoms_materialAmbientColor_3D: the ambient color for atoms in 3D scenes
Default Value: #000000
Unit: color - String atoms_materialSpecularColor_3D: the specular color for atoms in 3D scenes
Default Value: #555555
Unit: color - Number atoms_materialShininess_3D: the shininess of atoms in 3D scenes
Default Value: 32
Unit: positive integer - Boolean atoms_nonBondedAsStars_3D: display non-bonded atoms using a star geometry, good for visualizing ions or water oxygens in PDB files
Default Value: false
Unit: true/false - //Bond Specifications
- Boolean bonds_display: draw the bonds
Default Value: true
Unit: true/false - String bonds_color: bond color
Default Value: #000000
Unit: color - Number bonds_width_2D: width of the bonds for 2D depiction; also controls the width of primitive lines for bonds rendered in WebGL scenes
Default Value: 1
Unit: pixels - Number bonds_saturationWidth_2D: relative saturation width of double and triple bond lines for 2D depiction
Default Value: 0.2
Unit: %/100*bondLength - String bonds_ends_2D: bond end style for 2D depiction
Allowed Values: [butt, round, square]
Default Value: round - Boolean bonds_useJMOLColors: color the bond by using the Jmol colors of the connected atoms, the type of fill is controlled by the bonds_colorGradient specification
Default Value: false
Unit: true/false - Boolean bonds_usePYMOLColors: color the bond by using the PyMOL colors of the connected atoms, the type of fill is controlled by the bonds_colorGradient specification, will default to Jmol if that specification is also true
Default Value: false
Unit: true/false - Boolean bonds_colorGradient: color the bond by using a gradient between the two colors of the constituent atoms, rather than by using a color split
Default Value: false
Unit: true/false - Number bonds_saturationAngle_2D: the angle that saturated double bonds are clipped by for 2D depiction
Default Value: Math.PI/3
Unit: radians - Boolean bonds_symmetrical_2D: double bonds are drawn symmetrically always, instead of pointing towards the center of a ring, for instance; for 2D depiction
Default Value: false
Unit: true/false - Boolean bonds_clearOverlaps_2D: draws a small background to the bond in the background color to contrast between overlapping bonds for 2D depiction
Default Value: false
Unit: true/false - Number bonds_overlapClearWidth_2D: the extent of the overlap clearing in both directions for 2D depiction
Default Value: 0.5
Unit: pixels - Number bonds_atomLabelBuffer_2D: the amount that the bond pulls back from atom text for 2D depiction
Default Value: 1
Unit: pixels - Number bonds_wedgeThickness_2D: the thickness of stereochemical wedge bonds for 2D depiction
Default Value: 0.22
Unit: %/100*bondLength - Number bonds_hashWidth_2D: the width of hashes for 2D depiction
Default Value: 1
Unit: pixels - Number bonds_hashSpacing_2D: the spacing of hashes for 2D depiction
Default Value: 2.5
Unit: pixels - Boolean bonds_showBondOrders_3D: renders higher bond orders with multiple cylinders if true, higher bond orders will orient themselves to face the camera
Default Value: false
Unit: true/false - Number bonds_resolution_3D: the resolution of the cylinder vertex buffer used to render bonds in 3D scenes
Default Value: 60
Unit: positive integer - Boolean bonds_renderAsLines_3D: renders bonds as primitive lines in WebGL scenes, instead of as meshes
Default Value: false
Unit: true/false - Number bonds_cylinderDiameter_3D: the diameter of bonds in 3D scenes
Default Value: 0.3
Unit: Angstroms - String bonds_materialAmbientColor_3D: the ambient color for bonds in 3D scenes
Default Value: #222222
Unit: color - String bonds_materialSpecularColor_3D: the specular color for bonds in 3D scenes
Default Value: #555555
Unit: color - Number bonds_materialShininess_3D: the shininess of bonds in 3D scenes
Default Value: 32
Unit: positive integer - //Macromolecule Specifications
- Boolean proteins_displayRibbon: render ribbons for proteins, if any
Default Value: true
Unit: true/false - Boolean proteins_displayBackbone: render a stick trace along the alpha carbon backbone for proteins, if any
Default Value: false
Unit: true/false - Number proteins_backboneThickness: the thickness of the sticks used to render the alpha carbon backbone
Default Value: 1.5
Unit: Angstroms - String proteins_backboneColor: the color of the alpha carbon backbone trace
Default Value: #CCCCCC
Unit: color - Boolean proteins_ribbonCartoonize: display a cartoon version of the ribbons for proteins; by default ribbons and their edges are continuous, by using the cartoon model, ribbon edges will be constant widths for different parts of the structure and will jump at intersections, end of helices and sheets will render an arrowhead
Default Value: false
Unit: true/false - Boolean proteins_useShapelyColors: use “Shapely” colors for residues
Default Value: false
Unit: true/false - Boolean proteins_useAminoColors: use “Amino” colors for residues
Default Value: false
Unit: true/false - Boolean proteins_usePolarityColors: color amino acids by polar(red)/non-polar(white)
Default Value: false
Unit: true/false - String proteins_primaryColor: the color of the front of the ribbon
Default Value: #FF0D0D
Unit: color - String proteins_secondaryColor: the color of the back of the ribbon’ ticks
Default Value: #FFFF30
Unit: color - String proteins_ribbonCartoonHelixPrimaryColor: the color of the front of helices in cartoon models
Default Value: #00E740
Unit: color - String proteins_ribbonCartoonHelixSecondaryColor: the color of the back of helices in cartoon models
Default Value: #9905FF
Unit: color - String proteins_ribbonCartoonSheetColor: the color of sheets in cartoon models
Default Value: #E8BB99
Unit: color - Number proteins_ribbonThickness: the thickness of the mesh for the ribbon
Default Value: 0.2
Unit: Angstroms - Number proteins_verticalResolution: the vertical resolution of ribbon models, must be a positive integer; recommended 10 for hi, 6 for med, 3 for low
Default Value: 10
Unit: divisions - Number proteins_horizontalResolution: the horizontal resolution of ribbon models, must be a positive odd integer; recommended 9 for hi, 5 for med, 3 for low
Default Value: 9
Unit: divisions - String proteins_materialAmbientColor_3D: the ambient color for ribbons in 3D scenes
Default Value: #222222
Unit: color - String proteins_materialSpecularColor_3D: the specular color for ribbons in 3D scenes
Default Value: #555555
Unit: color - Number proteins_materialShininess_3D: the shininess of ribbons in 3D scenes
Default Value: 32
Unit: positive integer - Boolean nucleics_display: render tubes and platforms for nucleic acids, if any
Default Value: true
Unit: true/false - String nucleics_tubeColor: the color of the tubes and base handles for the nucleic acid models
Default Value: #CCCCCC
Unit: color - String nucleics_baseColor: the color of the base platforms for the nucleic acid models
Default Value: #C10000
Unit: color - Boolean nucleics_useShapelyColors: use “Shapely” colors for base platforms
Default Value: true
Unit: true/false - Number nucleics_tubeThickness: the thickness of the tubes that define the backbones of the nucleic acids
Default Value: 1.5
Unit: Angstroms - Number nucleics_tubeResolution_3D: the resolution of the tube used for the backbones of nucleic acids in 3D scenes
Default Value: 60
Unit: positive integer - Number proteins_verticalResolution: the vertical resolution of nucleic backbone models, must be a positive integer; recommended 10 for hi, 6 for med, 3 for low
Default Value: 10
Unit: divisions - String nucleics_materialAmbientColor_3D: the ambient color for nucleic acid models in 3D scenes
Default Value: #222222
Unit: color - String nucleics_materialSpecularColor_3D: the specular color for nucleic acid models in 3D scenes
Default Value: #555555
Unit: color - Number nucleics_materialShininess_3D: the shininess of nucleic acid models in 3D scenes
Default Value: 32
Unit: positive integer - Boolean macro_displayAtoms: render the atoms of the proteins and nucleic acids macromolecules, if any
Default Value: false
Unit: true/false - Boolean macro_displayBonds: render the bonds of the proteins and nucleic acids macromolecules, if any
Default Value: false
Unit: true/false - Number macro_atomToLigandDistance: this is the cutoff distance that will determine the distance from ligand molecules that is required to show macromolecule atoms; if no ligands are present, or if there are no distances calculated, this specification will have no effect; the PDBInterpreter must be set to calculate distances; if this value is -1, then all atoms are shown regardless of distance
Default Value: -1
Unit: Angstroms - Boolean macro_showWater: render water molecules, if any
Default Value: false
Unit: true/false - Boolean macro_colorByChain: color each individual chain with a unique color, overriding any other coloring specifications; colors are iterated in order, through HSL space
Default Value: false
Unit: true/false - //Surface Specifications
- Boolean surfaces_display: render surfaces, if any
Default Value: true
Unit: true/false - String surfaces_style: the sruface rendering style
Allowed Values: [Dot, Solid]
Default Value: Dot - String surfaces_color: the color of the surface
Default Value: #E9B862
Unit: color - String surfaces_materialAmbientColor_3D: the ambient color for surfaces in 3D scenes
Default Value: #000000
Unit: color - String surfaces_materialSpecularColor_3D: the specular color for surfaces in 3D scenes
Default Value: #000000
Unit: color - Number surfaces_materialShininess_3D: the shininess of surfaces in 3D scenes
Default Value: 32
Unit: positive integer - //Cystallographic Specifications
- Boolean crystals_displayUnitCell: render the unit cell, if this information is provided
Default Value: true
Unit: true/false - String crystals_unitCellColor: the color of the lines of the unit cell
Default Value: green
Unit: color - Number crystals_unitCellLineWidth: the width of the lines of the unit cell
Default Value: 1
Unit: positive number - //Spectrum Specifications
- String plots_color: plot color
Default Value: #000000
Unit: color - Number plots_width: width of the plot line
Default Value: 1
Unit: pixels - Boolean plots_showIntegration: display an integration line, typically for NMR spectra
Default Value: false
Unit: true/false - String plots_integrationColor: integration line color
Default Value: #c10000
Unit: color - Number plots_integrationLineWidth: width of the integration line
Default Value: 1
Unit: pixels - Boolean plots_showGrid: display an grid using the axes’ ticks
Default Value: false
Unit: true/false - String plots_gridColor: integration line color
Default Value: gray
Unit: color - Number plots_gridLineWidth: width of the integration line
Default Value: 0.5
Unit: pixels - Boolean plots_showYAxis: display the y-axis
Default Value: true
Unit: true/false - Boolean plots_flipXAxis: flip the x-axis, typical for certain domain units of NMR and IR spectra
Default Value: false
Unit: true/false - Number text_font_size: spectrum text font size
Default Value: 12
Unit: points - Array text_font_families: the spectrum text font families, families cascade through the array if not found on the users computer
Default Value: [Helvetica, Arial, Dialog]
Unit: Array<String> - String text_color: spectrum text color
Default Value: #000000
Unit: color - Function set3DRepresentation(String representation): presets the 3D representation for the main molecular structure for a Canvas3D, currently accepts: ‘Ball and Stick’, ‘van der Waals Spheres’, ‘Stick’, ‘Wireframe’, ‘Line’
ChemDoodle.structures.Queue
a queue data structure
constructor = new Function Queue()
- Function dequeue(): returns and removes the element at the beginning of the queue
returns Object - Function enqueue(Object o): adds an element to the end of the queue
returns Object - Function getOldestElement(): returns, but does not remove, the element at the beginning of the queue
returns Object - Function getSize(): returns the size of the queue
returns Number - Function isEmpty(): returns true if there are no elements in the queue
returns Boolean
ChemDoodle.structures.Point
represents a 2D point and contains functions for various 2D geometric calculations
constructor = new Function Point(Number x, Number y)
- Number x: x coordinate
Default Value: 0
Unit: pixels - Number y: y coordinate
Default Value: 0
Unit: pixels - Function add(Point p): add Point p
- Function angle(Point p): returns the angle to Point p, with the current Point as the origin (y-axis is inverted for the inverted canvases)
returns Number
Unit: radians - Function angleForStupidCanvasArcs(Point p): same as angle(), but for the contradictory way canvas arcs are handled
returns Number
Unit: radians - Function distance(Point p): returns the distance to Point p
returns Number
Unit: pixels - Function sub(Point p): subtract Point p
ChemDoodle.structures.Atom
represents a chemical atom
constructor = new Function Atom(String label, Number x, Number y, Number z)
prototype = Point
- String label: label of the atom, should be an element symbol; this field is chemically significant and will be expected to be an element symbol
Default Value: C
Unit: Element Symbol - String altLabel: alternate text to be displayed for an atom, which will override the rendering of the element symbol and any associated attributes; this field is ignored if null
Default Value: null - Number z: z coordinate
Default Value: 0
Unit: pixels - Number charge: atomic charge
Default Value: 0 - Number mass: mass number, values greater than -1 are rendered
Default Value: -1 - Number numLonePair: number of lone pairs to be rendered on an atom; this is a positive integer value
Default Value: 0 - Boolean isLone: not connected to any other atoms (if Carbon, draws a grey dot)
- Boolean isHover: for SketcherCanvas, mouse is hovered over this, draws a brown circle
- Boolean isSelected: for SketcherCanvas, mouse has clicked this, draws a blue circle
- Boolean isOverlap: for SketcherCanvas, overlaps another atom, draws a red circle
- Boolean isHidden: metadata set by the containing Molecule, states if the Atom is hidden
- Number coordinationNumber: metadata set by the containing Molecule, the valency of the Atom
- Number bondNumber: metadata set by the containing Molecule, the number of bonds connected to the Atom
- Number angleOfLeastInterference: metadata set by the containing Molecule, the angle in radians that points towards the largest open space between the bonds connected to the atom
- Function add3D(Atom a): the 3D counterpart to the same Point function
- Function distance3D(Atom a): the 3D counterpart to the same Point function
- Function draw(Context ctx, VisualSpecifications specs): draws this atom to the canvas that owns the Context using the given VisualSpecifications
- Function drawDecorations(Context ctx): draws decorations for the SketcherCanvas that owns the Context and has this Atom hovered
- Function isLabelVisible(VisualSpecifications specs): returns true if label is not ‘C’
returns Boolean
Unit: true/false - Function render(GLContext gl, VisualSpecifications specs): renders this atom to the 3D scene in the WebGL canvas that owns the GLContext using the given VisualSpecifications
- Function sub3D(Atom a): the 3D counterpart to the same Point function
ChemDoodle.structures.Ring
represents a chemical ring
constructor = new Function Ring()
- Array atoms: constituent atoms
- Array bonds: constituent bonds
- Point center: the center of this Ring, cached for performance
- Function getCenter(): returns a Point that specifies the center of this Ring
returns Point
Unit: pixels - Function setupBonds(Point p): loops through bonds and sets all Bond.ring objects in to itself, caches center
ChemDoodle.structures.Bond
represents a chemical bond
constructor = new Function Bond(Atom a1, Atom a2, Number bondOrder)
- static String STEREO_NONE: specifies no stereochemistry
- static String STEREO_PROTRUDING: specifies a protruding stereochemistry
- static String STEREO_RECESSED: specifies a recessed stereochemistry
- static String STEREO_AMBIGUOUS: specifies an ambiguous stereochemistry
- Atom a1: first Atom
- Atom a2: second Atom
- Number bondOrder: bond order
Allowed Values: [1, 2, 3]
Default Value: 1 - String stereo: stereochemical bias of the bond, must be one of the BOND_STEREO constants
Default Value: BOND_STEREO_NONE - Boolean isHover: for SketcherCanvas, mouse is hovered over this, draws brown handles
- Ring ring: the largest containing SSSR ring
- Function contains(Atom a): returns the Atom opposite Atom a
returns Boolean
Unit: true/false - Function draw(Context ctx, VisualSpecifications specs): draws this bond to the canvas that owns the Context using the given VisualSpecifications
- Function drawDecorations(Context ctx): draws decorations for the SketcherCanvas that owns the Context and has this Bond hovered
- Function getCenter(): returns a Point that specifies the center between the two Atoms in the Bond
returns Point
Unit: pixels - Function getLength(): returns the bond length on the XY plane
returns Number
Unit: pixels - Function getLength3D(): returns the 3D bond length
returns Number
Unit: pixels - Function getNeighbor(Atom a): returns the Atom opposite Atom a
returns Atom - Function render(GLContext gl, VisualSpecifications specs): renders this bond to the 3D scene in the WebGL canvas that owns the GLContext using the given VisualSpecifications
ChemDoodle.structures.Molecule
represents a chemical molecule
- Array atoms: constituent atoms
- Array bonds: constituent bonds
- Array rings: constituent rings
- Boolean findRings: will find rings in the check() function; this should be disabled by you, if not necessary, to improve performance
Default Value: true - Function check(Boolean force): sets up the molecule for drawing by checking for lone carbons, rings and z-sorting, as well as setting up the metadata for drawing; since this is a cpu intensive function, the force parameter is for efficiency, so the molecule can be checked often, with a false or no parameter and it will keep track that it needs to be checked, then when an important function (such as a render) needs the check to go through, you pass it a true and the check will be forced if the molecule needs to be checked.
- Function draw(Context ctx, VisualSpecifications specs): draws this molecule to the canvas that owns the Context using the given VisualSpecifications
- Function getAngles(Atom a): with a as the origin, returns an Array of all the angles to the immediately connected atoms in this Molecule, in ascending order
returns Array
Unit: radians - Function getAverageBondLength(): calculates the average bond length of the molecule, or returns 0 if there are no bonds, this is a 2D function
returns Number
Unit: pixels - Function getBonds(Atom a): returns an Array on Bond objects that contain the input Atom a in the molecule
returns Array
Unit: Bond - Function getCenter(): returns a Point that specifies the center of this Molecule
returns Point
Unit: pixels - Function getCenter3D(): returns an Atom that specifies the center of this Molecule in 3 dimensions
returns Atom
Unit: pixels - Function getCoordinationNumber(Array bs): adds the bond orders from the bs (Array of Bond) parameter together to calculate the coordination number
returns Number
Unit: coordination number - Function getDimension(): returns a Point that specifies the width and height of this Molecule in the XY plane. Among other uses, this method can be used to first find the dimensions of a molecule to set the dimensions of a Canvas to perfectly fit it (make sure to add some aesthetic buffer space).
returns Point
Unit: pixels - Function render(GLContext gl, VisualSpecifications specs): renders this molecule to the 3D scene in the WebGL canvas that owns the GLContext using the given VisualSpecifications
- Function scaleToAverageBondLength(Number length): scales the molecule so that the average bond length equals the input length, this is a 2D function
- Function setupMetaData(): sets up metadata for the molecule, used internally to determine how graphics are rendered
- Function sortAtomsByZ(): sorts atoms in ascending order by z coordinate
- Function sortBondsByZ(): sorts bonds in ascending order by their z coordinate
ChemDoodle.structures.Spectrum
data structure to hold spectrum information
- Array data: the spectrum plot as an array of Point objects
- Array metadata: this is an Array of String containing the header records from the JCAMP file
- Array dataDisplay: this is an Array of Object. Each object describes an item in the list of data items to be displayed on the top left of the spectrum. Three String parameters may be present: tag, display, value. If tag is present, then the JCAMP metadata will be searched for the corresponding JCAMP tag and placed in the list. If this tag is not found, it is ignored. If display is also provided, then the JCAMP tag name is replaced by the more appropriate title. You can also add custom items by providing the display and value parameters. If the value parameter is defined, then the tag parameter will be ignored if also defined.
- Number minX: the minimum domain value, set up by the setup method to the smallest x value in the data array after the spectrum is read, can also be manually set
- Number maxX: the maximum domain value, set up by the setup method to the largest x value in the data array after the spectrum is read, can also be manually set
- Number integrationSensitivity: this value states that only values greater than this percentage of the highest y-value in the spectrum will be considered in the integration
Default Value: 0.01
Unit: %/100 - String title: the title of the spectrum, most spectrum file formats provide a title, no title is displayed if the value is null
Default Value: null - String xUnit: the unit of the domain to be displayed under the x-axis, no x-axis title is displayed if the value is null
Default Value: null - String yUnit: the unit of the domain to be displayed under the y-axis, no y-axis title is displayed if the value is null
Default Value: null - Boolean continuous: determines how the plot will be drawn, if continuous is true, then the plot is rendered as a path from Point to Point in the data array, if continuous is false, then each data point will be rendered as a vertical line from y = 0
Default Value: true - Object memory: an object storing dimension metadata from the previous render
- Function alertMetadata(): will popup a Javascript alert dialog with the metadata from the JCAMP file
- Function draw(Context ctx, VisualSpecifications specs, Number width, Number height): draws this spectrum to the canvas that owns the Context using the given VisualSpecifications, the canvas’s width and height are also provided
- Function getClosestPlotInternalCoordinates(Number x): given the input x-coordinate from the canvas space, this function will return a point containing the plot coordinates of the spectrum point that has its x-coordinate closest to the input x coordinate; because the smallest resolution on screens is a pixel, this function will actually find the highest peak within a pixel range of the input x coordinate to return; can only be called after a render when memory is set, this function doesn’t make sense without a render first anyway
returns Point
Unit: spectrum units - Function getInternalCoordinates(Number x, Number y): function to obtain the x and y coordinates within the spectrum’s plot space given the input x and y coordinates from the canvas space; can only be called after a render when memory is set, this function doesn’t make sense without a render first anyway; essentially, this just calls getInverseTransformedX() and getInverseTransformedY()
returns Point
Unit: spectrum units - Function getInverseTransformedX(Number x): function to obtain the x-coordinate within the spectrum’s plot space given the input x-coordinate from the canvas space; can only be called after a render when memory is set, this function doesn’t make sense without a render first anyway
returns Number
Unit: x axis units - Function getInverseTransformedY(Number y): function to obtain the y-coordinate within the spectrum’s plot space given the input y-coordinate from the canvas space; can only be called after a render when memory is set, this function doesn’t make sense without a render first anyway
returns Number
Unit: y axis units - Function getTransformedX(Number x, VisualSpecifications specs, Number width, Number offsetLeft): used internally to obtain the x-coordinate within the canvas space given the input x-coordinate from the spectrum’s plot space
returns Number
Unit: pixels - Function getTransformedY(Number x, VisualSpecifications specs, Number height, Number offsetBottom, Number offsetTop): used internally to obtain the y-coordinate within the canvas space given the input y-coordinate from the spectrum’s plot space
returns Number
Unit: pixels - Function setup(): analyzes the data array for the default domain and scales the range between 0 and 1, called by the interpreters that read spectra files
- Function translate(Number dif, Number width): given the signed translation amount in pixels in the canvas’s domain space (in any order), will translate that domain by appropriately setting the minX and maxX parameters given the canvas width
- Function zoom(Number pixel1, Number pixel2, Number width, Boolean scaleY): given the input pixel1 and pixel2 values in the canvas’s domain space (in any order), will focus in on that domain by appropriately setting the minX and maxX parameters given the canvas width; optionally, if the scaleY parameter is true, this function will return a Number that should be the new scale for the VisualSpecifications.scale value to see the full peak; this function returns nothing if scaleY is false
returns Number newScale