2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 import java.awt.Container;
21 import java.awt.event.ComponentEvent;
22 import java.awt.event.ComponentListener;
23 import java.awt.event.ContainerEvent;
24 import java.awt.event.ContainerListener;
25 import java.util.BitSet;
27 import javax.swing.JPanel;
29 import jalview.api.AlignmentViewPanel;
30 import jalview.bin.Cache;
31 import jalview.datamodel.AlignmentI;
32 import jalview.datamodel.PDBEntry;
33 import jalview.datamodel.SequenceI;
35 import org.jmol.api.JmolAppConsoleInterface;
36 import org.jmol.api.JmolViewer;
37 import org.jmol.popup.JmolPopup;
38 import org.openscience.jmol.app.jmolpanel.AppConsole;
40 public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
46 private AppJmol appJmolWindow;
48 public AppJmolBinding(AppJmol appJmol, PDBEntry[] pdbentry,
49 SequenceI[][] sequenceIs, String[][] chains, String protocol)
51 super(pdbentry, sequenceIs, chains, protocol);
52 appJmolWindow = appJmol;
55 FeatureRenderer fr = null;
58 public jalview.api.FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
60 AlignmentPanel ap = (alignment==null) ? appJmolWindow.ap : (AlignmentPanel) alignment;
61 if (ap.av.showSequenceFeatures)
65 fr = new FeatureRenderer((AlignmentPanel)alignment);
68 fr.transferSettings(((AlignmentPanel)alignment).
69 seqPanel.seqCanvas.getFeatureRenderer());
76 public jalview.api.SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
78 return new SequenceRenderer(((AlignmentPanel)alignment).av);
81 public void sendConsoleEcho(String strEcho)
85 console.sendConsoleEcho(strEcho);
89 public void sendConsoleMessage(String strStatus)
91 if (console != null && strStatus != null)
92 // && !strStatus.equals("Script completed"))
93 // should we squash the script completed string ?
95 console.sendConsoleMessage(strStatus);
100 public void showUrl(String url, String target)
104 jalview.util.BrowserLauncher.openURL(url);
105 } catch (Exception e)
107 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
108 // TODO: 2.6 : warn user if browser was not configured.
113 public void refreshGUI()
115 // appJmolWindow.repaint();
116 javax.swing.SwingUtilities.invokeLater(new Runnable()
120 appJmolWindow.updateTitleAndMenus();
121 appJmolWindow.revalidate();
126 public void updateColours(Object source)
128 AlignmentPanel ap = (AlignmentPanel) source,topap;
129 // ignore events from unrelated or non-user interactive frames
130 if ((topap=appJmolWindow.getAlignmentPanelFor(ap.av.getAlignment()))==null || topap.alignFrame.getCurrentView() != ap.av || appJmolWindow.isUsedforcolourby(ap))
132 if (!isLoadingFromArchive()) {
133 colourBySequence(ap.av.getShowSequenceFeatures(), ap);
137 public void notifyScriptTermination(String strStatus, int msWalltime)
139 // todo - script termination doesn't happen ?
140 // if (console != null)
141 // console.notifyScriptTermination(strStatus,
145 public void showUrl(String url)
147 showUrl(url, "jmol");
150 public void newJmolPopup(boolean translateLocale, String menuName,
154 jmolpopup = JmolPopup.newJmolPopup(viewer, translateLocale, menuName,
158 public void selectionChanged(BitSet arg0)
160 // TODO Auto-generated method stub
164 public void refreshPdbEntries()
166 // TODO Auto-generated method stub
170 public void showConsole(boolean b)
172 appJmolWindow.showConsole(b);
176 * add the given sequences to the mapping scope for the given pdb file handle
179 * - pdbFile identifier
181 * - set of sequences it can be mapped to
183 public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)
185 for (int pe = 0; pe < pdbentry.length; pe++)
187 if (pdbentry[pe].getFile().equals(pdbFile))
189 addSequence(pe, seq);
195 protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
196 Container consolePanel, String buttonsToShow)
198 return new AppConsole(viewer, consolePanel, buttonsToShow);
202 protected void releaseUIResources()
204 appJmolWindow = null;
209 console.setVisible(false);
212 } catch (Exception x)
222 public void releaseReferences(Object svl)
224 if (svl instanceof SeqPanel) {
225 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);