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;
33 import org.jmol.api.JmolAppConsoleInterface;
34 import org.jmol.java.BS;
35 import org.jmol.popup.JmolAwtPopup;
36 import org.openscience.jmol.app.jmolpanel.console.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);
81 public void sendConsoleEcho(String strEcho)
85 console.sendConsoleEcho(strEcho);
90 public void sendConsoleMessage(String strStatus)
92 if (console != null && strStatus != null)
93 // && !strStatus.equals("Script completed"))
94 // should we squash the script completed string ?
96 console.sendConsoleMessage(strStatus);
101 public void showUrl(String url, String target)
105 jalview.util.BrowserLauncher.openURL(url);
106 } catch (Exception e)
108 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
109 // TODO: 2.6 : warn user if browser was not configured.
114 public void refreshGUI()
116 // appJmolWindow.repaint();
117 javax.swing.SwingUtilities.invokeLater(new Runnable()
121 appJmolWindow.updateTitleAndMenus();
122 appJmolWindow.revalidate();
127 public void updateColours(Object source)
129 AlignmentPanel ap = (AlignmentPanel) source, topap;
130 // ignore events from panels not used to colour this view
131 if (!appJmolWindow.isUsedforcolourby(ap))
135 if (!isLoadingFromArchive())
137 colourBySequence(ap.av.isShowSequenceFeatures(), ap);
142 public void notifyScriptTermination(String strStatus, int msWalltime)
144 // todo - script termination doesn't happen ?
145 // if (console != null)
146 // console.notifyScriptTermination(strStatus,
150 public void showUrl(String url)
152 showUrl(url, "jmol");
155 public void newJmolPopup(String menuName)
157 jmolpopup = new JmolAwtPopup();
158 jmolpopup.jpiInitialize((viewer), menuName);
162 public void selectionChanged(BS arg0)
164 // TODO Auto-generated method stub
169 public void refreshPdbEntries()
171 // TODO Auto-generated method stub
176 public void showConsole(boolean b)
178 appJmolWindow.showConsole(b);
182 protected JmolAppConsoleInterface createJmolConsole(
183 Container consolePanel, String buttonsToShow)
185 viewer.setJmolCallbackListener(this);
186 return new AppConsole(viewer, consolePanel, buttonsToShow);
190 protected void releaseUIResources()
192 appJmolWindow = null;
197 public void releaseReferences(Object svl)
199 if (svl instanceof SeqPanel)
201 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
206 public Map<String, Object> getJSpecViewProperty(String arg0)
208 // TODO Auto-generated method stub