2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.Container;
24 import java.util.BitSet;
26 import jalview.api.AlignmentViewPanel;
27 import jalview.bin.Cache;
28 import jalview.datamodel.PDBEntry;
29 import jalview.datamodel.SequenceI;
30 import jalview.structure.StructureSelectionManager;
32 import org.jmol.api.JmolAppConsoleInterface;
33 import org.jmol.api.JmolViewer;
34 import org.jmol.popup.JmolPopup;
35 import org.openscience.jmol.app.jmolpanel.AppConsole;
37 public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
43 private AppJmol appJmolWindow;
45 public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
46 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
49 super(sSm, pdbentry, sequenceIs, chains, protocol);
50 appJmolWindow = appJmol;
53 FeatureRenderer fr = null;
56 public jalview.api.FeatureRenderer getFeatureRenderer(
57 AlignmentViewPanel alignment)
59 AlignmentPanel ap = (alignment == null) ? appJmolWindow.ap
60 : (AlignmentPanel) alignment;
61 if (ap.av.isShowSequenceFeatures())
65 fr = (jalview.gui.FeatureRenderer) ap.cloneFeatureRenderer();
69 ap.updateFeatureRenderer(fr);
77 public jalview.api.SequenceRenderer getSequenceRenderer(
78 AlignmentViewPanel alignment)
80 return new SequenceRenderer(((AlignmentPanel) alignment).av);
83 public void sendConsoleEcho(String strEcho)
87 console.sendConsoleEcho(strEcho);
91 public void sendConsoleMessage(String strStatus)
93 if (console != null && strStatus != null)
94 // && !strStatus.equals("Script completed"))
95 // should we squash the script completed string ?
97 console.sendConsoleMessage(strStatus);
102 public void showUrl(String url, String target)
106 jalview.util.BrowserLauncher.openURL(url);
107 } catch (Exception e)
109 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
110 // TODO: 2.6 : warn user if browser was not configured.
115 public void refreshGUI()
117 // appJmolWindow.repaint();
118 javax.swing.SwingUtilities.invokeLater(new Runnable()
122 appJmolWindow.updateTitleAndMenus();
123 appJmolWindow.revalidate();
128 public void updateColours(Object source)
130 AlignmentPanel ap = (AlignmentPanel) source, topap;
131 // ignore events from panels not used to colour this view
132 if (!appJmolWindow.isUsedforcolourby(ap))
134 if (!isLoadingFromArchive())
136 colourBySequence(ap.av.isShowSequenceFeatures(), ap);
140 public void notifyScriptTermination(String strStatus, int msWalltime)
142 // todo - script termination doesn't happen ?
143 // if (console != null)
144 // console.notifyScriptTermination(strStatus,
148 public void showUrl(String url)
150 showUrl(url, "jmol");
153 public void newJmolPopup(boolean translateLocale, String menuName,
157 jmolpopup = new JmolPopup();
158 jmolpopup.initialize(viewer, translateLocale, menuName, asPopup);
161 public void selectionChanged(BitSet arg0)
163 // TODO Auto-generated method stub
167 public void refreshPdbEntries()
169 // TODO Auto-generated method stub
173 public void showConsole(boolean b)
175 appJmolWindow.showConsole(b);
179 * add the given sequences to the mapping scope for the given pdb file handle
182 * - pdbFile identifier
184 * - set of sequences it can be mapped to
186 public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)
188 for (int pe = 0; pe < pdbentry.length; pe++)
190 if (pdbentry[pe].getFile().equals(pdbFile))
192 addSequence(pe, seq);
198 protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
199 Container consolePanel, String buttonsToShow)
201 return new AppConsole(viewer, consolePanel, buttonsToShow);
205 protected void releaseUIResources()
207 appJmolWindow = null;
212 console.setVisible(false);
215 } catch (Exception x)
225 public void releaseReferences(Object svl)
227 if (svl instanceof SeqPanel)
229 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);