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;
31 import jalview.util.Platform;
33 import java.awt.Container;
35 import java.util.List;
38 import org.jmol.api.JmolAppConsoleInterface;
39 import javajs.util.BS;
41 import org.openscience.jmol.app.jmolpanel.console.AppConsole;
43 public class AppJmolBinding extends JalviewJmolBinding
45 private AppJmol appJmolWindow;
47 public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
48 PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
49 DataSourceType protocol)
51 super(sSm, pdbentry, sequenceIs, protocol);
52 appJmolWindow = appJmol;
56 protected IProgressIndicator getIProgressIndicator()
58 return appJmolWindow.progressBar;
62 public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
64 return new SequenceRenderer(((AlignmentPanel) alignment).av);
68 public void sendConsoleEcho(String strEcho)
72 console.sendConsoleEcho(strEcho);
77 public void sendConsoleMessage(String strStatus)
79 if (console != null && strStatus != null)
80 // && !strStatus.equals("Script completed"))
81 // should we squash the script completed string ?
83 console.sendConsoleMessage(strStatus);
88 public void showUrl(String url, String target)
92 jalview.util.BrowserLauncher.openURL(url);
95 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
96 // TODO: 2.6 : warn user if browser was not configured.
101 public void refreshGUI()
103 // appJmolWindow.repaint();
104 javax.swing.SwingUtilities.invokeLater(new Runnable()
109 appJmolWindow.updateTitleAndMenus();
110 appJmolWindow.revalidate();
116 public void updateColours(Object source)
118 AlignmentPanel ap = (AlignmentPanel) source;
119 // ignore events from panels not used to colour this view
120 if (!appJmolWindow.isUsedforcolourby(ap))
124 if (!isLoadingFromArchive())
126 colourBySequence(ap);
131 public void notifyScriptTermination(String strStatus, int msWalltime)
133 // todo - script termination doesn't happen ?
134 // if (console != null)
135 // console.notifyScriptTermination(strStatus,
140 public void showUrl(String url)
142 showUrl(url, "jmol");
145 public void newJmolPopup(String menuName)
147 // jmolpopup = new JmolAwtPopup();
148 // jmolpopup.jpiInitialize((viewer), menuName);
152 public void selectionChanged(BS arg0)
154 // TODO Auto-generated method stub
159 public void refreshPdbEntries()
161 // TODO Auto-generated method stub
166 public void showConsole(boolean b)
168 appJmolWindow.showConsole(b);
172 protected JmolAppConsoleInterface createJmolConsole(
173 Container consolePanel, String buttonsToShow)
175 viewer.setJmolCallbackListener(this);
176 return null;//BH can't do this yet. new AppConsole(viewer, consolePanel, buttonsToShow);
180 protected void releaseUIResources()
182 appJmolWindow = null;
187 public void releaseReferences(Object svl)
189 if (svl instanceof SeqPanel)
191 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
196 public Map<String, Object> getJSpecViewProperty(String arg0)
198 // TODO Auto-generated method stub
203 public JalviewStructureDisplayI getViewer()
205 return appJmolWindow;
209 public jalview.api.FeatureRenderer getFeatureRenderer(
210 AlignmentViewPanel alignment)
212 AlignmentPanel ap = (alignment == null)
213 ? appJmolWindow.getAlignmentPanel()
214 : (AlignmentPanel) alignment;
215 if (ap.av.isShowSequenceFeatures())
217 return ap.av.getAlignPanel().getSeqPanel().seqCanvas.fr;
223 @SuppressWarnings("unused")
224 public void cacheFiles(List<File> files) {
227 for (File f : files) {
228 String path = f.getAbsolutePath();
229 byte[] data = Platform.getFileBytes(f);
231 Platform.cacheFileData(path, data);