db260be11f16a1560baf1058b1ef8de7a3f181d1
[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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.FlowLayout;
26 import java.awt.Font;
27 import java.awt.GridLayout;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30
31 import javax.swing.JButton;
32 import javax.swing.JCheckBoxMenuItem;
33 import javax.swing.JComboBox;
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.event.MenuEvent;
41 import javax.swing.event.MenuListener;
42
43 import jalview.util.ImageMaker.TYPE;
44 import jalview.util.MessageManager;
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   public GPCAPanel(int dim)
89   {
90     try
91     {
92       jbInit();
93     } catch (Exception e)
94     {
95       e.printStackTrace();
96     }
97
98     for (int i = 1; i <= dim; i++)
99     {
100       xCombobox.addItem("dim " + i);
101       yCombobox.addItem("dim " + i);
102       zCombobox.addItem("dim " + i);
103     }
104   }
105
106   private void jbInit() throws Exception
107   {
108     setFrameIcon(null);
109     setName("jalview-pca");
110     this.getContentPane().setLayout(new BorderLayout());
111     JPanel jPanel2 = new JPanel();
112     jPanel2.setLayout(new FlowLayout());
113     JLabel jLabel1 = new JLabel();
114     jLabel1.setFont(VERDANA_12);
115     jLabel1.setText("x=");
116     JLabel jLabel2 = new JLabel();
117     jLabel2.setFont(VERDANA_12);
118     jLabel2.setText("y=");
119     JLabel jLabel3 = new JLabel();
120     jLabel3.setFont(VERDANA_12);
121     jLabel3.setText("z=");
122     jPanel2.setBackground(Color.white);
123     jPanel2.setBorder(null);
124     zCombobox.setFont(VERDANA_12);
125     zCombobox.addActionListener(new ActionListener()
126     {
127       @Override
128       public void actionPerformed(ActionEvent e)
129       {
130         doDimensionChange();
131       }
132     });
133     yCombobox.setFont(VERDANA_12);
134     yCombobox.addActionListener(new ActionListener()
135     {
136       @Override
137       public void actionPerformed(ActionEvent e)
138       {
139         doDimensionChange();
140       }
141     });
142     xCombobox.setFont(VERDANA_12);
143     xCombobox.addActionListener(new ActionListener()
144     {
145       @Override
146       public void actionPerformed(ActionEvent e)
147       {
148         doDimensionChange();
149       }
150     });
151     JButton resetButton = new JButton();
152     resetButton.setFont(VERDANA_12);
153     resetButton.setText(MessageManager.getString("action.reset"));
154     resetButton.addActionListener(new ActionListener()
155     {
156       @Override
157       public void actionPerformed(ActionEvent e)
158       {
159         resetButton_actionPerformed();
160       }
161     });
162     JMenu fileMenu = new JMenu();
163     fileMenu.setText(MessageManager.getString("action.file"));
164     JMenu saveMenu = new JMenu();
165     saveMenu.setText(MessageManager.getString("action.save_as"));
166     JMenuItem eps = new JMenuItem("EPS");
167     eps.addActionListener(new ActionListener()
168     {
169       @Override
170       public void actionPerformed(ActionEvent e)
171       {
172         makePCAImage(TYPE.EPS);
173       }
174     });
175     JMenuItem png = new JMenuItem("PNG");
176     png.addActionListener(new ActionListener()
177     {
178       @Override
179       public void actionPerformed(ActionEvent e)
180       {
181         makePCAImage(TYPE.PNG);
182       }
183     });
184     JMenuItem outputValues = new JMenuItem();
185     outputValues.setText(MessageManager.getString("label.output_values"));
186     outputValues.addActionListener(new ActionListener()
187     {
188       @Override
189       public void actionPerformed(ActionEvent e)
190       {
191         outputValues_actionPerformed();
192       }
193     });
194     JMenuItem outputPoints = new JMenuItem();
195     outputPoints.setText(MessageManager.getString("label.output_points"));
196     outputPoints.addActionListener(new ActionListener()
197     {
198       @Override
199       public void actionPerformed(ActionEvent e)
200       {
201         outputPoints_actionPerformed();
202       }
203     });
204     JMenuItem outputProjPoints = new JMenuItem();
205     outputProjPoints.setText(
206             MessageManager.getString("label.output_transformed_points"));
207     outputProjPoints.addActionListener(new ActionListener()
208     {
209       @Override
210       public void actionPerformed(ActionEvent e)
211       {
212         outputProjPoints_actionPerformed();
213       }
214     });
215     JMenuItem print = new JMenuItem();
216     print.setText(MessageManager.getString("action.print"));
217     print.addActionListener(new ActionListener()
218     {
219       @Override
220       public void actionPerformed(ActionEvent e)
221       {
222         print_actionPerformed();
223       }
224     });
225     JMenuItem outputAlignment = new JMenuItem();
226     outputAlignment.setText(
227       MessageManager.getString("label.output_alignment"));
228     outputAlignment.addActionListener(new ActionListener()
229     {
230       @Override
231       public void actionPerformed(ActionEvent e)
232       {
233         outputAlignment_actionPerformed();
234       }
235     });
236     viewMenu.setText(MessageManager.getString("action.view"));
237     viewMenu.addMenuListener(new MenuListener()
238     {
239       @Override
240       public void menuSelected(MenuEvent e)
241       {
242         viewMenu_menuSelected();
243       }
244
245       @Override
246       public void menuDeselected(MenuEvent e)
247       {
248       }
249
250       @Override
251       public void menuCanceled(MenuEvent e)
252       {
253       }
254     });
255     showLabels.setText(MessageManager.getString("label.show_labels"));
256     showLabels.addActionListener(new ActionListener()
257     {
258       @Override
259       public void actionPerformed(ActionEvent e)
260       {
261         showLabels_actionPerformed();
262       }
263     });
264     JMenuItem bgcolour = new JMenuItem();
265     bgcolour.setText(MessageManager.getString("action.background_colour"));
266     bgcolour.addActionListener(new ActionListener()
267     {
268       @Override
269       public void actionPerformed(ActionEvent e)
270       {
271         bgcolour_actionPerformed();
272       }
273     });
274     originalSeqData = new JMenuItem();
275     originalSeqData.setText(MessageManager.getString("label.input_data"));
276     originalSeqData.addActionListener(new ActionListener()
277     {
278       @Override
279       public void actionPerformed(ActionEvent e)
280       {
281         originalSeqData_actionPerformed();
282       }
283     });
284     associateViewsMenu.setText(
285             MessageManager.getString("label.associate_nodes_with"));
286
287     statusPanel.setLayout(new GridLayout());
288     statusBar.setFont(VERDANA_12);
289     // statusPanel.setBackground(Color.lightGray);
290     // statusBar.setBackground(Color.lightGray);
291     // statusPanel.add(statusBar, null);
292     JPanel panelBar = new JPanel(new BorderLayout());
293     panelBar.add(jPanel2, BorderLayout.NORTH);
294     panelBar.add(statusPanel, BorderLayout.SOUTH);
295     this.getContentPane().add(panelBar, BorderLayout.SOUTH);
296     jPanel2.add(jLabel1, null);
297     jPanel2.add(xCombobox, null);
298     jPanel2.add(jLabel2, null);
299     jPanel2.add(yCombobox, null);
300     jPanel2.add(jLabel3, null);
301     jPanel2.add(zCombobox, null);
302     jPanel2.add(resetButton, null);
303
304     JMenuBar jMenuBar1 = new JMenuBar();
305     jMenuBar1.add(fileMenu);
306     jMenuBar1.add(viewMenu);
307     setJMenuBar(jMenuBar1);
308     fileMenu.add(saveMenu);
309     fileMenu.add(outputValues);
310     fileMenu.add(print);
311     fileMenu.add(originalSeqData);
312     fileMenu.add(outputPoints);
313     fileMenu.add(outputProjPoints);
314     fileMenu.add(outputAlignment);
315     saveMenu.add(eps);
316     saveMenu.add(png);
317     viewMenu.add(showLabels);
318     viewMenu.add(bgcolour);
319     viewMenu.add(associateViewsMenu);
320   }
321
322   protected void resetButton_actionPerformed()
323   {
324   }
325
326   protected void outputPoints_actionPerformed()
327   {
328   }
329
330   protected void outputProjPoints_actionPerformed()
331   {
332   }
333
334   protected void outputAlignment_actionPerformed()
335   {
336   }
337
338   public void makePCAImage(TYPE imageType)
339   {
340   }
341
342   protected void outputValues_actionPerformed()
343   {
344   }
345
346   protected void print_actionPerformed()
347   {
348   }
349
350   protected void showLabels_actionPerformed()
351   {
352   }
353
354   protected void bgcolour_actionPerformed()
355   {
356   }
357
358   protected void originalSeqData_actionPerformed()
359   {
360   }
361
362   protected void viewMenu_menuSelected()
363   {
364   }
365
366   protected void doDimensionChange()
367   {
368   }
369 }