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 GPaSiMapPanel 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;
71 public GPaSiMapPanel()
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 GPaSiMapPanel(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 JMenuItem outputAlignment = new JMenuItem();
226 outputAlignment.setText(
227 MessageManager.getString("label.output_alignment"));
228 outputAlignment.addActionListener(new ActionListener()
231 public void actionPerformed(ActionEvent e)
233 outputAlignment_actionPerformed();
236 viewMenu.setText(MessageManager.getString("action.view"));
237 viewMenu.addMenuListener(new MenuListener()
240 public void menuSelected(MenuEvent e)
242 viewMenu_menuSelected();
246 public void menuDeselected(MenuEvent e)
251 public void menuCanceled(MenuEvent e)
255 showLabels.setText(MessageManager.getString("label.show_labels"));
256 showLabels.addActionListener(new ActionListener()
259 public void actionPerformed(ActionEvent e)
261 showLabels_actionPerformed();
264 JMenuItem bgcolour = new JMenuItem();
265 bgcolour.setText(MessageManager.getString("action.background_colour"));
266 bgcolour.addActionListener(new ActionListener()
269 public void actionPerformed(ActionEvent e)
271 bgcolour_actionPerformed();
274 originalSeqData = new JMenuItem();
275 originalSeqData.setText(MessageManager.getString("label.input_data"));
276 originalSeqData.addActionListener(new ActionListener()
279 public void actionPerformed(ActionEvent e)
281 originalSeqData_actionPerformed();
284 associateViewsMenu.setText(
285 MessageManager.getString("label.associate_nodes_with"));
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);
304 JMenuBar jMenuBar1 = new JMenuBar();
305 jMenuBar1.add(fileMenu);
306 jMenuBar1.add(viewMenu);
307 setJMenuBar(jMenuBar1);
308 fileMenu.add(saveMenu);
309 fileMenu.add(outputValues);
311 fileMenu.add(originalSeqData);
312 fileMenu.add(outputPoints);
313 fileMenu.add(outputProjPoints);
314 fileMenu.add(outputAlignment);
317 viewMenu.add(showLabels);
318 viewMenu.add(bgcolour);
319 viewMenu.add(associateViewsMenu);
322 protected void resetButton_actionPerformed()
326 protected void outputPoints_actionPerformed()
330 protected void outputProjPoints_actionPerformed()
334 protected void outputAlignment_actionPerformed()
338 public void makePCAImage(TYPE imageType)
342 protected void outputValues_actionPerformed()
346 protected void print_actionPerformed()
350 protected void showLabels_actionPerformed()
354 protected void bgcolour_actionPerformed()
358 protected void originalSeqData_actionPerformed()
362 protected void viewMenu_menuSelected()
366 protected void doDimensionChange()