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