2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.AlignmentPanel;
25 import jalview.util.MessageManager;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import java.util.ArrayList;
30 import java.util.Vector;
32 import javax.swing.ButtonGroup;
33 import javax.swing.JInternalFrame;
34 import javax.swing.JMenu;
35 import javax.swing.JMenuBar;
36 import javax.swing.JMenuItem;
37 import javax.swing.JRadioButtonMenuItem;
39 public abstract class GStructureViewer extends JInternalFrame implements
40 JalviewStructureDisplayI
42 // private AAStructureBindingModel bindingModel;
44 protected JMenu savemenu = new JMenu();
46 protected JMenu viewMenu = new JMenu();
48 protected JMenu chainMenu = new JMenu();
50 protected JMenu viewerActionMenu = new JMenu();
52 protected JMenuItem alignStructs = new JMenuItem();
54 protected JRadioButtonMenuItem seqColour = new JRadioButtonMenuItem();
56 protected JRadioButtonMenuItem chainColour = new JRadioButtonMenuItem();
58 protected JRadioButtonMenuItem chargeColour = new JRadioButtonMenuItem();
60 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
62 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
64 protected JRadioButtonMenuItem hydroColour = new JRadioButtonMenuItem();
66 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
68 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
70 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
72 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
74 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
76 protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
78 protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
80 protected JMenuItem helpItem = new JMenuItem();
83 * list of sequenceSet ids associated with the view
85 protected ArrayList<String> _aps = new ArrayList<String>();
88 * list of alignment panels to use for superposition
90 protected Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
93 * list of alignment panels that are used for colouring structures by aligned
96 protected Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
98 private String viewId = null;
103 public GStructureViewer()
108 } catch (Exception ex)
110 ex.printStackTrace();
114 private void jbInit() throws Exception
116 JMenuBar menuBar = new JMenuBar();
117 this.setJMenuBar(menuBar);
119 JMenu fileMenu = new JMenu();
120 fileMenu.setText(MessageManager.getString("action.file"));
122 savemenu.setActionCommand(MessageManager.getString("action.save_image"));
123 savemenu.setText(MessageManager.getString("action.save_as"));
125 JMenuItem pdbFile = new JMenuItem();
126 pdbFile.setText(MessageManager.getString("label.pdb_file"));
127 pdbFile.addActionListener(new ActionListener()
129 public void actionPerformed(ActionEvent actionEvent)
131 pdbFile_actionPerformed(actionEvent);
135 JMenuItem png = new JMenuItem();
137 png.addActionListener(new ActionListener()
139 public void actionPerformed(ActionEvent actionEvent)
141 png_actionPerformed(actionEvent);
145 JMenuItem eps = new JMenuItem();
147 eps.addActionListener(new ActionListener()
149 public void actionPerformed(ActionEvent actionEvent)
151 eps_actionPerformed(actionEvent);
155 JMenuItem viewMapping = new JMenuItem();
156 viewMapping.setText(MessageManager.getString("label.view_mapping"));
157 viewMapping.addActionListener(new ActionListener()
159 public void actionPerformed(ActionEvent actionEvent)
161 viewMapping_actionPerformed(actionEvent);
164 viewMenu.setText(MessageManager.getString("action.view"));
165 chainMenu.setText(MessageManager.getString("action.show_chain"));
167 JMenu colourMenu = new JMenu();
168 colourMenu.setText(MessageManager.getString("label.colours"));
170 JMenuItem backGround = new JMenuItem();
171 backGround.setText(MessageManager.getString("label.background_colour")
173 backGround.addActionListener(new ActionListener()
175 public void actionPerformed(ActionEvent actionEvent)
177 backGround_actionPerformed(actionEvent);
180 seqColour.setSelected(false);
181 seqColour.setText(MessageManager.getString("action.by_sequence"));
182 seqColour.addActionListener(new ActionListener()
184 public void actionPerformed(ActionEvent actionEvent)
186 seqColour_actionPerformed(actionEvent);
189 chainColour.setText(MessageManager.getString("action.by_chain"));
190 chainColour.addActionListener(new ActionListener()
192 public void actionPerformed(ActionEvent actionEvent)
194 chainColour_actionPerformed(actionEvent);
197 chargeColour.setText(MessageManager.getString("label.charge_cysteine"));
198 chargeColour.addActionListener(new ActionListener()
200 public void actionPerformed(ActionEvent actionEvent)
202 chargeColour_actionPerformed(actionEvent);
205 zappoColour.setText(MessageManager.getString("label.zappo"));
206 zappoColour.addActionListener(new ActionListener()
208 public void actionPerformed(ActionEvent actionEvent)
210 zappoColour_actionPerformed(actionEvent);
213 taylorColour.setText(MessageManager.getString("label.taylor"));
214 taylorColour.addActionListener(new ActionListener()
216 public void actionPerformed(ActionEvent actionEvent)
218 taylorColour_actionPerformed(actionEvent);
221 hydroColour.setText(MessageManager.getString("label.hydrophobicity"));
222 hydroColour.addActionListener(new ActionListener()
224 public void actionPerformed(ActionEvent actionEvent)
226 hydroColour_actionPerformed(actionEvent);
229 strandColour.setText(MessageManager
230 .getString("label.strand_propensity"));
231 strandColour.addActionListener(new ActionListener()
233 public void actionPerformed(ActionEvent actionEvent)
235 strandColour_actionPerformed(actionEvent);
238 helixColour.setText(MessageManager.getString("label.helix_propensity"));
239 helixColour.addActionListener(new ActionListener()
241 public void actionPerformed(ActionEvent actionEvent)
243 helixColour_actionPerformed(actionEvent);
246 turnColour.setText(MessageManager.getString("label.turn_propensity"));
247 turnColour.addActionListener(new ActionListener()
249 public void actionPerformed(ActionEvent actionEvent)
251 turnColour_actionPerformed(actionEvent);
254 buriedColour.setText(MessageManager.getString("label.buried_index"));
255 buriedColour.addActionListener(new ActionListener()
257 public void actionPerformed(ActionEvent actionEvent)
259 buriedColour_actionPerformed(actionEvent);
262 purinePyrimidineColour.setText(MessageManager
263 .getString("label.purine_pyrimidine"));
264 purinePyrimidineColour.addActionListener(new ActionListener()
266 public void actionPerformed(ActionEvent actionEvent)
268 purinePyrimidineColour_actionPerformed(actionEvent);
272 userColour.setText(MessageManager.getString("action.user_defined"));
273 userColour.addActionListener(new ActionListener()
275 public void actionPerformed(ActionEvent actionEvent)
277 userColour_actionPerformed(actionEvent);
280 viewerColour.setSelected(false);
282 .setText(MessageManager.getString("label.colour_with_jmol"));
283 viewerColour.setToolTipText(MessageManager
284 .getString("label.let_jmol_manage_structure_colours"));
285 viewerColour.addActionListener(new ActionListener()
287 public void actionPerformed(ActionEvent actionEvent)
289 viewerColour_actionPerformed(actionEvent);
293 JMenu helpMenu = new JMenu();
294 helpMenu.setText(MessageManager.getString("action.help"));
295 helpItem.setText(MessageManager.getString("label.jmol_help"));
296 helpItem.addActionListener(new ActionListener()
298 public void actionPerformed(ActionEvent actionEvent)
300 showHelp_actionPerformed(actionEvent);
304 .setText(MessageManager.getString("label.align_structures"));
305 alignStructs.addActionListener(new ActionListener()
307 public void actionPerformed(ActionEvent actionEvent)
309 alignStructs_actionPerformed(actionEvent);
312 viewerActionMenu.setText(MessageManager.getString("label.jmol"));
313 menuBar.add(fileMenu);
314 menuBar.add(viewMenu);
315 menuBar.add(colourMenu);
316 menuBar.add(viewerActionMenu);
317 viewerActionMenu.setVisible(false);
318 menuBar.add(helpMenu);
319 fileMenu.add(savemenu);
320 fileMenu.add(viewMapping);
321 savemenu.add(pdbFile);
324 viewMenu.add(chainMenu);
326 colourMenu.add(seqColour);
327 colourMenu.add(chainColour);
328 colourMenu.add(chargeColour);
329 colourMenu.add(zappoColour);
330 colourMenu.add(taylorColour);
331 colourMenu.add(hydroColour);
332 colourMenu.add(helixColour);
333 colourMenu.add(strandColour);
334 colourMenu.add(turnColour);
335 colourMenu.add(buriedColour);
336 colourMenu.add(purinePyrimidineColour);
337 colourMenu.add(userColour);
338 colourMenu.add(viewerColour);
339 colourMenu.add(backGround);
341 ButtonGroup colourButtons = new ButtonGroup();
343 colourButtons.add(seqColour);
344 colourButtons.add(chainColour);
345 colourButtons.add(chargeColour);
346 colourButtons.add(zappoColour);
347 colourButtons.add(taylorColour);
348 colourButtons.add(hydroColour);
349 colourButtons.add(helixColour);
350 colourButtons.add(strandColour);
351 colourButtons.add(turnColour);
352 colourButtons.add(buriedColour);
353 colourButtons.add(userColour);
354 colourButtons.add(viewerColour);
356 helpMenu.add(helpItem);
357 viewerActionMenu.add(alignStructs);
360 protected void viewerColour_actionPerformed(ActionEvent actionEvent)
364 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
368 public void pdbFile_actionPerformed(ActionEvent actionEvent)
373 public void png_actionPerformed(ActionEvent actionEvent)
378 public void eps_actionPerformed(ActionEvent actionEvent)
383 public void viewMapping_actionPerformed(ActionEvent actionEvent)
388 public void seqColour_actionPerformed(ActionEvent actionEvent)
393 public void chainColour_actionPerformed(ActionEvent actionEvent)
398 public void chargeColour_actionPerformed(ActionEvent actionEvent)
403 public void zappoColour_actionPerformed(ActionEvent actionEvent)
408 public void taylorColour_actionPerformed(ActionEvent actionEvent)
413 public void hydroColour_actionPerformed(ActionEvent actionEvent)
418 public void helixColour_actionPerformed(ActionEvent actionEvent)
423 public void strandColour_actionPerformed(ActionEvent actionEvent)
428 public void turnColour_actionPerformed(ActionEvent actionEvent)
433 public void buriedColour_actionPerformed(ActionEvent actionEvent)
438 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
443 public void userColour_actionPerformed(ActionEvent actionEvent)
448 public void backGround_actionPerformed(ActionEvent actionEvent)
453 public void showHelp_actionPerformed(ActionEvent actionEvent)
459 // return bindingModel;
462 // public void setBindingModel(AAStructureBindingModel bindingModel)
464 // this.bindingModel = bindingModel;
470 * @return true if this Jmol instance is linked with the given alignPanel
472 public boolean isLinkedWith(AlignmentPanel ap2)
474 return _aps.contains(ap2.av.getSequenceSetId());
477 public boolean isUsedforaligment(AlignmentPanel ap2)
480 return (_alignwith != null) && _alignwith.contains(ap2);
483 public boolean isUsedforcolourby(AlignmentPanel ap2)
485 return (_colourwith != null) && _colourwith.contains(ap2);
490 * @return TRUE if the view is NOT being coloured by the alignment colours.
492 public boolean isColouredByViewer()
494 return !getBinding().isColourBySequence();
497 public String getViewId()
501 viewId = System.currentTimeMillis() + "." + this.hashCode();
506 protected void setViewId(String viewId)
508 this.viewId = viewId;
511 public String getStateInfo()