JAL-1854 fix Checkstyle import violations
[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.ext.jmol.JalviewJmolBinding;
27 import jalview.io.DataSourceType;
28 import jalview.structure.StructureSelectionManager;
29
30 import java.awt.Container;
31 import java.util.Map;
32
33 import org.jmol.api.JmolAppConsoleInterface;
34 import org.jmol.console.AppletConsole;
35 import org.jmol.java.BS;
36
37 class AppletJmolBinding extends JalviewJmolBinding
38 {
39
40   /**
41    * Window that contains the bound Jmol instance
42    */
43   private AppletJmol appletJmolBinding;
44
45   public AppletJmolBinding(AppletJmol appletJmol,
46           StructureSelectionManager sSm, PDBEntry[] pdbentry,
47           SequenceI[][] seq, DataSourceType protocol)
48   {
49     super(sSm, pdbentry, seq, protocol);
50     appletJmolBinding = appletJmol;
51   }
52
53   @Override
54   public jalview.api.FeatureRenderer getFeatureRenderer(
55           AlignmentViewPanel alignment)
56   {
57     return appletJmolBinding.ap.getFeatureRenderer();
58   }
59
60   @Override
61   public jalview.api.SequenceRenderer getSequenceRenderer(
62           AlignmentViewPanel alignment)
63   {
64     return new SequenceRenderer(((AlignmentPanel) alignment).av);
65   }
66
67   @Override
68   public void sendConsoleEcho(String strEcho)
69   {
70     if (appletJmolBinding.scriptWindow == null)
71     {
72       appletJmolBinding.showConsole(true);
73     }
74
75     appletJmolBinding.addToHistory(strEcho);
76   }
77
78   @Override
79   public void sendConsoleMessage(String strStatus)
80   {
81     if (appletJmolBinding.history != null && strStatus != null
82             && !strStatus.equals("Script completed"))
83     {
84       appletJmolBinding.addToHistory(strStatus);
85     }
86   }
87
88   @Override
89   public void showUrl(String url, String target)
90   {
91     appletJmolBinding.ap.alignFrame.showURL(url, target);
92
93   }
94
95   @Override
96   public void refreshGUI()
97   {
98     appletJmolBinding.updateTitleAndMenus();
99   }
100
101   @Override
102   public void updateColours(Object source)
103   {
104     AlignmentPanel ap = (AlignmentPanel) source;
105     colourBySequence(ap);
106   }
107
108   @Override
109   public void showUrl(String url)
110   {
111     try
112     {
113       appletJmolBinding.ap.av.applet.getAppletContext()
114               .showDocument(new java.net.URL(url), "jmol");
115     } catch (java.net.MalformedURLException ex)
116     {
117     }
118   }
119
120   public void newJmolPopup(boolean translateLocale, String menuName,
121           boolean asPopup)
122   {
123     // jmolpopup = new JmolAwtPopup(); // is this used?
124     // jmolpopup.jpiInitialize((viewer), menuName);
125   }
126
127   @Override
128   public void notifyScriptTermination(String strStatus, int msWalltime)
129   {
130     // do nothing.
131   }
132
133   @Override
134   public void selectionChanged(BS arg0)
135   {
136     // TODO Auto-generated method stub
137
138   }
139
140   @Override
141   public void refreshPdbEntries()
142   {
143     // noop
144   }
145
146   @Override
147   public void showConsole(boolean show)
148   {
149     appletJmolBinding.showConsole(show);
150   }
151
152   @Override
153   protected JmolAppConsoleInterface createJmolConsole(
154           Container consolePanel, String buttonsToShow)
155   {
156     JmolAppConsoleInterface appc = new AppletConsole();
157     appc.start(viewer);
158     return appc;
159   }
160
161   @Override
162   protected void releaseUIResources()
163   {
164     appletJmolBinding = null;
165     closeConsole();
166   }
167
168   @Override
169   public void releaseReferences(Object svl)
170   {
171   }
172
173   @Override
174   public int[] resizeInnerPanel(String data)
175   {
176     return null;
177   }
178
179   @Override
180   public Map<String, Object> getJSpecViewProperty(String arg0)
181   {
182     return null;
183   }
184 }