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