From: <ha...@us...> - 2012-06-14 17:47:03
|
Revision: 17294 http://jmol.svn.sourceforge.net/jmol/?rev=17294&view=rev Author: hansonr Date: 2012-06-14 17:46:52 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Jmol/GLmol, Jmol/JME interfaces Modified Paths: -------------- trunk/Jmol/appletweb/JmolApi.js trunk/Jmol/appletweb/JmolApplet.jar trunk/Jmol/appletweb/JmolApplet.js trunk/Jmol/appletweb/JmolAppletSigned.jar trunk/Jmol/appletweb/JmolCore.js trunk/Jmol/appletweb/JmolGLmol.js Added Paths: ----------- trunk/Jmol/appletweb/JmolJME.js Modified: trunk/Jmol/appletweb/JmolApi.js =================================================================== --- trunk/Jmol/appletweb/JmolApi.js 2012-06-14 08:57:33 UTC (rev 17293) +++ trunk/Jmol/appletweb/JmolApi.js 2012-06-14 17:46:52 UTC (rev 17294) @@ -4,7 +4,15 @@ Jmol.getVersion = function(){return _version}; - Jmol._defaultInfo = { + Jmol.getApplet = function(id, Info, checkOnly) { + + // note that the variable name the return is assigned to MUST match the first parameter in quotes + // applet = Jmol.getApplet("applet", Info) + + checkOnly || (checkOnly = !1); + id || (id = "jmolApplet0"); + Info || (Info = {}); + var DefaultInfo = { color: "#FFFFFF", // applet object background color, as for older jmolSetBackgroundColor(s) width: 300, height: 300, @@ -22,19 +30,8 @@ jarFile: "JmolApplet0.jar", isSigned: false, debug: false - }; - - Jmol.getApplet = function(id, Info, checkOnly) { - - // note that the variable name the return is assigned to MUST match the first parameter in quotes - // applet = Jmol.getApplet("applet", Info) - - checkOnly || (checkOnly = !1); - id || (id = "jmolApplet0"); - Info || (Info = {}); - for (x in Jmol._defaultInfo) - if (typeof Info[x] == "undefined") - Info[x] = Jmol._defaultInfo[x]; + }; + Jmol._addDefaultInfo(Info, DefaultInfo); Jmol._debugAlert = Info.debug; Info.serverURL && (Jmol._serverUrl = Info.serverURL); var model = (checkOnly ? null : Info.defaultModel); @@ -64,6 +61,23 @@ return applet; } + Jmol.getJMEApplet = function(id, Info, linkedApplet) { + + // note that the variable name the return is assigned to MUST match the first parameter in quotes + // jme = Jmol.getJMEApplet("jme", Info) + + id || (id = "jme"); + Info || (Info = {}); + var DefaultInfo = { + width: 300, + height: 300, + jarPath: ".", + jarFile: "JME.jar", + }; + Jmol._addDefaultInfo(Info, DefaultInfo); + return new Jmol._JMEApplet(id, Info, linkedApplet); + } + Jmol.script = function(applet, script) { applet._script(script); } @@ -448,5 +462,19 @@ Jmol._syncedCommands = commands; // an array of commands; one or more may be null Jmol._syncedReady = {}; Jmol._isJmolJSVSync = isJmolJSV; - } + } + + /* + Jmol._grabberOptions = [ + ["$", "NCI(small molecules)"], + [":", "PubChem(small molecules)"], + ["=", "RCSB(macromolecules)"] + ]; + */ + + Jmol.setGrabberOptions = function(options) { + Jmol._grabberOptions = options; + } + + })(Jmol); Modified: trunk/Jmol/appletweb/JmolApplet.jar =================================================================== (Binary files differ) Modified: trunk/Jmol/appletweb/JmolApplet.js =================================================================== --- trunk/Jmol/appletweb/JmolApplet.js 2012-06-14 08:57:33 UTC (rev 17293) +++ trunk/Jmol/appletweb/JmolApplet.js 2012-06-14 17:46:52 UTC (rev 17294) @@ -42,49 +42,33 @@ this._syncKeyword = "Select:"; /* - * private variables - */ - var that = this; - - /* - * private methods - */ - var getJarFilename=function(fileNameOrFlag){ - that._jarFile = - (typeof(fileNameOrFlag) == "string" ? fileNameOrFlag : (fileNameOrFlag ? "JmolAppletSigned" : "JmolApplet") + "0.jar"); - } - var setCodebase=function(codebase) { - that._jarPath = codebase ? codebase : "."; - } - - /* * privileged methods */ - this._initialize = function(codebaseDirectory, fileNameOrUseSignedApplet) { + this._initialize = function(jarPath, jarFile) { + var doReport = false; if(this._jarFile) { var f = this._jarFile; if(f.indexOf("/") >= 0) { alert("This web page URL is requesting that the applet used be " + f + ". This is a possible security risk, particularly if the applet is signed, because signed applets can read and write files on your local machine or network."); var ok = prompt("Do you want to use applet " + f + "? ", "yes or no") if(ok == "yes") { - codebaseDirectory = f.substring(0, f.lastIndexOf("/")); - fileNameOrUseSignedApplet = f.substring(f.lastIndexOf("/") + 1); + jarPath = f.substring(0, f.lastIndexOf("/")); + jarFile = f.substring(f.lastIndexOf("/") + 1); } else { - getJarFilename(fileNameOrUseSignedApplet); - alert("The web page URL was ignored. Continuing using " + this._jarFile + ' in directory "' + codebaseDirectory + '"'); + doReport = true; } } else { - fileNameOrUseSignedApplet = f; + jarFile = f; } } - setCodebase(codebaseDirectory); - getJarFilename(fileNameOrUseSignedApplet); + this._jarPath = jarPath || "."; + this._jarFile = (typeof(jarFile) == "string" ? jarFile : (jarFile ? "JmolAppletSigned" : "JmolApplet") + "0.jar"); + if (doReport) + alert("The web page URL was ignored. Continuing using " + this._jarFile + ' in directory "' + this._jarPath + '"'); Jmol.controls == undefined || Jmol.controls._onloadResetForms(); - } - + } this._create(id, Info, caption); return this; - } Jmol._Applet.prototype._create = function(id, Info, caption){ @@ -97,7 +81,8 @@ progresscolor: "blue", boxbgcolor: Info.color || "black", boxfgcolor: "white", - boxmessage: "Downloading JmolApplet ..." + boxmessage: "Downloading JmolApplet ...", + script: (Info.color ? "background " + Info.color : "") }; var availableValues = "'progressbar','progresscolor','boxbgcolor','boxfgcolor','boxmessage',\ @@ -119,36 +104,27 @@ params.loadInline = (Info.inlineModel ? sterilizeInline(Info.inlineModel) : ""); params.appletReadyCallback = this._id + "._readyCallback"; - var myClass = "JmolApplet" - Jmol._createApplet(this, params, Info, myClass, null, caption); - - } - - Jmol._createApplet = function(applet, params, Info, myClass, script, caption) { - if (Jmol._syncedApplets.length) params.synccallback = "Jmol._mySyncCallback"; - params.java_arguments = "-Xmx" + Math.round(Info.memoryLimit || applet._memoryLimit) + "m"; + params.java_arguments = "-Xmx" + Math.round(Info.memoryLimit || this._memoryLimit) + "m"; - applet._initialize(Info.jarPath, Info.jarFile); + this._initialize(Info.jarPath, Info.jarFile); // size is set to 100% of containers' size, but only if resizable. // Note that resizability in MSIE requires: // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> - var w = (applet._containerWidth.indexOf("px") >= 0 ? applet._containerWidth : "100%"); - var h = (applet._containerHeight.indexOf("px") >= 0 ? applet._containerHeight : "100%"); + var w = (this._containerWidth.indexOf("px") >= 0 ? this._containerWidth : "100%"); + var h = (this._containerHeight.indexOf("px") >= 0 ? this._containerHeight : "100%"); var widthAndHeight = " style=\"width:" + w + ";height:" + h + "\" "; var tHeader, tFooter; if (Jmol.featureDetection.useIEObject || Jmol.featureDetection.useHtml4Object) { - params.archive = applet._jarFile; - if (script) - params.script = script; + params.archive = this._jarFile; params.mayscript = 'true'; - params.codebase = applet._jarPath; - params.code = myClass + ".class"; + params.codebase = this._jarPath; + params.code = "JmolApplet.class"; tHeader = - "<object name='" + applet._id + - "_object' id='" + applet._id + "_object' " + "\n" + + "<object name='" + this._id + + "_object' id='" + this._id + "_object' " + "\n" + widthAndHeight + "\n"; tFooter = "</object>"; } @@ -160,20 +136,20 @@ tHeader += " type='application/x-java-applet'\n>\n"; } else { // use applet tag tHeader = - "<applet name='" + applet._id + - "_object' id='" + applet._id + "_object' \n" + + "<applet name='" + this._id + "_object' " + + "id='" + this._id + "_object' \n" + widthAndHeight + "\n" + - " code='" + myClass + "'" + - " archive='" + applet._jarFile + "' codebase='" + applet._jarPath + "'\n" + + " code='JmolApplet'" + + " archive='" + this._jarFile + "' codebase='" + this._jarPath + "'\n" + " mayscript='true'>\n"; tFooter = "</applet>"; } var visitJava; if (Jmol.featureDetection.useIEObject || Jmol.featureDetection.useHtml4Object) { - var szX = "width:" + applet._width; + var szX = "width:" + this._width; if ( szX.indexOf("%")==-1 ) szX+="px"; - var szY = "height:" + applet._height; + var szY = "height:" + this._height; if ( szY.indexOf("%")==-1 ) szY+="px"; visitJava = "<p style='background-color:yellow; color:black; " + szX + ";" + szY + ";" + @@ -186,16 +162,16 @@ Jmol._noJavaMsg2 + "</font></td></tr></table>"; } - var t = Jmol._getWrapper(applet, true) + tHeader; + var t = Jmol._getWrapper(this, true) + tHeader; for (var i in params) if(params[i]) t+=" <param name='"+i+"' value='"+params[i]+"' />\n"; t += visitJava + tFooter - + Jmol._getWrapper(applet, false) - + (Info.addSelectionOptions ? Jmol._getGrabberOptions(applet, caption) : ""); + + Jmol._getWrapper(this, false) + + (Info.addSelectionOptions ? Jmol._getGrabberOptions(this, caption) : ""); if (Jmol._debugAlert) alert(t); - applet._code = Jmol._documentWrite(t); + this._code = Jmol._documentWrite(t); } Jmol._Applet.prototype._readyCallback = function(id, fullid, isReady, applet) { @@ -215,26 +191,30 @@ } Jmol._Applet.prototype._showInfo = function(tf) { + Jmol._getElement(this, "infoheaderspan").innerHTML = this._infoHeader; + if (this._info) + Jmol._getElement(this, "infodiv").innerHTML = this._info; if ((!this._isInfoVisible) == (!tf)) return; this._isInfoVisible = tf; // 1px does not work for MSIE - Jmol._getElement(this, "infotablediv").style.display = (tf ? "block" : "none"); var w = (tf ? "2px" : this._containerWidth.indexOf("px") >= 0 ? this._containerWidth : "100%"); var h = (tf ? "2px" : this._containerHeight.indexOf("px") >= 0 ? this._containerHeight : "100%"); - Jmol._getElement(this, "appletdiv").style.height = w; - Jmol._getElement(this, "appletdiv").style.width = h; + Jmol._getElement(this, "appletdiv").style.width = w; + Jmol._getElement(this, "appletdiv").style.height = h; + if (this._infoObject) { + this._infoObject._showInfo(tf); + } else { + Jmol._getElement(this, "infotablediv").style.display = (tf ? "block" : "none"); + } if (false && !tf)// -- occurring on Mac systems?) alert("returning to applet..." + w + " " + h); this._show(!tf); - if (tf) { - Jmol._getElement(this, "infoheaderdiv").innerHTML = this._infoHeader; - Jmol._getElement(this, "infodiv").innerHTML = this._info; - } } Jmol._Applet.prototype._search = function(query, script){ this._showInfo(false); + arguments.length > 1 || (query = null); Jmol._setQueryTerm(this, query); query || (query = Jmol._getElement(this, "query").value); query && (query = query.replace(/\"/g, "")); Modified: trunk/Jmol/appletweb/JmolAppletSigned.jar =================================================================== (Binary files differ) Modified: trunk/Jmol/appletweb/JmolCore.js =================================================================== --- trunk/Jmol/appletweb/JmolCore.js 2012-06-14 08:57:33 UTC (rev 17293) +++ trunk/Jmol/appletweb/JmolCore.js 2012-06-14 17:46:52 UTC (rev 17294) @@ -83,7 +83,7 @@ _restQueryXml: "<orgPdbQuery><queryType>org.pdb.query.simple.AdvancedKeywordQuery</queryType><description>Text Search</description><keywords>QUERY</keywords></orgPdbQuery>", _restReportUrl: "http://www.pdb.org/pdb/rest/customReport?pdbids=IDLIST&customReportColumns=structureId,structureTitle" }, - _getCanvas: function(){ /* only in JmolCD.js */ return null }, + _getCanvas: function(){ /* only in JmolCD.js or JmolGLmol.js */ return null }, _allowedJmolSize: [25, 2048, 300] // min, max, default (pixels) /* By setting the Jmol.allowedJmolSize[] variable in the webpage before calling Jmol.getApplet(), limits for applet size can be overriden. @@ -105,17 +105,26 @@ var info = Jmol._ajaxQueue.shift(); info && jQuery.ajax(info); } + + Jmol._grabberOptions = [ + ["$", "NCI(small molecules)"], + [":", "PubChem(small molecules)"], + ["=", "RCSB(macromolecules)"] + ]; + Jmol._getGrabberOptions = function(applet, note) { // feel free to adjust this look to anything you want if (!jQuery) return "" - return '<br /><input type="text" id="ID_query" onkeypress="13==event.which&&Jmol._applets[\'ID\']._search()"\ - size="32" value="" /><br /><nobr><select id="ID_select">\ - <option value="$" selected>NCI(small molecules)</option>\ - <option value=":">PubChem(small molecules)</option>\ - <option value="=">RCSB(macromolecules)</option>\ - </select>\<button id="ID_submit" onclick="Jmol._applets[\'ID\']._search()">Search</button></nobr>' + var s = '<br /><input type="text" id="ID_query" onkeypress="13==event.which&&Jmol._applets[\'ID\']._search()"\ + size="32" value="" /><br /><nobr><select id="ID_select">' + for (var i = 0; i < Jmol._grabberOptions.length; i++) { + var opt = Jmol._grabberOptions[i]; + s += '<option value="' + opt[0] + '" ' + (i == 0 ? 'selected' : '') + '>' + opt[1] + '</option>'; + } + s = (s + '</select>\<button id="ID_submit" onclick="Jmol._applets[\'ID\']._search()">Search</button></nobr>') .replace(/ID/g, applet._id) + (note ? note : ""); + return s; } Jmol._getWrapper = function(applet, isHeader) { @@ -126,9 +135,18 @@ if (typeof width !== "string" || width.indexOf("%") < 0) width += "px"; // for whatever reason, this outer table tag is required for MSIE compatibility + + // id_appletinfotablediv + // id_appletdiv + // id_infotablediv + // id_infoheaderdiv + // id_infoheaderspan + // id_infocheckboxspan + // id_infodiv + var s = (isHeader ? "<table style=\"width:Wpx;height:Hpx\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><div id=\"ID_appletinfotablediv\" style=\"width:100%;height:100%\"><div id=\"ID_appletdiv\" style=\"width:100%;height:100%\">" : "</div><div id=\"ID_infotablediv\" style=\"width:100%;height:100%;display:none;position:relative\">\ - <div style=\"height:20px;width:100%;background:yellow\"><span id=\"ID_infoheaderdiv\"></span><span style=\"position:absolute;width:10px;right:10px\"><a href=\"javascript:Jmol.showInfo(ID,false)\">[x]</a></span></div>\ + <div id=\"ID_infoheaderdiv\" style=\"height:20px;width:100%;background:yellow\"><span id=\"ID_infoheaderspan\"></span><span id=\"ID_infocheckboxspan\" style=\"position:absolute;width:10px;right:10px\"><a href=\"javascript:Jmol.showInfo(ID,false)\">[x]</a></span></div>\ <div id=\"ID_infodiv\" style=\"position:absolute;top:20px;bottom:0px;width:100%;height:95%;overflow-y:scroll\"></div></div></div></td></tr></table>"); if (width.indexOf("px") >= 0) s = s.replace(/width:100%/g, "width:" + width); @@ -591,6 +609,12 @@ obj._src = Info.src; } + Jmol._addDefaultInfo = function(Info, DefaultInfo) { + for (x in DefaultInfo) + if (typeof Info[x] == "undefined") + Info[x] = DefaultInfo[x]; + } + Jmol._cleanFileData = function(data) { if (data.indexOf("\r") >= 0 && data.indexOf("\n") >= 0) { return data.replace(/\r\n/g,"\n"); Modified: trunk/Jmol/appletweb/JmolGLmol.js =================================================================== --- trunk/Jmol/appletweb/JmolGLmol.js 2012-06-14 08:57:33 UTC (rev 17293) +++ trunk/Jmol/appletweb/JmolGLmol.js 2012-06-14 17:46:52 UTC (rev 17294) @@ -21,12 +21,11 @@ Jmol._getCanvas = function(id, Info, checkOnly) { // overrides the function in JmolCore.js var canvas = null; - if (Info.useWebGlIfAvailable && Jmol.featureDetection.supportsWebGL()) + if (Info.useWebGlIfAvailable && Jmol.featureDetection.supportsWebGL()) { canvas = new Jmol._Canvas3D(id, Info, null, checkOnly); - else - return null; - if (Jmol._document) - canvas._readyCallback(id, id, true, null); + if (Jmol._document) + canvas._readyCallback(id, id, true, null); + } return canvas; } @@ -49,9 +48,7 @@ //console.log(this); if (Jmol._document) { Jmol._documentWrite(t); - this.glmol = new GLmol(id + "_appletdiv", true); - this.glmol.defineRepresentation = Jmol._glmol_DefineRep; - this.glmol.wrapper = this; + this.create(id + "_appletdiv", true); this._setDefaults(); t = ""; } else { @@ -83,12 +80,12 @@ switch (Cmd.substring(0, pt)) { case "SETTING": switch (what) { - case "Ball and Stick": this.hetatmMode = 'ballAndStick2'; break; - case "Line": this.hetatmMode = 'line'; break; - case "van der Waals Spheres": this.hetatmMode = 'sphere'; break; + case "Ball and Stick": this._hetatmMode = 'ballAndStick2'; break; + case "Line": this._hetatmMode = 'line'; break; + case "van der Waals Spheres": this._hetatmMode = 'sphere'; break; } - this.glmol.rebuildScene(); - this.glmol.show(); + this.rebuildScene(); + this.show(); return; case "LOAD": if (what.indexOf("??") >= 0) { @@ -129,102 +126,102 @@ Jmol._loadFileData(glcanvas, fileName, function(data){Jmol._glProcessFileData(glcanvas, data, script)}); }; + proto.defineRepresentation = function() { + var all = this.getAllAtoms(); + var allHet = this.getHetatms(all); + var hetatm = this.removeSolvents(allHet); + this.colorByAtom(all, {}); + switch (this._colorMode) { + case 'ss': this.colorByStructure(all, 0xcc00cc, 0x00cccc); break; + case 'chain': this.colorByChain(all); break; + case 'chainbow': this.colorChainbow(all); break; + case 'b': this.colorByBFactor(all); break; + case 'polarity': this.colorByPolarity(all, 0xcc0000, 0xcccccc); break; + } + + var asu = new THREE.Object3D(); + switch (this._mainchainMode) { + case 'ribbon': + this.drawCartoon(asu, all, this.wraper.doNotSmoothen); + this.drawCartoonNucleicAcid(asu, all); + break; + case 'thickRibbon': + this.drawCartoon(asu, all, this.doNotSmoothen, this.thickness); + this.drawCartoonNucleicAcid(asu, all, null, this.thickness); + break; + case 'strand': + this.drawStrand(asu, all, null, null, null, null, null, doNotSmoothen); + this.drawStrandNucleicAcid(asu, all); + break; + case 'chain': + this.drawMainchainCurve(asu, all, this.curveWidth, 'CA', 1); + this.drawMainchainCurve(asu, all, this.curveWidth, 'O3\'', 1); + break; + case 'tube': + this.drawMainchainTube(asu, all, 'CA'); + this.drawMainchainTube(asu, all, 'O3\''); + break; + case 'bonds': + this.drawBondsAsLine(asu, all, this.lineWidth); + break; + } + + if (this.drawSidechains) + this.drawBondsAsLine(this.modelGroup, this.getSidechains(all), this.lineWidth); + + switch (this.baseMode) { + case 'nuclStick': this.drawNucleicAcidStick(this.modelGroup, all); break; + case 'nuclLine': this.drawNucleicAcidLine(this.modelGroup, all); break; + case 'nuclPolygon': this.drawNucleicAcidLadder(this.modelGroup, all); break; + } + + var target = this.symopAtoms ? asu : this.modelGroup; + if (this.showNonbonded) { + var nonBonded = this.getNonbonded(allHet); + if (this.nbMode == 'nb_sphere') { + this.drawAtomsAsIcosahedron(target, nonBonded, 0.3, true); + } else if (this.nbMode == 'nb_cross') { + this.drawAsCross(target, nonBonded, 0.3, true); + } + } + + switch (this._hetatmMode) { + case 'stick': this.drawBondsAsStick(target, hetatm, this.cylinderRadius, this.cylinderRadius, true); break; + case 'sphere': this.drawAtomsAsSphere(target, hetatm, this.sphereRadius); break; + case 'line': this.drawBondsAsLine(target, hetatm, this.curveWidth); break; + case 'ballAndStick': this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, false, 0.3); break; + case 'ballAndStick2': this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, true, 0.3); break; + } + + this.setBackground(this._backgroundColor); + + if (this.showCell) + this.drawUnitcell(this.modelGroup); + + if (this.drawBiomt) + this.drawSymmetryMates2(this.modelGroup, asu, this.protein.biomtMatrices); + + if (this.drawPacking) + this.drawSymmetryMatesWithTranslation2(this.modelGroup, asu, this.protein.symMat); + this.modelGroup.add(asu); + }; + return proto; }; - Jmol._Canvas3D.prototype = _glSetPrototype({}); + Jmol._Canvas3D.prototype = _glSetPrototype(new GLmol); - Jmol._Canvas3D.prototype._setDefaults = function() { - this.backgroundColor = 0x000000; - this.hetatmMode = 'ballAndStick2'; - this.mainchainMode = 'thickRibbon'; - this.colorMode = 'chainbow'; - }; + Jmol._Canvas3D.prototype._setDefaults = function() { + this._backgroundColor = 0x000000; + this._hetatmMode = 'ballAndStick2'; + this._mainchainMode = 'thickRibbon'; + this._colorMode = 'chainbow'; + }; Jmol._glProcessFileData = function(glcanvas, data, script) { - glcanvas.glmol.loadMoleculeStr(false, Jmol._cleanFileData(data)); + glcanvas.loadMoleculeStr(false, Jmol._cleanFileData(data)); script && Jmol.script(glcanvas, script); }; - Jmol._glmol_DefineRep = function() { - // "this" is glcanvas.glmol - var all = this.getAllAtoms(); - var allHet = this.getHetatms(all); - var hetatm = this.removeSolvents(allHet); - this.colorByAtom(all, {}); - switch (this.wrapper.colorMode) { - case 'ss': this.colorByStructure(all, 0xcc00cc, 0x00cccc); break; - case 'chain': this.colorByChain(all); break; - case 'chainbow': this.colorChainbow(all); break; - case 'b': this.colorByBFactor(all); break; - case 'polarity': this.colorByPolarity(all, 0xcc0000, 0xcccccc); break; - } - - var asu = new THREE.Object3D(); - switch (this.wrapper.mainchainMode) { - case 'ribbon': - this.drawCartoon(asu, all, this.wraper.doNotSmoothen); - this.drawCartoonNucleicAcid(asu, all); - break; - case 'thickRibbon': - this.drawCartoon(asu, all, this.wrapper.doNotSmoothen, this.thickness); - this.drawCartoonNucleicAcid(asu, all, null, this.thickness); - break; - case 'strand': - this.drawStrand(asu, all, null, null, null, null, null, doNotSmoothen); - this.drawStrandNucleicAcid(asu, all); - break; - case 'chain': - this.drawMainchainCurve(asu, all, this.curveWidth, 'CA', 1); - this.drawMainchainCurve(asu, all, this.curveWidth, 'O3\'', 1); - break; - case 'tube': - this.drawMainchainTube(asu, all, 'CA'); - this.drawMainchainTube(asu, all, 'O3\''); - break; - case 'bonds': - this.drawBondsAsLine(asu, all, this.lineWidth); - break; - } - - if (this.wrapper.drawSidechains) - this.drawBondsAsLine(this.modelGroup, this.getSidechains(all), this.lineWidth); - - switch (this.wrapper.baseMode) { - case 'nuclStick': this.drawNucleicAcidStick(this.modelGroup, all); break; - case 'nuclLine': this.drawNucleicAcidLine(this.modelGroup, all); break; - case 'nuclPolygon': this.drawNucleicAcidLadder(this.modelGroup, all); break; - } - - var target = this.wrapper.symopAtoms ? asu : this.modelGroup; - if (this.wrapper.showNonbonded) { - var nonBonded = this.getNonbonded(allHet); - if (this.wrapper.nbMode == 'nb_sphere') { - this.drawAtomsAsIcosahedron(target, nonBonded, 0.3, true); - } else if (this.wrapper.nbMode == 'nb_cross') { - this.drawAsCross(target, nonBonded, 0.3, true); - } - } - - switch (this.wrapper.hetatmMode) { - case 'stick': this.drawBondsAsStick(target, hetatm, this.cylinderRadius, this.cylinderRadius, true); break; - case 'sphere': this.drawAtomsAsSphere(target, hetatm, this.sphereRadius); break; - case 'line': this.drawBondsAsLine(target, hetatm, this.curveWidth); break; - case 'ballAndStick': this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, false, 0.3); break; - case 'ballAndStick2': this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, true, 0.3); break; - } - - this.setBackground(this.wrapper.backgroundColor); - - if (this.wrapper.showCell) - this.drawUnitcell(this.modelGroup); - - if (this.wrapper.drawBiomt) - this.drawSymmetryMates2(this.modelGroup, asu, this.protein.biomtMatrices); - - if (this.wrapper.drawPacking) - this.drawSymmetryMatesWithTranslation2(this.modelGroup, asu, this.protein.symMat); - this.modelGroup.add(asu); - }; })(Jmol); Added: trunk/Jmol/appletweb/JmolJME.js =================================================================== --- trunk/Jmol/appletweb/JmolJME.js (rev 0) +++ trunk/Jmol/appletweb/JmolJME.js 2012-06-14 17:46:52 UTC (rev 17294) @@ -0,0 +1,99 @@ +/* + JmolJME.js Bob Hanson ha...@st... 6/14/2012 + + JME 2D option -- use Jmol.getJMEApplet(id, Info, linkedApplet) to access + + linkedApplet puts JME into INFO block for that applet; + use Jmol.showInfo(jmol,true/false) to show/hide JME + + see http://chemapps.stolaf.edu/jmol/jme for files and demo + + There is a bug in JME that the first time it loads a model, it centers it, + but after that, it fails to center it. Could get around that, perhaps, by + creating a new JME applet each time. + + JME licensing: http://www.molinspiration.com/jme/doc/index.html + note that required boilerplate: "JME Editor courtesy of Peter Ertl, Novartis" + + + these methods are private to JmolJME.js + +*/ + +(function (Jmol, document) { + + Jmol._JMEApplet = function(id, Info, linkedApplet) { + this._jmolType = "Jmol._JME"; + Jmol._setObject(this, id, Info); + this._linkedApplet = linkedApplet; + this._jarFile = Info.jarFile || "JME.jar"; + this._jarPath = Info.jarPath || "."; + if (Jmol._document) { + if (this._linkedApplet) { + this._linkedApplet._infoObject = this; + this._linkedApplet._info = null; + var d = Jmol._getElement(this._linkedApplet, "infotablediv"); + d.style.display = "block"; + var d = Jmol._getElement(this._linkedApplet, "infodiv"); + Jmol._document = null; + d.innerHTML = this.create(); + Jmol._document = document; + this._showContainer(false); + } else { + this.create(); + } + } + return this; + } + + Jmol._JMEApplet.prototype.create = function() { + var w = (this._linkedApplet ? "2px" : this._containerWidth); + var h = (this._linkedApplet ? "2px" : this._containerHeight); + var s = '<applet code="JME.class" id="' + this._id + '_object" name="' + this._id + + '_object" archive="' + this._jarFile + '" codebase="' + this._jarPath + '" width="'+w+'" height="'+h+'">' + + '<param name="options" value="autoez" />' + + '</applet>'; + return this._code = Jmol._documentWrite(s); + } + + Jmol._JMEApplet.prototype._showInfo = function(tf) { + // from applet, so here is where we do the SMILES transfer + var jme = this._applet = Jmol._getElement(this, "object"); + var jmol = this._linkedApplet; + var jmeSMILES = jme.smiles(); + var jmolAtoms = jmeSMILES ? Jmol.evaluate(jmol, "{*}.find('SMILES', '" + jmeSMILES + "')") : "({})"; + var isOK = (jmolAtoms != "({})"); + if (!isOK) { + if (tf) { + // toJME + this._molData = Jmol.evaluate(jmol, "write('mol')") + setTimeout(this._id+"._applet.reset();"+this._id+"._applet.readMolFile("+this._id+"._molData)",100); + } else { + // toJmol + if (jmeSMILES) + Jmol.script(jmol, "load \"$" + jmeSMILES + "\""); + } + } + this._showContainer(tf); + this._show(tf); + } + + Jmol._JMEApplet.prototype._show = function(tf) { + var w = (!tf ? "2px" : "100%"); + var h = (!tf ? "2px" : "100%"); + Jmol._getElement(this, "object").style.width = w; + Jmol._getElement(this, "object").style.height = h; + Jmol._getElement(this._linkedApplet, "infoheaderspan").innerHTML = (tf ? this : this._linkedApplet)._infoHeader; + } + + Jmol._JMEApplet.prototype._showContainer = function(tf) { + var d = Jmol._getElement(this._linkedApplet, "infoheaderdiv"); + d.style.display = (tf ? "block" : "none"); + var w = (!tf ? "2px" : this._linkedApplet ? "100%" : this._containerWidth); + var h = (!tf ? "2px" : this._linkedApplet ? "100%" : this._containerHeight); + var d = Jmol._getElement(this._linkedApplet, "infotablediv"); + d.style.width = w; + d.style.height = h; + } + +})(Jmol, document); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |