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.
23 import jalview.bin.Cache;
24 import jalview.datamodel.Alignment;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.ColumnSelection;
27 import jalview.datamodel.PDBEntry;
28 import jalview.datamodel.SequenceI;
29 import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
30 import jalview.io.AppletFormatAdapter;
31 import jalview.io.JalviewFileChooser;
32 import jalview.io.JalviewFileView;
33 import jalview.schemes.BuriedColourScheme;
34 import jalview.schemes.ColourSchemeI;
35 import jalview.schemes.HelixColourScheme;
36 import jalview.schemes.HydrophobicColourScheme;
37 import jalview.schemes.PurinePyrimidineColourScheme;
38 import jalview.schemes.StrandColourScheme;
39 import jalview.schemes.TaylorColourScheme;
40 import jalview.schemes.TurnColourScheme;
41 import jalview.schemes.ZappoColourScheme;
42 import jalview.structures.models.AAStructureBindingModel;
43 import jalview.util.MessageManager;
44 import jalview.util.Platform;
45 import jalview.ws.dbsources.Pdb;
47 import java.awt.event.ActionEvent;
48 import java.awt.event.ActionListener;
49 import java.awt.event.ItemEvent;
50 import java.awt.event.ItemListener;
51 import java.io.BufferedReader;
53 import java.io.FileOutputStream;
54 import java.io.FileReader;
55 import java.io.IOException;
56 import java.io.PrintWriter;
57 import java.util.ArrayList;
58 import java.util.List;
59 import java.util.Vector;
61 import javax.swing.JCheckBoxMenuItem;
62 import javax.swing.JColorChooser;
63 import javax.swing.JInternalFrame;
64 import javax.swing.JMenu;
65 import javax.swing.JMenuItem;
66 import javax.swing.JOptionPane;
67 import javax.swing.event.InternalFrameAdapter;
68 import javax.swing.event.InternalFrameEvent;
69 import javax.swing.event.MenuEvent;
70 import javax.swing.event.MenuListener;
73 * GUI elements for handlnig an external chimera display
78 public class ChimeraViewFrame extends StructureViewerBase
80 private JalviewChimeraBinding jmb;
82 private boolean allChainsSelected = false;
84 private boolean alignAddedStructures = false;
87 * state flag for PDB retrieval thread
89 private boolean _started = false;
91 private boolean addingStructures = false;
93 private IProgressIndicator progressBar = null;
96 * pdb retrieval thread.
98 private Thread worker = null;
101 * Initialise menu options.
103 private void initMenus()
105 viewerActionMenu.setText(MessageManager.getString("label.chimera"));
106 viewerColour.setText(MessageManager
107 .getString("label.colour_with_chimera"));
108 viewerColour.setToolTipText(MessageManager
109 .getString("label.let_chimera_manage_structure_colours"));
110 helpItem.setText(MessageManager.getString("label.chimera_help"));
111 seqColour.setSelected(jmb.isColourBySequence());
112 viewerColour.setSelected(!jmb.isColourBySequence());
113 if (_colourwith == null)
115 _colourwith = new Vector<AlignmentPanel>();
117 if (_alignwith == null)
119 _alignwith = new Vector<AlignmentPanel>();
122 // save As not yet implemented
123 savemenu.setVisible(false);
125 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
126 MessageManager.getString("label.colour_by"), this, _colourwith,
130 public void itemStateChanged(ItemEvent e)
132 if (!seqColour.isSelected())
138 // update the Chimera display now.
139 seqColour_actionPerformed(null);
143 viewMenu.add(seqColourBy);
144 final ItemListener handler;
145 JMenu alpanels = new ViewSelectionMenu(
146 MessageManager.getString("label.superpose_with"), this,
147 _alignwith, handler = new ItemListener()
150 public void itemStateChanged(ItemEvent e)
152 alignStructs.setEnabled(_alignwith.size() > 0);
153 alignStructs.setToolTipText(MessageManager
155 "label.align_structures_using_linked_alignment_views",
157 { new Integer(_alignwith.size()).toString() }));
160 handler.itemStateChanged(null);
161 viewerActionMenu.add(alpanels);
162 viewerActionMenu.addMenuListener(new MenuListener()
166 public void menuSelected(MenuEvent e)
168 handler.itemStateChanged(null);
172 public void menuDeselected(MenuEvent e)
174 // TODO Auto-generated method stub
178 public void menuCanceled(MenuEvent e)
180 // TODO Auto-generated method stub
186 * add a single PDB structure to a new or existing Chimera view
193 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
194 String[] chains, final AlignmentPanel ap)
197 progressBar = ap.alignFrame;
198 // ////////////////////////////////
199 // Is the pdb file already loaded?
200 String alreadyMapped = ap.getStructureSelectionManager()
201 .alreadyMappedToFile(pdbentry.getId());
203 if (alreadyMapped != null)
205 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
206 MessageManager.formatMessage(
207 "label.pdb_entry_is_already_displayed", new Object[]
208 { pdbentry.getId() }), MessageManager.formatMessage(
209 "label.map_sequences_to_visible_window", new Object[]
210 { pdbentry.getId() }),
211 JOptionPane.YES_NO_CANCEL_OPTION);
213 if (option == JOptionPane.CANCEL_OPTION)
217 if (option == JOptionPane.YES_OPTION)
219 // TODO : Fix multiple seq to one chain issue here.
220 ap.getStructureSelectionManager().setMapping(seq, chains,
221 alreadyMapped, AppletFormatAdapter.FILE);
222 if (ap.getSeqPanel().seqCanvas.fr != null)
224 ap.getSeqPanel().seqCanvas.fr.featuresAdded();
225 ap.paintAlignment(true);
228 // Now this ChimeraViewFrame is mapped to new sequences. We must add
229 // them to the existing array
230 JInternalFrame[] frames = Desktop.instance.getAllFrames();
232 for (JInternalFrame frame : frames)
234 if (frame instanceof ChimeraViewFrame)
236 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
237 // JBPNOTE: this looks like a binding routine, rather than a gui
239 for (int pe = 0; pe < topView.jmb.getPdbCount(); pe++)
241 if (topView.jmb.getPdbEntry(pe).getFile()
245 topView.jmb.addSequence(pe, seq);
246 topView.addAlignmentPanel(ap);
247 // add it to the set used for colouring
248 topView.useAlignmentPanelForColourbyseq(ap);
249 topView.buildActionMenu();
250 ap.getStructureSelectionManager()
251 .sequenceColoursChanged(ap);
261 // /////////////////////////////////
262 // Check if there are other Chimera views involving this alignment
263 // and prompt user about adding this molecule to one of them
264 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
265 for (ChimeraViewFrame topView : existingViews)
267 // TODO: highlight topView in view somehow
268 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
269 MessageManager.formatMessage("label.add_pdbentry_to_view",
271 { pdbentry.getId(), topView.getTitle() }),
273 .getString("label.align_to_existing_structure_view"),
274 JOptionPane.YES_NO_CANCEL_OPTION);
275 if (option == JOptionPane.CANCEL_OPTION)
279 if (option == JOptionPane.YES_OPTION)
281 topView.useAlignmentPanelForSuperposition(ap);
282 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
286 // /////////////////////////////////
287 openNewChimera(ap, new PDBEntry[]
288 { pdbentry }, new SequenceI[][]
292 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
295 progressBar = ap.alignFrame;
296 jmb = new JalviewChimeraBindingModel(this,
297 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
298 addAlignmentPanel(ap);
299 useAlignmentPanelForColourbyseq(ap);
300 if (pdbentrys.length > 1)
302 alignAddedStructures = true;
303 useAlignmentPanelForSuperposition(ap);
305 jmb.setColourBySequence(true);
306 setSize(400, 400); // probably should be a configurable/dynamic default here
310 addingStructures = false;
311 worker = new Thread(this);
314 this.addInternalFrameListener(new InternalFrameAdapter()
316 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
325 * create a new viewer containing several structures superimposed using the
332 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
336 openNewChimera(ap, pe, seqs);
339 public AlignmentPanel[] getAllAlignmentPanels()
341 AlignmentPanel[] t, list = new AlignmentPanel[0];
342 for (String setid : _aps)
344 AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid);
347 t = new AlignmentPanel[list.length + panels.length];
348 System.arraycopy(list, 0, t, 0, list.length);
349 System.arraycopy(panels, 0, t, list.length, panels.length);
358 * set the primary alignmentPanel reference and add another alignPanel to the
359 * list of ones to use for colouring and aligning
363 public void addAlignmentPanel(AlignmentPanel nap)
365 if (getAlignmentPanel() == null)
367 setAlignmentPanel(nap);
369 if (!_aps.contains(nap.av.getSequenceSetId()))
371 _aps.add(nap.av.getSequenceSetId());
376 * remove any references held to the given alignment panel
380 public void removeAlignmentPanel(AlignmentPanel nap)
384 _alignwith.remove(nap);
385 _colourwith.remove(nap);
386 if (getAlignmentPanel() == nap)
388 setAlignmentPanel(null);
389 for (AlignmentPanel aps : getAllAlignmentPanels())
393 setAlignmentPanel(aps);
398 } catch (Exception ex)
401 if (getAlignmentPanel() != null)
407 public void useAlignmentPanelForSuperposition(AlignmentPanel nap)
409 addAlignmentPanel(nap);
410 if (!_alignwith.contains(nap))
416 public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap)
418 if (_alignwith.contains(nap))
420 _alignwith.remove(nap);
424 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap,
425 boolean enableColourBySeq)
427 useAlignmentPanelForColourbyseq(nap);
428 getBinding().setColourBySequence(enableColourBySeq);
429 seqColour.setSelected(enableColourBySeq);
430 viewerColour.setSelected(!enableColourBySeq);
433 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
435 addAlignmentPanel(nap);
436 if (!_colourwith.contains(nap))
438 _colourwith.add(nap);
442 public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap)
444 if (_colourwith.contains(nap))
446 _colourwith.remove(nap);
451 * add a new structure (with associated sequences and chains) to this viewer,
452 * retrieving it if necessary first.
459 * if true, new structure(s) will be align using associated alignment
461 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
462 final String[] chains, final boolean b,
463 final IProgressIndicator alignFrame)
465 if (pdbentry.getFile() == null)
467 if (worker != null && worker.isAlive())
469 // a retrieval is in progress, wait around and add ourselves to the
471 new Thread(new Runnable()
475 while (worker != null && worker.isAlive() && _started)
479 Thread.sleep(100 + ((int) Math.random() * 100));
481 } catch (Exception e)
486 // and call ourselves again.
487 addStructure(pdbentry, seq, chains, b, alignFrame);
493 // otherwise, start adding the structure.
494 jmb.addSequenceAndChain(new PDBEntry[]
495 { pdbentry }, new SequenceI[][]
496 { seq }, new String[][]
498 addingStructures = true;
500 alignAddedStructures = b;
501 progressBar = alignFrame; // visual indication happens on caller frame.
502 (worker = new Thread(this)).start();
506 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
508 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
509 JInternalFrame[] frames = Desktop.instance.getAllFrames();
511 for (JInternalFrame frame : frames)
513 if (frame instanceof ChimeraViewFrame)
515 if (((StructureViewerBase) frame).isLinkedWith(apanel))
517 result.add((ChimeraViewFrame) frame);
524 void initChimera(String command)
526 jmb.setFinishedInit(false);
527 // TODO: consider waiting until the structure/view is fully loaded before
529 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
530 getBounds().width, getBounds().height);
535 jmb.evalStateCommand(command, false);
536 jmb.setFinishedInit(true);
539 void setChainMenuItems(List<String> chainNames)
541 chainMenu.removeAll();
542 if (chainNames == null)
546 JMenuItem menuItem = new JMenuItem(
547 MessageManager.getString("label.all"));
548 menuItem.addActionListener(new ActionListener()
550 public void actionPerformed(ActionEvent evt)
552 allChainsSelected = true;
553 for (int i = 0; i < chainMenu.getItemCount(); i++)
555 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
557 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
561 allChainsSelected = false;
565 chainMenu.add(menuItem);
567 for (String chainName : chainNames)
569 menuItem = new JCheckBoxMenuItem(chainName, true);
570 menuItem.addItemListener(new ItemListener()
572 public void itemStateChanged(ItemEvent evt)
574 if (!allChainsSelected)
581 chainMenu.add(menuItem);
587 List<String> toshow = new ArrayList<String>();
588 for (int i = 0; i < chainMenu.getItemCount(); i++)
590 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
592 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
593 if (item.isSelected())
595 toshow.add(item.getText());
599 jmb.centerViewer(toshow);
603 * Close down this instance of Jalview's Chimera viewer, giving the user the
604 * option to close the associated Chimera window (process). They may wish to
605 * keep it open until they have had an opportunity to save any work.
607 public void closeViewer()
609 if (jmb.isChimeraRunning())
611 String prompt = MessageManager
612 .formatMessage("label.confirm_close_chimera", new Object[]
613 { jmb.getViewerTitle("Chimera", false) });
614 prompt = JvSwingUtils.wrapTooltip(true, prompt);
615 int confirm = JOptionPane.showConfirmDialog(this, prompt,
616 MessageManager.getString("label.close_viewer"),
617 JOptionPane.YES_NO_OPTION);
618 jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
620 setAlignmentPanel(null);
624 // TODO: check for memory leaks where instance isn't finalised because jmb
625 // holds a reference to the window
630 * Open any newly added PDB structures in Chimera, having first fetched data
631 * from PDB (if not already saved).
636 // todo - record which pdbids were successfully imported.
637 StringBuilder errormsgs = new StringBuilder(128);
638 StringBuilder files = new StringBuilder(128);
639 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
640 List<Integer> filePDBpos = new ArrayList<Integer>();
641 PDBEntry thePdbEntry = null;
644 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
645 // TODO: replace with reference fetching/transfer code (validate PDBentry
647 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
650 thePdbEntry = jmb.getPdbEntry(pi);
651 if (thePdbEntry.getFile() == null)
654 * Retrieve PDB data, save to file, attach to PDBEntry
656 file = fetchPdbFile(thePdbEntry);
659 errormsgs.append("'" + thePdbEntry.getId() + "' ");
665 * Got file already - ignore if already loaded in Chimera.
667 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
669 if (curfiles != null && curfiles.length > 0)
671 addingStructures = true; // already files loaded.
672 for (int c = 0; c < curfiles.length; c++)
674 if (curfiles[c].equals(file))
684 filePDB.add(thePdbEntry);
685 filePDBpos.add(Integer.valueOf(pi));
686 files.append(" \"" + Platform.escapeString(file) + "\"");
689 } catch (OutOfMemoryError oomerror)
691 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
693 } catch (Exception ex)
695 ex.printStackTrace();
696 errormsgs.append("When retrieving pdbfiles for '"
697 + thePdbEntry.getId() + "'");
699 if (errormsgs.length() > 0)
702 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
703 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
705 { errormsgs.toString() }), MessageManager
706 .getString("label.couldnt_load_file"),
707 JOptionPane.ERROR_MESSAGE);
710 if (files.length() > 0)
712 if (!addingStructures)
717 } catch (Exception ex)
719 Cache.log.error("Couldn't open Chimera viewer!", ex);
723 for (PDBEntry pe : filePDB)
726 if (pe.getFile() != null)
730 int pos = filePDBpos.get(num).intValue();
732 jmb.addSequence(pos, jmb.getSequence()[pos]);
733 File fl = new File(pe.getFile());
734 String protocol = AppletFormatAdapter.URL;
739 protocol = AppletFormatAdapter.FILE;
741 } catch (Throwable e)
744 // Explicitly map to the filename used by Chimera ;
745 // TODO: use pe.getId() instead of pe.getFile() ?
746 jmb.getSsm().setMapping(jmb.getSequence()[pos], null,
749 } catch (OutOfMemoryError oomerror)
752 "When trying to open and map structures from Chimera!",
754 } catch (Exception ex)
756 Cache.log.error("Couldn't open " + pe.getFile()
757 + " in Chimera viewer!", ex);
760 Cache.log.debug("File locations are " + files);
764 jmb.setFinishedInit(true);
765 jmb.setLoadingFromArchive(false);
767 // refresh the sequence colours for the new structure(s)
768 for (AlignmentPanel ap : _colourwith)
770 jmb.updateColours(ap);
772 // do superposition if asked to
773 if (alignAddedStructures)
775 new Thread(new Runnable()
779 alignStructs_withAllAlignPanels();
782 alignAddedStructures = false;
784 addingStructures = false;
791 * Fetch PDB data and save to a local file. Returns the full path to the file,
792 * or null if fetch fails.
794 * @param processingEntry
798 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
800 String filePath = null;
801 Pdb pdbclient = new Pdb();
802 AlignmentI pdbseq = null;
803 String pdbid = processingEntry.getId();
804 long hdl = pdbid.hashCode() - System.currentTimeMillis();
805 if (progressBar != null)
807 progressBar.setProgressBar(MessageManager.formatMessage(
808 "status.fetching_pdb", new Object[]
813 pdbseq = pdbclient.getSequenceRecords(pdbid);
814 } catch (OutOfMemoryError oomerror)
816 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
819 if (progressBar != null)
826 .getString("label.state_completed"),
831 * If PDB data were saved and are not invalid (empty alignment), return the
834 if (pdbseq != null && pdbseq.getHeight() > 0)
836 // just use the file name from the first sequence's first PDBEntry
837 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
838 .elementAt(0)).getFile()).getAbsolutePath();
839 processingEntry.setFile(filePath);
845 public void pdbFile_actionPerformed(ActionEvent actionEvent)
847 JalviewFileChooser chooser = new JalviewFileChooser(
848 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
850 chooser.setFileView(new JalviewFileView());
851 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
852 chooser.setToolTipText(MessageManager.getString("action.save"));
854 int value = chooser.showSaveDialog(this);
856 if (value == JalviewFileChooser.APPROVE_OPTION)
858 BufferedReader in = null;
861 // TODO: cope with multiple PDB files in view
862 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
863 File outFile = chooser.getSelectedFile();
865 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
867 while ((data = in.readLine()) != null)
869 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
875 } catch (Exception ex)
877 ex.printStackTrace();
885 } catch (IOException e)
895 public void viewMapping_actionPerformed(ActionEvent actionEvent)
897 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
900 for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
902 cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
903 cap.appendText("\n");
905 } catch (OutOfMemoryError e)
908 "composing sequence-structure alignments for display in text box.",
913 jalview.gui.Desktop.addInternalFrame(cap,
914 MessageManager.getString("label.pdb_sequence_mapping"), 550,
919 public void eps_actionPerformed(ActionEvent e)
923 .getString("error.eps_generation_not_implemented"));
927 public void png_actionPerformed(ActionEvent e)
931 .getString("error.png_generation_not_implemented"));
935 public void viewerColour_actionPerformed(ActionEvent actionEvent)
937 if (viewerColour.isSelected())
939 // disable automatic sequence colouring.
940 jmb.setColourBySequence(false);
945 public void seqColour_actionPerformed(ActionEvent actionEvent)
947 jmb.setColourBySequence(seqColour.isSelected());
948 if (_colourwith == null)
950 _colourwith = new Vector<AlignmentPanel>();
952 if (jmb.isColourBySequence())
954 if (!jmb.isLoadingFromArchive())
956 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
958 // Make the currently displayed alignment panel the associated view
959 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
962 // Set the colour using the current view for the associated alignframe
963 for (AlignmentPanel ap : _colourwith)
965 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
971 public void chainColour_actionPerformed(ActionEvent actionEvent)
973 chainColour.setSelected(true);
978 public void chargeColour_actionPerformed(ActionEvent actionEvent)
980 chargeColour.setSelected(true);
981 jmb.colourByCharge();
985 public void zappoColour_actionPerformed(ActionEvent actionEvent)
987 zappoColour.setSelected(true);
988 jmb.setJalviewColourScheme(new ZappoColourScheme());
992 public void taylorColour_actionPerformed(ActionEvent actionEvent)
994 taylorColour.setSelected(true);
995 jmb.setJalviewColourScheme(new TaylorColourScheme());
999 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1001 hydroColour.setSelected(true);
1002 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1006 public void helixColour_actionPerformed(ActionEvent actionEvent)
1008 helixColour.setSelected(true);
1009 jmb.setJalviewColourScheme(new HelixColourScheme());
1013 public void strandColour_actionPerformed(ActionEvent actionEvent)
1015 strandColour.setSelected(true);
1016 jmb.setJalviewColourScheme(new StrandColourScheme());
1020 public void turnColour_actionPerformed(ActionEvent actionEvent)
1022 turnColour.setSelected(true);
1023 jmb.setJalviewColourScheme(new TurnColourScheme());
1027 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1029 buriedColour.setSelected(true);
1030 jmb.setJalviewColourScheme(new BuriedColourScheme());
1034 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1036 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1040 public void userColour_actionPerformed(ActionEvent actionEvent)
1042 userColour.setSelected(true);
1043 new UserDefinedColours(this, null);
1047 public void backGround_actionPerformed(ActionEvent actionEvent)
1049 java.awt.Color col = JColorChooser
1050 .showDialog(this, MessageManager
1051 .getString("label.select_backgroud_colour"), null);
1054 jmb.setBackgroundColour(col);
1059 public void showHelp_actionPerformed(ActionEvent actionEvent)
1063 jalview.util.BrowserLauncher
1064 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1065 } catch (Exception ex)
1070 public void updateTitleAndMenus()
1072 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1077 setChainMenuItems(jmb.chainNames);
1079 this.setTitle(jmb.getViewerTitle("Chimera", true));
1080 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1082 viewerActionMenu.setVisible(true);
1084 if (!jmb.isLoadingFromArchive())
1086 seqColour_actionPerformed(null);
1094 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1098 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1100 alignStructs_withAllAlignPanels();
1103 private void alignStructs_withAllAlignPanels()
1105 if (getAlignmentPanel() == null)
1110 if (_alignwith.size() == 0)
1112 _alignwith.add(getAlignmentPanel());
1117 AlignmentI[] als = new Alignment[_alignwith.size()];
1118 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1119 int[] alm = new int[_alignwith.size()];
1122 for (AlignmentPanel ap : _alignwith)
1124 als[a] = ap.av.getAlignment();
1126 alc[a++] = ap.av.getColumnSelection();
1128 jmb.superposeStructures(als, alm, alc);
1129 } catch (Exception e)
1131 StringBuffer sp = new StringBuffer();
1132 for (AlignmentPanel ap : _alignwith)
1134 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1136 Cache.log.info("Couldn't align structures with the " + sp.toString()
1137 + "associated alignment panels.", e);
1143 public void setJalviewColourScheme(ColourSchemeI ucs)
1145 jmb.setJalviewColourScheme(ucs);
1152 * @return first alignment panel displaying given alignment, or the default
1155 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1157 for (AlignmentPanel ap : getAllAlignmentPanels())
1159 if (ap.av.getAlignment() == alignment)
1164 return getAlignmentPanel();
1168 public AAStructureBindingModel getBinding()
1174 * Ask Chimera to save its session to the designated file path. Returns true
1175 * if successful, else false.
1179 public boolean saveSession(String filepath)
1181 return jmb.saveSession(filepath);