2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
23 import java.awt.event.*;
\r
24 import jalview.datamodel.*;
\r
25 import jalview.appletgui.*;
\r
26 import jalview.schemes.*;
\r
27 import java.awt.event.ActionListener;
\r
28 import java.awt.event.ActionEvent;
\r
31 public class AppletPDBViewer extends Frame implements ActionListener, ItemListener
\r
33 AppletPDBCanvas pdbcanvas;
\r
34 public AppletPDBViewer(String pdbtext,String type,
\r
36 SeqCanvas seqcanvas)
\r
43 catch (Exception ex)
\r
45 ex.printStackTrace();
\r
48 pdbcanvas = new AppletPDBCanvas(seqcanvas, seq);
\r
50 add(pdbcanvas, BorderLayout.CENTER);
\r
52 StringBuffer title = new StringBuffer(seq.getName() + ":");
\r
54 jalview.bin.JalviewLite.addFrame(this,title.toString(),400, 400);
\r
57 PDBfile pdbfile = new PDBfile(pdbtext, type);
\r
58 pdbcanvas.setPDBFile(pdbfile);
\r
60 catch(Exception ex){
\r
61 pdbcanvas.errorLoading = true;
\r
62 pdbcanvas.repaint();
\r
66 public void actionPerformed(ActionEvent evt)
\r
68 if(evt.getSource()==mapping)
\r
69 mapping_actionPerformed();
\r
70 else if(evt.getSource()==wire)
\r
71 wire_actionPerformed();
\r
72 else if(evt.getSource()==depth)
\r
73 depth_actionPerformed();
\r
74 else if(evt.getSource()==zbuffer)
\r
75 zbuffer_actionPerformed();
\r
76 else if(evt.getSource()==charge)
\r
77 charge_actionPerformed();
\r
79 else if(evt.getSource()==chain)
\r
80 chain_actionPerformed();
\r
81 else if(evt.getSource()==seqButton)
\r
82 seqButton_actionPerformed();
\r
83 else if(evt.getSource()==zappo)
\r
84 pdbcanvas.setColours(new ZappoColourScheme());
\r
85 else if(evt.getSource()==taylor)
\r
86 pdbcanvas.setColours(new TaylorColourScheme());
\r
87 else if(evt.getSource()==hydro)
\r
88 pdbcanvas.setColours(new HydrophobicColourScheme());
\r
89 else if(evt.getSource()==helix)
\r
90 pdbcanvas.setColours(new HelixColourScheme());
\r
91 else if(evt.getSource()==strand)
\r
92 pdbcanvas.setColours(new StrandColourScheme());
\r
93 else if(evt.getSource()==turn)
\r
94 pdbcanvas.setColours(new TurnColourScheme());
\r
95 else if(evt.getSource()==buried)
\r
96 pdbcanvas.setColours(new BuriedColourScheme());
\r
97 else if(evt.getSource()==user)
\r
99 pdbcanvas.bysequence = false;
\r
100 new jalview.appletgui.UserDefinedColours(pdbcanvas);
\r
104 public void itemStateChanged(ItemEvent evt)
\r
106 if (evt.getSource() == allchains)
\r
107 allchains_itemStateChanged();
\r
108 else if (evt.getSource() == wire)
\r
109 wire_actionPerformed();
\r
110 else if (evt.getSource() == depth)
\r
111 depth_actionPerformed();
\r
112 else if (evt.getSource() == zbuffer)
\r
113 zbuffer_actionPerformed();
\r
117 private void jbInit()
\r
120 setMenuBar(jMenuBar1);
\r
121 fileMenu.setLabel("File");
\r
122 coloursMenu.setLabel("Colours");
\r
123 mapping.setLabel("View Mapping");
\r
124 mapping.addActionListener(this);
\r
125 wire.setLabel("Wireframe");
\r
126 wire.addItemListener(this);
\r
127 depth.setState(true);
\r
128 depth.setLabel("Depthcue");
\r
129 depth.addItemListener(this);
\r
130 zbuffer.setState(true);
\r
131 zbuffer.setLabel("Z Buffering");
\r
132 zbuffer.addItemListener(this);
\r
133 charge.setLabel("Charge & Cysteine");
\r
134 charge.addActionListener(this);
\r
135 hydro.setLabel("Hydrophobicity");
\r
136 hydro.addActionListener(this);
\r
137 chain.setLabel("By Chain");
\r
138 chain.addActionListener(this);
\r
139 seqButton.setLabel("By Sequence");
\r
140 seqButton.addActionListener(this);
\r
141 allchains.setLabel("All Chains Visible");
\r
142 allchains.addItemListener(this);
\r
143 viewMenu.setLabel("View");
\r
144 zappo.setLabel("Zappo");
\r
145 zappo.addActionListener(this);
\r
146 taylor.setLabel("Taylor");
\r
147 taylor.addActionListener(this);
\r
148 helix.setLabel("Helix Propensity");
\r
149 helix.addActionListener(this);
\r
150 strand.setLabel("Strand Propensity");
\r
151 strand.addActionListener(this);
\r
152 turn.setLabel("Turn Propensity");
\r
153 turn.addActionListener(this);
\r
154 buried.setLabel("Buried Index");
\r
155 buried.addActionListener(this);
\r
156 user.setLabel("User Defined...");
\r
157 user.addActionListener(this);
\r
158 jMenuBar1.add(fileMenu);
\r
159 jMenuBar1.add(coloursMenu);
\r
160 jMenuBar1.add(viewMenu);
\r
161 fileMenu.add(mapping);;
\r
163 coloursMenu.add(seqButton);
\r
164 coloursMenu.add(chain);
\r
165 coloursMenu.add(charge);
\r
166 coloursMenu.add(zappo);
\r
167 coloursMenu.add(taylor);
\r
168 coloursMenu.add(hydro);
\r
169 coloursMenu.add(helix);
\r
170 coloursMenu.add(strand);
\r
171 coloursMenu.add(turn);
\r
172 coloursMenu.add(buried);
\r
173 coloursMenu.add(user);
\r
174 viewMenu.add(wire);
\r
175 viewMenu.add(depth);
\r
176 viewMenu.add(zbuffer);
\r
177 viewMenu.add(allchains);
\r
178 allchains.setState(true);
\r
181 MenuBar jMenuBar1 = new MenuBar();
\r
182 Menu fileMenu = new Menu();
\r
183 Menu coloursMenu = new Menu();
\r
184 MenuItem mapping = new MenuItem();
\r
185 CheckboxGroup bg = new CheckboxGroup();
\r
186 CheckboxMenuItem wire = new CheckboxMenuItem();
\r
187 CheckboxMenuItem depth = new CheckboxMenuItem();
\r
188 CheckboxMenuItem zbuffer = new CheckboxMenuItem();
\r
190 MenuItem charge = new MenuItem();
\r
191 MenuItem hydro = new MenuItem();
\r
192 MenuItem chain = new MenuItem();
\r
193 MenuItem seqButton = new MenuItem();
\r
195 CheckboxMenuItem allchains = new CheckboxMenuItem();
\r
196 Menu viewMenu = new Menu();
\r
197 MenuItem turn = new MenuItem();
\r
198 MenuItem strand = new MenuItem();
\r
199 MenuItem helix = new MenuItem();
\r
200 MenuItem taylor = new MenuItem();
\r
201 MenuItem zappo = new MenuItem();
\r
202 MenuItem buried = new MenuItem();
\r
203 MenuItem user = new MenuItem();
\r
205 public void charge_actionPerformed()
\r
207 pdbcanvas.bysequence = false;
\r
208 pdbcanvas.pdb.setChargeColours();
\r
209 pdbcanvas.redrawneeded=true;
\r
210 pdbcanvas.repaint();
\r
213 public void chain_actionPerformed()
\r
215 pdbcanvas.bysequence = false;
\r
216 pdbcanvas.pdb.setChainColours();
\r
217 pdbcanvas.redrawneeded=true;
\r
218 pdbcanvas.repaint();
\r
221 public void zbuffer_actionPerformed()
\r
223 pdbcanvas.zbuffer = ! pdbcanvas.zbuffer;
\r
224 pdbcanvas.redrawneeded=true;
\r
225 pdbcanvas.repaint();
\r
228 public void depth_actionPerformed()
\r
230 pdbcanvas.depthcue = ! pdbcanvas.depthcue;
\r
231 pdbcanvas.redrawneeded=true;
\r
232 pdbcanvas.repaint();
\r
235 public void wire_actionPerformed()
\r
237 pdbcanvas.wire = ! pdbcanvas.wire;
\r
238 pdbcanvas.redrawneeded=true;
\r
239 pdbcanvas.repaint();
\r
242 public void seqButton_actionPerformed()
\r
244 pdbcanvas.bysequence = true;
\r
245 pdbcanvas.updateSeqColours();
\r
246 pdbcanvas.repaint();
\r
250 public void mapping_actionPerformed()
\r
252 jalview.appletgui.CutAndPasteTransfer cap
\r
253 = new jalview.appletgui.CutAndPasteTransfer(false, null);
\r
254 Frame frame = new Frame();
\r
256 jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 500, 600);
\r
257 cap.setText(pdbcanvas.mappingDetails.toString());
\r
260 public void allchains_itemStateChanged()
\r
262 pdbcanvas.setAllchainsVisible(allchains.getState());
\r