2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.api.AlignmentViewPanel;
24 import jalview.bin.Cache;
25 import jalview.datamodel.PDBEntry;
26 import jalview.datamodel.SequenceI;
27 import jalview.ext.jmol.JalviewJmolBinding;
28 import jalview.structure.StructureSelectionManager;
30 import java.awt.Container;
31 import java.util.BitSet;
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 JalviewJmolBinding
40 private AppJmol appJmolWindow;
42 private FeatureRenderer fr = null;
44 public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
45 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
48 super(sSm, pdbentry, sequenceIs, chains, protocol);
49 appJmolWindow = appJmol;
53 public FeatureRenderer getFeatureRenderer(
54 AlignmentViewPanel alignment)
56 AlignmentPanel ap = (alignment == null) ? appJmolWindow.getAlignmentPanel()
57 : (AlignmentPanel) alignment;
58 if (ap.av.isShowSequenceFeatures())
62 fr = (jalview.gui.FeatureRenderer) ap.cloneFeatureRenderer();
66 ap.updateFeatureRenderer(fr);
74 public SequenceRenderer getSequenceRenderer(
75 AlignmentViewPanel alignment)
77 return new SequenceRenderer(((AlignmentPanel) alignment).av);
80 public void sendConsoleEcho(String strEcho)
84 console.sendConsoleEcho(strEcho);
88 public void sendConsoleMessage(String strStatus)
90 if (console != null && strStatus != null)
91 // && !strStatus.equals("Script completed"))
92 // should we squash the script completed string ?
94 console.sendConsoleMessage(strStatus);
99 public void showUrl(String url, String target)
103 jalview.util.BrowserLauncher.openURL(url);
104 } catch (Exception e)
106 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
107 // TODO: 2.6 : warn user if browser was not configured.
112 public void refreshGUI()
114 // appJmolWindow.repaint();
115 javax.swing.SwingUtilities.invokeLater(new Runnable()
119 appJmolWindow.updateTitleAndMenus();
120 appJmolWindow.revalidate();
125 public void updateColours(Object source)
127 AlignmentPanel ap = (AlignmentPanel) source, topap;
128 // ignore events from panels not used to colour this view
129 if (!appJmolWindow.isUsedforcolourby(ap))
133 if (!isLoadingFromArchive())
135 colourBySequence(ap.av.isShowSequenceFeatures(), ap);
139 public void notifyScriptTermination(String strStatus, int msWalltime)
141 // todo - script termination doesn't happen ?
142 // if (console != null)
143 // console.notifyScriptTermination(strStatus,
147 public void showUrl(String url)
149 showUrl(url, "jmol");
152 public void newJmolPopup(boolean translateLocale, String menuName,
155 jmolpopup = new JmolPopup();
156 jmolpopup.initialize(viewer, translateLocale, menuName, asPopup);
159 public void selectionChanged(BitSet arg0)
161 // TODO Auto-generated method stub
165 public void refreshPdbEntries()
167 // TODO Auto-generated method stub
171 public void showConsole(boolean b)
173 appJmolWindow.showConsole(b);
177 protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
178 Container consolePanel, String buttonsToShow)
180 return new AppConsole(viewer, consolePanel, buttonsToShow);
184 protected void releaseUIResources()
186 appJmolWindow = null;
191 public void releaseReferences(Object svl)
193 if (svl instanceof SeqPanel)
195 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);