05826a20a2efecadc16517b74252a28358a5a924
[jalview.git] / src / jalview / jbgui / GStructureViewer.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
3  * Copyright (C) 2014 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.jbgui;
22
23 import jalview.api.structures.JalviewStructureDisplayI;
24 import jalview.util.MessageManager;
25
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28
29 import javax.swing.ButtonGroup;
30 import javax.swing.JInternalFrame;
31 import javax.swing.JMenu;
32 import javax.swing.JMenuBar;
33 import javax.swing.JMenuItem;
34 import javax.swing.JRadioButtonMenuItem;
35
36 public abstract class GStructureViewer extends JInternalFrame implements
37         JalviewStructureDisplayI
38 {
39   // private AAStructureBindingModel bindingModel;
40
41   protected JMenu savemenu = new JMenu();
42
43   protected JMenu viewMenu = new JMenu();
44
45   protected JMenu chainMenu = new JMenu();
46
47   protected JMenu viewerActionMenu = new JMenu();
48
49   protected JMenuItem alignStructs = new JMenuItem();
50
51   protected JRadioButtonMenuItem seqColour = new JRadioButtonMenuItem();
52
53   protected JRadioButtonMenuItem chainColour = new JRadioButtonMenuItem();
54
55   protected JRadioButtonMenuItem chargeColour = new JRadioButtonMenuItem();
56
57   protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
58
59   protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
60
61   protected JRadioButtonMenuItem hydroColour = new JRadioButtonMenuItem();
62
63   protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
64
65   protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
66
67   protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
68
69   protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
70
71   protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
72
73   protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
74
75   protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
76
77   protected JMenuItem helpItem = new JMenuItem();
78
79   /**
80    * Constructor
81    */
82   public GStructureViewer()
83   {
84     try
85     {
86       jbInit();
87     } catch (Exception ex)
88     {
89       ex.printStackTrace();
90     }
91   }
92
93   private void jbInit() throws Exception
94   {
95     JMenuBar menuBar = new JMenuBar();
96     this.setJMenuBar(menuBar);
97
98     JMenu fileMenu = new JMenu();
99     fileMenu.setText(MessageManager.getString("action.file"));
100
101     savemenu.setActionCommand(MessageManager.getString("action.save_image"));
102     savemenu.setText(MessageManager.getString("action.save_as"));
103
104     JMenuItem pdbFile = new JMenuItem();
105     pdbFile.setText(MessageManager.getString("label.pdb_file"));
106     pdbFile.addActionListener(new ActionListener()
107     {
108       public void actionPerformed(ActionEvent actionEvent)
109       {
110         pdbFile_actionPerformed(actionEvent);
111       }
112     });
113
114     JMenuItem png = new JMenuItem();
115     png.setText("PNG");
116     png.addActionListener(new ActionListener()
117     {
118       public void actionPerformed(ActionEvent actionEvent)
119       {
120         png_actionPerformed(actionEvent);
121       }
122     });
123
124     JMenuItem eps = new JMenuItem();
125     eps.setText("EPS");
126     eps.addActionListener(new ActionListener()
127     {
128       public void actionPerformed(ActionEvent actionEvent)
129       {
130         eps_actionPerformed(actionEvent);
131       }
132     });
133
134     JMenuItem viewMapping = new JMenuItem();
135     viewMapping.setText(MessageManager.getString("label.view_mapping"));
136     viewMapping.addActionListener(new ActionListener()
137     {
138       public void actionPerformed(ActionEvent actionEvent)
139       {
140         viewMapping_actionPerformed(actionEvent);
141       }
142     });
143     viewMenu.setText(MessageManager.getString("action.view"));
144     chainMenu.setText(MessageManager.getString("action.show_chain"));
145
146     JMenu colourMenu = new JMenu();
147     colourMenu.setText(MessageManager.getString("label.colours"));
148
149     JMenuItem backGround = new JMenuItem();
150     backGround.setText(MessageManager.getString("label.background_colour")
151             + "...");
152     backGround.addActionListener(new ActionListener()
153     {
154       public void actionPerformed(ActionEvent actionEvent)
155       {
156         backGround_actionPerformed(actionEvent);
157       }
158     });
159     seqColour.setSelected(false);
160     seqColour.setText(MessageManager.getString("action.by_sequence"));
161     seqColour.addActionListener(new ActionListener()
162     {
163       public void actionPerformed(ActionEvent actionEvent)
164       {
165         seqColour_actionPerformed(actionEvent);
166       }
167     });
168     chainColour.setText(MessageManager.getString("action.by_chain"));
169     chainColour.addActionListener(new ActionListener()
170     {
171       public void actionPerformed(ActionEvent actionEvent)
172       {
173         chainColour_actionPerformed(actionEvent);
174       }
175     });
176     chargeColour.setText(MessageManager.getString("label.charge_cysteine"));
177     chargeColour.addActionListener(new ActionListener()
178     {
179       public void actionPerformed(ActionEvent actionEvent)
180       {
181         chargeColour_actionPerformed(actionEvent);
182       }
183     });
184     zappoColour.setText(MessageManager.getString("label.zappo"));
185     zappoColour.addActionListener(new ActionListener()
186     {
187       public void actionPerformed(ActionEvent actionEvent)
188       {
189         zappoColour_actionPerformed(actionEvent);
190       }
191     });
192     taylorColour.setText(MessageManager.getString("label.taylor"));
193     taylorColour.addActionListener(new ActionListener()
194     {
195       public void actionPerformed(ActionEvent actionEvent)
196       {
197         taylorColour_actionPerformed(actionEvent);
198       }
199     });
200     hydroColour.setText(MessageManager.getString("label.hydrophobicity"));
201     hydroColour.addActionListener(new ActionListener()
202     {
203       public void actionPerformed(ActionEvent actionEvent)
204       {
205         hydroColour_actionPerformed(actionEvent);
206       }
207     });
208     strandColour.setText(MessageManager
209             .getString("label.strand_propensity"));
210     strandColour.addActionListener(new ActionListener()
211     {
212       public void actionPerformed(ActionEvent actionEvent)
213       {
214         strandColour_actionPerformed(actionEvent);
215       }
216     });
217     helixColour.setText(MessageManager.getString("label.helix_propensity"));
218     helixColour.addActionListener(new ActionListener()
219     {
220       public void actionPerformed(ActionEvent actionEvent)
221       {
222         helixColour_actionPerformed(actionEvent);
223       }
224     });
225     turnColour.setText(MessageManager.getString("label.turn_propensity"));
226     turnColour.addActionListener(new ActionListener()
227     {
228       public void actionPerformed(ActionEvent actionEvent)
229       {
230         turnColour_actionPerformed(actionEvent);
231       }
232     });
233     buriedColour.setText(MessageManager.getString("label.buried_index"));
234     buriedColour.addActionListener(new ActionListener()
235     {
236       public void actionPerformed(ActionEvent actionEvent)
237       {
238         buriedColour_actionPerformed(actionEvent);
239       }
240     });
241     purinePyrimidineColour.setText(MessageManager
242             .getString("label.purine_pyrimidine"));
243     purinePyrimidineColour.addActionListener(new ActionListener()
244     {
245       public void actionPerformed(ActionEvent actionEvent)
246       {
247         purinePyrimidineColour_actionPerformed(actionEvent);
248       }
249     });
250
251     userColour.setText(MessageManager.getString("action.user_defined"));
252     userColour.addActionListener(new ActionListener()
253     {
254       public void actionPerformed(ActionEvent actionEvent)
255       {
256         userColour_actionPerformed(actionEvent);
257       }
258     });
259     viewerColour.setSelected(false);
260     viewerColour
261             .setText(MessageManager.getString("label.colour_with_jmol"));
262     viewerColour.setToolTipText(MessageManager
263             .getString("label.let_jmol_manage_structure_colours"));
264     viewerColour.addActionListener(new ActionListener()
265     {
266       public void actionPerformed(ActionEvent actionEvent)
267       {
268         viewerColour_actionPerformed(actionEvent);
269       }
270     });
271
272     JMenu helpMenu = new JMenu();
273     helpMenu.setText(MessageManager.getString("action.help"));
274     helpItem.setText(MessageManager.getString("label.jmol_help"));
275     helpItem.addActionListener(new ActionListener()
276     {
277       public void actionPerformed(ActionEvent actionEvent)
278       {
279         showHelp_actionPerformed(actionEvent);
280       }
281     });
282     alignStructs
283             .setText(MessageManager.getString("label.align_structures"));
284     alignStructs.addActionListener(new ActionListener()
285     {
286       public void actionPerformed(ActionEvent actionEvent)
287       {
288         alignStructs_actionPerformed(actionEvent);
289       }
290     });
291     viewerActionMenu.setText(MessageManager.getString("label.jmol"));
292     menuBar.add(fileMenu);
293     menuBar.add(viewMenu);
294     menuBar.add(colourMenu);
295     menuBar.add(viewerActionMenu);
296     viewerActionMenu.setVisible(false);
297     menuBar.add(helpMenu);
298     fileMenu.add(savemenu);
299     fileMenu.add(viewMapping);
300     savemenu.add(pdbFile);
301     savemenu.add(png);
302     savemenu.add(eps);
303     viewMenu.add(chainMenu);
304
305     colourMenu.add(seqColour);
306     colourMenu.add(chainColour);
307     colourMenu.add(chargeColour);
308     colourMenu.add(zappoColour);
309     colourMenu.add(taylorColour);
310     colourMenu.add(hydroColour);
311     colourMenu.add(helixColour);
312     colourMenu.add(strandColour);
313     colourMenu.add(turnColour);
314     colourMenu.add(buriedColour);
315     colourMenu.add(purinePyrimidineColour);
316     colourMenu.add(userColour);
317     colourMenu.add(viewerColour);
318     colourMenu.add(backGround);
319
320     ButtonGroup colourButtons = new ButtonGroup();
321
322     colourButtons.add(seqColour);
323     colourButtons.add(chainColour);
324     colourButtons.add(chargeColour);
325     colourButtons.add(zappoColour);
326     colourButtons.add(taylorColour);
327     colourButtons.add(hydroColour);
328     colourButtons.add(helixColour);
329     colourButtons.add(strandColour);
330     colourButtons.add(turnColour);
331     colourButtons.add(buriedColour);
332     colourButtons.add(userColour);
333     colourButtons.add(viewerColour);
334
335     helpMenu.add(helpItem);
336     viewerActionMenu.add(alignStructs);
337   }
338
339   protected void viewerColour_actionPerformed(ActionEvent actionEvent)
340   {
341   }
342
343   protected void alignStructs_actionPerformed(ActionEvent actionEvent)
344   {
345   }
346
347   public void pdbFile_actionPerformed(ActionEvent actionEvent)
348   {
349
350   }
351
352   public void png_actionPerformed(ActionEvent actionEvent)
353   {
354
355   }
356
357   public void eps_actionPerformed(ActionEvent actionEvent)
358   {
359
360   }
361
362   public void viewMapping_actionPerformed(ActionEvent actionEvent)
363   {
364
365   }
366
367   public void seqColour_actionPerformed(ActionEvent actionEvent)
368   {
369
370   }
371
372   public void chainColour_actionPerformed(ActionEvent actionEvent)
373   {
374
375   }
376
377   public void chargeColour_actionPerformed(ActionEvent actionEvent)
378   {
379
380   }
381
382   public void zappoColour_actionPerformed(ActionEvent actionEvent)
383   {
384
385   }
386
387   public void taylorColour_actionPerformed(ActionEvent actionEvent)
388   {
389
390   }
391
392   public void hydroColour_actionPerformed(ActionEvent actionEvent)
393   {
394
395   }
396
397   public void helixColour_actionPerformed(ActionEvent actionEvent)
398   {
399
400   }
401
402   public void strandColour_actionPerformed(ActionEvent actionEvent)
403   {
404
405   }
406
407   public void turnColour_actionPerformed(ActionEvent actionEvent)
408   {
409
410   }
411
412   public void buriedColour_actionPerformed(ActionEvent actionEvent)
413   {
414
415   }
416
417   public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
418   {
419
420   }
421
422   public void userColour_actionPerformed(ActionEvent actionEvent)
423   {
424
425   }
426
427   public void backGround_actionPerformed(ActionEvent actionEvent)
428   {
429
430   }
431
432   public void showHelp_actionPerformed(ActionEvent actionEvent)
433   {
434
435   }
436
437   // {
438   // return bindingModel;
439   // }
440
441   // public void setBindingModel(AAStructureBindingModel bindingModel)
442   // {
443   // this.bindingModel = bindingModel;
444   // }
445
446 }