X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=67327c13b26aed3f956a86c4c5b7bbf9e3c251e6;hb=c8f5deb89ce327cd4a103025122e2ee11a4c97fb;hp=8e723807051d6bc0460792f7059ca10e75bea361;hpb=e683768e084c5e2999846de881b3903f62417919;p=jalview.git diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 8e72380..67327c1 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -1,5 +1,5 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * * This file is part of Jalview. @@ -26,6 +26,7 @@ import java.awt.event.*; import javax.swing.JPanel; +import jalview.api.AlignmentViewPanel; import jalview.api.FeatureRenderer; import jalview.api.SequenceRenderer; import jalview.api.SequenceStructureBinding; @@ -43,7 +44,8 @@ import org.jmol.viewer.Viewer; import jalview.schemes.*; public abstract class JalviewJmolBinding implements StructureListener, - JmolStatusListener, SequenceStructureBinding, JmolSelectionListener + JmolStatusListener, SequenceStructureBinding, + JmolSelectionListener, ComponentListener { /** @@ -80,6 +82,8 @@ public abstract class JalviewJmolBinding implements StructureListener, public Vector chainNames; + Hashtable chainFile; + /** * array of target chains for seuqences - tied to pdbentry and sequence[] */ @@ -113,7 +117,7 @@ public abstract class JalviewJmolBinding implements StructureListener, public PDBEntry[] pdbentry; /** - * datasource protocol for access to PDBEntry + * datasource protocol for access to PDBEntrylatest */ String protocol = null; @@ -210,8 +214,9 @@ public abstract class JalviewJmolBinding implements StructureListener, p = mlength; mlength = lbl.indexOf(":", p); } while (p < mlength && mlength < (lbl.length() - 2)); + // TODO: lookup each pdb id and recover proper model number for it. cmd.append(":" + lbl.substring(mlength + 1) + " /" - + getModelNum(lbl.substring(0, mlength)) + " or "); + + (1 + getModelNum((String) chainFile.get(lbl))) + " or "); } if (cmd.length() > 0) cmd.setLength(cmd.length() - 4); @@ -229,8 +234,15 @@ public abstract class JalviewJmolBinding implements StructureListener, viewer.setJmolStatusListener(null); lastCommand = null; viewer = null; + releaseUIResources(); } + /** + * called by JalviewJmolbinding after closeViewer is called - release any + * resources and references so they can be garbage collected. + */ + protected abstract void releaseUIResources(); + public void colourByChain() { colourBySequence = false; @@ -282,195 +294,242 @@ public abstract class JalviewJmolBinding implements StructureListener, public void superposeStructures(AlignmentI alignment, int refStructure, ColumnSelection hiddenCols) { + superposeStructures(new AlignmentI[] + { alignment }, new int[] + { refStructure }, new ColumnSelection[] + { hiddenCols }); + } + + public void superposeStructures(AlignmentI[] _alignment, + int[] _refStructure, ColumnSelection[] _hiddenCols) + { String[] files = getPdbFile(); - if (refStructure >= files.length) - { - System.err.println("Invalid reference structure value " - + refStructure); - refStructure = -1; - } - if (refStructure < -1) + StringBuffer selectioncom = new StringBuffer(); + assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length); + // union of all aligned positions are collected together. + for (int a = 0; a < _alignment.length; a++) { - refStructure = -1; - } - StringBuffer command = new StringBuffer(), selectioncom = new StringBuffer(); + int refStructure = _refStructure[a]; + AlignmentI alignment = _alignment[a]; + ColumnSelection hiddenCols = _hiddenCols[a]; + if (a > 0 + && selectioncom.length() > 0 + && !selectioncom.substring(selectioncom.length() - 1).equals( + "|")) + { + selectioncom.append("|"); + } + // process this alignment + if (refStructure >= files.length) + { + System.err.println("Invalid reference structure value " + + refStructure); + refStructure = -1; + } + if (refStructure < -1) + { + refStructure = -1; + } + StringBuffer command = new StringBuffer(); - boolean matched[] = new boolean[alignment.getWidth()]; - for (int m = 0; m < matched.length; m++) - { + boolean matched[] = new boolean[alignment.getWidth()]; + for (int m = 0; m < matched.length; m++) + { - matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true; - } + matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true; + } - int commonrpositions[][] = new int[files.length][alignment.getWidth()]; - String isel[] = new String[files.length]; - // reference structure - all others are superposed in it - String[] targetC = new String[files.length]; - for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) - { - StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); + int commonrpositions[][] = new int[files.length][alignment.getWidth()]; + String isel[] = new String[files.length]; + // reference structure - all others are superposed in it + String[] targetC = new String[files.length]; + String[] chainNames = new String[files.length]; + for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) + { + StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); - if (mapping == null || mapping.length < 1) - continue; + if (mapping == null || mapping.length < 1) + continue; - int lastPos = -1; - for (int s = 0; s < sequence[pdbfnum].length; s++) - { - for (int sp, m = 0; m < mapping.length; m++) + int lastPos = -1; + for (int s = 0; s < sequence[pdbfnum].length; s++) { - if (mapping[m].getSequence() == sequence[pdbfnum][s] - && (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1) + for (int sp, m = 0; m < mapping.length; m++) { - if (refStructure == -1) - { - refStructure = pdbfnum; - } - SequenceI asp = alignment.getSequenceAt(sp); - for (int r = 0; r < matched.length; r++) + if (mapping[m].getSequence() == sequence[pdbfnum][s] + && (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1) { - if (!matched[r]) + if (refStructure == -1) { - continue; + refStructure = pdbfnum; } - matched[r] = false; // assume this is not a good site - if (r >= asp.getLength()) + SequenceI asp = alignment.getSequenceAt(sp); + for (int r = 0; r < matched.length; r++) { - continue; - } + if (!matched[r]) + { + continue; + } + matched[r] = false; // assume this is not a good site + if (r >= asp.getLength()) + { + continue; + } - if (jalview.util.Comparison.isGap(asp.getCharAt(r))) + if (jalview.util.Comparison.isGap(asp.getCharAt(r))) + { + // no mapping to gaps in sequence + continue; + } + int t = asp.findPosition(r); // sequence position + int apos = mapping[m].getAtomNum(t); + int pos = mapping[m].getPDBResNum(t); + + if (pos < 1 || pos == lastPos) + { + // can't align unmapped sequence + continue; + } + matched[r] = true; // this is a good ite + lastPos = pos; + // just record this residue position + commonrpositions[pdbfnum][r] = pos; + } + // create model selection suffix + isel[pdbfnum] = "/" + (pdbfnum + 1) + ".1"; + if (mapping[m].getChain() == null + || mapping[m].getChain().trim().length() == 0) { - // no mapping to gaps in sequence - continue; + targetC[pdbfnum] = ""; } - int t = asp.findPosition(r); // sequence position - int apos = mapping[m].getAtomNum(t); - int pos = mapping[m].getPDBResNum(t); - - if (pos < 1 || pos == lastPos) + else { - // can't align unmapped sequence - continue; + targetC[pdbfnum] = ":" + mapping[m].getChain(); } - matched[r] = true; // this is a good ite - lastPos = pos; - // just record this residue position - commonrpositions[pdbfnum][r] = pos; - } - // create model selection suffix - isel[pdbfnum] = "/" + (pdbfnum + 1) + ".1"; - if (mapping[m].getChain() == null - || mapping[m].getChain().trim().length() == 0) - { - targetC[pdbfnum] = ""; - } - else - { - targetC[pdbfnum] = ":" + mapping[m].getChain(); + chainNames[pdbfnum] = mapping[m].getPdbId() + + targetC[pdbfnum]; + // move on to next pdb file + s = sequence[pdbfnum].length; + break; } - // move on to next pdb file - s = sequence[pdbfnum].length; - break; } } } - } - String[] selcom = new String[files.length]; - int nmatched=0; - // generate select statements to select regions to superimpose structures - { - for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) + String[] selcom = new String[files.length]; + int nmatched = 0; + // generate select statements to select regions to superimpose structures { - String chainCd = targetC[pdbfnum]; - int lpos = -1; - boolean run = false; - StringBuffer molsel = new StringBuffer(); - molsel.append("{"); - for (int r = 0; r < matched.length; r++) + for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { - if (matched[r]) + String chainCd = targetC[pdbfnum]; + int lpos = -1; + boolean run = false; + StringBuffer molsel = new StringBuffer(); + molsel.append("{"); + for (int r = 0; r < matched.length; r++) { - if (pdbfnum==0) { - nmatched++; - } - if (lpos != commonrpositions[pdbfnum][r] - 1) + if (matched[r]) { - // discontinuity - if (lpos != -1) + if (pdbfnum == 0) { - molsel.append(lpos); - molsel.append(chainCd); - // molsel.append("} {"); - molsel.append("|"); + nmatched++; } - } - else - { - // continuous run - and lpos >-1 - if (!run) + if (lpos != commonrpositions[pdbfnum][r] - 1) + { + // discontinuity + if (lpos != -1) + { + molsel.append(lpos); + molsel.append(chainCd); + // molsel.append("} {"); + molsel.append("|"); + } + } + else { - // at the beginning, so add dash - molsel.append(lpos); - molsel.append("-"); + // continuous run - and lpos >-1 + if (!run) + { + // at the beginning, so add dash + molsel.append(lpos); + molsel.append("-"); + } + run = true; } - run = true; + lpos = commonrpositions[pdbfnum][r]; + // molsel.append(lpos); } - lpos = commonrpositions[pdbfnum][r]; - // molsel.append(lpos); + } + // add final selection phrase + if (lpos != -1) + { + molsel.append(lpos); + molsel.append(chainCd); + molsel.append("}"); + } + selcom[pdbfnum] = molsel.toString(); + selectioncom.append("(("); + selectioncom.append(selcom[pdbfnum].substring(1, + selcom[pdbfnum].length() - 1)); + selectioncom.append(" )& "); + selectioncom.append(pdbfnum + 1); + selectioncom.append(".1)"); + if (pdbfnum < files.length - 1) + { + selectioncom.append("|"); } } - // add final selection phrase - if (lpos != -1) + } + // 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) { - molsel.append(lpos); - molsel.append(chainCd); - molsel.append("}"); + continue; } - selcom[pdbfnum] = molsel.toString(); - selectioncom.append("(("); - selectioncom.append(selcom[pdbfnum].substring(1, - selcom[pdbfnum].length() - 1)); - selectioncom.append(" )& "); - selectioncom.append(pdbfnum + 1); - selectioncom.append(".1)"); - if (pdbfnum < files.length - 1) + command.append("echo "); + command.append("\"Superposing ("); + command.append(chainNames[pdbfnum]); + command.append(") against reference ("); + command.append(chainNames[refStructure]); + command.append(")\";\ncompare "); + command.append("{"); + command.append(1 + pdbfnum); + command.append(".1} {"); + command.append(1 + refStructure); + command.append(".1} SUBSET {*.CA | *.P} ATOMS "); + + // form the matched pair strings + String sep = ""; + for (int s = 0; s < 2; s++) { - selectioncom.append("|"); + command.append(selcom[(s == 0 ? pdbfnum : refStructure)]); } + command.append(" ROTATE TRANSLATE;\n"); } + System.out.println("Select regions:\n" + selectioncom.toString()); + evalStateCommand("select *; cartoons off; backbone; select (" + + selectioncom.toString() + "); cartoons; "); + // selcom.append("; ribbons; "); + System.out.println("Superimpose command(s):\n" + command.toString()); + + evalStateCommand(command.toString()); } - // 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) - { - continue; - } - command.append("compare "); - command.append("{"); - command.append(1 + pdbfnum); - command.append(".1} {"); - command.append(1 + refStructure); - command.append(".1} SUBSET {*.CA | *.P} ATOMS "); - - // form the matched pair strings - String sep = ""; - for (int s = 0; s < 2; s++) + if (selectioncom.length() > 0) + {// finally, mark all regions that were superposed. + if (selectioncom.substring(selectioncom.length() - 1).equals("|")) { - command.append(selcom[(s == 0 ? pdbfnum : refStructure)]); + selectioncom.setLength(selectioncom.length() - 1); } - command.append(" ROTATE TRANSLATE;\n"); + System.out.println("Select regions:\n" + selectioncom.toString()); + evalStateCommand("select *; cartoons off; backbone; select (" + + selectioncom.toString() + "); cartoons; "); + // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString()); } - System.out.println("Select regions:\n" + selectioncom.toString()); - evalStateCommand("select *; cartoons off; backbone; select (" - + selectioncom.toString() + "); cartoons; "); - // selcom.append("; ribbons; "); - System.out.println("Superimpose command(s):\n" + command.toString()); - - evalStateCommand(command.toString()); - - // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString()); } public void evalStateCommand(String command) @@ -489,7 +548,8 @@ public abstract class JalviewJmolBinding implements StructureListener, * using the getFeatureRenderer() and getSequenceRenderer() renderers but only * if colourBySequence is enabled. */ - public void colourBySequence(boolean showFeatures, AlignmentI alignment) + public void colourBySequence(boolean showFeatures, + jalview.api.AlignmentViewPanel alignmentv) { if (!colourBySequence) return; @@ -498,14 +558,15 @@ public abstract class JalviewJmolBinding implements StructureListener, return; } String[] files = getPdbFile(); - SequenceRenderer sr = getSequenceRenderer(); + + SequenceRenderer sr = getSequenceRenderer(alignmentv); FeatureRenderer fr = null; if (showFeatures) { - fr = getFeatureRenderer(); + fr = getFeatureRenderer(alignmentv); } - + AlignmentI alignment = alignmentv.getAlignment(); StringBuffer command = new StringBuffer(); for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) @@ -540,7 +601,7 @@ public abstract class JalviewJmolBinding implements StructureListener, Color col = sr.getResidueBoxColour(sequence[pdbfnum][s], r); - if (showFeatures) + if (showFeatures && fr != null) col = fr.findFeatureColour(col, sequence[pdbfnum][s], r); String newSelcom = (mapping[m].getChain() != " " ? ":" + mapping[m].getChain() : "") @@ -652,9 +713,12 @@ public abstract class JalviewJmolBinding implements StructureListener, * returns the current featureRenderer that should be used to colour the * structures * + * @param alignment + * * @return */ - public abstract FeatureRenderer getFeatureRenderer(); + public abstract FeatureRenderer getFeatureRenderer( + AlignmentViewPanel alignment); /** * instruct the Jalview binding to update the pdbentries vector if necessary @@ -689,7 +753,7 @@ public abstract class JalviewJmolBinding implements StructureListener, // /StructureListener public synchronized String[] getPdbFile() { - if (viewer==null) + if (viewer == null) { return new String[0]; } @@ -705,8 +769,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++; } @@ -730,9 +794,12 @@ public abstract class JalviewJmolBinding implements StructureListener, * returns the current sequenceRenderer that should be used to colour the * structures * + * @param alignment + * * @return */ - public abstract SequenceRenderer getSequenceRenderer(); + public abstract SequenceRenderer getSequenceRenderer( + AlignmentViewPanel alignment); // /////////////////////////////// // JmolStatusListener @@ -827,6 +894,7 @@ public abstract class JalviewJmolBinding implements StructureListener, public void mouseOverStructure(int atomIndex, String strInfo) { int pdbResNum; + int alocsep = strInfo.indexOf("^"); int mdlSep = strInfo.indexOf("/"); int chainSeparator = strInfo.indexOf(":"), chainSeparator1 = -1; @@ -839,9 +907,18 @@ public abstract class JalviewJmolBinding implements StructureListener, chainSeparator = mdlSep; } } - pdbResNum = Integer.parseInt(strInfo.substring( - strInfo.indexOf("]") + 1, chainSeparator)); + // handle insertion codes + if (alocsep != -1) + { + pdbResNum = Integer.parseInt(strInfo.substring( + strInfo.indexOf("]") + 1, alocsep)); + } + else + { + pdbResNum = Integer.parseInt(strInfo.substring( + strInfo.indexOf("]") + 1, chainSeparator)); + } String chainId; if (strInfo.indexOf(":") > -1) @@ -1019,12 +1096,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) { @@ -1044,6 +1125,7 @@ public abstract class JalviewJmolBinding implements StructureListener, String[] oldmodels = modelFileNames; modelFileNames = null; chainNames = new Vector(); + chainFile = new Hashtable(); boolean notifyLoaded = false; String[] modelfilenames = getPdbFile(); ssm = StructureSelectionManager.getStructureSelectionManager(); @@ -1093,9 +1175,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 +1190,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 +1227,6 @@ public abstract class JalviewJmolBinding implements StructureListener, pdb = ssm.setMapping(sequence[pe], chains[pe], pdbentry[pe].getFile(), protocol); - } } if (matches) @@ -1153,8 +1235,10 @@ public abstract class JalviewJmolBinding implements StructureListener, // add an entry for every chain in the model for (int i = 0; i < pdb.chains.size(); i++) { - chainNames.addElement(new String(pdb.id + ":" - + ((MCview.PDBChain) pdb.chains.elementAt(i)).id)); + String chid = new String(pdb.id + ":" + + ((MCview.PDBChain) pdb.chains.elementAt(i)).id); + chainFile.put(chid, pdbentry[pe].getFile()); + chainNames.addElement(chid); } notifyLoaded = true; } @@ -1162,19 +1246,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) @@ -1192,7 +1276,7 @@ public abstract class JalviewJmolBinding implements StructureListener, ssm.addStructureViewerListener(this); if (notifyLoaded) { - FeatureRenderer fr = getFeatureRenderer(); + FeatureRenderer fr = getFeatureRenderer(null); if (fr != null) { fr.featuresAdded(); @@ -1292,9 +1376,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 @@ -1305,12 +1391,14 @@ public abstract class JalviewJmolBinding implements StructureListener, * @param codeBase * @param commandOptions */ - public void allocateViewer(Component renderPanel, boolean jmolfileio, + public void allocateViewer(Container renderPanel, boolean jmolfileio, 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,88 +1409,54 @@ 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(Container 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() { - - @Override - public JmolScriptEditorInterface getScriptEditor() - { - return console.getScriptEditor(); - } - @Override - public JmolAppConsoleInterface getAppConsole(Viewer viewer, - Component display) - { - return console; - } + console = createJmolConsole(viewer, consolePanel, buttonsToShow); + if (consolePanel != null) + { + consolePanel.addComponentListener(this); - public String getText() - { - return console.getText(); - } + } - @Override - public Object getMyMenuBar() - { - return console.getMyMenuBar(); - } + } - @Override - public void setVisible(boolean b) - { - showConsole(b); - } + protected abstract JmolAppConsoleInterface createJmolConsole( + JmolViewer viewer2, Container consolePanel, String buttonsToShow); - @Override - public void sendConsoleEcho(String strEcho) - { - console.sendConsoleEcho(strEcho); - - } + protected org.jmol.api.JmolAppConsoleInterface console = null; - @Override - public void sendConsoleMessage(String strInfo) - { - console.sendConsoleMessage(strInfo); - } + public void componentResized(ComponentEvent e) + { - @Override - public void zap() - { - console.zap(); - } + } + + public void componentMoved(ComponentEvent e) + { - @Override - public void dispose() - { - console.dispose(); - } - - - }); - - } - - protected abstract JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2, - Container consolePanel, String buttonsToShow); - protected org.jmol.api.JmolAppConsoleInterface console = null; + public void componentShown(ComponentEvent e) + { + showConsole(true); + } + + public void componentHidden(ComponentEvent e) + { + showConsole(false); + } public void setLoadingFromArchive(boolean loadingFromArchive) {