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 jalview.util.ImageMaker.TYPE;
24 import jalview.util.MessageManager;
26 import java.awt.BorderLayout;
27 import java.awt.Color;
28 import java.awt.FlowLayout;
30 import java.awt.GridLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
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;
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
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()
110 public void actionPerformed(ActionEvent e)
115 yCombobox.setFont(VERDANA_12);
116 yCombobox.addActionListener(new ActionListener()
119 public void actionPerformed(ActionEvent e)
124 xCombobox.setFont(VERDANA_12);
125 xCombobox.addActionListener(new ActionListener()
128 public void actionPerformed(ActionEvent e)
133 JButton resetButton = new JButton();
134 resetButton.setFont(VERDANA_12);
135 resetButton.setText(MessageManager.getString("action.reset"));
136 resetButton.addActionListener(new ActionListener()
139 public void actionPerformed(ActionEvent e)
141 resetButton_actionPerformed();
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()
152 public void actionPerformed(ActionEvent e)
154 makePCAImage(TYPE.EPS);
157 JMenuItem png = new JMenuItem("PNG");
158 png.addActionListener(new ActionListener()
161 public void actionPerformed(ActionEvent e)
163 makePCAImage(TYPE.PNG);
166 JMenuItem outputValues = new JMenuItem();
167 outputValues.setText(MessageManager.getString("label.output_values"));
168 outputValues.addActionListener(new ActionListener()
171 public void actionPerformed(ActionEvent e)
173 outputValues_actionPerformed();
176 JMenuItem outputPoints = new JMenuItem();
177 outputPoints.setText(MessageManager.getString("label.output_points"));
178 outputPoints.addActionListener(new ActionListener()
181 public void actionPerformed(ActionEvent e)
183 outputPoints_actionPerformed();
186 JMenuItem outputProjPoints = new JMenuItem();
187 outputProjPoints.setText(
188 MessageManager.getString("label.output_transformed_points"));
189 outputProjPoints.addActionListener(new ActionListener()
192 public void actionPerformed(ActionEvent e)
194 outputProjPoints_actionPerformed();
197 JMenuItem print = new JMenuItem();
198 print.setText(MessageManager.getString("action.print"));
199 print.addActionListener(new ActionListener()
202 public void actionPerformed(ActionEvent e)
204 print_actionPerformed();
207 viewMenu.setText(MessageManager.getString("action.view"));
208 viewMenu.addMenuListener(new MenuListener()
211 public void menuSelected(MenuEvent e)
213 viewMenu_menuSelected();
217 public void menuDeselected(MenuEvent e)
222 public void menuCanceled(MenuEvent e)
226 showLabels.setText(MessageManager.getString("label.show_labels"));
227 showLabels.addActionListener(new ActionListener()
230 public void actionPerformed(ActionEvent e)
232 showLabels_actionPerformed();
235 JMenuItem bgcolour = new JMenuItem();
236 bgcolour.setText(MessageManager.getString("action.background_colour"));
237 bgcolour.addActionListener(new ActionListener()
240 public void actionPerformed(ActionEvent e)
242 bgcolour_actionPerformed();
245 originalSeqData = new JMenuItem();
246 originalSeqData.setText(MessageManager.getString("label.input_data"));
247 originalSeqData.addActionListener(new ActionListener()
250 public void actionPerformed(ActionEvent e)
252 originalSeqData_actionPerformed();
255 associateViewsMenu.setText(
256 MessageManager.getString("label.associate_nodes_with"));
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);
275 JMenuBar jMenuBar1 = new JMenuBar();
276 jMenuBar1.add(fileMenu);
277 jMenuBar1.add(viewMenu);
278 setJMenuBar(jMenuBar1);
279 fileMenu.add(saveMenu);
280 fileMenu.add(outputValues);
282 fileMenu.add(originalSeqData);
283 fileMenu.add(outputPoints);
284 fileMenu.add(outputProjPoints);
287 viewMenu.add(showLabels);
288 viewMenu.add(bgcolour);
289 viewMenu.add(associateViewsMenu);
292 protected void resetButton_actionPerformed()
296 protected void outputPoints_actionPerformed()
300 protected void outputProjPoints_actionPerformed()
304 public void makePCAImage(TYPE imageType)
308 protected void outputValues_actionPerformed()
312 protected void print_actionPerformed()
316 protected void showLabels_actionPerformed()
320 protected void bgcolour_actionPerformed()
324 protected void originalSeqData_actionPerformed()
328 protected void viewMenu_menuSelected()
332 protected void doDimensionChange()