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;
40 import javajs.util.BS;
42 public class AppJmolBinding extends JalviewJmolBinding
44 protected AppJmol appJmolWindow;
46 public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
47 PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
48 DataSourceType protocol)
50 super(sSm, pdbentry, sequenceIs, protocol);
51 appJmolWindow = appJmol;
55 protected IProgressIndicator getIProgressIndicator()
57 return appJmolWindow.progressBar;
61 public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
63 return new SequenceRenderer(((AlignmentPanel) alignment).av);
67 public void sendConsoleEcho(String strEcho)
71 console.sendConsoleEcho(strEcho);
76 public void sendConsoleMessage(String strStatus)
78 if (console != null && strStatus != null)
79 // && !strStatus.equals("Script completed"))
80 // should we squash the script completed string ?
82 console.sendConsoleMessage(strStatus);
87 public void showUrl(String url, String target)
91 jalview.util.BrowserLauncher.openURL(url);
94 Cache.log.error("Failed to launch Jmol-associated url " + url, e);
95 // TODO: 2.6 : warn user if browser was not configured.
100 public void refreshGUI()
102 // appJmolWindow.repaint();
103 javax.swing.SwingUtilities.invokeLater(new Runnable()
108 appJmolWindow.updateTitleAndMenus();
109 // initiates a colourbySequence
110 // via seqColour_ActionPerformed.
111 appJmolWindow.revalidate();
117 public void updateColours(Object source)
119 AlignmentPanel ap = (AlignmentPanel) source;
120 // ignore events from panels not used to colour this view
121 if (!appJmolWindow.isUsedforcolourby(ap))
125 if (!isLoadingFromArchive())
127 colourBySequence(ap);
132 public void notifyScriptTermination(String strStatus, int msWalltime)
134 // todo - script termination doesn't happen ?
135 // if (console != null)
136 // console.notifyScriptTermination(strStatus,
141 public void showUrl(String url)
143 showUrl(url, "jmol");
146 public void newJmolPopup(String menuName)
148 // jmolpopup = new JmolAwtPopup();
149 // jmolpopup.jpiInitialize((viewer), menuName);
153 public void selectionChanged(BS arg0)
155 // TODO Auto-generated method stub
160 public void refreshPdbEntries()
162 // TODO Auto-generated method stub
167 public void showConsole(boolean b)
169 appJmolWindow.showConsole(b);
173 protected JmolAppConsoleInterface createJmolConsole(
174 Container consolePanel, String buttonsToShow)
176 viewer.setJmolCallbackListener(this);
177 return null;//BH can't do this yet. new AppConsole(viewer, consolePanel, buttonsToShow);
181 protected void releaseUIResources()
183 appJmolWindow = null;
188 public void releaseReferences(Object svl)
190 if (svl instanceof SeqPanel)
192 appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
197 public Map<String, Object> getJSpecViewProperty(String arg0)
199 // TODO Auto-generated method stub
204 public JalviewStructureDisplayI getViewer()
206 return appJmolWindow;
210 public jalview.api.FeatureRenderer getFeatureRenderer(
211 AlignmentViewPanel alignment)
213 AlignmentPanel ap = (alignment == null)
214 ? appJmolWindow.getAlignmentPanel()
215 : (AlignmentPanel) alignment;
216 if (ap.av.isShowSequenceFeatures())
218 return ap.av.getAlignPanel().getSeqPanel().seqCanvas.fr;
224 @SuppressWarnings("unused")
225 public void cacheFiles(List<File> files)
233 Platform.cacheFileData(f);