Search:
Class scilligence.JSDraw2.Editor
class
scilligence.JSDraw2.Editor
Constructor Summary
Constructor a JSDraw Editor
Function Summary
Activate the editor and set focus
Clean up reaction
clear
(bool
redraw)
Clear all contents
copy()
Copy
Create a JSDraw Editor
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
cut()
Cut
doCmd
(string
cmd)
Do a toolbar command
fitToWindow
(number
maxBondLength)
Fit the molecule to the view window
Get the Editor object by its ID
getCenter
(array
atoms)
Get the center of a set of atoms
Get exact mass
Get Extinction Coefficient
getFormula
(bool
html)
Get Formula
getFragment
(Atom
a)
Get the fragment containing a given atom
Get molecular weight
getMolfile
(bool
v3000)
Get molfile data
Get Rxnfile
Get SMILES
getSvg()
Get SVG data
Get JSDraw Xml data
highlight
(string or Mol
query)
Highlight a query structure
static
init()
Initialize all DIV HTML elements and their class marked as JSDraw, and convert all of them into JSDraw Editor
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
Move the structure to center of the view window
past
(Point
pos)
Paste
pushundo()
Push the current status into undo stack
readCookie
(string
name)
Read the structure from a saved cookie
redo()
Redo once
redraw()
Redraw the molecule
refresh
(bool
modified)
Refresh the display
Reset scaling
Rotate atoms around a point
Scale the molecule
Select all object
Load file data
setJdx
(string
data)
Set Secptrum JDX data
setModified
(bool
f)
Set modified flag
setMol
(Mol
mol)
Load a Mol object
setMolFile
(string
molfile)
Load a molfile
setRxnFile
(string
rxnfile)
Load a rxnfile
setXml
(string
xml)
Set JSDraw Xml data
static
showAbout()
Show JSDraw About box
Show JSDraw Poup Editor
undo()
Undo once
Write the current structure into a cookie, so it can be reloaded next time
Event Summary
Called when the structure is changed
Constructor Details
constructor Editor
Editor(string
dv, dictionary
options)
Constructor a JSDraw Editor
Parameters:
dv
- the id of the div placeholder
options
- the options for the editor:- background - background color
- biology - Set this flag to false to hide seqence button
- buttonshape - circle, or square
- data - actual data
- dataformat - data format. It can be molfile, rxnfile, html
- height
- focusbox - indicate if show focusing box if focused. default: true
- focuscolor - the border color when focused
- inktools - set this flag to false to hide ink tools
- highlighterrors - set this flag to false not to highlight errors in reb box
- ondatachange - datachange event handler
- plugins - plugins, as an array [{iconurl, tooltips, onclick}, ...]
- popup - Create a viewer, and double-click to show popup editor
- popupheight - Popup Editor height
- popupwidth - Popup Editor width
- query - Set this flag to false to disable query atoms (A, R, X, Q, *, etc.) in periodic table
- removeHydrogens - Remove hydrogen atoms before show the structure
- rxn - Set this flag to false to disable reaction buttons on toolbar
- scale - A factore to zoom the whole editor, including toolbars. This is useful for iPad applications
- sendquery - Set this flag to false to hide PubChem, ChemSpider search button
- skin - set this to "w8" to display the editor in JSDraw2 mode; leave this parameter to empty to display editor in classic mode (2.0)
- showcarbon - all or terminal
- showfilemenu - set this flag to false to hide file menus
- showimplicithydrogens - Set flag to false to hide implicit hydrogens
- showtoolbar - set this flag to false not to show toolbar
- viewonly
- width
Function Details
function activate
activate(bool
f, bool
show)
Activate the editor and set focus
Parameters:
f
- indicate setting focus or name
show
- indicate if redrawing the structure
Returns:
null
function cleanupRxn
cleanupRxn()
Clean up reaction
Returns:
true if it is a reaction
function clear
clear(bool
redraw)
Clear all contents
Parameters:
redraw
- indicate if redrawing the view wndow
Returns:
null
function copy
copy()
Copy
Returns:
null
function create
static
create(string or DOM
id, dictonary
options)
Create a JSDraw Editor
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
Parameters:
id
- the ID of DIV placehold, or the DIV DOM object
options
- creating options. Please check Editor contructor for details function cut
cut()
Cut
Returns:
null
function doCmd
doCmd(string
cmd)
Do a toolbar command
Parameters:
cmd
- the command name
Returns:
null
function fitToWindow
fitToWindow(number
maxBondLength)
Fit the molecule to the view window
Parameters:
maxBondLength
- maximum bond length
Returns:
null
function get
static
get(string
id)
Get the Editor object by its ID
Parameters:
id
- the Editor ID
Returns:
the Editor object
function getCenter
getCenter(array
atoms)
Get the center of a set of atoms
Parameters:
atoms
- an array of atoms
Returns:
a Point object
function getExactMass
getExactMass()
Get exact mass
Returns:
a number
function getExtinctionCoefficient
getExtinctionCoefficient()
Get Extinction Coefficient
Returns:
a number
function getFormula
getFormula(bool
html)
Get Formula
Parameters:
html
- indicate if rendering Formula in HTML format
Returns:
a string
function getFragment
getFragment(Atom
a)
Get the fragment containing a given atom
Parameters:
a
- the given atom
Returns:
the fragement as a Mol object
function getMolWeight
getMolWeight()
Get molecular weight
Returns:
a number
function getMolfile
getMolfile(bool
v3000)
Get molfile data
Parameters:
v3000
- indicate if rendering it in mol v3000 format
Returns:
the molfile string
function getRxnfile
getRxnfile(bool
groupbyplus, bool
v3000)
Get Rxnfile
Parameters:
groupbyplus
- indicate if grouping reactants/products based on explicit plus signs
v3000
- indicate if rendering in v3000 format
Returns:
a string
function getSmiles
getSmiles()
Get SMILES
Returns:
a string
function getSvg
getSvg()
Get SVG data
Returns:
the svg string
function getXml
getXml(number
width, number
height, bool
viewonly)
Get JSDraw Xml data
Parameters:
width
- the view width
height
- the view height
viewonly
- indicate if it is viewonly mode
Returns:
a string
function highlight
highlight(string or Mol
query)
Highlight a query structure
Parameters:
query
- the query structure
Returns:
true or false
function init
static
init()
Initialize all DIV HTML elements and their class marked as JSDraw, and convert all of them into JSDraw Editor
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
This function can be called before document.onload().
new JSDraw2.Editor() can only be used in or after document.onload().
function moveCenter
moveCenter()
Move the structure to center of the view window
Returns:
null
function past
past(Point
pos)
Paste
Parameters:
pos
- place the pasted structure to this location
Returns:
the Mol
function pushundo
pushundo()
Push the current status into undo stack
Returns:
null
function readCookie
readCookie(string
name)
Read the structure from a saved cookie
Parameters:
name
- cookie name
Returns:
null
function redo
redo()
Redo once
Returns:
null
function redraw
redraw()
Redraw the molecule
Returns:
null
function refresh
refresh(bool
modified)
Refresh the display
Parameters:
modified
- modified flag
Returns:
null
function resetScale
resetScale()
Reset scaling
Returns:
null
function rotate
rotate(array
atoms, Point
origin, deg
atoms)
Rotate atoms around a point
Parameters:
atoms
- an array of atom
origin
- rotating orgin
atoms
- rotating degree
Returns:
null
function scale
scale(number
s, Point
origin)
Scale the molecule
Parameters:
s
- the scaling factor
origin
- the scaling origin
Returns:
null
function selectAll
selectAll()
Select all object
Returns:
true or false
function setFile
setFile(string
data, string
filetype)
Load file data
Parameters:
data
- the file contents
filetype
- the file type: mol, rxn, xml. Other file types can be loaded with JSDraw.WebServices
Returns:
the Mol object loaded
function setJdx
setJdx(string
data)
Set Secptrum JDX data
Parameters:
data
- JDX string function setModified
setModified(bool
f)
Set modified flag
Parameters:
f
- true or false
Returns:
null
function setMol
setMol(Mol
mol)
Load a Mol object
Parameters:
mol
- the Mol object to be loaded
Returns:
true or false
function setMolFile
setMolFile(string
molfile)
Load a molfile
Parameters:
molfile
- the mol file contents
Returns:
null
function setRxnFile
setRxnFile(string
rxnfile)
Load a rxnfile
Parameters:
rxnfile
- the rxn file contents
Returns:
null
function setXml
setXml(string
xml)
Set JSDraw Xml data
Parameters:
xml
- the JSDraw Xml string
Returns:
the Mol object loaded
function showAbout
static
showAbout()
Show JSDraw About box
Returns:
null
function showPopup
static
showPopup(string
title, string
btnText, function(editor)
btnFn, number
zindex)
Show JSDraw Poup Editor
Parameters:
title
- the title of the Popup dialog
btnText
- the button text of the Popup dialog
btnFn
- the callback function when user clicks on the button
zindex
- the zIndex of the dialog DOM function undo
undo()
Undo once
Returns:
null
function writeCookie
writeCookie(string
name, number
days)
Write the current structure into a cookie, so it can be reloaded next time
Parameters:
name
- cookie name
days
- cookie valid days
Returns:
null
Event Details
event ondatachange
bool
ondatachange(Editor
editor)
Called when the structure is changed
Parameters:
editor
this Editor
Returns:
null
Example: <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script> <script type="text/javascript" src='http://[PATH]/Scilligence.JSDraw2.js'></script> </head> <body> <div id='ed'></div> <script type='text/javascript'> dojo.ready(function() { // create a JSDraw Editor var editor = new JSDraw2.Editor("ed", { skin: "w8", width: 800, height: 400 }); // create a JSDraw viewer //var editor = new JSDraw2.Editor("ed", { skin: "w8", width: 800, height: 400, viewonly: true }); // create a JSDraw popup Editor //var editor = new JSDraw2.Editor("ed", { skin: "w8", width: 800, height: 400, popup: true }); }); </script> </body> </html>