Merge branch 'releases/Release_2_10_2b1_Branch'
[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.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
41         implements 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(
97             MessageManager.getString("action.save_image"));
98     savemenu.setText(MessageManager.getString("action.save_as"));
99
100     JMenuItem pdbFile = new JMenuItem();
101     pdbFile.setText(MessageManager.getString("label.pdb_file"));
102     pdbFile.addActionListener(new ActionListener()
103     {
104       @Override
105       public void actionPerformed(ActionEvent actionEvent)
106       {
107         pdbFile_actionPerformed(actionEvent);
108       }
109     });
110
111     JMenuItem png = new JMenuItem();
112     png.setText("PNG");
113     png.addActionListener(new ActionListener()
114     {
115       @Override
116       public void actionPerformed(ActionEvent actionEvent)
117       {
118         png_actionPerformed(actionEvent);
119       }
120     });
121
122     JMenuItem eps = new JMenuItem();
123     eps.setText("EPS");
124     eps.addActionListener(new ActionListener()
125     {
126       @Override
127       public void actionPerformed(ActionEvent actionEvent)
128       {
129         eps_actionPerformed(actionEvent);
130       }
131     });
132
133     JMenuItem viewMapping = new JMenuItem();
134     viewMapping.setText(MessageManager.getString("label.view_mapping"));
135     viewMapping.addActionListener(new ActionListener()
136     {
137       @Override
138       public void actionPerformed(ActionEvent actionEvent)
139       {
140         viewMapping_actionPerformed(actionEvent);
141       }
142     });
143
144     viewMenu = new JMenu();
145     viewMenu.setText(MessageManager.getString("action.view"));
146
147     chainMenu = new JMenu();
148     chainMenu.setText(MessageManager.getString("action.show_chain"));
149
150     fitToWindow = new JMenuItem();
151     fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
152     fitToWindow.addActionListener(new ActionListener()
153     {
154       @Override
155       public void actionPerformed(ActionEvent actionEvent)
156       {
157         fitToWindow_actionPerformed();
158       }
159     });
160
161     JMenu helpMenu = new JMenu();
162     helpMenu.setText(MessageManager.getString("action.help"));
163     helpItem = new JMenuItem();
164     helpItem.setText(MessageManager.getString("label.jmol_help"));
165     helpItem.addActionListener(new ActionListener()
166     {
167       @Override
168       public void actionPerformed(ActionEvent actionEvent)
169       {
170         showHelp_actionPerformed(actionEvent);
171       }
172     });
173     alignStructs = new JMenuItem();
174     alignStructs.setText(
175             MessageManager.getString("label.superpose_structures"));
176     alignStructs.addActionListener(new ActionListener()
177     {
178       @Override
179       public void actionPerformed(ActionEvent actionEvent)
180       {
181         alignStructs_actionPerformed(actionEvent);
182       }
183     });
184
185     viewerActionMenu = new JMenu(); // text set in sub-classes
186     viewerActionMenu.setVisible(false);
187     viewerActionMenu.add(alignStructs);
188     colourMenu = new JMenu();
189     colourMenu.setText(MessageManager.getString("label.colours"));
190     fileMenu.add(savemenu);
191     fileMenu.add(viewMapping);
192     savemenu.add(pdbFile);
193     savemenu.add(png);
194     savemenu.add(eps);
195     viewMenu.add(chainMenu);
196     helpMenu.add(helpItem);
197
198     menuBar.add(fileMenu);
199     menuBar.add(viewMenu);
200     menuBar.add(colourMenu);
201     menuBar.add(viewerActionMenu);
202     menuBar.add(helpMenu);
203
204     statusPanel = new JPanel();
205     statusPanel.setLayout(new GridLayout());
206     this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
207     statusBar = new JLabel();
208     statusPanel.add(statusBar, null);
209   }
210
211   protected void fitToWindow_actionPerformed()
212   {
213   }
214
215   protected void highlightSelection_actionPerformed()
216   {
217   }
218
219   protected void viewerColour_actionPerformed(ActionEvent actionEvent)
220   {
221   }
222
223   protected abstract String alignStructs_actionPerformed(
224           ActionEvent actionEvent);
225
226   public void pdbFile_actionPerformed(ActionEvent actionEvent)
227   {
228
229   }
230
231   public void png_actionPerformed(ActionEvent actionEvent)
232   {
233
234   }
235
236   public void eps_actionPerformed(ActionEvent actionEvent)
237   {
238
239   }
240
241   public void viewMapping_actionPerformed(ActionEvent actionEvent)
242   {
243
244   }
245
246   public void seqColour_actionPerformed(ActionEvent actionEvent)
247   {
248
249   }
250
251   public void chainColour_actionPerformed(ActionEvent actionEvent)
252   {
253
254   }
255
256   public void chargeColour_actionPerformed(ActionEvent actionEvent)
257   {
258
259   }
260
261   public void background_actionPerformed(ActionEvent actionEvent)
262   {
263
264   }
265
266   public void showHelp_actionPerformed(ActionEvent actionEvent)
267   {
268
269   }
270 }