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