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.appletgui.AlignmentPanel;
24 import jalview.appletgui.EmbmenuFrame;
25 import jalview.datamodel.PDBEntry;
26 import jalview.datamodel.SequenceI;
27 import jalview.io.DataSourceType;
28 import jalview.schemes.BuriedColourScheme;
29 import jalview.schemes.HelixColourScheme;
30 import jalview.schemes.HydrophobicColourScheme;
31 import jalview.schemes.StrandColourScheme;
32 import jalview.schemes.TaylorColourScheme;
33 import jalview.schemes.TurnColourScheme;
34 import jalview.schemes.ZappoColourScheme;
35 import jalview.util.MessageManager;
37 import java.awt.BorderLayout;
38 import java.awt.CheckboxGroup;
39 import java.awt.CheckboxMenuItem;
40 import java.awt.Frame;
42 import java.awt.MenuBar;
43 import java.awt.MenuItem;
44 import java.awt.event.ActionEvent;
45 import java.awt.event.ActionListener;
46 import java.awt.event.ItemEvent;
47 import java.awt.event.ItemListener;
49 public class AppletPDBViewer extends EmbmenuFrame implements
50 ActionListener, ItemListener
52 AppletPDBCanvas pdbcanvas;
54 public AppletPDBViewer(PDBEntry pdbentry, SequenceI[] seq,
55 String[] chains, AlignmentPanel ap, DataSourceType protocol)
60 } catch (Exception ex)
65 pdbcanvas = new AppletPDBCanvas(pdbentry, seq, chains, ap, protocol);
67 embedMenuIfNeeded(pdbcanvas);
68 add(pdbcanvas, BorderLayout.CENTER);
70 StringBuffer title = new StringBuffer(seq[0].getName() + ":"
71 + pdbcanvas.pdbentry.getFile());
73 jalview.bin.JalviewLite.addFrame(this, title.toString(), 400, 400);
78 public void actionPerformed(ActionEvent evt)
80 if (evt.getSource() == mapping)
82 jalview.appletgui.CutAndPasteTransfer cap = new jalview.appletgui.CutAndPasteTransfer(
84 Frame frame = new Frame();
86 jalview.bin.JalviewLite.addFrame(frame,
87 MessageManager.getString("label.pdb_sequence_mapping"), 500,
89 cap.setText(pdbcanvas.mappingDetails.toString());
92 else if (evt.getSource() == charge)
94 pdbcanvas.bysequence = false;
95 pdbcanvas.pdb.setChargeColours();
98 else if (evt.getSource() == chain)
100 pdbcanvas.bysequence = false;
101 pdbcanvas.pdb.setChainColours();
103 else if (evt.getSource() == seqButton)
105 pdbcanvas.bysequence = true;
106 pdbcanvas.colourBySequence();
109 else if (evt.getSource() == zappo)
111 pdbcanvas.setColours(new ZappoColourScheme());
113 else if (evt.getSource() == taylor)
115 pdbcanvas.setColours(new TaylorColourScheme());
117 else if (evt.getSource() == hydro)
119 pdbcanvas.setColours(new HydrophobicColourScheme());
121 else if (evt.getSource() == helix)
123 pdbcanvas.setColours(new HelixColourScheme());
125 else if (evt.getSource() == strand)
127 pdbcanvas.setColours(new StrandColourScheme());
129 else if (evt.getSource() == turn)
131 pdbcanvas.setColours(new TurnColourScheme());
133 else if (evt.getSource() == buried)
135 pdbcanvas.setColours(new BuriedColourScheme());
137 else if (evt.getSource() == user)
139 pdbcanvas.bysequence = false;
140 new jalview.appletgui.UserDefinedColours(pdbcanvas);
143 pdbcanvas.redrawneeded = true;
149 public void itemStateChanged(ItemEvent evt)
151 if (evt.getSource() == allchains)
153 pdbcanvas.setAllchainsVisible(allchains.getState());
155 else if (evt.getSource() == wire)
157 pdbcanvas.wire = !pdbcanvas.wire;
159 else if (evt.getSource() == depth)
161 pdbcanvas.depthcue = !pdbcanvas.depthcue;
163 else if (evt.getSource() == zbuffer)
165 pdbcanvas.zbuffer = !pdbcanvas.zbuffer;
167 pdbcanvas.redrawneeded = true;
171 private void jbInit() throws Exception
173 setMenuBar(jMenuBar1);
174 fileMenu.setLabel(MessageManager.getString("action.file"));
175 coloursMenu.setLabel(MessageManager.getString("label.colours"));
176 mapping.setLabel(MessageManager.getString("label.view_mapping"));
177 mapping.addActionListener(this);
178 wire.setLabel(MessageManager.getString("label.wireframe"));
179 wire.addItemListener(this);
180 depth.setState(true);
181 depth.setLabel(MessageManager.getString("label.depthcue"));
182 depth.addItemListener(this);
183 zbuffer.setState(true);
184 zbuffer.setLabel(MessageManager.getString("label.z_buffering"));
185 zbuffer.addItemListener(this);
186 charge.setLabel(MessageManager.getString("label.charge_cysteine"));
187 charge.addActionListener(this);
188 hydro.setLabel(MessageManager
189 .getString("label.colourScheme_hydrophobic"));
190 hydro.addActionListener(this);
191 chain.setLabel(MessageManager.getString("action.by_chain"));
192 chain.addActionListener(this);
193 seqButton.setLabel(MessageManager.getString("action.by_sequence"));
194 seqButton.addActionListener(this);
196 .setLabel(MessageManager.getString("label.all_chains_visible"));
197 allchains.addItemListener(this);
198 viewMenu.setLabel(MessageManager.getString("action.view"));
199 zappo.setLabel(MessageManager.getString("label.colourScheme_zappo"));
200 zappo.addActionListener(this);
201 taylor.setLabel(MessageManager.getString("label.colourScheme_taylor"));
202 taylor.addActionListener(this);
203 helix.setLabel(MessageManager
204 .getString("label.colourScheme_helix_propensity"));
205 helix.addActionListener(this);
206 strand.setLabel(MessageManager
207 .getString("label.colourScheme_strand_propensity"));
208 strand.addActionListener(this);
209 turn.setLabel(MessageManager
210 .getString("label.colourScheme_turn_propensity"));
211 turn.addActionListener(this);
212 buried.setLabel(MessageManager
213 .getString("label.colourScheme_buried_index"));
214 buried.addActionListener(this);
215 user.setLabel(MessageManager.getString("action.user_defined"));
216 user.addActionListener(this);
217 jMenuBar1.add(fileMenu);
218 jMenuBar1.add(coloursMenu);
219 jMenuBar1.add(viewMenu);
220 fileMenu.add(mapping);
223 coloursMenu.add(seqButton);
224 coloursMenu.add(chain);
225 coloursMenu.add(charge);
226 coloursMenu.add(zappo);
227 coloursMenu.add(taylor);
228 coloursMenu.add(hydro);
229 coloursMenu.add(helix);
230 coloursMenu.add(strand);
231 coloursMenu.add(turn);
232 coloursMenu.add(buried);
233 coloursMenu.add(user);
236 viewMenu.add(zbuffer);
237 viewMenu.add(allchains);
238 allchains.setState(true);
241 MenuBar jMenuBar1 = new MenuBar();
243 Menu fileMenu = new Menu();
245 Menu coloursMenu = new Menu();
247 MenuItem mapping = new MenuItem();
249 CheckboxGroup bg = new CheckboxGroup();
251 CheckboxMenuItem wire = new CheckboxMenuItem();
253 CheckboxMenuItem depth = new CheckboxMenuItem();
255 CheckboxMenuItem zbuffer = new CheckboxMenuItem();
257 MenuItem charge = new MenuItem();
259 MenuItem hydro = new MenuItem();
261 MenuItem chain = new MenuItem();
263 MenuItem seqButton = new MenuItem();
265 CheckboxMenuItem allchains = new CheckboxMenuItem();
267 Menu viewMenu = new Menu();
269 MenuItem turn = new MenuItem();
271 MenuItem strand = new MenuItem();
273 MenuItem helix = new MenuItem();
275 MenuItem taylor = new MenuItem();
277 MenuItem zappo = new MenuItem();
279 MenuItem buried = new MenuItem();
281 MenuItem user = new MenuItem();
283 // End StructureListener
284 // //////////////////////////