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.api.structures.JalviewStructureDisplayI;
24 import jalview.gui.ColourMenuHelper.ColourChangeListener;
25 import jalview.util.ImageMaker.TYPE;
26 import jalview.util.MessageManager;
28 import java.awt.BorderLayout;
29 import java.awt.GridLayout;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
33 import javax.swing.JInternalFrame;
34 import javax.swing.JLabel;
35 import javax.swing.JMenu;
36 import javax.swing.JMenuBar;
37 import javax.swing.JMenuItem;
38 import javax.swing.JPanel;
39 import javax.swing.JRadioButtonMenuItem;
41 public abstract class GStructureViewer extends JInternalFrame
42 implements JalviewStructureDisplayI, ColourChangeListener
44 // private AAStructureBindingModel bindingModel;
46 protected JMenu savemenu;
48 protected JMenu viewMenu;
50 protected JMenu colourMenu;
52 protected JMenu chainMenu;
54 protected JMenu viewerActionMenu;
56 protected JMenuItem alignStructs;
58 protected JMenuItem fitToWindow;
60 protected JRadioButtonMenuItem seqColour;
62 protected JRadioButtonMenuItem chainColour;
64 protected JRadioButtonMenuItem chargeColour;
66 protected JRadioButtonMenuItem viewerColour;
68 protected JMenuItem helpItem;
70 protected JLabel statusBar;
72 protected JPanel statusPanel;
77 public GStructureViewer()
82 } catch (Exception ex)
88 private void jbInit() throws Exception
90 JMenuBar menuBar = new JMenuBar();
91 this.setJMenuBar(menuBar);
93 JMenu fileMenu = new JMenu();
94 fileMenu.setText(MessageManager.getString("action.file"));
96 savemenu = new JMenu();
97 savemenu.setActionCommand(
98 MessageManager.getString("action.save_image"));
99 savemenu.setText(MessageManager.getString("action.save_as"));
101 JMenuItem pdbFile = new JMenuItem();
102 pdbFile.setText(MessageManager.getString("label.pdb_file"));
103 pdbFile.addActionListener(new ActionListener()
106 public void actionPerformed(ActionEvent actionEvent)
108 pdbFile_actionPerformed(actionEvent);
112 JMenuItem png = new JMenuItem();
114 png.addActionListener(new ActionListener()
117 public void actionPerformed(ActionEvent actionEvent)
119 makePDBImage(TYPE.PNG);
123 JMenuItem eps = new JMenuItem();
125 eps.addActionListener(new ActionListener()
128 public void actionPerformed(ActionEvent actionEvent)
130 makePDBImage(TYPE.EPS);
134 JMenuItem viewMapping = new JMenuItem();
135 viewMapping.setText(MessageManager.getString("label.view_mapping"));
136 viewMapping.addActionListener(new ActionListener()
139 public void actionPerformed(ActionEvent actionEvent)
141 viewMapping_actionPerformed(actionEvent);
145 viewMenu = new JMenu();
146 viewMenu.setText(MessageManager.getString("action.view"));
148 chainMenu = new JMenu();
149 chainMenu.setText(MessageManager.getString("action.show_chain"));
151 fitToWindow = new JMenuItem();
152 fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
153 fitToWindow.addActionListener(new ActionListener()
156 public void actionPerformed(ActionEvent actionEvent)
158 fitToWindow_actionPerformed();
162 JMenu helpMenu = new JMenu();
163 helpMenu.setText(MessageManager.getString("action.help"));
164 helpItem = new JMenuItem();
165 helpItem.setText(MessageManager.getString("label.jmol_help"));
166 helpItem.addActionListener(new ActionListener()
169 public void actionPerformed(ActionEvent actionEvent)
171 showHelp_actionPerformed(actionEvent);
174 alignStructs = new JMenuItem();
175 alignStructs.setText(
176 MessageManager.getString("label.superpose_structures"));
177 alignStructs.addActionListener(new ActionListener()
180 public void actionPerformed(ActionEvent actionEvent)
182 alignStructs_actionPerformed(actionEvent);
186 viewerActionMenu = new JMenu(); // text set in sub-classes
187 viewerActionMenu.setVisible(false);
188 viewerActionMenu.add(alignStructs);
189 colourMenu = new JMenu();
190 colourMenu.setText(MessageManager.getString("label.colours"));
191 fileMenu.add(savemenu);
192 fileMenu.add(viewMapping);
193 savemenu.add(pdbFile);
196 viewMenu.add(chainMenu);
197 helpMenu.add(helpItem);
199 menuBar.add(fileMenu);
200 menuBar.add(viewMenu);
201 menuBar.add(colourMenu);
202 menuBar.add(viewerActionMenu);
203 menuBar.add(helpMenu);
205 statusPanel = new JPanel();
206 statusPanel.setLayout(new GridLayout());
207 this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
208 statusBar = new JLabel();
209 statusPanel.add(statusBar, null);
212 protected void fitToWindow_actionPerformed()
216 protected void highlightSelection_actionPerformed()
220 protected void viewerColour_actionPerformed(ActionEvent actionEvent)
224 protected abstract String alignStructs_actionPerformed(
225 ActionEvent actionEvent);
227 public void pdbFile_actionPerformed(ActionEvent actionEvent)
232 public void makePDBImage(TYPE imageType)
237 public void viewMapping_actionPerformed(ActionEvent actionEvent)
242 public void seqColour_actionPerformed(ActionEvent actionEvent)
247 public void chainColour_actionPerformed(ActionEvent actionEvent)
252 public void chargeColour_actionPerformed(ActionEvent actionEvent)
257 public void background_actionPerformed(ActionEvent actionEvent)
262 public void showHelp_actionPerformed(ActionEvent actionEvent)