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 @SuppressWarnings("serial")
42 public abstract class GStructureViewer extends JInternalFrame
43 implements JalviewStructureDisplayI, ColourChangeListener
45 // private AAStructureBindingModel bindingModel;
47 protected JMenu savemenu;
49 protected JMenu viewMenu;
51 protected JMenu colourMenu;
53 protected JMenu chainMenu;
55 protected JMenu viewerActionMenu;
57 protected JMenuItem alignStructs;
59 protected JMenuItem fitToWindow;
61 protected JRadioButtonMenuItem seqColour;
63 protected JRadioButtonMenuItem chainColour;
65 protected JRadioButtonMenuItem chargeColour;
67 protected JRadioButtonMenuItem viewerColour;
69 protected JMenuItem helpItem;
71 protected JLabel statusBar;
73 protected JPanel statusPanel;
78 public GStructureViewer()
83 } catch (Exception ex)
89 private void jbInit() throws Exception
92 setName("jalview-structureviewer");
94 JMenuBar menuBar = new JMenuBar();
95 this.setJMenuBar(menuBar);
97 JMenu fileMenu = new JMenu();
98 fileMenu.setText(MessageManager.getString("action.file"));
100 savemenu = new JMenu();
101 savemenu.setActionCommand(
102 MessageManager.getString("action.save_image"));
103 savemenu.setText(MessageManager.getString("action.save_as"));
105 JMenuItem pdbFile = new JMenuItem();
106 pdbFile.setText(MessageManager.getString("label.pdb_file"));
107 pdbFile.addActionListener(new ActionListener()
110 public void actionPerformed(ActionEvent actionEvent)
112 pdbFile_actionPerformed(actionEvent);
116 JMenuItem png = new JMenuItem();
118 png.addActionListener(new ActionListener()
121 public void actionPerformed(ActionEvent actionEvent)
123 makePDBImage(TYPE.PNG);
127 JMenuItem eps = new JMenuItem();
129 eps.addActionListener(new ActionListener()
132 public void actionPerformed(ActionEvent actionEvent)
134 makePDBImage(TYPE.EPS);
138 JMenuItem viewMapping = new JMenuItem();
139 viewMapping.setText(MessageManager.getString("label.view_mapping"));
140 viewMapping.addActionListener(new ActionListener()
143 public void actionPerformed(ActionEvent actionEvent)
145 viewMapping_actionPerformed(actionEvent);
149 viewMenu = new JMenu();
150 viewMenu.setText(MessageManager.getString("action.view"));
152 chainMenu = new JMenu();
153 chainMenu.setText(MessageManager.getString("action.show_chain"));
155 fitToWindow = new JMenuItem();
156 fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
157 fitToWindow.addActionListener(new ActionListener()
160 public void actionPerformed(ActionEvent actionEvent)
162 fitToWindow_actionPerformed();
166 JMenu helpMenu = new JMenu();
167 helpMenu.setText(MessageManager.getString("action.help"));
168 helpItem = new JMenuItem();
169 helpItem.setText(MessageManager.getString("label.jmol_help"));
170 helpItem.addActionListener(new ActionListener()
173 public void actionPerformed(ActionEvent actionEvent)
175 showHelp_actionPerformed(actionEvent);
178 alignStructs = new JMenuItem();
179 alignStructs.setText(
180 MessageManager.getString("label.superpose_structures"));
181 alignStructs.addActionListener(new ActionListener()
184 public void actionPerformed(ActionEvent actionEvent)
186 alignStructs_actionPerformed(actionEvent);
190 viewerActionMenu = new JMenu(); // text set in sub-classes
191 viewerActionMenu.setVisible(false);
192 viewerActionMenu.add(alignStructs);
193 colourMenu = new JMenu();
194 colourMenu.setText(MessageManager.getString("label.colours"));
195 fileMenu.add(savemenu);
196 fileMenu.add(viewMapping);
197 savemenu.add(pdbFile);
200 viewMenu.add(chainMenu);
201 helpMenu.add(helpItem);
203 menuBar.add(fileMenu);
204 menuBar.add(viewMenu);
205 menuBar.add(colourMenu);
206 menuBar.add(viewerActionMenu);
207 menuBar.add(helpMenu);
209 statusPanel = new JPanel();
210 statusPanel.setLayout(new GridLayout());
211 this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
212 statusBar = new JLabel();
213 statusPanel.add(statusBar, null);
216 protected void fitToWindow_actionPerformed()
220 protected void highlightSelection_actionPerformed()
224 protected void viewerColour_actionPerformed(ActionEvent actionEvent)
228 protected abstract String alignStructs_actionPerformed(
229 ActionEvent actionEvent);
231 public void pdbFile_actionPerformed(ActionEvent actionEvent)
236 public void makePDBImage(TYPE imageType)
241 public void viewMapping_actionPerformed(ActionEvent actionEvent)
246 public void seqColour_actionPerformed(ActionEvent actionEvent)
251 public void chainColour_actionPerformed(ActionEvent actionEvent)
256 public void chargeColour_actionPerformed(ActionEvent actionEvent)
261 public void background_actionPerformed(ActionEvent actionEvent)
266 public void showHelp_actionPerformed(ActionEvent actionEvent)