import java.util.Map;
import java.util.Vector;
-import javax.swing.SwingUtilities;
-
import org.jmol.adapter.smarter.SmarterJmolAdapter;
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.api.JmolSelectionListener;
{
// remove listeners for all structures in viewer
getSsm().removeStructureViewerListener(this, this.getStructureFiles());
- viewer.dispose();
+ if (viewer != null)
+ {
+ viewer.dispose();
+ }
lastCommand = null;
viewer = null;
releaseUIResources();
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
*
protected void colourBySequence(
final StructureMappingcommandSet[] colourBySequenceCommands)
{
- SwingUtilities.invokeLater(new Runnable()
+ if (colourby != null)
+ {
+ colourby.interrupt();
+ colourby = null;
+ }
+ Thread colourby = new Thread(new Runnable()
{
@Override
public void run()
}
}
});
+ colourby.start();
+ this.colourby = colourby;
}
/**
{
if (resetLastRes.length() > 0)
{
- viewer.evalStringQuiet(resetLastRes.toString());
+ jmolScript(resetLastRes.toString());
resetLastRes.setLength(0);
}
for (AtomSpec atom : atoms)
cmd.append("spacefill 200;select none");
- viewer.evalStringQuiet(cmd.toString());
+ jmolScript(cmd.toString());
jmolHistory(true);
}
private void jmolHistory(boolean enable)
{
- viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
+ jmolScript("History " + ((debug || enable) ? "on" : "off"));
}
public void loadInline(String string)
try
{
// recover PDB filename for the model hovered over.
- int _mp = _modelFileNameMap.length - 1,
- mnumber = new Integer(mdlId).intValue() - 1;
- while (mnumber < _modelFileNameMap[_mp])
+ int mnumber = new Integer(mdlId).intValue() - 1;
+ if (_modelFileNameMap != null)
{
- _mp--;
+ int _mp = _modelFileNameMap.length - 1;
+
+ while (mnumber < _modelFileNameMap[_mp])
+ {
+ _mp--;
+ }
+ pdbfilename = modelFileNames[_mp];
}
- pdbfilename = modelFileNames[_mp];
- if (pdbfilename == null)
+ else
{
- pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
- .getAbsolutePath();
- }
+ if (mnumber >= 0 && mnumber < modelFileNames.length)
+ {
+ pdbfilename = modelFileNames[mnumber];
+ }
+ if (pdbfilename == null)
+ {
+ pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
+ .getAbsolutePath();
+ }
+ }
} catch (Exception e)
{
}
{
/**
* this implements the toggle label behaviour copied from the original
- * structure viewer, MCView
+ * structure viewer, mc_view
*/
if (strData != null)
{
if (!atomsPicked.contains(picked))
{
- viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
+ jmolScript("select " + picked + ";label %n %r:%c");
atomsPicked.addElement(picked);
}
else
// 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;
// }
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
return chainNames;
}
- protected abstract IProgressIndicator getIProgressIndicator();
+ protected IProgressIndicator getIProgressIndicator()
+ {
+ return null;
+ }
public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
{
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");
}
/**
*/
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
* @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 = "";
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);
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("<<Jmol<< " + s);
+
+ return s;
+ }
+
@Override
public int[] resizeInnerPanel(String data)
{
{
showConsole(false);
}
+
}