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.api.SequenceRendererI;
25 import jalview.api.structures.JalviewStructureDisplayI;
26 import jalview.bin.Cache;
27 import jalview.datamodel.PDBEntry;
28 import jalview.datamodel.SequenceI;
29 import jalview.ext.jmol.JalviewJmolBinding;
30 import jalview.io.DataSourceType;
31 import jalview.structure.StructureSelectionManager;
33 import java.awt.Container;
36 import org.jmol.api.JmolAppConsoleInterface;
37 import org.jmol.java.BS;
38 import org.openscience.jmol.app.jmolpanel.console.AppConsole;
40 public class AppJmolBinding extends JalviewJmolBinding
42 private AppJmol appJmolWindow;
44 public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
45 PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
46 DataSourceType protocol)
48 super(sSm, pdbentry, sequenceIs, protocol);
49 appJmolWindow = appJmol;
53 protected IProgressIndicator getIProgressIndicator()
55 return appJmolWindow.progressBar;
59 public void sendConsoleEcho(String strEcho)
63 console.sendConsoleEcho(strEcho);
68 public void sendConsoleMessage(String strStatus)
70 if (console != null && strStatus != null)
71 // && !strStatus.equals("Script completed"))
72 // should we squash the script completed string ?
74 console.sendConsoleMessage(strStatus);
79 public void showUrl(String url, String target)
83 jalview.util.BrowserLauncher.openURL(url);
86 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
87 // TODO: 2.6 : warn user if browser was not configured.
92 public void refreshGUI()
94 // appJmolWindow.repaint();
95 javax.swing.SwingUtilities.invokeLater(new Runnable()
100 appJmolWindow.updateTitleAndMenus();
101 appJmolWindow.revalidate();
107 public void notifyScriptTermination(String strStatus, int msWalltime)
109 // todo - script termination doesn't happen ?
110 // if (console != null)
111 // console.notifyScriptTermination(strStatus,
116 public void showUrl(String url)
118 showUrl(url, "jmol");
121 public void newJmolPopup(String menuName)
123 // jmolpopup = new JmolAwtPopup();
124 // jmolpopup.jpiInitialize((viewer), menuName);
128 public void selectionChanged(BS arg0)
133 public void refreshPdbEntries()
138 public void showConsole(boolean b)
140 appJmolWindow.showConsole(b);
144 protected JmolAppConsoleInterface createJmolConsole(
145 Container consolePanel, String buttonsToShow)
147 viewer.setJmolCallbackListener(this);
148 return new AppConsole(viewer, consolePanel, buttonsToShow);
152 protected void releaseUIResources()
154 appJmolWindow = null;
159 public void releaseReferences(Object svl)
161 if (svl instanceof SeqPanel)
163 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
168 public Map<String, Object> getJSpecViewProperty(String arg0)
174 public JalviewStructureDisplayI getViewer()
176 return appJmolWindow;
180 public jalview.api.FeatureRenderer getFeatureRenderer(
181 AlignmentViewPanel alignment)
183 AlignmentPanel ap = (alignment == null)
184 ? appJmolWindow.getAlignmentPanel()
185 : (AlignmentPanel) alignment;
186 if (ap.av.isShowSequenceFeatures())
188 return ap.av.getAlignPanel().getSeqPanel().seqCanvas.fr;