JAL-1988 Hack to ensure Quit dialog box is moved to front
[jalview.git] / src / jalview / jbgui / GPCAPanel.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.util.ImageMaker.TYPE;
24 import jalview.util.MessageManager;
25
26 import java.awt.BorderLayout;
27 import java.awt.Color;
28 import java.awt.FlowLayout;
29 import java.awt.Font;
30 import java.awt.GridLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33
34 import javax.swing.JButton;
35 import javax.swing.JCheckBoxMenuItem;
36 import javax.swing.JComboBox;
37 import javax.swing.JInternalFrame;
38 import javax.swing.JLabel;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuBar;
41 import javax.swing.JMenuItem;
42 import javax.swing.JPanel;
43 import javax.swing.event.MenuEvent;
44 import javax.swing.event.MenuListener;
45
46 public class GPCAPanel extends JInternalFrame
47 {
48   private static final Font VERDANA_12 = new Font("Verdana", 0, 12);
49
50   protected JComboBox<String> xCombobox = new JComboBox<>();
51
52   protected JComboBox<String> yCombobox = new JComboBox<>();
53
54   protected JComboBox<String> zCombobox = new JComboBox<>();
55
56   protected JMenu viewMenu = new JMenu();
57
58   protected JCheckBoxMenuItem showLabels = new JCheckBoxMenuItem();
59
60   protected JMenu associateViewsMenu = new JMenu();
61
62   protected JLabel statusBar = new JLabel();
63
64   protected JPanel statusPanel = new JPanel();
65
66   protected JMenuItem originalSeqData;
67
68   /**
69    * Constructor
70    */
71   public GPCAPanel()
72   {
73     try
74     {
75       jbInit();
76     } catch (Exception e)
77     {
78       e.printStackTrace();
79     }
80
81     for (int i = 1; i < 8; i++)
82     {
83       xCombobox.addItem("dim " + i);
84       yCombobox.addItem("dim " + i);
85       zCombobox.addItem("dim " + i);
86     }
87   }
88
89   private void jbInit() throws Exception
90   {
91     setName("jalview-pca");
92     this.getContentPane().setLayout(new BorderLayout());
93     JPanel jPanel2 = new JPanel();
94     jPanel2.setLayout(new FlowLayout());
95     JLabel jLabel1 = new JLabel();
96     jLabel1.setFont(VERDANA_12);
97     jLabel1.setText("x=");
98     JLabel jLabel2 = new JLabel();
99     jLabel2.setFont(VERDANA_12);
100     jLabel2.setText("y=");
101     JLabel jLabel3 = new JLabel();
102     jLabel3.setFont(VERDANA_12);
103     jLabel3.setText("z=");
104     jPanel2.setBackground(Color.white);
105     jPanel2.setBorder(null);
106     zCombobox.setFont(VERDANA_12);
107     zCombobox.addActionListener(new ActionListener()
108     {
109       @Override
110       public void actionPerformed(ActionEvent e)
111       {
112         doDimensionChange();
113       }
114     });
115     yCombobox.setFont(VERDANA_12);
116     yCombobox.addActionListener(new ActionListener()
117     {
118       @Override
119       public void actionPerformed(ActionEvent e)
120       {
121         doDimensionChange();
122       }
123     });
124     xCombobox.setFont(VERDANA_12);
125     xCombobox.addActionListener(new ActionListener()
126     {
127       @Override
128       public void actionPerformed(ActionEvent e)
129       {
130         doDimensionChange();
131       }
132     });
133     JButton resetButton = new JButton();
134     resetButton.setFont(VERDANA_12);
135     resetButton.setText(MessageManager.getString("action.reset"));
136     resetButton.addActionListener(new ActionListener()
137     {
138       @Override
139       public void actionPerformed(ActionEvent e)
140       {
141         resetButton_actionPerformed();
142       }
143     });
144     JMenu fileMenu = new JMenu();
145     fileMenu.setText(MessageManager.getString("action.file"));
146     JMenu saveMenu = new JMenu();
147     saveMenu.setText(MessageManager.getString("action.save_as"));
148     JMenuItem eps = new JMenuItem("EPS");
149     eps.addActionListener(new ActionListener()
150     {
151       @Override
152       public void actionPerformed(ActionEvent e)
153       {
154         makePCAImage(TYPE.EPS);
155       }
156     });
157     JMenuItem png = new JMenuItem("PNG");
158     png.addActionListener(new ActionListener()
159     {
160       @Override
161       public void actionPerformed(ActionEvent e)
162       {
163         makePCAImage(TYPE.PNG);
164       }
165     });
166     JMenuItem outputValues = new JMenuItem();
167     outputValues.setText(MessageManager.getString("label.output_values"));
168     outputValues.addActionListener(new ActionListener()
169     {
170       @Override
171       public void actionPerformed(ActionEvent e)
172       {
173         outputValues_actionPerformed();
174       }
175     });
176     JMenuItem outputPoints = new JMenuItem();
177     outputPoints.setText(MessageManager.getString("label.output_points"));
178     outputPoints.addActionListener(new ActionListener()
179     {
180       @Override
181       public void actionPerformed(ActionEvent e)
182       {
183         outputPoints_actionPerformed();
184       }
185     });
186     JMenuItem outputProjPoints = new JMenuItem();
187     outputProjPoints.setText(
188             MessageManager.getString("label.output_transformed_points"));
189     outputProjPoints.addActionListener(new ActionListener()
190     {
191       @Override
192       public void actionPerformed(ActionEvent e)
193       {
194         outputProjPoints_actionPerformed();
195       }
196     });
197     JMenuItem print = new JMenuItem();
198     print.setText(MessageManager.getString("action.print"));
199     print.addActionListener(new ActionListener()
200     {
201       @Override
202       public void actionPerformed(ActionEvent e)
203       {
204         print_actionPerformed();
205       }
206     });
207     viewMenu.setText(MessageManager.getString("action.view"));
208     viewMenu.addMenuListener(new MenuListener()
209     {
210       @Override
211       public void menuSelected(MenuEvent e)
212       {
213         viewMenu_menuSelected();
214       }
215
216       @Override
217       public void menuDeselected(MenuEvent e)
218       {
219       }
220
221       @Override
222       public void menuCanceled(MenuEvent e)
223       {
224       }
225     });
226     showLabels.setText(MessageManager.getString("label.show_labels"));
227     showLabels.addActionListener(new ActionListener()
228     {
229       @Override
230       public void actionPerformed(ActionEvent e)
231       {
232         showLabels_actionPerformed();
233       }
234     });
235     JMenuItem bgcolour = new JMenuItem();
236     bgcolour.setText(MessageManager.getString("action.background_colour"));
237     bgcolour.addActionListener(new ActionListener()
238     {
239       @Override
240       public void actionPerformed(ActionEvent e)
241       {
242         bgcolour_actionPerformed();
243       }
244     });
245     originalSeqData = new JMenuItem();
246     originalSeqData.setText(MessageManager.getString("label.input_data"));
247     originalSeqData.addActionListener(new ActionListener()
248     {
249       @Override
250       public void actionPerformed(ActionEvent e)
251       {
252         originalSeqData_actionPerformed();
253       }
254     });
255     associateViewsMenu.setText(
256             MessageManager.getString("label.associate_nodes_with"));
257
258     statusPanel.setLayout(new GridLayout());
259     statusBar.setFont(VERDANA_12);
260     // statusPanel.setBackground(Color.lightGray);
261     // statusBar.setBackground(Color.lightGray);
262     // statusPanel.add(statusBar, null);
263     JPanel panelBar = new JPanel(new BorderLayout());
264     panelBar.add(jPanel2, BorderLayout.NORTH);
265     panelBar.add(statusPanel, BorderLayout.SOUTH);
266     this.getContentPane().add(panelBar, BorderLayout.SOUTH);
267     jPanel2.add(jLabel1, null);
268     jPanel2.add(xCombobox, null);
269     jPanel2.add(jLabel2, null);
270     jPanel2.add(yCombobox, null);
271     jPanel2.add(jLabel3, null);
272     jPanel2.add(zCombobox, null);
273     jPanel2.add(resetButton, null);
274
275     JMenuBar jMenuBar1 = new JMenuBar();
276     jMenuBar1.add(fileMenu);
277     jMenuBar1.add(viewMenu);
278     setJMenuBar(jMenuBar1);
279     fileMenu.add(saveMenu);
280     fileMenu.add(outputValues);
281     fileMenu.add(print);
282     fileMenu.add(originalSeqData);
283     fileMenu.add(outputPoints);
284     fileMenu.add(outputProjPoints);
285     saveMenu.add(eps);
286     saveMenu.add(png);
287     viewMenu.add(showLabels);
288     viewMenu.add(bgcolour);
289     viewMenu.add(associateViewsMenu);
290   }
291
292   protected void resetButton_actionPerformed()
293   {
294   }
295
296   protected void outputPoints_actionPerformed()
297   {
298   }
299
300   protected void outputProjPoints_actionPerformed()
301   {
302   }
303
304   public void makePCAImage(TYPE imageType)
305   {
306   }
307
308   protected void outputValues_actionPerformed()
309   {
310   }
311
312   protected void print_actionPerformed()
313   {
314   }
315
316   protected void showLabels_actionPerformed()
317   {
318   }
319
320   protected void bgcolour_actionPerformed()
321   {
322   }
323
324   protected void originalSeqData_actionPerformed()
325   {
326   }
327
328   protected void viewMenu_menuSelected()
329   {
330   }
331
332   protected void doDimensionChange()
333   {
334   }
335 }