Revision: 20341 http://sourceforge.net/p/jmol/code/20341 Author: hansonr Date: 2015-02-28 17:15:25 +0000 (Sat, 28 Feb 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.12_2015.02.28"
note: show image replaced by new command IMAGE new feature: image 300 400 # adjustable size new feature: image CLOSE "" # the model image new feature: image CLOSE "c:/temp/t.bmp" # the image for this file new feature: image CLOSE # close all new feature: image ID ... -- id for IMAGE CLOSE; -- displayed in title of frame -- examples: image ID "test" image ID "test" 400 500 image ID "test" "bob.png" image ID "test" close new feature: write IMAGE -- same as IMAGE new feature: write IMAGE 500 500 -- same as IMAGE 500 500 Modified Paths: -------------- trunk/Jmol/src/org/jmol/console/GenericConsole.java trunk/Jmol/src/org/jmol/script/ScriptEval.java trunk/Jmol/src/org/jmol/script/T.java trunk/Jmol/src/org/jmol/scriptext/CmdExt.java trunk/Jmol/src/org/jmol/viewer/FileManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/StatusManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/console/GenericConsole.java =================================================================== --- trunk/Jmol/src/org/jmol/console/GenericConsole.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/console/GenericConsole.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -297,34 +297,77 @@ @Override public boolean notifyEnabled(CBK type) { // See org.jmol.viewer.JmolConstants.java for a complete list - switch (type) { - case ECHO: - case MEASURE: - case MESSAGE: - case PICK: - return true; - case ANIMFRAME: - case APPLETREADY: - case ATOMMOVED: - case CLICK: - case DRAGDROP: - case ERROR: - case EVAL: - case HOVER: - case IMAGE: - case LOADSTRUCT: - case MINIMIZATION: - case SERVICE: - case RESIZE: - case SCRIPT: - case SYNC: - case STRUCTUREMODIFIED: - break; + // ignore in JavaScript + /** + * @j2sNative + * + * + */ + { + switch (type) { + case ECHO: + case MEASURE: + case MESSAGE: + case PICK: + return true; + case ANIMFRAME: + case APPLETREADY: + case ATOMMOVED: + case CLICK: + case DRAGDROP: + case ERROR: + case EVAL: + case HOVER: + case IMAGE: + case LOADSTRUCT: + case MINIMIZATION: + case SERVICE: + case RESIZE: + case SCRIPT: + case SYNC: + case STRUCTUREMODIFIED: + break; + } } return false; } @Override + @SuppressWarnings("incomplete-switch") + public void notifyCallback(CBK type, Object[] data) { + // ignore in JavaScript + /** + * @j2sNative + * + * + */ + { + String strInfo = (data == null || data[1] == null ? null : data[1] + .toString()); + switch (type) { + case ECHO: + sendConsoleEcho(strInfo); + break; + case MEASURE: + String mystatus = (String) data[3]; + if (mystatus.indexOf("Picked") >= 0 + || mystatus.indexOf("Sequence") >= 0) // picking mode + sendConsoleMessage(strInfo); + else if (mystatus.indexOf("Completed") >= 0) + sendConsoleEcho(strInfo.substring(strInfo.lastIndexOf(",") + 2, + strInfo.length() - 1)); + break; + case MESSAGE: + sendConsoleMessage(data == null ? null : strInfo); + break; + case PICK: + sendConsoleMessage(strInfo); + break; + } + } + } + + @Override public String getText() { return output.getText(); } @@ -363,32 +406,6 @@ } @Override - @SuppressWarnings("incomplete-switch") - public void notifyCallback(CBK type, Object[] data) { - String strInfo = (data == null || data[1] == null ? null : data[1] - .toString()); - switch (type) { - case ECHO: - sendConsoleEcho(strInfo); - break; - case MEASURE: - String mystatus = (String) data[3]; - if (mystatus.indexOf("Picked") >= 0 || mystatus.indexOf("Sequence") >= 0) // picking mode - sendConsoleMessage(strInfo); - else if (mystatus.indexOf("Completed") >= 0) - sendConsoleEcho(strInfo.substring(strInfo.lastIndexOf(",") + 2, strInfo - .length() - 1)); - break; - case MESSAGE: - sendConsoleMessage(data == null ? null : strInfo); - break; - case PICK: - sendConsoleMessage(strInfo); - break; - } - } - - @Override public void setCallbackFunction(String callbackType, String callbackFunction) { // application-dependent option } Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/script/ScriptEval.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -2506,6 +2506,7 @@ case T.connect: case T.console: case T.hbond: // hbond connect + case T.image: case T.stereo: case T.mapproperty: case T.minimize: Modified: trunk/Jmol/src/org/jmol/script/T.java =================================================================== --- trunk/Jmol/src/org/jmol/script/T.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/script/T.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -305,34 +305,35 @@ public final static int bind = scriptCommand | 4; public final static int bondorder = scriptCommand | 5; public final static int calculate = scriptCommand | 6; -//public final static int cache see mathfunc +//public final static int cache see mathfunc public final static int capture = scriptCommand | 7; public final static int cd = scriptCommand | 8 /* must be even */| implicitStringCommand | expression; // must be even public final static int centerat = scriptCommand | 9; -//public final static int color see intproperty +//public final static int color see intproperty //public final static int configuration see intproperty - public final static int connect = scriptCommand | 10; + public final static int connect = scriptCommand | 10; public final static int console = scriptCommand | 11 | defaultON; -//public final static int data see mathfunc +//public final static int data see mathfunc public final static int delay = scriptCommand | 13 | defaultON; - public final static int depth = scriptCommand | 14 | intparam | defaultON; + public final static int depth = scriptCommand | 14 | intparam | defaultON; public final static int exit = scriptCommand | 15 | noArgs; public final static int exitjmol = scriptCommand | 16 | noArgs; -//public final static int file see intproperty +//public final static int file see intproperty public final static int font = scriptCommand | 18; public final static int frame = scriptCommand | 19; //public final static int getproperty see mathfunc public final static int gotocmd = scriptCommand | 20 /*must be even*/| implicitStringCommand; - public final static int hbond = scriptCommand | 22 | deprecatedparam | expression | defaultON; + public final static int hbond = scriptCommand | 22 | deprecatedparam | expression | defaultON; public final static int history = scriptCommand | 23 | deprecatedparam; - public final static int initialize = scriptCommand | 24 | noArgs; - public final static int invertSelected = scriptCommand | 25; -//public final static int load see mathfunc - public final static int loop = scriptCommand | 26 | defaultON; + public final static int image = scriptCommand | 24; + public final static int initialize = scriptCommand | 25 | noArgs; + public final static int invertSelected = scriptCommand | 26; +//public final static int load see mathfunc + public final static int loop = scriptCommand | 27 | defaultON; public final static int mapproperty = scriptCommand | 28 | expression; public final static int minimize = scriptCommand | 30; -//public final static int model see mathfunc -//public final static int measure see mathfunc +//public final static int model see mathfunc +//public final static int measure see mathfunc public final static int move = scriptCommand | 32; public final static int moveto = scriptCommand | 33; public final static int mutate = scriptCommand | 34; @@ -341,8 +342,8 @@ public final static int parallel = flowCommand | 36; public final static int plot = scriptCommand | 37; public final static int process = flowCommand | 39; -// public final static int prompt see mathfunc -// public final static int push see mathfunc = scriptCommand | 40 | noArgs; //internal only +// public final static int prompt see mathfunc +// public final static int push see mathfunc //internal only public final static int quit = scriptCommand | 41 | noArgs; public final static int ramachandran = scriptCommand | 42 | expression; public final static int redomove = scriptCommand | 43; @@ -1207,7 +1208,6 @@ public final static int ignore = misc | 152; public final static int inchi = misc | 153; public final static int inchikey = misc | 154; - public final static int image = misc | 155; public final static int increment = misc | 157; public final static int info = misc | 158; public final static int inline = misc | 159; Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -149,6 +149,9 @@ case T.hbond: connect(0); break; + case T.image: + image(); + break; case T.mapproperty: mapProperty(); break; @@ -1870,6 +1873,58 @@ setShapeProperty(JC.SHAPE_ELLIPSOIDS, "thisID", null); } + private void image() throws ScriptException { + // image ... + // image id XXXX... + // ... "filename" + // ... close + // ... close "filename" + if (!chk) + vwr.getConsole();// especially important for JavaScript + int pt = 1; + String id = null; + if (tokAt(1) == T.id) { + // image ID ... + id = e.optParameterAsString(++pt); + pt++; + } + String fileName = e.optParameterAsString(pt); + if (!fileName.equals("close") && (slen == pt || slen == pt + 2)) { + // image + // image 400 400 + // image id "testing" + // image id "testing" 400 400 + int width = (slen == pt + 2 ? intParameter(pt++) : -1); + int height = (width < 0 ? -1 : intParameter(pt)); + Map<String, Object> params = new Hashtable<String, Object>(); + params.put("fileName", "\1\1" + id); + params.put("backgroundColor", Integer.valueOf(vwr.getBackgroundArgb())); + params.put("type", "png"); + params.put("quality", Integer.valueOf(-1)); + params.put("width", Integer.valueOf(width)); + params.put("height", Integer.valueOf(height)); + if (!chk) + vwr.processWriteOrCapture(params); + return; + } + pt++; + boolean isClose = false; + if (fileName.equalsIgnoreCase("close")) { + // image close + // image ID "testing" close + // image close "filename" + e.checkLength(slen == pt || id != null ? pt : pt + 1); + isClose = true; + fileName = (slen == pt && id == null ? "closeall" : e + .optParameterAsString(pt)); + } else { + e.checkLength(pt); + } + if (!chk) + vwr.fm.loadImage(isClose ? "\1close" : fileName, "\1" + fileName + "\1" + + id); + } + private void mapProperty() throws ScriptException { // map {1.1}.straightness {2.1}.property_x resno BS bsFrom, bsTo; @@ -2997,16 +3052,16 @@ boolean isCommand = true; boolean showOnly = false; if (args == null) { - // write command or show IMAGE + // write command args = st; showOnly = (vwr.isApplet && !vwr.isSignedApplet || !vwr.haveAccess(ACCESS.ALL) || vwr.fm.getPathForAllFiles() .length() > 0); } else { - // write() function + // write() function or image pt = pt0 = 0; - isCommand = false; - showOnly = true; + isCommand = (args == st); + showOnly = !isCommand; } // check for special considerations involving first parameter @@ -3058,7 +3113,7 @@ // accept write ...... AS type - if (tok != T.nada && isCommand && tokAt(slen - 2) == T.as) { + if (tok != T.nada && isCommand && slen > 1 && tokAt(slen - 2) == T.as) { type = paramAsStr(slen - 1).toUpperCase(); pt0 = argCount; argCount -= 2; @@ -3605,7 +3660,7 @@ if (token != null) tok = token.tok; } - if (tok != T.symop && tok != T.state && tok != T.property && tok != T.image) + if (tok != T.symop && tok != T.state && tok != T.property) checkLength(-3); if (slen == 2 && str.indexOf("?") >= 0) { showString(vwr.getAllSettings(str.substring(0, str.indexOf("?")))); @@ -3616,30 +3671,6 @@ if (!chk) msg = ((SV) eval.theToken).escape(); break; - case T.image: - vwr.getConsole();// especially important for JavaScript - if (slen == 2 || slen == 4 && !chk) { - // show image - // show image 400 400 - write(null); - return; - } - // show image close - // show image close "myfile" - String fileName = eval.optParameterAsString(2); - boolean isClose = false; - if (fileName.equalsIgnoreCase("close")) { - eval.checkLength(-4); - isClose = true; - fileName = (slen == 3 ? "none" : eval.optParameterAsString(3)); - } else { - eval.checkLength23(); - } - len = st.length; - if (!chk) - vwr.fm.loadImage(len == 2 ? null : isClose ? "\1close" : fileName, "\1" + fileName); - str = null; - break; case T.domains: eval.checkLength23(); len = st.length; Modified: trunk/Jmol/src/org/jmol/viewer/FileManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/FileManager.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/viewer/FileManager.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -906,10 +906,10 @@ Object image = null; String nameOrError = null; byte[] bytes = null; - boolean isWriteImage = (echoName != null && echoName.startsWith("\1")); - if (isWriteImage) { - if (echoName.equals("\1none")) { - vwr.loadImageData(Boolean.TRUE, "\1none", echoName, null); + boolean isShowImage = (echoName != null && echoName.startsWith("\1")); + if (isShowImage) { + if (echoName.equals("\1closeall\1null")) { + vwr.loadImageData(Boolean.TRUE, "\1closeall", "\1closeall", null); return; } if ("\1close".equals(nameOrBytes)) { @@ -945,7 +945,7 @@ } if (!vwr.isJS && image != null && bytes != null) nameOrError = ";base64," + Base64.getBase64(bytes).toString(); - if (!vwr.isJS || isWriteImage && nameOrError == null) + if (!vwr.isJS || isShowImage && nameOrError == null) vwr.loadImageData(image, nameOrError, echoName, null); // JSmol will call that from awtjs2d.Platform.java asynchronously } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-02-28 17:15:25 UTC (rev 20341) @@ -14,8 +14,35 @@ TODO: remove HTML5 dependency on synchronous file loading (check SCRIPT command for problems) -Jmol.___JmolVersion="14.3.12_2015.02.26" +Jmol.___JmolVersion="14.3.12_2015.02.28" +note: show image replaced by new command IMAGE + +new feature: image 300 400 # adjustable size +new feature: image CLOSE "" # the model image +new feature: image CLOSE "c:/temp/t.bmp" # the image for this file +new feature: image CLOSE # close all +new feature: image ID ... + -- id for IMAGE CLOSE; + -- displayed in title of frame + -- examples: + + image ID "test" + image ID "test" 400 500 + image ID "test" "bob.png" + image ID "test" close + + +new feature: write IMAGE + -- same as IMAGE + +new feature: write IMAGE 500 500 + -- same as IMAGE 500 500 + + + +JmolVersion="14.3.12_2015.02.26" + bug fix: imageFontScaling integer instead of float; does not scale appropriately on resize bug fix: writing image of MO fails to write info (Jmol 12 or before) @@ -46,6 +73,8 @@ JmolVersion="14.3.12_2015.02.24" +// 02.28 removes "show " from these + new feature: show IMAGE -- pops up a frame with the current image -- allows "Save As..." Modified: trunk/Jmol/src/org/jmol/viewer/StatusManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StatusManager.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/viewer/StatusManager.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -86,7 +86,7 @@ public class StatusManager { protected Viewer vwr; - private JmolStatusListener jsl; + JmolStatusListener jsl; JmolCallbackListener cbl; public String statusList = ""; @@ -246,16 +246,7 @@ return list; } - synchronized void setJmolStatusListener(JmolStatusListener jmolStatusListener, JmolCallbackListener jmolCallbackListener) { - this.jsl = jmolStatusListener; - this.cbl = (jmolCallbackListener == null ? (JmolCallbackListener) jmolStatusListener : jmolCallbackListener); - } - - synchronized void setJmolCallbackListener(JmolCallbackListener jmolCallbackListener) { - this.cbl = jmolCallbackListener; - } - - Map<CBK, String> jmolScriptCallbacks = new Hashtable<CBK, String>(); + private Map<CBK, String> jmolScriptCallbacks = new Hashtable<CBK, String>(); private String jmolScriptCallback(CBK callback) { String s = jmolScriptCallbacks.get(callback); @@ -361,7 +352,7 @@ * called by Viewer.loadImageData to pop up a window with an image in it * * @param title - * @param image or Boolean.TRUE for "none" or Boolean.FALSE for "close" + * @param image or Boolean.TRUE for "close all" or Boolean.FALSE for "close" */ synchronized void showImage(String title, Object image) { String sJmol = jmolScriptCallback(CBK.IMAGE); @@ -379,6 +370,9 @@ } if (imageMap == null) imageMap = new Hashtable<String, GenericImageDialog>(); + title = title.substring(title.indexOf("\1") + 1); + if (title.equals("null")) + title = ""; GenericImageDialog d = imageMap.get(title); if (Boolean.FALSE.equals(image)) { if (d != null) Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-02-26 15:45:30 UTC (rev 20340) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2015-02-28 17:15:25 UTC (rev 20341) @@ -4186,13 +4186,13 @@ } @Override - public void setJmolCallbackListener(JmolCallbackListener jmolCallbackListener) { - sm.setJmolCallbackListener(jmolCallbackListener); + public void setJmolCallbackListener(JmolCallbackListener listener) { + sm.cbl = listener; } @Override - public void setJmolStatusListener(JmolStatusListener jmolStatusListener) { - sm.setJmolStatusListener(jmolStatusListener, null); + public void setJmolStatusListener(JmolStatusListener listener) { + sm.cbl = sm.jsl = listener; } public Lst<Lst<Lst<Object>>> getStatusChanged(String statusNameList) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits