Merge branch 'releases/Release_2_11_4_Branch'
[jalview.git] / 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.gui.ColourMenuHelper.ColourChangeListener;
25 import jalview.util.MessageManager;
26
27 import java.awt.BorderLayout;
28 import java.awt.GridLayout;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31
32 import javax.swing.JInternalFrame;
33 import javax.swing.JLabel;
34 import javax.swing.JMenu;
35 import javax.swing.JMenuBar;
36 import javax.swing.JMenuItem;
37 import javax.swing.JPanel;
38 import javax.swing.JRadioButtonMenuItem;
39
40 public abstract class GStructureViewer extends JInternalFrame implements
41         JalviewStructureDisplayI, ColourChangeListener
42 {
43   // private AAStructureBindingModel bindingModel;
44
45   protected JMenu savemenu;
46
47   protected JMenu viewMenu;
48
49   protected JMenu colourMenu;
50
51   protected JMenu chainMenu;
52
53   protected JMenu viewerActionMenu;
54
55   protected JMenuItem alignStructs;
56
57   protected JMenuItem fitToWindow;
58
59   protected JRadioButtonMenuItem seqColour;
60
61   protected JRadioButtonMenuItem chainColour;
62
63   protected JRadioButtonMenuItem chargeColour;
64
65   protected JRadioButtonMenuItem viewerColour;
66
67   protected JMenuItem helpItem;
68
69   protected JLabel statusBar;
70
71   protected JPanel statusPanel;
72
73   /**
74    * Constructor
75    */
76   public GStructureViewer()
77   {
78     try
79     {
80       jbInit();
81     } catch (Exception ex)
82     {
83       ex.printStackTrace();
84     }
85   }
86
87   private void jbInit() throws Exception
88   {
89     JMenuBar menuBar = new JMenuBar();
90     this.setJMenuBar(menuBar);
91
92     JMenu fileMenu = new JMenu();
93     fileMenu.setText(MessageManager.getString("action.file"));
94
95     savemenu = new JMenu();
96     savemenu.setActionCommand(MessageManager.getString("action.save_image"));
97     savemenu.setText(MessageManager.getString("action.save_as"));
98
99     JMenuItem pdbFile = new JMenuItem();
100     pdbFile.setText(MessageManager.getString("label.pdb_file"));
101     pdbFile.addActionListener(new ActionListener()
102     {
103       @Override
104       public void actionPerformed(ActionEvent actionEvent)
105       {
106         pdbFile_actionPerformed(actionEvent);
107       }
108     });
109
110     JMenuItem png = new JMenuItem();
111     png.setText("PNG");
112     png.addActionListener(new ActionListener()
113     {
114       @Override
115       public void actionPerformed(ActionEvent actionEvent)
116       {
117         png_actionPerformed(actionEvent);
118       }
119     });
120
121     JMenuItem eps = new JMenuItem();
122     eps.setText("EPS");
123     eps.addActionListener(new ActionListener()
124     {
125       @Override
126       public void actionPerformed(ActionEvent actionEvent)
127       {
128         eps_actionPerformed(actionEvent);
129       }
130     });
131
132     JMenuItem viewMapping = new JMenuItem();
133     viewMapping.setText(MessageManager.getString("label.view_mapping"));
134     viewMapping.addActionListener(new ActionListener()
135     {
136       @Override
137       public void actionPerformed(ActionEvent actionEvent)
138       {
139         viewMapping_actionPerformed(actionEvent);
140       }
141     });
142
143     viewMenu = new JMenu();
144     viewMenu.setText(MessageManager.getString("action.view"));
145
146     chainMenu = new JMenu();
147     chainMenu.setText(MessageManager.getString("action.show_chain"));
148
149     fitToWindow = new JMenuItem();
150     fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
151     fitToWindow.addActionListener(new ActionListener()
152     {
153       @Override
154       public void actionPerformed(ActionEvent actionEvent)
155       {
156         fitToWindow_actionPerformed();
157       }
158     });
159
160     JMenu helpMenu = new JMenu();
161     helpMenu.setText(MessageManager.getString("action.help"));
162     helpItem = new JMenuItem();
163     helpItem.setText(MessageManager.getString("label.jmol_help"));
164     helpItem.addActionListener(new ActionListener()
165     {
166       @Override
167       public void actionPerformed(ActionEvent actionEvent)
168       {
169         showHelp_actionPerformed(actionEvent);
170       }
171     });
172     alignStructs = new JMenuItem();
173     alignStructs.setText(MessageManager
174             .getString("label.superpose_structures"));
175     alignStructs.addActionListener(new ActionListener()
176     {
177       @Override
178       public void actionPerformed(ActionEvent actionEvent)
179       {
180         alignStructs_actionPerformed(actionEvent);
181       }
182     });
183
184     viewerActionMenu = new JMenu(); // text set in sub-classes
185     viewerActionMenu.setVisible(false);
186     viewerActionMenu.add(alignStructs);
187     colourMenu = new JMenu();
188     colourMenu.setText(MessageManager.getString("label.colours"));
189     fileMenu.add(savemenu);
190     fileMenu.add(viewMapping);
191     savemenu.add(pdbFile);
192     savemenu.add(png);
193     savemenu.add(eps);
194     viewMenu.add(chainMenu);
195     helpMenu.add(helpItem);
196
197     menuBar.add(fileMenu);
198     menuBar.add(viewMenu);
199     menuBar.add(colourMenu);
200     menuBar.add(viewerActionMenu);
201     menuBar.add(helpMenu);
202
203     statusPanel = new JPanel();
204     statusPanel.setLayout(new GridLayout());
205     this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
206     statusBar = new JLabel();
207     statusPanel.add(statusBar, null);
208   }
209
210   protected void fitToWindow_actionPerformed()
211   {
212   }
213
214   protected void highlightSelection_actionPerformed()
215   {
216   }
217
218   protected void viewerColour_actionPerformed(ActionEvent actionEvent)
219   {
220   }
221
222   protected abstract String alignStructs_actionPerformed(
223           ActionEvent actionEvent);
224
225   public void pdbFile_actionPerformed(ActionEvent actionEvent)
226   {
227
228   }
229
230   public void png_actionPerformed(ActionEvent actionEvent)
231   {
232
233   }
234
235   public void eps_actionPerformed(ActionEvent actionEvent)
236   {
237
238   }
239
240   public void viewMapping_actionPerformed(ActionEvent actionEvent)
241   {
242
243   }
244
245   public void seqColour_actionPerformed(ActionEvent actionEvent)
246   {
247
248   }
249
250   public void chainColour_actionPerformed(ActionEvent actionEvent)
251   {
252
253   }
254
255   public void chargeColour_actionPerformed(ActionEvent actionEvent)
256   {
257
258   }
259
260   public void background_actionPerformed(ActionEvent actionEvent)
261   {
262
263   }
264
265   public void showHelp_actionPerformed(ActionEvent actionEvent)
266   {
267
268   }
269 }