X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=4698e4d5e42d87f54bf3d713a1bcb60eca802c2f;hb=8946f41687f4c822ac8d15ee8551f23f156735c4;hp=c0a1e0dc4a2279c03cfb8e55084014c1658b4f58;hpb=6cbfab156ee784944a03caaa0a7374b71325a871;p=jalview.git diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index c0a1e0d..4698e4d 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -165,7 +165,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { // remove listeners for all structures in viewer getSsm().removeStructureViewerListener(this, this.getStructureFiles()); - viewer.dispose(); + if (viewer != null) + { + viewer.dispose(); + } lastCommand = null; viewer = null; releaseUIResources(); @@ -471,13 +474,14 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel jmolHistory(false); if (lastCommand == null || !lastCommand.equals(command)) { - viewer.evalStringQuiet(command + "\n"); + jmolScript(command + "\n"); } jmolHistory(true); lastCommand = command; } Thread colourby = null; + /** * Sends a set of colour commands to the structure viewer * @@ -492,7 +496,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel colourby.interrupt(); colourby = null; } - colourby = new Thread(new Runnable() + Thread colourby = new Thread(new Runnable() { @Override public void run() @@ -507,6 +511,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } }); colourby.start(); + this.colourby = colourby; } /** @@ -669,7 +674,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { if (resetLastRes.length() > 0) { - viewer.evalStringQuiet(resetLastRes.toString()); + jmolScript(resetLastRes.toString()); resetLastRes.setLength(0); } for (AtomSpec atom : atoms) @@ -727,7 +732,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel cmd.append("spacefill 200;select none"); - viewer.evalStringQuiet(cmd.toString()); + jmolScript(cmd.toString()); jmolHistory(true); } @@ -736,7 +741,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel private void jmolHistory(boolean enable) { - viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off")); + jmolScript("History " + ((debug || enable) ? "on" : "off")); } public void loadInline(String string) @@ -865,7 +870,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { /** * this implements the toggle label behaviour copied from the original - * structure viewer, MCView + * structure viewer, mc_view */ if (strData != null) { @@ -896,7 +901,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel if (!atomsPicked.contains(picked)) { - viewer.evalStringQuiet("select " + picked + ";label %n %r:%c"); + jmolScript("select " + picked + ";label %n %r:%c"); atomsPicked.addElement(picked); } else @@ -1084,8 +1089,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel // see JAL-623 - need method of matching pasted data up { pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], - pdbfile, DataSourceType.PASTE, - getIProgressIndicator()); + pdbfile, DataSourceType.PASTE, getIProgressIndicator()); getPdbEntry(modelnum).setFile("INLINE" + pdb.getId()); matches = true; foundEntry = true; @@ -1160,7 +1164,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel // } if (!isLoadingFromArchive()) { - viewer.evalStringQuiet( + jmolScript( "model *; select backbone;restrict;cartoon;wireframe off;spacefill off"); } // register ourselves as a listener and notify the gui that it needs to @@ -1260,7 +1264,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel public void showHelp() { - showUrl("http://jmol.sourceforge.net/docs/JmolUserGuide/", "jmolHelp"); + showUrl("http://wiki.jmol.org" + // BH 2018 "http://jmol.sourceforge.net/docs/JmolUserGuide/" + , "jmolHelp"); } /** @@ -1284,7 +1290,16 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ public abstract void showConsole(boolean show); + public static Viewer getJmolData(JmolParser jmolParser) + { + return (Viewer) JmolViewer.allocateViewer(null, null, null, null, null, + "-x -o -n", jmolParser); + } + /** + * + * + * * @param renderPanel * @param jmolfileio * - when true will initialise jmol's file IO system (should be false @@ -1315,13 +1330,16 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel * @param consolePanel * - panel to contain Jmol console * @param buttonsToShow - * - buttons to show on the console, in ordr + * - buttons to show on the console, in order */ public void allocateViewer(Container renderPanel, boolean jmolfileio, String htmlName, URL documentBase, URL codeBase, String commandOptions, final Container consolePanel, String buttonsToShow) { + + System.err.println("Allocating Jmol Viewer: " + commandOptions); + if (commandOptions == null) { commandOptions = ""; @@ -1333,7 +1351,15 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel viewer.setJmolStatusListener(this); // extends JmolCallbackListener - console = createJmolConsole(consolePanel, buttonsToShow); + try + { + console = createJmolConsole(consolePanel, buttonsToShow); + } catch (Throwable e) + { + System.err.println("Could not create Jmol application console. " + + e.getMessage()); + e.printStackTrace(); + } if (consolePanel != null) { consolePanel.addComponentListener(this); @@ -1345,17 +1371,32 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel protected abstract JmolAppConsoleInterface createJmolConsole( Container consolePanel, String buttonsToShow); + // BH 2018 -- Jmol console is not working due to problems with styled + // documents. + protected org.jmol.api.JmolAppConsoleInterface console = null; @Override public void setBackgroundColour(java.awt.Color col) { jmolHistory(false); - viewer.evalStringQuiet("background [" + col.getRed() + "," - + col.getGreen() + "," + col.getBlue() + "];"); + jmolScript("background [" + col.getRed() + "," + col.getGreen() + "," + + col.getBlue() + "];"); jmolHistory(true); } + private String jmolScript(String script) + { + + System.err.println(">>Jmol>> " + script); + + String s = viewer.scriptWait(script); + + System.err.println("<