/*
- * 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.
import jalview.schemes.*;
public abstract class JalviewJmolBinding implements StructureListener,
- JmolStatusListener, SequenceStructureBinding, JmolSelectionListener
+ JmolStatusListener, SequenceStructureBinding,
+ JmolSelectionListener, ComponentListener
{
/**
public Vector chainNames;
+ Hashtable chainFile;
+
/**
* array of target chains for seuqences - tied to pdbentry and sequence[]
*/
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);
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;
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() : "")
String[] oldmodels = modelFileNames;
modelFileNames = null;
chainNames = new Vector();
+ chainFile = new Hashtable();
boolean notifyLoaded = false;
String[] modelfilenames = getPdbFile();
ssm = StructureSelectionManager.getStructureSelectionManager();
// 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;
}
* @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)
{
* @param buttonsToShow
* - buttons to show on the console, in ordr
*/
- public void allocateViewer(Component renderPanel, boolean jmolfileio,
+ public void allocateViewer(Container renderPanel, boolean jmolfileio,
String htmlName, URL documentBase, URL codeBase,
String commandOptions, final Container consolePanel,
String buttonsToShow)
commandOptions, this);
console = createJmolConsole(viewer, consolePanel, buttonsToShow);
- if (console != null)
+ if (consolePanel != null)
{
- viewer.setConsole(new JmolAppConsoleInterface()
- {
-
- @Override
- public JmolScriptEditorInterface getScriptEditor()
- {
- return console.getScriptEditor();
- }
-
- @Override
- public JmolAppConsoleInterface getAppConsole(Viewer viewer,
- Component display)
- {
- return console;
- }
+ consolePanel.addComponentListener(this);
- public String getText()
- {
- return console.getText();
- }
-
- @Override
- public Object getMyMenuBar()
- {
- return console.getMyMenuBar();
- }
-
- @Override
- public void setVisible(boolean b)
- {
- showConsole(b);
- }
+ }
- @Override
- public void sendConsoleEcho(String strEcho)
- {
- console.sendConsoleEcho(strEcho);
+ }
- }
+ protected abstract JmolAppConsoleInterface createJmolConsole(
+ JmolViewer viewer2, Container consolePanel, String buttonsToShow);
- @Override
- public void sendConsoleMessage(String strInfo)
- {
- console.sendConsoleMessage(strInfo);
- }
+ protected org.jmol.api.JmolAppConsoleInterface console = null;
- @Override
- public void zap()
- {
- console.zap();
- }
+ @Override
+ public void componentResized(ComponentEvent e)
+ {
- @Override
- public void dispose()
- {
- console.dispose();
- }
+ }
- });
- }
+ @Override
+ public void componentMoved(ComponentEvent e)
+ {
}
- protected abstract JmolAppConsoleInterface createJmolConsole(
- JmolViewer viewer2, Container consolePanel, String buttonsToShow);
+ @Override
+ public void componentShown(ComponentEvent e)
+ {
+ showConsole(true);
+ }
- protected org.jmol.api.JmolAppConsoleInterface console = null;
+ @Override
+ public void componentHidden(ComponentEvent e)
+ {
+ showConsole(false);
+ }
public void setLoadingFromArchive(boolean loadingFromArchive)
{