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.bin.Cache;
30 import jalview.datamodel.PDBEntry;
31 import jalview.datamodel.SequenceI;
33 import org.jmol.api.JmolAppConsoleInterface;
34 import org.jmol.api.JmolViewer;
35 import org.jmol.popup.JmolPopup;
36 import org.openscience.jmol.app.jmolpanel.AppConsole;
38 public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
44 private AppJmol appJmolWindow;
46 public AppJmolBinding(AppJmol appJmol, PDBEntry[] pdbentry,
47 SequenceI[][] sequenceIs, String[][] chains, String protocol)
49 super(pdbentry, sequenceIs, chains, protocol);
50 appJmolWindow = appJmol;
53 FeatureRenderer fr = null;
56 public jalview.api.FeatureRenderer getFeatureRenderer()
58 if (appJmolWindow.ap.av.showSequenceFeatures)
62 fr = new FeatureRenderer(appJmolWindow.ap);
65 fr.transferSettings(appJmolWindow.ap.seqPanel.seqCanvas
66 .getFeatureRenderer());
73 public jalview.api.SequenceRenderer getSequenceRenderer()
75 return new SequenceRenderer(appJmolWindow.ap.av);
78 public void sendConsoleEcho(String strEcho)
82 console.sendConsoleEcho(strEcho);
86 public void sendConsoleMessage(String strStatus)
88 if (console != null && strStatus != null)
89 // && !strStatus.equals("Script completed"))
90 // should we squash the script completed string ?
92 console.sendConsoleMessage(strStatus);
97 public void showUrl(String url, String target)
101 jalview.util.BrowserLauncher.openURL(url);
102 } catch (Exception e)
104 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
105 // TODO: 2.6 : warn user if browser was not configured.
110 public void refreshGUI()
112 // appJmolWindow.repaint();
113 javax.swing.SwingUtilities.invokeLater(new Runnable() {
115 appJmolWindow.updateTitleAndMenus();
116 appJmolWindow.revalidate();
120 public void updateColours(Object source)
122 AlignmentPanel ap = (AlignmentPanel) source;
123 if (appJmolWindow.ap.alignFrame.getCurrentView() != ap.av)
126 colourBySequence(ap.av.getShowSequenceFeatures(), ap.av.alignment);
129 public void notifyScriptTermination(String strStatus, int msWalltime)
131 // todo - script termination doesn't happen ?
132 //if (console != null)
133 //console.notifyScriptTermination(strStatus,
137 public void showUrl(String url)
139 showUrl(url, "jmol");
142 public void newJmolPopup(boolean translateLocale, String menuName,
146 jmolpopup = JmolPopup.newJmolPopup(viewer, translateLocale, menuName,
150 public void selectionChanged(BitSet arg0)
152 // TODO Auto-generated method stub
156 public void refreshPdbEntries()
158 // TODO Auto-generated method stub
162 public void showConsole(boolean b) {
163 appJmolWindow.showConsole(b);
167 * add the given sequences to the mapping scope for the given pdb file handle
170 * - pdbFile identifier
172 * - set of sequences it can be mapped to
174 public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)
176 for (int pe = 0; pe < pdbentry.length; pe++)
178 if (pdbentry[pe].getFile().equals(pdbFile))
180 addSequence(pe, seq);
186 protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
187 Container consolePanel, String buttonsToShow)
189 return new AppConsole(viewer, consolePanel, buttonsToShow);
193 protected void releaseUIResources()
195 appJmolWindow = null;
198 console.setVisible(false);
199 } catch (Error e) {} catch (Exception x) {};