JAL-1683 replace year/version strings with tokens in source
[jalview.git] / src / jalview / appletgui / AppletJmolBinding.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.appletgui;
22
23 import jalview.api.AlignmentViewPanel;
24 import jalview.datamodel.PDBEntry;
25 import jalview.datamodel.SequenceI;
26 import jalview.structure.StructureSelectionManager;
27
28 import java.awt.Container;
29 import java.util.BitSet;
30
31 import org.jmol.api.JmolAppConsoleInterface;
32 import org.jmol.api.JmolViewer;
33 import org.jmol.popup.JmolPopup;
34
35 class AppletJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
36 {
37
38   /**
39    * Window that contains the bound Jmol instance
40    */
41   private AppletJmol appletJmolBinding;
42
43   public AppletJmolBinding(AppletJmol appletJmol,
44           StructureSelectionManager sSm, PDBEntry[] pdbentry,
45           SequenceI[][] seq, String[][] chains, String protocol)
46   {
47     super(sSm, pdbentry, seq, chains, protocol);
48     appletJmolBinding = appletJmol;
49   }
50
51   public jalview.api.FeatureRenderer getFeatureRenderer(
52           AlignmentViewPanel alignment)
53   {
54     AlignmentPanel ap = (AlignmentPanel) alignment;
55     if (appletJmolBinding.ap.av.isShowSequenceFeatures())
56     {
57       if (appletJmolBinding.fr == null)
58       {
59         appletJmolBinding.fr = new jalview.appletgui.FeatureRenderer(
60                 appletJmolBinding.ap.av);
61       }
62
63       appletJmolBinding.fr
64               .transferSettings(appletJmolBinding.ap.seqPanel.seqCanvas
65                       .getFeatureRenderer());
66     }
67
68     return appletJmolBinding.fr;
69   }
70
71   public jalview.api.SequenceRenderer getSequenceRenderer(
72           AlignmentViewPanel alignment)
73   {
74     return new SequenceRenderer(((AlignmentPanel) alignment).av);
75   }
76
77   public void sendConsoleEcho(String strEcho)
78   {
79     if (appletJmolBinding.scriptWindow == null)
80     {
81       appletJmolBinding.showConsole(true);
82     }
83
84     appletJmolBinding.history.append("\n" + strEcho);
85   }
86
87   public void sendConsoleMessage(String strStatus)
88   {
89     if (appletJmolBinding.history != null && strStatus != null
90             && !strStatus.equals("Script completed"))
91     {
92       appletJmolBinding.history.append("\n" + strStatus);
93     }
94   }
95
96   public void showUrl(String url, String target)
97   {
98     appletJmolBinding.ap.alignFrame.showURL(url, target);
99
100   }
101
102   public void refreshGUI()
103   {
104     appletJmolBinding.updateTitleAndMenus();
105   }
106
107   public void updateColours(Object source)
108   {
109     AlignmentPanel ap = (AlignmentPanel) source;
110     colourBySequence(ap.av.isShowSequenceFeatures(), ap);
111   }
112
113   public void showUrl(String url)
114   {
115     try
116     {
117       appletJmolBinding.ap.av.applet.getAppletContext().showDocument(
118               new java.net.URL(url), "jmol");
119     } catch (java.net.MalformedURLException ex)
120     {
121     }
122   }
123
124   public void newJmolPopup(boolean translateLocale, String menuName,
125           boolean asPopup)
126   {
127
128     jmolpopup = new JmolPopup();
129     jmolpopup.initialize(viewer, translateLocale, menuName, asPopup);
130   }
131
132   public void notifyScriptTermination(String strStatus, int msWalltime)
133   {
134     // do nothing.
135   }
136
137   public void selectionChanged(BitSet arg0)
138   {
139     // TODO Auto-generated method stub
140
141   }
142
143   @Override
144   public void refreshPdbEntries()
145   {
146     // noop
147   }
148
149   @Override
150   public void showConsole(boolean show)
151   {
152     appletJmolBinding.showConsole(show);
153   }
154
155   @Override
156   protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
157           Container consolePanel, String buttonsToShow)
158   {
159     // return new org.jmol.console.AppletConsole(viewer2, consolePanel);
160     JmolAppConsoleInterface appc = new org.jmol.console.AppletConsole()
161             .getAppConsole(viewer2);
162     return appc;
163   }
164
165   @Override
166   protected void releaseUIResources()
167   {
168     appletJmolBinding = null;
169     closeConsole();
170   }
171
172   @Override
173   public void releaseReferences(Object svl)
174   {
175   }
176
177   @Override
178   public void resizeInnerPanel(String data)
179   {
180     // TODO Auto-generated method stub
181
182   }
183 }