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