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