From: jprocter Date: Mon, 13 Sep 2010 21:03:05 +0000 (+0000) Subject: refactored to remove App reference in Applet (JAL-638) X-Git-Tag: Release_2_6~45 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=201bc30894442f6bc28ae412199e6f776eb42b5f;p=jalview.git refactored to remove App reference in Applet (JAL-638) --- diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 8e72380..31f91ee 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -376,7 +376,7 @@ public abstract class JalviewJmolBinding implements StructureListener, } } String[] selcom = new String[files.length]; - int nmatched=0; + int nmatched = 0; // generate select statements to select regions to superimpose structures { for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) @@ -390,7 +390,8 @@ public abstract class JalviewJmolBinding implements StructureListener, { if (matched[r]) { - if (pdbfnum==0) { + if (pdbfnum == 0) + { nmatched++; } if (lpos != commonrpositions[pdbfnum][r] - 1) @@ -439,8 +440,10 @@ public abstract class JalviewJmolBinding implements StructureListener, } } } - // TODO: consider bailing if nmatched less than 4 because superposition not well defined. - // TODO: refactor superposable position search (above) from jmol selection construction (below) + // TODO: consider bailing if nmatched less than 4 because superposition not + // well defined. + // TODO: refactor superposable position search (above) from jmol selection + // construction (below) for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { if (pdbfnum == refStructure) @@ -689,7 +692,7 @@ public abstract class JalviewJmolBinding implements StructureListener, // /StructureListener public synchronized String[] getPdbFile() { - if (viewer==null) + if (viewer == null) { return new String[0]; } @@ -705,8 +708,8 @@ public abstract class JalviewJmolBinding implements StructureListener, mset[j] = viewer.getModelFileName(i); _modelFileNameMap[j] = i; // record the model index for the filename // skip any additional models in the same file (NMR structures) - if ((mset[j] == null ? mset[j] != mset[j - 1] : (mset[j - 1] == null - || !mset[j].equals(mset[j - 1])))) + if ((mset[j] == null ? mset[j] != mset[j - 1] + : (mset[j - 1] == null || !mset[j].equals(mset[j - 1])))) { j++; } @@ -1019,12 +1022,16 @@ public abstract class JalviewJmolBinding implements StructureListener, return false; } - // incremented every time a load notification is successfully handled - lightweight mechanism for other threads to detect when they can start referrring to new structures. - private long loadNotifiesHandled=0; + // incremented every time a load notification is successfully handled - + // lightweight mechanism for other threads to detect when they can start + // referrring to new structures. + private long loadNotifiesHandled = 0; + public long getLoadNotifiesHandled() { return loadNotifiesHandled; } + public void notifyFileLoaded(String fullPathName, String fileName2, String modelName, String errorMsg, int modelParts) { @@ -1093,9 +1100,10 @@ public abstract class JalviewJmolBinding implements StructureListener, 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 = viewer.getData(""+(1+_modelFileNameMap[modelnum])+".0", - "PDB"); + // prolly need to resolve modelnumber properly - for now just use our + // 'best guess' + pdbfile = viewer.getData("" + (1 + _modelFileNameMap[modelnum]) + + ".0", "PDB"); pdbfhash = "" + pdbfile.hashCode(); } if (pdbentry != null) @@ -1107,8 +1115,8 @@ public abstract class JalviewJmolBinding implements StructureListener, boolean matches = false; if (fileName == null) { - if (false) - // see JAL-623 - need method of matching pasted data up + if (false) + // see JAL-623 - need method of matching pasted data up { pdb = ssm.setMapping(sequence[pe], chains[pe], pdbfile, AppletFormatAdapter.PASTE); @@ -1144,7 +1152,6 @@ public abstract class JalviewJmolBinding implements StructureListener, pdb = ssm.setMapping(sequence[pe], chains[pe], pdbentry[pe].getFile(), protocol); - } } if (matches) @@ -1162,19 +1169,19 @@ public abstract class JalviewJmolBinding implements StructureListener, } 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 = viewer.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 - // if properly registered then - notifyLoaded = true; + // 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 = viewer.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 + // if properly registered then + notifyLoaded = true; - } } + } // FILE LOADED OK // so finally, update the jmol bits and pieces if (jmolpopup != null) @@ -1292,9 +1299,11 @@ public abstract class JalviewJmolBinding implements StructureListener, /** * called to show or hide the associated console window container. + * * @param show */ public abstract void showConsole(boolean show); + /** * @param renderPanel * @param jmolfileio @@ -1309,8 +1318,10 @@ public abstract class JalviewJmolBinding implements StructureListener, String htmlName, URL documentBase, URL codeBase, String commandOptions) { - allocateViewer(renderPanel, jmolfileio, htmlName, documentBase, codeBase, commandOptions, null,null); + allocateViewer(renderPanel, jmolfileio, htmlName, documentBase, + codeBase, commandOptions, null, null); } + /** * * @param renderPanel @@ -1321,22 +1332,26 @@ public abstract class JalviewJmolBinding implements StructureListener, * @param documentBase * @param codeBase * @param commandOptions - * @param consolePanel - panel to contain Jmol console - * @param buttonsToShow - buttons to show on the console, in ordr + * @param consolePanel + * - panel to contain Jmol console + * @param buttonsToShow + * - buttons to show on the console, in ordr */ - public void allocateViewer(Component renderPanel, boolean jmolfileio, - String htmlName, URL documentBase, URL codeBase, - String commandOptions, final Container consolePanel, String buttonsToShow) - { - viewer = JmolViewer.allocateViewer(renderPanel, + public void allocateViewer(Component renderPanel, boolean jmolfileio, + String htmlName, URL documentBase, URL codeBase, + String commandOptions, final Container consolePanel, + String buttonsToShow) + { + viewer = JmolViewer.allocateViewer(renderPanel, (jmolfileio ? new SmarterJmolAdapter() : null), htmlName + ((Object) this).toString(), documentBase, codeBase, commandOptions, this); - - console = createJmolConsole(viewer, consolePanel, - buttonsToShow); - - viewer.setConsole(new JmolAppConsoleInterface() { + + console = createJmolConsole(viewer, consolePanel, buttonsToShow); + if (console != null) + { + viewer.setConsole(new JmolAppConsoleInterface() + { @Override public JmolScriptEditorInterface getScriptEditor() @@ -1372,7 +1387,7 @@ public abstract class JalviewJmolBinding implements StructureListener, public void sendConsoleEcho(String strEcho) { console.sendConsoleEcho(strEcho); - + } @Override @@ -1392,15 +1407,14 @@ public abstract class JalviewJmolBinding implements StructureListener, { console.dispose(); } - - + }); - - + } + } - - protected abstract JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2, - Container consolePanel, String buttonsToShow); + + protected abstract JmolAppConsoleInterface createJmolConsole( + JmolViewer viewer2, Container consolePanel, String buttonsToShow); protected org.jmol.api.JmolAppConsoleInterface console = null;