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.GridLayout;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
28 import javax.swing.JInternalFrame;
29 import javax.swing.JLabel;
30 import javax.swing.JMenu;
31 import javax.swing.JMenuBar;
32 import javax.swing.JMenuItem;
33 import javax.swing.JPanel;
34 import javax.swing.JRadioButtonMenuItem;
36 import jalview.api.structures.JalviewStructureDisplayI;
37 import jalview.gui.ColourMenuHelper.ColourChangeListener;
38 import jalview.util.ImageMaker.TYPE;
39 import jalview.util.MessageManager;
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 hetatmMenu;
57 protected JMenu viewerActionMenu;
59 protected JMenuItem alignStructs;
61 protected JMenuItem fitToWindow;
63 protected JRadioButtonMenuItem seqColour;
65 protected JRadioButtonMenuItem chainColour;
67 protected JRadioButtonMenuItem chargeColour;
69 protected JRadioButtonMenuItem viewerColour;
71 protected JMenuItem helpItem;
73 protected JLabel statusBar;
75 protected JPanel statusPanel;
80 public GStructureViewer()
85 } catch (Exception ex)
91 private void jbInit() throws Exception
94 setName("jalview-structureviewer");
96 JMenuBar menuBar = new JMenuBar();
97 this.setJMenuBar(menuBar);
99 JMenu fileMenu = new JMenu();
100 fileMenu.setText(MessageManager.getString("action.file"));
102 savemenu = new JMenu();
103 savemenu.setActionCommand(
104 MessageManager.getString("action.save_image"));
105 savemenu.setText(MessageManager.getString("action.save_as"));
107 JMenuItem pdbFile = new JMenuItem();
108 pdbFile.setText(MessageManager.getString("label.pdb_file"));
109 pdbFile.addActionListener(new ActionListener()
112 public void actionPerformed(ActionEvent actionEvent)
114 pdbFile_actionPerformed();
118 JMenuItem png = new JMenuItem();
120 png.addActionListener(new ActionListener()
123 public void actionPerformed(ActionEvent actionEvent)
125 makePDBImage(TYPE.PNG);
129 JMenuItem eps = new JMenuItem();
131 eps.addActionListener(new ActionListener()
134 public void actionPerformed(ActionEvent actionEvent)
136 makePDBImage(TYPE.EPS);
140 JMenuItem viewMapping = new JMenuItem();
141 viewMapping.setText(MessageManager.getString("label.view_mapping"));
142 viewMapping.addActionListener(new ActionListener()
145 public void actionPerformed(ActionEvent actionEvent)
147 viewMapping_actionPerformed();
151 viewMenu = new JMenu();
152 viewMenu.setText(MessageManager.getString("action.view"));
154 chainMenu = new JMenu();
155 chainMenu.setText(MessageManager.getString("action.show_chain"));
157 hetatmMenu = new JMenu();
158 hetatmMenu.setText(MessageManager.getString("action.show_hetatm"));
160 fitToWindow = new JMenuItem();
161 fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
162 fitToWindow.addActionListener(new ActionListener()
165 public void actionPerformed(ActionEvent actionEvent)
167 fitToWindow_actionPerformed();
171 JMenu helpMenu = new JMenu();
172 helpMenu.setText(MessageManager.getString("action.help"));
173 helpItem = new JMenuItem();
174 helpItem.addActionListener(new ActionListener()
177 public void actionPerformed(ActionEvent actionEvent)
179 showHelp_actionPerformed();
182 alignStructs = new JMenuItem();
183 alignStructs.setText(
184 MessageManager.getString("label.superpose_structures"));
185 alignStructs.addActionListener(new ActionListener()
188 public void actionPerformed(ActionEvent actionEvent)
190 alignStructsWithAllAlignPanels();
194 viewerActionMenu = new JMenu(); // text set in sub-classes
195 viewerActionMenu.setVisible(false);
196 viewerActionMenu.add(alignStructs);
197 colourMenu = new JMenu();
198 colourMenu.setText(MessageManager.getString("label.colours"));
199 fileMenu.add(savemenu);
200 fileMenu.add(viewMapping);
201 savemenu.add(pdbFile);
204 viewMenu.add(chainMenu);
205 viewMenu.add(hetatmMenu);
206 helpMenu.add(helpItem);
208 menuBar.add(fileMenu);
209 menuBar.add(viewMenu);
210 menuBar.add(colourMenu);
211 menuBar.add(viewerActionMenu);
212 menuBar.add(helpMenu);
214 statusPanel = new JPanel();
215 statusPanel.setLayout(new GridLayout());
216 this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
217 statusBar = new JLabel();
218 statusPanel.add(statusBar, null);
221 protected void fitToWindow_actionPerformed()
223 getBinding().focusView();
226 protected void highlightSelection_actionPerformed()
230 protected void viewerColour_actionPerformed()
234 protected abstract String alignStructsWithAllAlignPanels();
236 public void pdbFile_actionPerformed()
241 public void makePDBImage(TYPE imageType)
246 public void viewMapping_actionPerformed()
251 public void seqColour_actionPerformed()
256 public void chainColour_actionPerformed()
261 public void chargeColour_actionPerformed()
266 public void background_actionPerformed()
271 public void showHelp_actionPerformed()