import javajs.util.BS;
public abstract class JalviewJmolBinding extends AAStructureBindingModel
- implements JmolStatusListener, JmolSelectionListener, ComponentListener {
+ implements JmolStatusListener, JmolSelectionListener,
+ ComponentListener
+{
private String lastMessage;
/*
public Viewer jmolViewer;
- public JalviewJmolBinding(StructureSelectionManager ssm, PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
- DataSourceType protocol) {
+ public JalviewJmolBinding(StructureSelectionManager ssm,
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
+ DataSourceType protocol)
+ {
super(ssm, pdbentry, sequenceIs, protocol);
setStructureCommands(new JmolCommands());
/*
*/
}
- public JalviewJmolBinding(StructureSelectionManager ssm, SequenceI[][] seqs, Viewer theViewer) {
+ public JalviewJmolBinding(StructureSelectionManager ssm,
+ SequenceI[][] seqs, Viewer theViewer)
+ {
super(ssm, seqs);
jmolViewer = theViewer;
*
* @return
*/
- public String getViewerTitle() {
+ public String getViewerTitle()
+ {
return getViewerTitle("Jmol", true);
}
- private String jmolScript(String script) {
+ private String jmolScript(String script)
+ {
Cache.log.debug(">>Jmol>> " + script);
String s = jmolViewer.evalStringQuiet(script); // scriptWait(script); BH
Cache.log.debug("<<Jmol<< " + s);
}
@Override
- public List<String> executeCommand(StructureCommandI command, boolean getReply) {
- if (command == null) {
+ public List<String> executeCommand(StructureCommandI command,
+ boolean getReply)
+ {
+ if (command == null)
+ {
return null;
}
String cmd = command.getCommand();
jmolHistory(false);
- if (lastCommand == null || !lastCommand.equals(cmd)) {
+ if (lastCommand == null || !lastCommand.equals(cmd))
+ {
jmolScript(cmd + "\n");
}
jmolHistory(true);
return null;
}
- public void createImage(String file, String type, int quality) {
+ public void createImage(String file, String type, int quality)
+ {
System.out.println("JMOL CREATE IMAGE");
}
@Override
- public String createImage(String fileName, String type, Object textOrBytes, int quality) {
+ public String createImage(String fileName, String type,
+ Object textOrBytes, int quality)
+ {
System.out.println("JMOL CREATE IMAGE");
return null;
}
@Override
- public String eval(String strEval) {
+ public String eval(String strEval)
+ {
// System.out.println(strEval);
// "# 'eval' is implemented only for the applet.";
return null;
// //////////////////////////
@Override
- public float[][] functionXY(String functionName, int x, int y) {
+ public float[][] functionXY(String functionName, int x, int y)
+ {
return null;
}
@Override
- public float[][][] functionXYZ(String functionName, int nx, int ny, int nz) {
+ public float[][][] functionXYZ(String functionName, int nx, int ny,
+ int nz)
+ {
// TODO Auto-generated method stub
return null;
}
private int _modelFileNameMap[];
@Override
- public synchronized String[] getStructureFiles() {
- if (jmolViewer == null) {
+ public synchronized String[] getStructureFiles()
+ {
+ if (jmolViewer == null)
+ {
return new String[0];
}
- if (modelFileNames == null) {
+ if (modelFileNames == null)
+ {
int modelCount = jmolViewer.ms.mc;
String filePath = null;
List<String> mset = new ArrayList<>();
- for (int i = 0; i < modelCount; ++i) {
+ for (int i = 0; i < modelCount; ++i)
+ {
/*
* defensive check for null as getModelFileName can return null even when model
* count ms.mc is > 0
*/
filePath = jmolViewer.ms.getModelFileName(i);
- if (filePath != null && !mset.contains(filePath)) {
+ if (filePath != null && !mset.contains(filePath))
+ {
mset.add(filePath);
}
}
- if (!mset.isEmpty()) {
+ if (!mset.isEmpty())
+ {
modelFileNames = mset.toArray(new String[mset.size()]);
}
}
* map from string to applet
*/
@Override
- public Map<String, Object> getRegistryInfo() {
+ public Map<String, Object> getRegistryInfo()
+ {
// TODO Auto-generated method stub
return null;
}
// ///////////////////////////////
// JmolStatusListener
- public void handlePopupMenu(int x, int y) {
+ public void handlePopupMenu(int x, int y)
+ {
// jmolpopup.show(x, y);
// jmolpopup.jpiShow(x, y);
}
* Highlight zero, one or more atoms on the structure
*/
@Override
- public void highlightAtoms(List<AtomSpec> atoms) {
- if (atoms != null) {
- if (resetLastRes.length() > 0) {
+ public void highlightAtoms(List<AtomSpec> atoms)
+ {
+ if (atoms != null)
+ {
+ if (resetLastRes.length() > 0)
+ {
jmolScript(resetLastRes.toString());
resetLastRes.setLength(0);
}
- for (AtomSpec atom : atoms) {
- highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(), atom.getChain(), atom.getPdbFile());
+ for (AtomSpec atom : atoms)
+ {
+ highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(),
+ atom.getChain(), atom.getPdbFile());
}
}
}
// jmol/ssm only
- public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile) {
+ public void highlightAtom(int atomIndex, int pdbResNum, String chain,
+ String pdbfile)
+ {
String modelId = getModelIdForFile(pdbfile);
- if (modelId.isEmpty()) {
+ if (modelId.isEmpty())
+ {
return;
}
StringBuilder cmd = new StringBuilder(64);
selection.append("select ").append(String.valueOf(pdbResNum));
selection.append(":");
- if (!chain.equals(" ")) {
+ if (!chain.equals(" "))
+ {
selection.append(chain);
}
selection.append(" /").append(modelId);
- cmd.append(selection).append(";wireframe 100;").append(selection).append(" and not hetero;")
- .append("spacefill 200;select none");
+ cmd.append(selection).append(";wireframe 100;").append(selection)
+ .append(" and not hetero;").append("spacefill 200;select none");
- resetLastRes.append(selection).append(";wireframe 0;").append(selection).append(" and not hetero; spacefill 0;");
+ resetLastRes.append(selection).append(";wireframe 0;").append(selection)
+ .append(" and not hetero; spacefill 0;");
jmolScript(cmd.toString());
jmolHistory(true);
private boolean debug = true;
- private void jmolHistory(boolean enable) {
+ private void jmolHistory(boolean enable)
+ {
jmolScript("History " + ((debug || enable) ? "on" : "off"));
}
- public void loadInline(String string) {
+ public void loadInline(String string)
+ {
loadedInline = true;
// TODO: re JAL-623
// viewer.loadInline(strModel, isAppend);
jmolViewer.openStringInline(string);
}
- protected void mouseOverStructure(int atomIndex, final String strInfo) {
+ protected void mouseOverStructure(int atomIndex, final String strInfo)
+ {
int pdbResNum;
int alocsep = strInfo.indexOf("^");
int mdlSep = strInfo.indexOf("/");
int chainSeparator = strInfo.indexOf(":"), chainSeparator1 = -1;
- if (chainSeparator == -1) {
+ if (chainSeparator == -1)
+ {
chainSeparator = strInfo.indexOf(".");
- if (mdlSep > -1 && mdlSep < chainSeparator) {
+ if (mdlSep > -1 && mdlSep < chainSeparator)
+ {
chainSeparator1 = chainSeparator;
chainSeparator = mdlSep;
}
}
// handle insertion codes
- if (alocsep != -1) {
- pdbResNum = Integer.parseInt(strInfo.substring(strInfo.indexOf("]") + 1, alocsep));
+ if (alocsep != -1)
+ {
+ pdbResNum = Integer.parseInt(
+ strInfo.substring(strInfo.indexOf("]") + 1, alocsep));
- } else {
- pdbResNum = Integer.parseInt(strInfo.substring(strInfo.indexOf("]") + 1, chainSeparator));
+ }
+ else
+ {
+ pdbResNum = Integer.parseInt(
+ strInfo.substring(strInfo.indexOf("]") + 1, chainSeparator));
}
String chainId;
- if (strInfo.indexOf(":") > -1) {
- chainId = strInfo.substring(strInfo.indexOf(":") + 1, strInfo.indexOf("."));
- } else {
+ if (strInfo.indexOf(":") > -1)
+ {
+ chainId = strInfo.substring(strInfo.indexOf(":") + 1,
+ strInfo.indexOf("."));
+ }
+ else
+ {
chainId = " ";
}
String pdbfilename = modelFileNames[0]; // default is first model
- if (mdlSep > -1) {
- if (chainSeparator1 == -1) {
+ if (mdlSep > -1)
+ {
+ if (chainSeparator1 == -1)
+ {
chainSeparator1 = strInfo.indexOf(".", mdlSep);
}
- String mdlId = (chainSeparator1 > -1) ? strInfo.substring(mdlSep + 1, chainSeparator1)
- : strInfo.substring(mdlSep + 1);
- try {
+ String mdlId = (chainSeparator1 > -1)
+ ? strInfo.substring(mdlSep + 1, chainSeparator1)
+ : strInfo.substring(mdlSep + 1);
+ try
+ {
// recover PDB filename for the model hovered over.
int mnumber = Integer.valueOf(mdlId).intValue() - 1;
- if (_modelFileNameMap != null) {
+ if (_modelFileNameMap != null)
+ {
int _mp = _modelFileNameMap.length - 1;
- while (mnumber < _modelFileNameMap[_mp]) {
+ while (mnumber < _modelFileNameMap[_mp])
+ {
_mp--;
}
pdbfilename = modelFileNames[_mp];
- } else {
- if (mnumber >= 0 && mnumber < modelFileNames.length) {
+ }
+ else
+ {
+ if (mnumber >= 0 && mnumber < modelFileNames.length)
+ {
pdbfilename = modelFileNames[mnumber];
}
- if (pdbfilename == null) {
- pdbfilename = new File(jmolViewer.ms.getModelFileName(mnumber)).getAbsolutePath();
+ if (pdbfilename == null)
+ {
+ pdbfilename = new File(jmolViewer.ms.getModelFileName(mnumber))
+ .getAbsolutePath();
}
}
- } catch (Exception e) {
+ } catch (Exception e)
+ {
}
}
* highlight position on alignment(s); if some text is returned, show this as a
* second line on the structure hover tooltip
*/
- String label = getSsm().mouseOverStructure(pdbResNum, chainId, pdbfilename);
- if (label != null) {
+ String label = getSsm().mouseOverStructure(pdbResNum, chainId,
+ pdbfilename);
+ if (label != null)
+ {
// change comma to pipe separator (newline token for Jmol)
label = label.replace(',', '|');
StringTokenizer toks = new StringTokenizer(strInfo, " ");
StringBuilder sb = new StringBuilder();
- sb.append("select ").append(String.valueOf(pdbResNum)).append(":").append(chainId).append("/1");
- sb.append(";set hoverLabel \"").append(toks.nextToken()).append(" ").append(toks.nextToken());
+ sb.append("select ").append(String.valueOf(pdbResNum)).append(":")
+ .append(chainId).append("/1");
+ sb.append(";set hoverLabel \"").append(toks.nextToken()).append(" ")
+ .append(toks.nextToken());
sb.append("|").append(label).append("\"");
executeCommand(new StructureCommand(sb.toString()), false);
}
}
- public void notifyAtomHovered(int atomIndex, String strInfo, String data) {
- if (strInfo.equals(lastMessage)) {
+ public void notifyAtomHovered(int atomIndex, String strInfo, String data)
+ {
+ if (strInfo.equals(lastMessage))
+ {
return;
}
lastMessage = strInfo;
- if (data != null) {
- System.err.println(
- "Ignoring additional hover info: " + data + " (other info: '" + strInfo + "' pos " + atomIndex + ")");
+ if (data != null)
+ {
+ System.err.println("Ignoring additional hover info: " + data
+ + " (other info: '" + strInfo + "' pos " + atomIndex + ")");
}
mouseOverStructure(atomIndex, strInfo);
}
* }
*/
- public void notifyAtomPicked(int atomIndex, String strInfo, String strData) {
+ public void notifyAtomPicked(int atomIndex, String strInfo,
+ String strData)
+ {
/**
- * this implements the toggle label behaviour copied from the original structure
- * viewer, mc_view
+ * this implements the toggle label behaviour copied from the original
+ * structure viewer, mc_view
*/
- if (strData != null) {
+ if (strData != null)
+ {
System.err.println("Ignoring additional pick data string " + strData);
}
int chainSeparator = strInfo.indexOf(":");
int p = 0;
- if (chainSeparator == -1) {
+ if (chainSeparator == -1)
+ {
chainSeparator = strInfo.indexOf(".");
}
- String picked = strInfo.substring(strInfo.indexOf("]") + 1, chainSeparator);
+ String picked = strInfo.substring(strInfo.indexOf("]") + 1,
+ chainSeparator);
String mdlString = "";
- if ((p = strInfo.indexOf(":")) > -1) {
+ if ((p = strInfo.indexOf(":")) > -1)
+ {
picked += strInfo.substring(p, strInfo.indexOf("."));
}
- if ((p = strInfo.indexOf("/")) > -1) {
+ if ((p = strInfo.indexOf("/")) > -1)
+ {
mdlString += strInfo.substring(p, strInfo.indexOf(" #"));
}
- picked = "((" + picked + ".CA" + mdlString + ")|(" + picked + ".P" + mdlString + "))";
+ picked = "((" + picked + ".CA" + mdlString + ")|(" + picked + ".P"
+ + mdlString + "))";
jmolHistory(false);
- if (!atomsPicked.contains(picked)) {
+ if (!atomsPicked.contains(picked))
+ {
jmolScript("select " + picked + ";label %n %r:%c");
atomsPicked.addElement(picked);
- } else {
+ }
+ else
+ {
jmolViewer.evalString("select " + picked + ";label off");
atomsPicked.removeElement(picked);
}
}
@Override
- public void notifyCallback(CBK type, Object[] data) {
+ public void notifyCallback(CBK type, Object[] data)
+ {
/*
* ensure processed in AWT thread to avoid risk of deadlocks
*/
- SwingUtilities.invokeLater(new Runnable() {
+ SwingUtilities.invokeLater(new Runnable()
+ {
@Override
- public void run() {
+ public void run()
+ {
processCallback(type, data);
}
});
* @param type
* @param data
*/
- protected void processCallback(CBK type, Object[] data) {
- try {
- switch (type) {
+ protected void processCallback(CBK type, Object[] data)
+ {
+ try
+ {
+ switch (type)
+ {
case LOADSTRUCT:
- notifyFileLoaded((String) data[1], (String) data[2], (String) data[3], (String) data[4],
- ((Integer) data[5]).intValue());
+ notifyFileLoaded((String) data[1], (String) data[2],
+ (String) data[3], (String) data[4],
+ ((Integer) data[5]).intValue());
break;
case PICK:
- notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]);
+ notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1],
+ (String) data[0]);
// also highlight in alignment
// deliberate fall through
case HOVER:
- notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1], (String) data[0]);
+ notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1],
+ (String) data[0]);
break;
case SCRIPT:
- notifyScriptTermination((String) data[2], ((Integer) data[3]).intValue());
+ notifyScriptTermination((String) data[2],
+ ((Integer) data[3]).intValue());
break;
case ECHO:
sendConsoleEcho((String) data[1]);
break;
case MESSAGE:
- sendConsoleMessage((data == null) ? ((String) null) : (String) data[1]);
+ sendConsoleMessage(
+ (data == null) ? ((String) null) : (String) data[1]);
break;
case ERROR:
// System.err.println("Ignoring error callback.");
case CLICK:
default:
- System.err.println("Unhandled callback " + type + " " + data[1].toString());
+ System.err.println(
+ "Unhandled callback " + type + " " + data[1].toString());
break;
}
- } catch (Exception e) {
+ } catch (Exception e)
+ {
System.err.println("Squashed Jmol callback handler error:");
e.printStackTrace();
}
}
@Override
- public boolean notifyEnabled(CBK callbackPick) {
- switch (callbackPick) {
+ public boolean notifyEnabled(CBK callbackPick)
+ {
+ switch (callbackPick)
+ {
case ECHO:
case LOADSTRUCT:
case MEASURE:
// referrring to new structures.
private long loadNotifiesHandled = 0;
- public long getLoadNotifiesHandled() {
+ public long getLoadNotifiesHandled()
+ {
return loadNotifiesHandled;
}
- public void notifyFileLoaded(String fullPathName, String fileName2, String modelName, String errorMsg,
- int modelParts) {
- if (errorMsg != null) {
+ public void notifyFileLoaded(String fullPathName, String fileName2,
+ String modelName, String errorMsg, int modelParts)
+ {
+ if (errorMsg != null)
+ {
fileLoadingError = errorMsg;
refreshGUI();
return;
modelFileNames = null;
boolean notifyLoaded = false;
String[] modelfilenames = getStructureFiles();
- if (modelfilenames == null) {
+ if (modelfilenames == null)
+ {
// Jmol is still loading files!
return;
}
// first check if we've lost any structures
- if (oldmodels != null && oldmodels.length > 0) {
+ if (oldmodels != null && oldmodels.length > 0)
+ {
int oldm = 0;
- for (int i = 0; i < oldmodels.length; i++) {
- for (int n = 0; n < modelfilenames.length; n++) {
- if (modelfilenames[n] == oldmodels[i]) {
+ for (int i = 0; i < oldmodels.length; i++)
+ {
+ for (int n = 0; n < modelfilenames.length; n++)
+ {
+ if (modelfilenames[n] == oldmodels[i])
+ {
oldmodels[i] = null;
break;
}
}
- if (oldmodels[i] != null) {
+ if (oldmodels[i] != null)
+ {
oldm++;
}
}
- if (oldm > 0) {
+ if (oldm > 0)
+ {
String[] oldmfn = new String[oldm];
oldm = 0;
- for (int i = 0; i < oldmodels.length; i++) {
- if (oldmodels[i] != null) {
+ for (int i = 0; i < oldmodels.length; i++)
+ {
+ if (oldmodels[i] != null)
+ {
oldmfn[oldm++] = oldmodels[i];
}
}
}
}
refreshPdbEntries();
- for (int modelnum = 0; modelnum < modelfilenames.length; modelnum++) {
+ for (int modelnum = 0; modelnum < modelfilenames.length; modelnum++)
+ {
String fileName = modelfilenames[modelnum];
boolean foundEntry = false;
StructureFile pdb = null;
String pdbfile = null;
// model was probably loaded inline - so check the pdb file hashcode
- if (loadedInline) {
+ if (loadedInline)
+ {
// calculate essential attributes for the pdb data imported inline.
// prolly need to resolve modelnumber properly - for now just use our
// 'best guess'
- pdbfile = jmolViewer.getData("" + (1 + _modelFileNameMap[modelnum]) + ".0", "PDB");
+ pdbfile = jmolViewer.getData(
+ "" + (1 + _modelFileNameMap[modelnum]) + ".0", "PDB");
}
// search pdbentries and sequences to find correct pdbentry for this
// model
- for (int pe = 0; pe < getPdbCount(); pe++) {
+ for (int pe = 0; pe < getPdbCount(); pe++)
+ {
boolean matches = false;
addSequence(pe, getSequence()[pe]);
- if (fileName == null) {
+ if (fileName == null)
+ {
if (false)
// see JAL-623 - need method of matching pasted data up
{
- pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], pdbfile, DataSourceType.PASTE,
- getIProgressIndicator());
+ pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe],
+ pdbfile, DataSourceType.PASTE, getIProgressIndicator());
getPdbEntry(modelnum).setFile("INLINE" + pdb.getId());
matches = true;
foundEntry = true;
}
- } else {
+ }
+ else
+ {
File fl = new File(getPdbEntry(pe).getFile());
matches = fl.equals(new File(fileName));
- if (matches) {
+ if (matches)
+ {
foundEntry = true;
// TODO: Jmol can in principle retrieve from CLASSLOADER but
// this
// to be tested. See mantis bug
// https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
DataSourceType protocol = DataSourceType.URL;
- try {
- if (fl.exists()) {
+ try
+ {
+ if (fl.exists())
+ {
protocol = DataSourceType.FILE;
}
- } catch (Exception e) {
- } catch (Error e) {
+ } catch (Exception e)
+ {
+ } catch (Error e)
+ {
}
// Explicitly map to the filename used by Jmol ;
- pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], fileName, protocol, getIProgressIndicator());
+ pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe],
+ fileName, protocol, getIProgressIndicator());
// pdbentry[pe].getFile(), protocol);
}
}
- if (matches) {
+ if (matches)
+ {
stashFoundChains(pdb, fileName);
notifyLoaded = true;
}
}
- if (!foundEntry && associateNewStructs) {
+ if (!foundEntry && associateNewStructs)
+ {
// this is a foreign pdb file that jalview doesn't know about - add
// it to the dataset and try to find a home - either on a matching
// sequence or as a new sequence.
- String pdbcontent = jmolViewer.getData("/" + (modelnum + 1) + ".1", "PDB");
+ String pdbcontent = jmolViewer.getData("/" + (modelnum + 1) + ".1",
+ "PDB");
// parse pdb file into a chain, etc.
// locate best match for pdb in associated views and add mapping to
// ssm
// // potential for deadlock here:
// // jmolpopup.updateComputedMenus();
// }
- if (!isLoadingFromArchive()) {
- jmolScript("model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
+ if (!isLoadingFromArchive())
+ {
+ jmolScript(
+ "model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
}
// register ourselves as a listener and notify the gui that it needs to
// update itself.
getSsm().addStructureViewerListener(this);
- if (notifyLoaded) {
+ if (notifyLoaded)
+ {
FeatureRenderer fr = getFeatureRenderer(null);
- if (fr != null) {
+ if (fr != null)
+ {
FeatureSettingsModelI colours = new Pdb().getFeatureColourScheme();
- ((AppJmol) getViewer()).getAlignmentPanel().av.applyFeaturesStyle(colours);
+ ((AppJmol) getViewer()).getAlignmentPanel().av
+ .applyFeaturesStyle(colours);
}
refreshGUI();
loadNotifiesHandled++;
setLoadingFromArchive(false);
}
- protected IProgressIndicator getIProgressIndicator() {
+ protected IProgressIndicator getIProgressIndicator()
+ {
return null;
}
- public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) {
+ public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
+ {
notifyAtomPicked(iatom, strMeasure, null);
}
- public abstract void notifyScriptTermination(String strStatus, int msWalltime);
+ public abstract void notifyScriptTermination(String strStatus,
+ int msWalltime);
/**
* display a message echoed from the jmol viewer
// /////////////////////////////
/**
- * @param strStatus status message - usually the response received after a
- * script executed
+ * @param strStatus
+ * status message - usually the response received after a script
+ * executed
*/
public abstract void sendConsoleMessage(String strStatus);
@Override
- public void setCallbackFunction(String callbackType, String callbackFunction) {
- System.err
- .println("Ignoring set-callback request to associate " + callbackType + " with function " + callbackFunction);
+ public void setCallbackFunction(String callbackType,
+ String callbackFunction)
+ {
+ System.err.println("Ignoring set-callback request to associate "
+ + callbackType + " with function " + callbackFunction);
}
- public void showHelp() {
+ public void showHelp()
+ {
showUrl("http://wiki.jmol.org"
// BH 2018 "http://jmol.sourceforge.net/docs/JmolUserGuide/"
- , "jmolHelp");
+ , "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);
+ 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 in applet context)
+ * @param jmolfileio
+ * - when true will initialise jmol's file IO system (should be false
+ * in applet context)
* @param htmlName
* @param documentBase
* @param codeBase
* @param commandOptions
*/
- public void allocateViewer(Container renderPanel, boolean jmolfileio, String htmlName, URL documentBase, URL codeBase,
- String commandOptions) {
- allocateViewer(renderPanel, jmolfileio, htmlName, documentBase, codeBase, commandOptions, null, null);
+ public void allocateViewer(Container renderPanel, boolean jmolfileio,
+ String htmlName, URL documentBase, URL codeBase,
+ String commandOptions)
+ {
+ allocateViewer(renderPanel, jmolfileio, htmlName, documentBase,
+ codeBase, commandOptions, null, null);
}
/**
*
* @param renderPanel
- * @param jmolfileio - when true will initialise jmol's file IO system
- * (should be false in applet context)
+ * @param jmolfileio
+ * - when true will initialise jmol's file IO system (should be false
+ * in applet context)
* @param htmlName
* @param documentBase
* @param codeBase
* @param commandOptions
- * @param consolePanel - panel to contain Jmol console
- * @param buttonsToShow - buttons to show on the console, in order
+ * @param consolePanel
+ * - panel to contain Jmol console
+ * @param buttonsToShow
+ * - 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) {
+ 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) {
+ if (commandOptions == null)
+ {
commandOptions = "";
}
- jmolViewer = (Viewer) JmolViewer.allocateViewer(renderPanel, (jmolfileio ? new SmarterJmolAdapter() : null),
- htmlName + ((Object) this).toString(), documentBase, codeBase, commandOptions, this);
+ jmolViewer = (Viewer) JmolViewer.allocateViewer(renderPanel,
+ (jmolfileio ? new SmarterJmolAdapter() : null),
+ htmlName + ((Object) this).toString(), documentBase, codeBase,
+ commandOptions, this);
jmolViewer.setJmolStatusListener(this); // extends JmolCallbackListener
- try {
+ try
+ {
console = createJmolConsole(consolePanel, buttonsToShow);
- } catch (Throwable e) {
- System.err.println("Could not create Jmol application console. " + e.getMessage());
+ } catch (Throwable e)
+ {
+ System.err.println("Could not create Jmol application console. "
+ + e.getMessage());
e.printStackTrace();
}
- if (consolePanel != null) {
+ if (consolePanel != null)
+ {
consolePanel.addComponentListener(this);
}
}
- protected abstract JmolAppConsoleInterface createJmolConsole(Container consolePanel, String buttonsToShow);
+ 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 int[] resizeInnerPanel(String data) {
+ public int[] resizeInnerPanel(String data)
+ {
// Jalview doesn't honour resize panel requests
return null;
}
/**
*
*/
- protected void closeConsole() {
- if (console != null) {
- try {
+ protected void closeConsole()
+ {
+ if (console != null)
+ {
+ try
+ {
console.setVisible(false);
- } catch (Error e) {
- } catch (Exception x) {
+ } catch (Error e)
+ {
+ } catch (Exception x)
+ {
}
;
console = null;
* ComponentListener method
*/
@Override
- public void componentMoved(ComponentEvent e) {
+ public void componentMoved(ComponentEvent e)
+ {
}
/**
* ComponentListener method
*/
@Override
- public void componentResized(ComponentEvent e) {
+ public void componentResized(ComponentEvent e)
+ {
}
/**
* ComponentListener method
*/
@Override
- public void componentShown(ComponentEvent e) {
+ public void componentShown(ComponentEvent e)
+ {
showConsole(true);
}
* ComponentListener method
*/
@Override
- public void componentHidden(ComponentEvent e) {
+ public void componentHidden(ComponentEvent e)
+ {
showConsole(false);
}
@Override
- protected String getModelIdForFile(String pdbFile) {
- if (modelFileNames == null) {
+ protected String getModelIdForFile(String pdbFile)
+ {
+ if (modelFileNames == null)
+ {
return "";
}
- for (int i = 0; i < modelFileNames.length; i++) {
- if (modelFileNames[i].equalsIgnoreCase(pdbFile)) {
+ for (int i = 0; i < modelFileNames.length; i++)
+ {
+ if (modelFileNames[i].equalsIgnoreCase(pdbFile))
+ {
return String.valueOf(i + 1);
}
}
}
@Override
- protected ViewerType getViewerType() {
+ protected ViewerType getViewerType()
+ {
return ViewerType.JMOL;
}
@Override
- protected String getModelId(int pdbfnum, String file) {
+ protected String getModelId(int pdbfnum, String file)
+ {
return String.valueOf(pdbfnum + 1);
}
* @see https://chemapps.stolaf.edu/jmol/docs/#writemodel
*/
@Override
- public String getSessionFileExtension() {
+ public String getSessionFileExtension()
+ {
return ".spt";
}
@Override
- public void selectionChanged(BS arg0) {
+ public void selectionChanged(BS arg0)
+ {
// TODO Auto-generated method stub
}
@Override
- public SequenceRenderer getSequenceRenderer(AlignmentViewPanel avp) {
+ public SequenceRenderer getSequenceRenderer(AlignmentViewPanel avp)
+ {
return new jalview.gui.SequenceRenderer(avp.getAlignViewport());
}
@Override
- public String getHelpURL() {
+ public String getHelpURL()
+ {
return "http://wiki.jmol.org"; // BH 2018
}
}