JAL-2157 JAL-1803 refactored Sequence.updatePDBIds, parse DBRefs with
[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       @Override
118       public void actionPerformed(ActionEvent actionEvent)
119       {
120         pdbFile_actionPerformed(actionEvent);
121       }
122     });
123
124     JMenuItem png = new JMenuItem();
125     png.setText("PNG");
126     png.addActionListener(new ActionListener()
127     {
128       @Override
129       public void actionPerformed(ActionEvent actionEvent)
130       {
131         png_actionPerformed(actionEvent);
132       }
133     });
134
135     JMenuItem eps = new JMenuItem();
136     eps.setText("EPS");
137     eps.addActionListener(new ActionListener()
138     {
139       @Override
140       public void actionPerformed(ActionEvent actionEvent)
141       {
142         eps_actionPerformed(actionEvent);
143       }
144     });
145
146     JMenuItem viewMapping = new JMenuItem();
147     viewMapping.setText(MessageManager.getString("label.view_mapping"));
148     viewMapping.addActionListener(new ActionListener()
149     {
150       @Override
151       public void actionPerformed(ActionEvent actionEvent)
152       {
153         viewMapping_actionPerformed(actionEvent);
154       }
155     });
156     viewMenu.setText(MessageManager.getString("action.view"));
157
158     chainMenu.setText(MessageManager.getString("action.show_chain"));
159
160     fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
161     fitToWindow.addActionListener(new ActionListener()
162     {
163       @Override
164       public void actionPerformed(ActionEvent actionEvent)
165       {
166         fitToWindow_actionPerformed();
167       }
168     });
169
170     JMenu colourMenu = new JMenu();
171     colourMenu.setText(MessageManager.getString("label.colours"));
172
173     JMenuItem backGround = new JMenuItem();
174     backGround
175             .setText(MessageManager.getString("action.background_colour"));
176     backGround.addActionListener(new ActionListener()
177     {
178       @Override
179       public void actionPerformed(ActionEvent actionEvent)
180       {
181         backGround_actionPerformed(actionEvent);
182       }
183     });
184     seqColour.setSelected(false);
185     seqColour.setText(MessageManager.getString("action.by_sequence"));
186     seqColour.addActionListener(new ActionListener()
187     {
188       @Override
189       public void actionPerformed(ActionEvent actionEvent)
190       {
191         seqColour_actionPerformed(actionEvent);
192       }
193     });
194     chainColour.setText(MessageManager.getString("action.by_chain"));
195     chainColour.addActionListener(new ActionListener()
196     {
197       @Override
198       public void actionPerformed(ActionEvent actionEvent)
199       {
200         chainColour_actionPerformed(actionEvent);
201       }
202     });
203     chargeColour.setText(MessageManager.getString("label.charge_cysteine"));
204     chargeColour.addActionListener(new ActionListener()
205     {
206       @Override
207       public void actionPerformed(ActionEvent actionEvent)
208       {
209         chargeColour_actionPerformed(actionEvent);
210       }
211     });
212     zappoColour.setText(MessageManager.getString("label.zappo"));
213     zappoColour.addActionListener(new ActionListener()
214     {
215       @Override
216       public void actionPerformed(ActionEvent actionEvent)
217       {
218         zappoColour_actionPerformed(actionEvent);
219       }
220     });
221     taylorColour.setText(MessageManager.getString("label.taylor"));
222     taylorColour.addActionListener(new ActionListener()
223     {
224       @Override
225       public void actionPerformed(ActionEvent actionEvent)
226       {
227         taylorColour_actionPerformed(actionEvent);
228       }
229     });
230     hydroColour.setText(MessageManager.getString("label.hydrophobicity"));
231     hydroColour.addActionListener(new ActionListener()
232     {
233       @Override
234       public void actionPerformed(ActionEvent actionEvent)
235       {
236         hydroColour_actionPerformed(actionEvent);
237       }
238     });
239     strandColour.setText(MessageManager
240             .getString("label.strand_propensity"));
241     strandColour.addActionListener(new ActionListener()
242     {
243       @Override
244       public void actionPerformed(ActionEvent actionEvent)
245       {
246         strandColour_actionPerformed(actionEvent);
247       }
248     });
249     helixColour.setText(MessageManager.getString("label.helix_propensity"));
250     helixColour.addActionListener(new ActionListener()
251     {
252       @Override
253       public void actionPerformed(ActionEvent actionEvent)
254       {
255         helixColour_actionPerformed(actionEvent);
256       }
257     });
258     turnColour.setText(MessageManager.getString("label.turn_propensity"));
259     turnColour.addActionListener(new ActionListener()
260     {
261       @Override
262       public void actionPerformed(ActionEvent actionEvent)
263       {
264         turnColour_actionPerformed(actionEvent);
265       }
266     });
267     buriedColour.setText(MessageManager.getString("label.buried_index"));
268     buriedColour.addActionListener(new ActionListener()
269     {
270       @Override
271       public void actionPerformed(ActionEvent actionEvent)
272       {
273         buriedColour_actionPerformed(actionEvent);
274       }
275     });
276     purinePyrimidineColour.setText(MessageManager
277             .getString("label.purine_pyrimidine"));
278     purinePyrimidineColour.addActionListener(new ActionListener()
279     {
280       @Override
281       public void actionPerformed(ActionEvent actionEvent)
282       {
283         purinePyrimidineColour_actionPerformed(actionEvent);
284       }
285     });
286
287     userColour.setText(MessageManager.getString("action.user_defined"));
288     userColour.addActionListener(new ActionListener()
289     {
290       @Override
291       public void actionPerformed(ActionEvent actionEvent)
292       {
293         userColour_actionPerformed(actionEvent);
294       }
295     });
296     viewerColour.setSelected(false);
297     viewerColour
298             .setText(MessageManager.getString("label.colour_with_jmol"));
299     viewerColour.setToolTipText(MessageManager
300             .getString("label.let_jmol_manage_structure_colours"));
301     viewerColour.addActionListener(new ActionListener()
302     {
303       @Override
304       public void actionPerformed(ActionEvent actionEvent)
305       {
306         viewerColour_actionPerformed(actionEvent);
307       }
308     });
309
310     JMenu helpMenu = new JMenu();
311     helpMenu.setText(MessageManager.getString("action.help"));
312     helpItem.setText(MessageManager.getString("label.jmol_help"));
313     helpItem.addActionListener(new ActionListener()
314     {
315       @Override
316       public void actionPerformed(ActionEvent actionEvent)
317       {
318         showHelp_actionPerformed(actionEvent);
319       }
320     });
321     alignStructs
322             .setText(MessageManager.getString("label.align_structures"));
323     alignStructs.addActionListener(new ActionListener()
324     {
325       @Override
326       public void actionPerformed(ActionEvent actionEvent)
327       {
328         alignStructs_actionPerformed(actionEvent);
329       }
330     });
331     viewerActionMenu.setText(MessageManager.getString("label.jmol"));
332     menuBar.add(fileMenu);
333     menuBar.add(viewMenu);
334     menuBar.add(colourMenu);
335     menuBar.add(viewerActionMenu);
336     viewerActionMenu.setVisible(false);
337     menuBar.add(helpMenu);
338     fileMenu.add(savemenu);
339     fileMenu.add(viewMapping);
340     savemenu.add(pdbFile);
341     savemenu.add(png);
342     savemenu.add(eps);
343     viewMenu.add(chainMenu);
344
345     colourMenu.add(seqColour);
346     colourMenu.add(chainColour);
347     colourMenu.add(chargeColour);
348     colourMenu.add(zappoColour);
349     colourMenu.add(taylorColour);
350     colourMenu.add(hydroColour);
351     colourMenu.add(helixColour);
352     colourMenu.add(strandColour);
353     colourMenu.add(turnColour);
354     colourMenu.add(buriedColour);
355     colourMenu.add(purinePyrimidineColour);
356     colourMenu.add(userColour);
357     colourMenu.add(viewerColour);
358     colourMenu.add(backGround);
359
360     ButtonGroup colourButtons = new ButtonGroup();
361
362     colourButtons.add(seqColour);
363     colourButtons.add(chainColour);
364     colourButtons.add(chargeColour);
365     colourButtons.add(zappoColour);
366     colourButtons.add(taylorColour);
367     colourButtons.add(hydroColour);
368     colourButtons.add(helixColour);
369     colourButtons.add(strandColour);
370     colourButtons.add(turnColour);
371     colourButtons.add(buriedColour);
372     colourButtons.add(purinePyrimidineColour);
373     colourButtons.add(userColour);
374     colourButtons.add(viewerColour);
375
376     helpMenu.add(helpItem);
377     viewerActionMenu.add(alignStructs);
378
379     statusPanel.setLayout(new GridLayout());
380     this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
381     statusPanel.add(statusBar, null);
382   }
383
384   protected void fitToWindow_actionPerformed()
385   {
386   }
387
388   protected void highlightSelection_actionPerformed()
389   {
390   }
391
392   protected void viewerColour_actionPerformed(ActionEvent actionEvent)
393   {
394   }
395
396   protected void alignStructs_actionPerformed(ActionEvent actionEvent)
397   {
398   }
399
400   public void pdbFile_actionPerformed(ActionEvent actionEvent)
401   {
402
403   }
404
405   public void png_actionPerformed(ActionEvent actionEvent)
406   {
407
408   }
409
410   public void eps_actionPerformed(ActionEvent actionEvent)
411   {
412
413   }
414
415   public void viewMapping_actionPerformed(ActionEvent actionEvent)
416   {
417
418   }
419
420   public void seqColour_actionPerformed(ActionEvent actionEvent)
421   {
422
423   }
424
425   public void chainColour_actionPerformed(ActionEvent actionEvent)
426   {
427
428   }
429
430   public void chargeColour_actionPerformed(ActionEvent actionEvent)
431   {
432
433   }
434
435   public void zappoColour_actionPerformed(ActionEvent actionEvent)
436   {
437
438   }
439
440   public void taylorColour_actionPerformed(ActionEvent actionEvent)
441   {
442
443   }
444
445   public void hydroColour_actionPerformed(ActionEvent actionEvent)
446   {
447
448   }
449
450   public void helixColour_actionPerformed(ActionEvent actionEvent)
451   {
452
453   }
454
455   public void strandColour_actionPerformed(ActionEvent actionEvent)
456   {
457
458   }
459
460   public void turnColour_actionPerformed(ActionEvent actionEvent)
461   {
462
463   }
464
465   public void buriedColour_actionPerformed(ActionEvent actionEvent)
466   {
467
468   }
469
470   public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
471   {
472
473   }
474
475   public void userColour_actionPerformed(ActionEvent actionEvent)
476   {
477
478   }
479
480   public void backGround_actionPerformed(ActionEvent actionEvent)
481   {
482
483   }
484
485   public void showHelp_actionPerformed(ActionEvent actionEvent)
486   {
487
488   }
489
490   // {
491   // return bindingModel;
492   // }
493
494   // public void setBindingModel(AAStructureBindingModel bindingModel)
495   // {
496   // this.bindingModel = bindingModel;
497   // }
498
499 }