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