From: jprocter Date: Thu, 17 Jun 2010 15:53:13 +0000 (+0000) Subject: update to Jmol series 12 (JAL-582) X-Git-Tag: Release_2_6~176 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ea990f32cf34a867377d25f7fc05bfbfb15f6fb3;p=jalview.git update to Jmol series 12 (JAL-582) --- diff --git a/.classpath b/.classpath index 93d1eaf..d29d712 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,7 @@ - + @@ -15,10 +15,10 @@ - - + + diff --git a/lib/Jmol-11.0.2.jar b/lib/Jmol-11.0.2.jar deleted file mode 100644 index 4c428e1..0000000 Binary files a/lib/Jmol-11.0.2.jar and /dev/null differ diff --git a/lib/Jmol-12.0.RC18.jar b/lib/Jmol-12.0.RC18.jar new file mode 100644 index 0000000..d026d2d Binary files /dev/null and b/lib/Jmol-12.0.RC18.jar differ diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index caaffa2..28eb61a 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -29,6 +29,8 @@ import org.jmol.api.*; import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.popup.*; +import org.jmol.viewer.JmolConstants; + import jalview.schemes.*; public class AppletJmol extends EmbmenuFrame implements StructureListener, @@ -187,14 +189,10 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, embedMenuIfNeeded(renderPanel); this.add(renderPanel, BorderLayout.CENTER); viewer = JmolViewer.allocateViewer(renderPanel, - new SmarterJmolAdapter()); - - viewer.setAppletContext("jalview", ap.av.applet.getDocumentBase(), - ap.av.applet.getCodeBase(), null); - - viewer.setJmolStatusListener(this); + new SmarterJmolAdapter(), "jalviewJmol", ap.av.applet.getDocumentBase(), + ap.av.applet.getCodeBase(), "", this); - jmolpopup = JmolPopup.newJmolPopup(viewer); + jmolpopup = JmolPopup.newJmolPopup(viewer, true, "Jmol", true); this.addWindowListener(new WindowAdapter() { @@ -706,13 +704,8 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, { } - public void setCallbackFunction(String callbackType, - String callbackFunction) - { - } - public void notifyFileLoaded(String fullPathName, String fileName, - String modelName, Object clientFile, String errorMsg) + String modelName, String errorMsg, int modelParts) { if (errorMsg != null) { @@ -725,6 +718,7 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, if (fileName != null) { + // TODO: do some checking using the modelPts number of parts against our own estimate of the number of chains // FILE LOADED OK jmolpopup.updateComputedMenus(); viewer @@ -786,15 +780,6 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, return; } - public void notifyFrameChanged(int frameNo) - { - boolean isAnimationRunning = (frameNo <= -2); - } - - public void notifyScriptStart(String statusMessage, String additionalInfo) - { - } - public void sendConsoleEcho(String strEcho) { if (scriptWindow == null) @@ -823,16 +808,15 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) { - notifyAtomPicked(iatom, strMeasure); - } - - public void notifyNewDefaultModeMeasurement(int count, String strInfo) - { + notifyAtomPicked(iatom, strMeasure, null); } - public void notifyAtomPicked(int atomIndex, String strInfo) + public void notifyAtomPicked(int atomIndex, String strInfo, String strData) { - + if (strData!=null) + { + System.err.println("Ignoring additional pick data string "+strData); + } int chainSeparator = strInfo.indexOf(":"); if (chainSeparator == -1) @@ -845,7 +829,7 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, picked += strInfo.substring(strInfo.indexOf(":") + 1, strInfo .indexOf(".")); - picked += ".CA"; + picked = "(("+picked+".CA" + ")|("+picked+".P"+"))"; if (!atomsPicked.contains(picked)) { @@ -859,14 +843,15 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, } } - public void notifyAtomHovered(int atomIndex, String strInfo) + public void notifyAtomHovered(int atomIndex, String strInfo, String data) { + if (data!=null) + { + System.err.println("Ignoring additional hover info: "+data); + } mouseOverStructure(atomIndex, strInfo); } - public void sendSyncScript(String script, String appletName) - { - } public void showUrl(String url) { @@ -898,9 +883,9 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, validate(); } - public float functionXY(String functionName, int x, int y) + public float[][] functionXY(String functionName, int x, int y) { - return 0; + return null ; } // /End JmolStatusListener @@ -937,4 +922,97 @@ public class AppletJmol extends EmbmenuFrame implements StructureListener, } } + @Override + public String createImage(String fileName, String type, + Object textOrBytes, int quality) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public float[][][] functionXYZ(String functionName, int nx, int ny, int nz) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public Hashtable getRegistryInfo() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public void notifyCallback(int type, Object[] data) + { + try { + switch (type) + { + case JmolConstants.CALLBACK_LOADSTRUCT: + notifyFileLoaded((String) data[1], (String) data[2], + (String) data[3], (String) data[4], ((Integer) data[5]).intValue()); + + break; + case JmolConstants.CALLBACK_PICK: + notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]); + // also highlight in alignment + case JmolConstants.CALLBACK_HOVER: + notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]); + break; + case JmolConstants.CALLBACK_SCRIPT: + notifyScriptTermination((String)data[2], ((Integer)data[3]).intValue()); + break; + case JmolConstants.CALLBACK_ECHO: + sendConsoleEcho((String)data[1]); + break; + case JmolConstants.CALLBACK_MESSAGE: + sendConsoleMessage((data==null) ? ((String) null) : (String)data[1]); + break; + case JmolConstants.CALLBACK_MEASURE: + case JmolConstants.CALLBACK_CLICK: + default: + System.err.println("Unhandled callback "+type+" "+data); + break; + } + } + catch (Exception e) + { + System.err.println("Squashed Jmol callback handler error:"); + e.printStackTrace(); + } + } + + @Override + public boolean notifyEnabled(int callbackPick) + { + switch (callbackPick) + { + case JmolConstants.CALLBACK_ECHO: + case JmolConstants.CALLBACK_LOADSTRUCT: + case JmolConstants.CALLBACK_MEASURE: + case JmolConstants.CALLBACK_MESSAGE: + case JmolConstants.CALLBACK_PICK: + case JmolConstants.CALLBACK_SCRIPT: + case JmolConstants.CALLBACK_HOVER: + case JmolConstants.CALLBACK_ERROR: + return true; + case JmolConstants.CALLBACK_CLICK: + case JmolConstants.CALLBACK_ANIMFRAME: + case JmolConstants.CALLBACK_MINIMIZATION: + case JmolConstants.CALLBACK_RESIZE: + case JmolConstants.CALLBACK_SYNC: + } + return false; + } + + @Override + public void setCallbackFunction(String callbackType, + String callbackFunction) + { + System.err.println("Ignoring set-callback request to associate "+callbackType+" with function "+callbackFunction); + + } + } diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index c18015a..7945fa7 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -26,6 +26,7 @@ import java.awt.event.*; import java.io.*; import jalview.jbgui.GStructureViewer; +import jalview.bin.Cache; import jalview.datamodel.*; import jalview.gui.*; import jalview.structure.*; @@ -37,6 +38,7 @@ import jalview.ws.ebi.EBIFetchClient; import org.jmol.api.*; import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.popup.*; +import org.jmol.viewer.JmolConstants; public class AppJmol extends GStructureViewer implements StructureListener, JmolStatusListener, Runnable @@ -84,7 +86,6 @@ public class AppJmol extends GStructureViewer implements StructureListener, pdbentry = new PDBEntry(); pdbentry.setFile(file); pdbentry.setId(id); - this.chains = chains; this.sequence = seq; this.ap = ap; this.setBounds(bounds); @@ -226,15 +227,13 @@ public class AppJmol extends GStructureViewer implements StructureListener, this.setTitle(title.toString()); jalview.gui.Desktop.addInternalFrame(this, title.toString(), getBounds().width, getBounds().height); + // * OK, but safer to assign htmlName, URL bases, comandOptions, and + // statusListener now. viewer = org.jmol.api.JmolViewer.allocateViewer(renderPanel, - new SmarterJmolAdapter()); + new SmarterJmolAdapter(), "", null, null, "", this); - viewer.setAppletContext("", null, null, ""); - - viewer.setJmolStatusListener(this); - - jmolpopup = JmolPopup.newJmolPopup(viewer); + jmolpopup = JmolPopup.newJmolPopup(viewer, true, "Jmol", true); viewer.evalStringQuiet(command); } @@ -779,13 +778,8 @@ public class AppJmol extends GStructureViewer implements StructureListener, System.out.println("JMOL CREATE IMAGE"); } - public void setCallbackFunction(String callbackType, - String callbackFunction) - { - } - public void notifyFileLoaded(String fullPathName, String fileName, - String modelName, Object clientFile, String errorMsg) + String modelName, String errorMsg, int modelParts) { if (errorMsg != null) { @@ -798,7 +792,7 @@ public class AppJmol extends GStructureViewer implements StructureListener, if (fileName != null) { - + // TODO: do some checking using the modelPts number of parts against our own estimate of the number of chains // FILE LOADED OK ssm = StructureSelectionManager.getStructureSelectionManager(); MCview.PDBfile pdbFile = ssm.setMapping(sequence, chains, pdbentry @@ -830,15 +824,6 @@ public class AppJmol extends GStructureViewer implements StructureListener, return; } - public void notifyFrameChanged(int frameNo) - { - boolean isAnimationRunning = (frameNo <= -2); - } - - public void notifyScriptStart(String statusMessage, String additionalInfo) - { - } - public void sendConsoleEcho(String strEcho) { if (scriptWindow != null) @@ -864,15 +849,15 @@ public class AppJmol extends GStructureViewer implements StructureListener, public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) { - notifyAtomPicked(iatom, strMeasure); + notifyAtomPicked(iatom, strMeasure, null); } - public void notifyNewDefaultModeMeasurement(int count, String strInfo) - { - } - - public void notifyAtomPicked(int atomIndex, String strInfo) + public void notifyAtomPicked(int atomIndex, String strInfo, String strData) { + if (strData!=null) + { + Cache.log.info("Non null pick data string: "+strData+" (other info: '"+strInfo+"' pos "+atomIndex+")"); + } Matcher matcher = pattern.matcher(strInfo); matcher.find(); @@ -885,7 +870,7 @@ public class AppJmol extends GStructureViewer implements StructureListener, if (chainId != null) picked += (":" + chainId.substring(1, chainId.length())); - picked += ".CA"; + picked = "(("+picked+".CA" + ")|("+picked+".P"+"))"; if (!atomsPicked.contains(picked)) { @@ -908,17 +893,25 @@ public class AppJmol extends GStructureViewer implements StructureListener, } } - public void notifyAtomHovered(int atomIndex, String strInfo) + public void notifyAtomHovered(int atomIndex, String strInfo, String data) { + if (data!=null) + { + Cache.log.info("Non null hover data string: "+data+" (other info: '"+strInfo+"' pos "+atomIndex+")"); + } mouseOverStructure(atomIndex, strInfo); } - public void sendSyncScript(String script, String appletName) - { - } - + @Override public void showUrl(String url) { + try { + jalview.util.BrowserLauncher.openURL(url); + } catch (IOException e) + { + Cache.log.error("Failed to launch Jmol-associated url "+url,e); + // TODO: 2.6 : warn user if browser was not configured. + } } public void showConsole(boolean showConsole) @@ -952,9 +945,9 @@ public class AppJmol extends GStructureViewer implements StructureListener, validate(); } - public float functionXY(String functionName, int x, int y) + public float[][] functionXY(String functionName, int x, int y) { - return 0; + return null; } // /End JmolStatusListener @@ -1006,4 +999,96 @@ public class AppJmol extends GStructureViewer implements StructureListener, return viewId; } + @Override + public String createImage(String fileName, String type, + Object textOrBytes, int quality) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public float[][][] functionXYZ(String functionName, int nx, int ny, int nz) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public Hashtable getRegistryInfo() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public void notifyCallback(int type, Object[] data) + { + try { + switch (type) + { + case JmolConstants.CALLBACK_LOADSTRUCT: + notifyFileLoaded((String) data[1], (String) data[2], + (String) data[3], (String) data[4], ((Integer) data[5]).intValue()); + + break; + case JmolConstants.CALLBACK_PICK: + notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]); + // also highlight in alignment + case JmolConstants.CALLBACK_HOVER: + notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]); + break; + case JmolConstants.CALLBACK_SCRIPT: + notifyScriptTermination((String)data[2], ((Integer)data[3]).intValue()); + break; + case JmolConstants.CALLBACK_ECHO: + sendConsoleEcho((String)data[1]); + break; + case JmolConstants.CALLBACK_MESSAGE: + sendConsoleMessage((data==null) ? ((String) null) : (String)data[1]); + break; + case JmolConstants.CALLBACK_MEASURE: + case JmolConstants.CALLBACK_CLICK: + default: + System.err.println("Unhandled callback "+type+" "+data); + break; + } + } + catch (Exception e) + { + Cache.log.warn("Squashed Jmol callback handler error: ",e); + } + } + + @Override + public boolean notifyEnabled(int callbackPick) + { + switch (callbackPick) + { + case JmolConstants.CALLBACK_ECHO: + case JmolConstants.CALLBACK_LOADSTRUCT: + case JmolConstants.CALLBACK_MEASURE: + case JmolConstants.CALLBACK_MESSAGE: + case JmolConstants.CALLBACK_PICK: + case JmolConstants.CALLBACK_SCRIPT: + case JmolConstants.CALLBACK_HOVER: + case JmolConstants.CALLBACK_ERROR: + return true; + case JmolConstants.CALLBACK_CLICK: + case JmolConstants.CALLBACK_ANIMFRAME: + case JmolConstants.CALLBACK_MINIMIZATION: + case JmolConstants.CALLBACK_RESIZE: + case JmolConstants.CALLBACK_SYNC: + } + return false; + } + + @Override + public void setCallbackFunction(String callbackType, + String callbackFunction) + { + Cache.log.debug("Ignoring set-callback request to associate "+callbackType+" with function "+callbackFunction); + + } + } diff --git a/src/jalview/gui/ScriptWindow.java b/src/jalview/gui/ScriptWindow.java index ff377f7..de31fcf 100644 --- a/src/jalview/gui/ScriptWindow.java +++ b/src/jalview/gui/ScriptWindow.java @@ -230,7 +230,7 @@ public final class ScriptWindow extends JPanel implements ActionListener, else { boolean isScriptExecuting = viewer.isScriptExecuting(); - if (viewer.checkHalt(strCommand)) + if (viewer.checkHalt(strCommand, true)) strErrorMessage = (isScriptExecuting ? "string execution halted with " + strCommand : "no script was executing");