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.structures.JalviewStructureDisplayI;
25 import jalview.bin.Cache;
26 import jalview.datamodel.PDBEntry;
27 import jalview.datamodel.SequenceI;
28 import jalview.ext.jmol.JalviewJmolBinding;
29 import jalview.io.DataSourceType;
30 import jalview.structure.StructureSelectionManager;
32 import java.awt.Container;
35 import org.jmol.api.JmolAppConsoleInterface;
36 import org.jmol.java.BS;
37 import org.openscience.jmol.app.jmolpanel.console.AppConsole;
39 public class AppJmolBinding extends JalviewJmolBinding
41 private AppJmol appJmolWindow;
43 public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
44 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, DataSourceType protocol)
46 super(sSm, pdbentry, sequenceIs, protocol);
47 appJmolWindow = appJmol;
51 public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
53 return new SequenceRenderer(((AlignmentPanel) alignment).av);
57 public void sendConsoleEcho(String strEcho)
61 console.sendConsoleEcho(strEcho);
66 public void sendConsoleMessage(String strStatus)
68 if (console != null && strStatus != null)
69 // && !strStatus.equals("Script completed"))
70 // should we squash the script completed string ?
72 console.sendConsoleMessage(strStatus);
77 public void showUrl(String url, String target)
81 jalview.util.BrowserLauncher.openURL(url);
84 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
85 // TODO: 2.6 : warn user if browser was not configured.
90 public void refreshGUI()
92 // appJmolWindow.repaint();
93 javax.swing.SwingUtilities.invokeLater(new Runnable()
98 appJmolWindow.updateTitleAndMenus();
99 appJmolWindow.revalidate();
105 public void updateColours(Object source)
107 AlignmentPanel ap = (AlignmentPanel) source;
108 // ignore events from panels not used to colour this view
109 if (!appJmolWindow.isUsedforcolourby(ap))
113 if (!isLoadingFromArchive())
115 colourBySequence(ap);
120 public void notifyScriptTermination(String strStatus, int msWalltime)
122 // todo - script termination doesn't happen ?
123 // if (console != null)
124 // console.notifyScriptTermination(strStatus,
129 public void showUrl(String url)
131 showUrl(url, "jmol");
134 public void newJmolPopup(String menuName)
136 // jmolpopup = new JmolAwtPopup();
137 // jmolpopup.jpiInitialize((viewer), menuName);
141 public void selectionChanged(BS arg0)
143 // TODO Auto-generated method stub
148 public void refreshPdbEntries()
150 // TODO Auto-generated method stub
155 public void showConsole(boolean b)
157 appJmolWindow.showConsole(b);
161 protected JmolAppConsoleInterface createJmolConsole(
162 Container consolePanel, String buttonsToShow)
164 viewer.setJmolCallbackListener(this);
165 return new AppConsole(viewer, consolePanel, buttonsToShow);
169 protected void releaseUIResources()
171 appJmolWindow = null;
176 public void releaseReferences(Object svl)
178 if (svl instanceof SeqPanel)
180 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
185 public Map<String, Object> getJSpecViewProperty(String arg0)
187 // TODO Auto-generated method stub
192 public JalviewStructureDisplayI getViewer()
194 return appJmolWindow;
198 public jalview.api.FeatureRenderer getFeatureRenderer(
199 AlignmentViewPanel alignment)
201 AlignmentPanel ap = (alignment == null) ? appJmolWindow
202 .getAlignmentPanel() : (AlignmentPanel) alignment;
203 if (ap.av.isShowSequenceFeatures())
205 return ap.av.getAlignPanel().getSeqPanel().seqCanvas.fr;