JAL-1807 update
[jalviewjs.git] / unused / appletgui / ExtJmol.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.api.FeatureRenderer;
25 import jalview.api.SequenceRenderer;
26 import jalview.datamodel.PDBEntry;
27 import jalview.datamodel.SequenceI;
28 import jalview.ext.jmol.JalviewJmolBinding;
29
30 import java.awt.Container;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.Map;
34 import java.util.Vector;
35
36 import org.jmol.api.JmolAppConsoleInterface;
37 import org.jmol.java.BS;
38 import org.jmol.viewer.Viewer;
39
40 /**
41  * bind an alignment view to an external Jmol instance.
42  * 
43  * @author JimP
44  * 
45  */
46 public class ExtJmol extends JalviewJmolBinding
47 {
48
49   private AlignmentPanel ap;
50
51   protected ExtJmol(jalview.appletgui.AlignFrame alframe,
52           PDBEntry[] pdbentry, SequenceI[][] seq, String[][] chains,
53           String protocol)
54   {
55     super(alframe.alignPanel.getStructureSelectionManager(), pdbentry, seq,
56             chains, protocol);
57   }
58
59   public ExtJmol(Viewer viewer, AlignmentPanel alignPanel,
60           SequenceI[][] seqs)
61   {
62     super(alignPanel.getStructureSelectionManager(), seqs, viewer);
63     ap = alignPanel;
64     notifyFileLoaded(null, null, null, null, 0);
65   }
66
67   private void notifyFileLoaded(Object object, Object object2, Object object3,
68                         Object object4, int i) {
69                 // TODO Auto-generated method stub
70                 
71         }
72
73         public void updateColours(Object source)
74   {
75
76     // TODO Auto-generated method stub
77
78   }
79
80   public void showUrl(String arg0)
81   {
82     showUrl(arg0, "jmol");
83   }
84
85   @Override
86   public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
87   {
88     AlignmentPanel ap = (AlignmentPanel) alignment;
89     if (ap.av.isShowSequenceFeatures())
90     {
91       return ap.getFeatureRenderer();
92     }
93     else
94     {
95       return null;
96     }
97   }
98
99   @Override
100   public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment)
101   {
102     return ((AlignmentPanel) alignment).getSequenceRenderer();
103   }
104
105   @Override
106   public void notifyScriptTermination(String strStatus, int msWalltime)
107   {
108     // ignore
109   }
110
111   @Override
112   public void sendConsoleEcho(String strEcho)
113   {
114     // ignore
115   }
116
117   @Override
118   public void sendConsoleMessage(String strStatus)
119   {
120     // ignore
121   }
122
123   @Override
124   public void showUrl(String url, String target)
125   {
126     ap.alignFrame.showURL(url, target);
127   }
128
129   @Override
130   public void refreshGUI()
131   {
132     // ignore
133   }
134
135   public void selectionChanged(BS arg0)
136   {
137     System.out.println(arg0);
138   }
139
140   @Override
141   public void refreshPdbEntries()
142   {
143     List<PDBEntry> pdbe = new ArrayList<PDBEntry>();
144     List<String> fileids = new ArrayList<String>();
145     SequenceI[] sq = ap.av.getAlignment().getSequencesArray();
146     for (int s = 0; s < sq.length; s++)
147     {
148       Vector<PDBEntry> pdbids = sq[s].getPDBId();
149       if (pdbids != null)
150       {
151         for (int pe = 0, peSize = pdbids.size(); pe < peSize; pe++)
152         {
153           PDBEntry pentry = pdbids.elementAt(pe);
154           if (!fileids.contains(pentry.getId()))
155           {
156             pdbe.add(pentry);
157           }
158           else
159           {
160             fileids.add(pentry.getId());
161           }
162         }
163       }
164     }
165     PDBEntry[] newEntries = new PDBEntry[pdbe.size()];
166     for (int pe = 0; pe < pdbe.size(); pe++)
167     {
168       newEntries[pe] = pdbe.get(pe);
169     }
170     setPdbentry(newEntries);
171   }
172
173   @Override
174   public void showConsole(boolean show)
175   {
176     // This never gets called because we haven't overriden the associated Jmol's
177     // console
178     System.err
179             .println("WARNING: unexpected call to ExtJmol's showConsole method. (showConsole="
180                     + show);
181   }
182
183   @Override
184   protected JmolAppConsoleInterface createJmolConsole(
185           Container consolePanel, String buttonsToShow)
186   {
187     // TODO Auto-generated method stub
188     return null;
189   }
190
191   @Override
192   protected void releaseUIResources()
193   {
194     ap = null;
195     closeConsole();
196
197   }
198
199   @Override
200   public void releaseReferences(Object svl)
201   {
202     // TODO Auto-generated method stub
203
204   }
205
206   @Override
207   public Map<String, Object> getJSpecViewProperty(String arg0)
208   {
209     // TODO Auto-generated method stub
210     return null;
211   }
212
213 }