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);
89 private void jbInit() throws Exception
92 setName("jalview-pca");
93 this.getContentPane().setLayout(new BorderLayout());
94 JPanel jPanel2 = new JPanel();
95 jPanel2.setLayout(new FlowLayout());
96 JLabel jLabel1 = new JLabel();
97 jLabel1.setFont(VERDANA_12);
98 jLabel1.setText("x=");
99 JLabel jLabel2 = new JLabel();
100 jLabel2.setFont(VERDANA_12);
101 jLabel2.setText("y=");
102 JLabel jLabel3 = new JLabel();
103 jLabel3.setFont(VERDANA_12);
104 jLabel3.setText("z=");
105 jPanel2.setBackground(Color.white);
106 jPanel2.setBorder(null);
107 zCombobox.setFont(VERDANA_12);
108 zCombobox.addActionListener(new ActionListener()
111 public void actionPerformed(ActionEvent e)
116 yCombobox.setFont(VERDANA_12);
117 yCombobox.addActionListener(new ActionListener()
120 public void actionPerformed(ActionEvent e)
125 xCombobox.setFont(VERDANA_12);
126 xCombobox.addActionListener(new ActionListener()
129 public void actionPerformed(ActionEvent e)
134 JButton resetButton = new JButton();
135 resetButton.setFont(VERDANA_12);
136 resetButton.setText(MessageManager.getString("action.reset"));
137 resetButton.addActionListener(new ActionListener()
140 public void actionPerformed(ActionEvent e)
142 resetButton_actionPerformed();
145 JMenu fileMenu = new JMenu();
146 fileMenu.setText(MessageManager.getString("action.file"));
147 JMenu saveMenu = new JMenu();
148 saveMenu.setText(MessageManager.getString("action.save_as"));
149 JMenuItem eps = new JMenuItem("EPS");
150 eps.addActionListener(new ActionListener()
153 public void actionPerformed(ActionEvent e)
155 makePCAImage(TYPE.EPS);
158 JMenuItem png = new JMenuItem("PNG");
159 png.addActionListener(new ActionListener()
162 public void actionPerformed(ActionEvent e)
164 makePCAImage(TYPE.PNG);
167 JMenuItem outputValues = new JMenuItem();
168 outputValues.setText(MessageManager.getString("label.output_values"));
169 outputValues.addActionListener(new ActionListener()
172 public void actionPerformed(ActionEvent e)
174 outputValues_actionPerformed();
177 JMenuItem outputPoints = new JMenuItem();
178 outputPoints.setText(MessageManager.getString("label.output_points"));
179 outputPoints.addActionListener(new ActionListener()
182 public void actionPerformed(ActionEvent e)
184 outputPoints_actionPerformed();
187 JMenuItem outputProjPoints = new JMenuItem();
188 outputProjPoints.setText(
189 MessageManager.getString("label.output_transformed_points"));
190 outputProjPoints.addActionListener(new ActionListener()
193 public void actionPerformed(ActionEvent e)
195 outputProjPoints_actionPerformed();
198 JMenuItem print = new JMenuItem();
199 print.setText(MessageManager.getString("action.print"));
200 print.addActionListener(new ActionListener()
203 public void actionPerformed(ActionEvent e)
205 print_actionPerformed();
208 viewMenu.setText(MessageManager.getString("action.view"));
209 viewMenu.addMenuListener(new MenuListener()
212 public void menuSelected(MenuEvent e)
214 viewMenu_menuSelected();
218 public void menuDeselected(MenuEvent e)
223 public void menuCanceled(MenuEvent e)
227 showLabels.setText(MessageManager.getString("label.show_labels"));
228 showLabels.addActionListener(new ActionListener()
231 public void actionPerformed(ActionEvent e)
233 showLabels_actionPerformed();
236 JMenuItem bgcolour = new JMenuItem();
237 bgcolour.setText(MessageManager.getString("action.background_colour"));
238 bgcolour.addActionListener(new ActionListener()
241 public void actionPerformed(ActionEvent e)
243 bgcolour_actionPerformed();
246 originalSeqData = new JMenuItem();
247 originalSeqData.setText(MessageManager.getString("label.input_data"));
248 originalSeqData.addActionListener(new ActionListener()
251 public void actionPerformed(ActionEvent e)
253 originalSeqData_actionPerformed();
256 associateViewsMenu.setText(
257 MessageManager.getString("label.associate_nodes_with"));
259 statusPanel.setLayout(new GridLayout());
260 statusBar.setFont(VERDANA_12);
261 // statusPanel.setBackground(Color.lightGray);
262 // statusBar.setBackground(Color.lightGray);
263 // statusPanel.add(statusBar, null);
264 JPanel panelBar = new JPanel(new BorderLayout());
265 panelBar.add(jPanel2, BorderLayout.NORTH);
266 panelBar.add(statusPanel, BorderLayout.SOUTH);
267 this.getContentPane().add(panelBar, BorderLayout.SOUTH);
268 jPanel2.add(jLabel1, null);
269 jPanel2.add(xCombobox, null);
270 jPanel2.add(jLabel2, null);
271 jPanel2.add(yCombobox, null);
272 jPanel2.add(jLabel3, null);
273 jPanel2.add(zCombobox, null);
274 jPanel2.add(resetButton, null);
276 JMenuBar jMenuBar1 = new JMenuBar();
277 jMenuBar1.add(fileMenu);
278 jMenuBar1.add(viewMenu);
279 setJMenuBar(jMenuBar1);
280 fileMenu.add(saveMenu);
281 fileMenu.add(outputValues);
283 fileMenu.add(originalSeqData);
284 fileMenu.add(outputPoints);
285 fileMenu.add(outputProjPoints);
288 viewMenu.add(showLabels);
289 viewMenu.add(bgcolour);
290 viewMenu.add(associateViewsMenu);
293 protected void resetButton_actionPerformed()
297 protected void outputPoints_actionPerformed()
301 protected void outputProjPoints_actionPerformed()
305 public void makePCAImage(TYPE imageType)
309 protected void outputValues_actionPerformed()
313 protected void print_actionPerformed()
317 protected void showLabels_actionPerformed()
321 protected void bgcolour_actionPerformed()
325 protected void originalSeqData_actionPerformed()
329 protected void viewMenu_menuSelected()
333 protected void doDimensionChange()