2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.FlowLayout;
27 import java.awt.GridLayout;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
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;
43 import jalview.util.ImageMaker.TYPE;
44 import jalview.util.MessageManager;
46 public class GPCAPanel extends JInternalFrame
48 private static final Font VERDANA_12 = new Font("Verdana", 0, 12);
50 protected JComboBox<String> xCombobox = new JComboBox<>();
52 protected JComboBox<String> yCombobox = new JComboBox<>();
54 protected JComboBox<String> zCombobox = new JComboBox<>();
56 protected JMenu viewMenu = new JMenu();
58 protected JCheckBoxMenuItem showLabels = new JCheckBoxMenuItem();
60 protected JMenu associateViewsMenu = new JMenu();
62 protected JLabel statusBar = new JLabel();
64 protected JPanel statusPanel = new JPanel();
66 protected JMenuItem originalSeqData;
81 for (int i = 1; i < 8; i++)
83 xCombobox.addItem("dim " + i);
84 yCombobox.addItem("dim " + i);
85 zCombobox.addItem("dim " + i);
88 public GPCAPanel(int dim)
98 for (int i = 1; i <= dim; i++)
100 xCombobox.addItem("dim " + i);
101 yCombobox.addItem("dim " + i);
102 zCombobox.addItem("dim " + i);
106 private void jbInit() throws Exception
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()
128 public void actionPerformed(ActionEvent e)
133 yCombobox.setFont(VERDANA_12);
134 yCombobox.addActionListener(new ActionListener()
137 public void actionPerformed(ActionEvent e)
142 xCombobox.setFont(VERDANA_12);
143 xCombobox.addActionListener(new ActionListener()
146 public void actionPerformed(ActionEvent e)
151 JButton resetButton = new JButton();
152 resetButton.setFont(VERDANA_12);
153 resetButton.setText(MessageManager.getString("action.reset"));
154 resetButton.addActionListener(new ActionListener()
157 public void actionPerformed(ActionEvent e)
159 resetButton_actionPerformed();
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()
170 public void actionPerformed(ActionEvent e)
172 makePCAImage(TYPE.EPS);
175 JMenuItem png = new JMenuItem("PNG");
176 png.addActionListener(new ActionListener()
179 public void actionPerformed(ActionEvent e)
181 makePCAImage(TYPE.PNG);
184 JMenuItem outputValues = new JMenuItem();
185 outputValues.setText(MessageManager.getString("label.output_values"));
186 outputValues.addActionListener(new ActionListener()
189 public void actionPerformed(ActionEvent e)
191 outputValues_actionPerformed();
194 JMenuItem outputPoints = new JMenuItem();
195 outputPoints.setText(MessageManager.getString("label.output_points"));
196 outputPoints.addActionListener(new ActionListener()
199 public void actionPerformed(ActionEvent e)
201 outputPoints_actionPerformed();
204 JMenuItem outputProjPoints = new JMenuItem();
205 outputProjPoints.setText(
206 MessageManager.getString("label.output_transformed_points"));
207 outputProjPoints.addActionListener(new ActionListener()
210 public void actionPerformed(ActionEvent e)
212 outputProjPoints_actionPerformed();
215 JMenuItem print = new JMenuItem();
216 print.setText(MessageManager.getString("action.print"));
217 print.addActionListener(new ActionListener()
220 public void actionPerformed(ActionEvent e)
222 print_actionPerformed();
225 viewMenu.setText(MessageManager.getString("action.view"));
226 viewMenu.addMenuListener(new MenuListener()
229 public void menuSelected(MenuEvent e)
231 viewMenu_menuSelected();
235 public void menuDeselected(MenuEvent e)
240 public void menuCanceled(MenuEvent e)
244 showLabels.setText(MessageManager.getString("label.show_labels"));
245 showLabels.addActionListener(new ActionListener()
248 public void actionPerformed(ActionEvent e)
250 showLabels_actionPerformed();
253 JMenuItem bgcolour = new JMenuItem();
254 bgcolour.setText(MessageManager.getString("action.background_colour"));
255 bgcolour.addActionListener(new ActionListener()
258 public void actionPerformed(ActionEvent e)
260 bgcolour_actionPerformed();
263 originalSeqData = new JMenuItem();
264 originalSeqData.setText(MessageManager.getString("label.input_data"));
265 originalSeqData.addActionListener(new ActionListener()
268 public void actionPerformed(ActionEvent e)
270 originalSeqData_actionPerformed();
273 associateViewsMenu.setText(
274 MessageManager.getString("label.associate_nodes_with"));
276 statusPanel.setLayout(new GridLayout());
277 statusBar.setFont(VERDANA_12);
278 // statusPanel.setBackground(Color.lightGray);
279 // statusBar.setBackground(Color.lightGray);
280 // statusPanel.add(statusBar, null);
281 JPanel panelBar = new JPanel(new BorderLayout());
282 panelBar.add(jPanel2, BorderLayout.NORTH);
283 panelBar.add(statusPanel, BorderLayout.SOUTH);
284 this.getContentPane().add(panelBar, BorderLayout.SOUTH);
285 jPanel2.add(jLabel1, null);
286 jPanel2.add(xCombobox, null);
287 jPanel2.add(jLabel2, null);
288 jPanel2.add(yCombobox, null);
289 jPanel2.add(jLabel3, null);
290 jPanel2.add(zCombobox, null);
291 jPanel2.add(resetButton, null);
293 JMenuBar jMenuBar1 = new JMenuBar();
294 jMenuBar1.add(fileMenu);
295 jMenuBar1.add(viewMenu);
296 setJMenuBar(jMenuBar1);
297 fileMenu.add(saveMenu);
298 fileMenu.add(outputValues);
300 fileMenu.add(originalSeqData);
301 fileMenu.add(outputPoints);
302 fileMenu.add(outputProjPoints);
305 viewMenu.add(showLabels);
306 viewMenu.add(bgcolour);
307 viewMenu.add(associateViewsMenu);
310 protected void resetButton_actionPerformed()
314 protected void outputPoints_actionPerformed()
318 protected void outputProjPoints_actionPerformed()
322 public void makePCAImage(TYPE imageType)
326 protected void outputValues_actionPerformed()
330 protected void print_actionPerformed()
334 protected void showLabels_actionPerformed()
338 protected void bgcolour_actionPerformed()
342 protected void originalSeqData_actionPerformed()
346 protected void viewMenu_menuSelected()
350 protected void doDimensionChange()