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()
117 appJmolWindow.updateTitleAndMenus();
118 appJmolWindow.revalidate();
123 public void updateColours(Object source)
125 AlignmentPanel ap = (AlignmentPanel) source;
126 if (appJmolWindow.ap.alignFrame.getCurrentView() != ap.av)
129 colourBySequence(ap.av.getShowSequenceFeatures(), ap.av.alignment);
132 public void notifyScriptTermination(String strStatus, int msWalltime)
134 // todo - script termination doesn't happen ?
135 // if (console != null)
136 // console.notifyScriptTermination(strStatus,
140 public void showUrl(String url)
142 showUrl(url, "jmol");
145 public void newJmolPopup(boolean translateLocale, String menuName,
149 jmolpopup = JmolPopup.newJmolPopup(viewer, translateLocale, menuName,
153 public void selectionChanged(BitSet arg0)
155 // TODO Auto-generated method stub
159 public void refreshPdbEntries()
161 // TODO Auto-generated method stub
165 public void showConsole(boolean b)
167 appJmolWindow.showConsole(b);
171 * add the given sequences to the mapping scope for the given pdb file handle
174 * - pdbFile identifier
176 * - set of sequences it can be mapped to
178 public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)
180 for (int pe = 0; pe < pdbentry.length; pe++)
182 if (pdbentry[pe].getFile().equals(pdbFile))
184 addSequence(pe, seq);
190 protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
191 Container consolePanel, String buttonsToShow)
193 return new AppConsole(viewer, consolePanel, buttonsToShow);
197 protected void releaseUIResources()
199 appJmolWindow = null;
204 console.setVisible(false);
207 } catch (Exception x)