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 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();
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();
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.addActionListener(new ActionListener()
172 public void actionPerformed(ActionEvent actionEvent)
174 showHelp_actionPerformed();
177 alignStructs = new JMenuItem();
178 alignStructs.setText(
179 MessageManager.getString("label.superpose_structures"));
180 alignStructs.addActionListener(new ActionListener()
183 public void actionPerformed(ActionEvent actionEvent)
185 alignStructsWithAllAlignPanels();
189 viewerActionMenu = new JMenu(); // text set in sub-classes
190 viewerActionMenu.setVisible(false);
191 viewerActionMenu.add(alignStructs);
192 colourMenu = new JMenu();
193 colourMenu.setText(MessageManager.getString("label.colours"));
194 fileMenu.add(savemenu);
195 fileMenu.add(viewMapping);
196 savemenu.add(pdbFile);
199 viewMenu.add(chainMenu);
200 helpMenu.add(helpItem);
202 menuBar.add(fileMenu);
203 menuBar.add(viewMenu);
204 menuBar.add(colourMenu);
205 menuBar.add(viewerActionMenu);
206 menuBar.add(helpMenu);
208 statusPanel = new JPanel();
209 statusPanel.setLayout(new GridLayout());
210 this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
211 statusBar = new JLabel();
212 statusPanel.add(statusBar, null);
215 protected void fitToWindow_actionPerformed()
217 getBinding().focusView();
220 protected void highlightSelection_actionPerformed()
224 protected void viewerColour_actionPerformed()
228 protected abstract String alignStructsWithAllAlignPanels();
230 public void pdbFile_actionPerformed()
235 public void makePDBImage(TYPE imageType)
240 public void viewMapping_actionPerformed()
245 public void seqColour_actionPerformed()
250 public void chainColour_actionPerformed()
255 public void chargeColour_actionPerformed()
260 public void background_actionPerformed()
265 public void showHelp_actionPerformed()