update author list in license for (JAL-826)
[jalview.git] / src / jalview / appletgui / ExtJmol.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.appletgui;
19
20 import java.awt.Container;
21 import java.util.BitSet;
22 import java.util.Hashtable;
23 import java.util.Vector;
24
25 import org.jmol.api.JmolAppConsoleInterface;
26 import org.jmol.api.JmolViewer;
27
28 import jalview.api.AlignmentViewPanel;
29 import jalview.api.FeatureRenderer;
30 import jalview.api.SequenceRenderer;
31 import jalview.datamodel.AlignmentI;
32 import jalview.datamodel.PDBEntry;
33 import jalview.datamodel.SequenceI;
34 import jalview.ext.jmol.JalviewJmolBinding;
35
36 /**
37  * bind an alignment view to an external Jmol instance.
38  * 
39  * @author JimP
40  * 
41  */
42 public class ExtJmol extends JalviewJmolBinding
43 {
44
45   private AlignmentPanel ap;
46
47   protected ExtJmol(jalview.appletgui.AlignFrame alframe,
48           PDBEntry[] pdbentry, SequenceI[][] seq, String[][] chains,
49           String protocol)
50   {
51     super(alframe.alignPanel.getStructureSelectionManager(), pdbentry, seq, chains, protocol);
52   }
53
54   public ExtJmol(JmolViewer viewer, AlignmentPanel alignPanel,
55           SequenceI[][] seqs)
56   {
57     super(alignPanel.getStructureSelectionManager(), viewer);
58     ap = alignPanel;
59     this.sequence = seqs;
60     notifyFileLoaded(null, null, null, null, 0);
61   }
62
63   public void updateColours(Object source)
64   {
65
66     // TODO Auto-generated method stub
67
68   }
69
70   public void showUrl(String arg0)
71   {
72     showUrl(arg0, "jmol");
73   }
74
75   public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
76   {
77     AlignmentPanel ap = (AlignmentPanel)alignment;
78     if (ap.av.showSequenceFeatures)
79     {
80       return ap.getFeatureRenderer();
81     }
82     else
83     {
84       return null;
85     }
86   }
87
88   public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
89   {
90     return ((AlignmentPanel)alignment).getSequenceRenderer();
91   }
92
93   public void notifyScriptTermination(String strStatus, int msWalltime)
94   {
95     // ignore
96   }
97
98   public void sendConsoleEcho(String strEcho)
99   {
100     // ignore
101   }
102
103   public void sendConsoleMessage(String strStatus)
104   {
105     // ignore
106   }
107
108   public void showUrl(String url, String target)
109   {
110     ap.alignFrame.showURL(url, target);
111   }
112
113   public void refreshGUI()
114   {
115     // ignore
116   }
117
118   public void selectionChanged(BitSet arg0)
119   {
120     System.out.println(arg0);
121   }
122
123   public void refreshPdbEntries()
124   {
125     Vector pdbe = new Vector();
126     Hashtable fileids = new Hashtable();
127     SequenceI[] sq = ap.av.getAlignment().getSequencesArray();
128     for (int s = 0; s < sq.length; s++)
129     {
130       Vector pdbids = sq[s].getPDBId();
131       if (pdbids != null)
132       {
133         for (int pe = 0, peSize = pdbids.size(); pe < peSize; pe++)
134         {
135           PDBEntry pentry = (PDBEntry) pdbids.elementAt(pe);
136           if (!fileids.containsKey(pentry.getId()))
137           {
138             pdbe.addElement(pentry);
139           }
140         }
141       }
142     }
143     pdbentry = new PDBEntry[pdbe.size()];
144     for (int pe = 0; pe < pdbe.size(); pe++)
145     {
146       pdbentry[pe] = (PDBEntry) pdbe.elementAt(pe);
147     }
148   }
149
150   @Override
151   public void showConsole(boolean show)
152   {
153     // This never gets called because we haven't overriden the associated Jmol's
154     // console
155     System.err
156             .println("WARNING: unexpected call to ExtJmol's showConsole method. (showConsole="
157                     + show);
158   }
159
160   @Override
161   protected JmolAppConsoleInterface createJmolConsole(JmolViewer viewer2,
162           Container consolePanel, String buttonsToShow)
163   {
164     // TODO Auto-generated method stub
165     return null;
166   }
167
168   @Override
169   protected void releaseUIResources()
170   {
171     ap = null;
172     if (console != null)
173     {
174       try
175       {
176         console.setVisible(false);
177       } catch (Error e)
178       {
179       } catch (Exception x)
180       {
181       }
182       ;
183       console = null;
184     }
185
186   }
187
188   @Override
189   public void releaseReferences(Object svl)
190   {
191     // TODO Auto-generated method stub
192     
193   }
194
195 }