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;
27 import jalview.util.Platform;
29 import java.awt.BorderLayout;
30 import java.awt.GridLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
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.JRadioButtonMenuItem;
42 @SuppressWarnings("serial")
43 public abstract class GStructureViewer extends JInternalFrame
44 implements JalviewStructureDisplayI, ColourChangeListener
46 // private AAStructureBindingModel bindingModel;
48 protected JMenu savemenu;
50 protected JMenu viewMenu;
52 protected JMenu colourMenu;
54 protected JMenu chainMenu;
56 protected JMenu viewerActionMenu;
58 protected JMenuItem alignStructs;
60 protected JMenuItem fitToWindow;
62 protected JRadioButtonMenuItem seqColour;
64 protected JRadioButtonMenuItem chainColour;
66 protected JRadioButtonMenuItem chargeColour;
68 protected JRadioButtonMenuItem viewerColour;
70 protected JMenuItem helpItem;
72 protected JLabel statusBar;
74 protected JPanel statusPanel;
79 public GStructureViewer()
84 } catch (Exception ex)
90 private void jbInit() throws Exception
93 setName(Platform.getAppID("structureviewer"));
95 JMenuBar menuBar = new JMenuBar();
96 this.setJMenuBar(menuBar);
98 JMenu fileMenu = new JMenu();
99 fileMenu.setText(MessageManager.getString("action.file"));
101 savemenu = new JMenu();
102 savemenu.setActionCommand(
103 MessageManager.getString("action.save_image"));
104 savemenu.setText(MessageManager.getString("action.save_as"));
106 JMenuItem pdbFile = new JMenuItem();
107 pdbFile.setText(MessageManager.getString("label.pdb_file"));
108 pdbFile.addActionListener(new ActionListener()
111 public void actionPerformed(ActionEvent actionEvent)
113 pdbFile_actionPerformed(actionEvent);
117 JMenuItem png = new JMenuItem();
119 png.addActionListener(new ActionListener()
122 public void actionPerformed(ActionEvent actionEvent)
124 makePDBImage(TYPE.PNG);
128 JMenuItem eps = new JMenuItem();
130 eps.addActionListener(new ActionListener()
133 public void actionPerformed(ActionEvent actionEvent)
135 makePDBImage(TYPE.EPS);
139 JMenuItem viewMapping = new JMenuItem();
140 viewMapping.setText(MessageManager.getString("label.view_mapping"));
141 viewMapping.addActionListener(new ActionListener()
144 public void actionPerformed(ActionEvent actionEvent)
146 viewMapping_actionPerformed(actionEvent);
150 viewMenu = new JMenu();
151 viewMenu.setText(MessageManager.getString("action.view"));
153 chainMenu = new JMenu();
154 chainMenu.setText(MessageManager.getString("action.show_chain"));
156 fitToWindow = new JMenuItem();
157 fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
158 fitToWindow.addActionListener(new ActionListener()
161 public void actionPerformed(ActionEvent actionEvent)
163 fitToWindow_actionPerformed();
167 JMenu helpMenu = new JMenu();
168 helpMenu.setText(MessageManager.getString("action.help"));
169 helpItem = new JMenuItem();
170 helpItem.setText(MessageManager.getString("label.jmol_help"));
171 helpItem.addActionListener(new ActionListener()
174 public void actionPerformed(ActionEvent actionEvent)
176 showHelp_actionPerformed(actionEvent);
179 alignStructs = new JMenuItem();
180 alignStructs.setText(
181 MessageManager.getString("label.superpose_structures"));
182 alignStructs.addActionListener(new ActionListener()
185 public void actionPerformed(ActionEvent actionEvent)
187 alignStructs_actionPerformed(actionEvent);
191 viewerActionMenu = new JMenu(); // text set in sub-classes
192 viewerActionMenu.setVisible(false);
193 viewerActionMenu.add(alignStructs);
194 colourMenu = new JMenu();
195 colourMenu.setText(MessageManager.getString("label.colours"));
196 fileMenu.add(savemenu);
197 fileMenu.add(viewMapping);
198 savemenu.add(pdbFile);
201 viewMenu.add(chainMenu);
202 helpMenu.add(helpItem);
204 menuBar.add(fileMenu);
205 menuBar.add(viewMenu);
206 menuBar.add(colourMenu);
207 menuBar.add(viewerActionMenu);
208 menuBar.add(helpMenu);
210 statusPanel = new JPanel();
211 statusPanel.setLayout(new GridLayout());
212 this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
213 statusBar = new JLabel();
214 statusPanel.add(statusBar, null);
217 protected void fitToWindow_actionPerformed()
221 protected void highlightSelection_actionPerformed()
225 protected void viewerColour_actionPerformed(ActionEvent actionEvent)
229 protected abstract String alignStructs_actionPerformed(
230 ActionEvent actionEvent);
232 public void pdbFile_actionPerformed(ActionEvent actionEvent)
237 public void makePDBImage(TYPE imageType)
242 public void viewMapping_actionPerformed(ActionEvent actionEvent)
247 public void seqColour_actionPerformed(ActionEvent actionEvent)
252 public void chainColour_actionPerformed(ActionEvent actionEvent)
257 public void chargeColour_actionPerformed(ActionEvent actionEvent)
262 public void background_actionPerformed(ActionEvent actionEvent)
267 public void showHelp_actionPerformed(ActionEvent actionEvent)