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.
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.awt.event.ItemEvent;
26 import java.awt.event.ItemListener;
27 import java.io.BufferedReader;
29 import java.io.FileOutputStream;
30 import java.io.FileReader;
31 import java.io.IOException;
32 import java.io.PrintWriter;
33 import java.util.ArrayList;
34 import java.util.List;
35 import java.util.Random;
36 import java.util.Vector;
38 import javax.swing.JCheckBoxMenuItem;
39 import javax.swing.JColorChooser;
40 import javax.swing.JInternalFrame;
41 import javax.swing.JMenu;
42 import javax.swing.JMenuItem;
43 import javax.swing.JOptionPane;
44 import javax.swing.event.InternalFrameAdapter;
45 import javax.swing.event.InternalFrameEvent;
46 import javax.swing.event.MenuEvent;
47 import javax.swing.event.MenuListener;
49 import jalview.bin.Cache;
50 import jalview.datamodel.Alignment;
51 import jalview.datamodel.AlignmentI;
52 import jalview.datamodel.ColumnSelection;
53 import jalview.datamodel.PDBEntry;
54 import jalview.datamodel.SequenceI;
55 import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
56 import jalview.io.AppletFormatAdapter;
57 import jalview.io.JalviewFileChooser;
58 import jalview.io.JalviewFileView;
59 import jalview.schemes.BuriedColourScheme;
60 import jalview.schemes.ColourSchemeI;
61 import jalview.schemes.HelixColourScheme;
62 import jalview.schemes.HydrophobicColourScheme;
63 import jalview.schemes.PurinePyrimidineColourScheme;
64 import jalview.schemes.StrandColourScheme;
65 import jalview.schemes.TaylorColourScheme;
66 import jalview.schemes.TurnColourScheme;
67 import jalview.schemes.ZappoColourScheme;
68 import jalview.structures.models.AAStructureBindingModel;
69 import jalview.util.MessageManager;
70 import jalview.util.Platform;
71 import jalview.ws.dbsources.Pdb;
74 * GUI elements for handlnig an external chimera display
79 public class ChimeraViewFrame extends StructureViewerBase
81 private JalviewChimeraBinding jmb;
83 private boolean allChainsSelected = false;
85 private boolean alignAddedStructures = false;
88 * state flag for PDB retrieval thread
90 private boolean _started = false;
92 private boolean addingStructures = false;
94 private IProgressIndicator progressBar = null;
97 * pdb retrieval thread.
99 private Thread worker = null;
102 * Path to Chimera session file. This is set when an open Jalview/Chimera
103 * session is saved, or on restore from a Jalview project (if it holds the
104 * filename of any saved Chimera sessions).
106 private String chimeraSessionFile = null;
108 private Random random = new Random();
111 * Initialise menu options.
113 private void initMenus()
115 viewerActionMenu.setText(MessageManager.getString("label.chimera"));
116 viewerColour.setText(MessageManager
117 .getString("label.colour_with_chimera"));
118 viewerColour.setToolTipText(MessageManager
119 .getString("label.let_chimera_manage_structure_colours"));
120 helpItem.setText(MessageManager.getString("label.chimera_help"));
121 seqColour.setSelected(jmb.isColourBySequence());
122 viewerColour.setSelected(!jmb.isColourBySequence());
123 if (_colourwith == null)
125 _colourwith = new Vector<AlignmentPanel>();
127 if (_alignwith == null)
129 _alignwith = new Vector<AlignmentPanel>();
132 // save As not yet implemented
133 savemenu.setVisible(false);
135 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
136 MessageManager.getString("label.colour_by"), this, _colourwith,
140 public void itemStateChanged(ItemEvent e)
142 if (!seqColour.isSelected())
148 // update the Chimera display now.
149 seqColour_actionPerformed(null);
153 viewMenu.add(seqColourBy);
154 final ItemListener handler;
155 JMenu alpanels = new ViewSelectionMenu(
156 MessageManager.getString("label.superpose_with"), this,
157 _alignwith, handler = new ItemListener()
160 public void itemStateChanged(ItemEvent e)
162 alignStructs.setEnabled(_alignwith.size() > 0);
163 alignStructs.setToolTipText(MessageManager
165 "label.align_structures_using_linked_alignment_views",
167 { new Integer(_alignwith.size()).toString() }));
170 handler.itemStateChanged(null);
171 viewerActionMenu.add(alpanels);
172 viewerActionMenu.addMenuListener(new MenuListener()
176 public void menuSelected(MenuEvent e)
178 handler.itemStateChanged(null);
182 public void menuDeselected(MenuEvent e)
184 // TODO Auto-generated method stub
188 public void menuCanceled(MenuEvent e)
190 // TODO Auto-generated method stub
196 * add a single PDB structure to a new or existing Chimera view
203 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
204 String[] chains, final AlignmentPanel ap)
207 progressBar = ap.alignFrame;
208 // ////////////////////////////////
209 // Is the pdb file already loaded?
210 String alreadyMapped = ap.getStructureSelectionManager()
211 .alreadyMappedToFile(pdbentry.getId());
213 if (alreadyMapped != null)
215 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
216 MessageManager.formatMessage(
217 "label.pdb_entry_is_already_displayed", new Object[]
218 { pdbentry.getId() }), MessageManager.formatMessage(
219 "label.map_sequences_to_visible_window", new Object[]
220 { pdbentry.getId() }),
221 JOptionPane.YES_NO_CANCEL_OPTION);
223 if (option == JOptionPane.CANCEL_OPTION)
227 if (option == JOptionPane.YES_OPTION)
229 // TODO : Fix multiple seq to one chain issue here.
230 ap.getStructureSelectionManager().setMapping(seq, chains,
231 alreadyMapped, AppletFormatAdapter.FILE);
232 if (ap.getSeqPanel().seqCanvas.fr != null)
234 ap.getSeqPanel().seqCanvas.fr.featuresAdded();
235 ap.paintAlignment(true);
238 // Now this ChimeraViewFrame is mapped to new sequences. We must add
239 // them to the existing array
240 JInternalFrame[] frames = Desktop.instance.getAllFrames();
242 for (JInternalFrame frame : frames)
244 if (frame instanceof ChimeraViewFrame)
246 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
247 // JBPNOTE: this looks like a binding routine, rather than a gui
249 for (int pe = 0; pe < topView.jmb.getPdbCount(); pe++)
251 if (topView.jmb.getPdbEntry(pe).getFile()
255 topView.jmb.addSequence(pe, seq);
256 topView.addAlignmentPanel(ap);
257 // add it to the set used for colouring
258 topView.useAlignmentPanelForColourbyseq(ap);
259 topView.buildActionMenu();
260 ap.getStructureSelectionManager()
261 .sequenceColoursChanged(ap);
271 // /////////////////////////////////
272 // Check if there are other Chimera views involving this alignment
273 // and prompt user about adding this molecule to one of them
274 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
275 for (ChimeraViewFrame topView : existingViews)
277 // TODO: highlight topView in view somehow
279 * JAL-1742 exclude view with this structure already mapped (don't offer
280 * to align chain B to chain A of the same structure)
282 if (topView.hasPdbId(pdbentry.getId()))
286 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
287 MessageManager.formatMessage("label.add_pdbentry_to_view",
289 { pdbentry.getId(), topView.getTitle() }),
291 .getString("label.align_to_existing_structure_view"),
292 JOptionPane.YES_NO_CANCEL_OPTION);
293 if (option == JOptionPane.CANCEL_OPTION)
297 if (option == JOptionPane.YES_OPTION)
299 topView.useAlignmentPanelForSuperposition(ap);
300 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
304 // /////////////////////////////////
305 openNewChimera(ap, new PDBEntry[]
306 { pdbentry }, new SequenceI[][]
311 * Create a helper to manage progress bar display
313 protected void createProgressBar()
315 if (progressBar == null)
317 progressBar = new ProgressBar(statusPanel, statusBar);
321 protected boolean hasPdbId(String pdbId)
323 return jmb.hasPdbId(pdbId);
326 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
331 String[][] chains = extractChains(seqs);
332 jmb = new JalviewChimeraBindingModel(this,
333 ap.getStructureSelectionManager(), pdbentrys, seqs, chains,
335 addAlignmentPanel(ap);
336 useAlignmentPanelForColourbyseq(ap);
337 if (pdbentrys.length > 1)
339 alignAddedStructures = true;
340 useAlignmentPanelForSuperposition(ap);
342 jmb.setColourBySequence(true);
343 setSize(400, 400); // probably should be a configurable/dynamic default here
346 addingStructures = false;
347 worker = new Thread(this);
350 this.addInternalFrameListener(new InternalFrameAdapter()
352 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
361 * Retrieve chains for sequences by inspecting their PDB refs. The hope is
362 * that the first will be to the sequence's own chain. Really need a more
363 * managed way of doing this.
368 protected String[][] extractChains(SequenceI[][] seqs)
370 String[][] chains = new String[seqs.length][];
371 for (int i = 0; i < seqs.length; i++)
373 chains[i] = new String[seqs[i].length];
375 for (SequenceI seq : seqs[i])
378 if (seq.getDatasetSequence() != null)
380 Vector<PDBEntry> pdbrefs = seq.getDatasetSequence().getPDBId();
381 if (pdbrefs != null && pdbrefs.size() > 0)
383 chain = pdbrefs.get(0).getChainCode();
386 chains[i][seqno++] = chain;
393 * create a new viewer containing several structures superimposed using the
400 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
404 openNewChimera(ap, pe, seqs);
408 * Create a new viewer from saved session state data including Chimera session
411 * @param chimeraSession
416 * @param colourByChimera
417 * @param colourBySequence
419 public ChimeraViewFrame(String chimeraSession, AlignmentPanel alignPanel,
421 SequenceI[][] seqsArray, boolean colourByChimera,
422 boolean colourBySequence)
425 this.chimeraSessionFile = chimeraSession;
426 openNewChimera(alignPanel, pdbArray, seqsArray);
429 jmb.setColourBySequence(false);
430 seqColour.setSelected(false);
431 viewerColour.setSelected(true);
433 else if (colourBySequence)
435 jmb.setColourBySequence(true);
436 seqColour.setSelected(true);
437 viewerColour.setSelected(false);
442 * add a new structure (with associated sequences and chains) to this viewer,
443 * retrieving it if necessary first.
450 * if true, new structure(s) will be align using associated alignment
452 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
453 final String[] chains, final boolean b,
454 final IProgressIndicator alignFrame)
456 if (pdbentry.getFile() == null)
458 if (worker != null && worker.isAlive())
460 // a retrieval is in progress, wait around and add ourselves to the
462 new Thread(new Runnable()
466 while (worker != null && worker.isAlive() && _started)
470 Thread.sleep(100 + ((int) Math.random() * 100));
472 } catch (Exception e)
477 // and call ourselves again.
478 addStructure(pdbentry, seq, chains, b, alignFrame);
484 // otherwise, start adding the structure.
485 jmb.addSequenceAndChain(new PDBEntry[]
486 { pdbentry }, new SequenceI[][]
487 { seq }, new String[][]
489 addingStructures = true;
491 alignAddedStructures = b;
492 progressBar = alignFrame; // visual indication happens on caller frame.
493 (worker = new Thread(this)).start();
497 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
499 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
500 JInternalFrame[] frames = Desktop.instance.getAllFrames();
502 for (JInternalFrame frame : frames)
504 if (frame instanceof ChimeraViewFrame)
506 if (((StructureViewerBase) frame).isLinkedWith(apanel))
508 result.add((ChimeraViewFrame) frame);
516 * Launch Chimera. If we have a chimera session file name, send Chimera the
517 * command to open its saved session file.
521 jmb.setFinishedInit(false);
522 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
523 getBounds().width, getBounds().height);
526 * Pass an empty 'command' to launch Chimera
528 jmb.evalStateCommand("", false);
530 if (this.chimeraSessionFile != null)
532 boolean opened = jmb.openSession(chimeraSessionFile);
536 .println("An error occurred opening Chimera session file "
537 + chimeraSessionFile);
540 jmb.setFinishedInit(true);
542 jmb.startChimeraListener();
545 void setChainMenuItems(List<String> chainNames)
547 chainMenu.removeAll();
548 if (chainNames == null)
552 JMenuItem menuItem = new JMenuItem(
553 MessageManager.getString("label.all"));
554 menuItem.addActionListener(new ActionListener()
556 public void actionPerformed(ActionEvent evt)
558 allChainsSelected = true;
559 for (int i = 0; i < chainMenu.getItemCount(); i++)
561 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
563 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
567 allChainsSelected = false;
571 chainMenu.add(menuItem);
573 for (String chainName : chainNames)
575 menuItem = new JCheckBoxMenuItem(chainName, true);
576 menuItem.addItemListener(new ItemListener()
578 public void itemStateChanged(ItemEvent evt)
580 if (!allChainsSelected)
587 chainMenu.add(menuItem);
593 List<String> toshow = new ArrayList<String>();
594 for (int i = 0; i < chainMenu.getItemCount(); i++)
596 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
598 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
599 if (item.isSelected())
601 toshow.add(item.getText());
605 jmb.centerViewer(toshow);
609 * Close down this instance of Jalview's Chimera viewer, giving the user the
610 * option to close the associated Chimera window (process). They may wish to
611 * keep it open until they have had an opportunity to save any work.
613 * @param closeChimera
614 * if true, close any linked Chimera process; if false, prompt first
616 public void closeViewer(boolean closeChimera)
618 if (jmb.isChimeraRunning())
622 String prompt = MessageManager.formatMessage(
623 "label.confirm_close_chimera", new Object[]
624 { jmb.getViewerTitle("Chimera", false) });
625 prompt = JvSwingUtils.wrapTooltip(true, prompt);
626 int confirm = JOptionPane.showConfirmDialog(this, prompt,
627 MessageManager.getString("label.close_viewer"),
628 JOptionPane.YES_NO_OPTION);
629 closeChimera = confirm == JOptionPane.YES_OPTION;
631 jmb.closeViewer(closeChimera);
633 setAlignmentPanel(null);
637 // TODO: check for memory leaks where instance isn't finalised because jmb
638 // holds a reference to the window
643 * Open any newly added PDB structures in Chimera, having first fetched data
644 * from PDB (if not already saved).
649 // todo - record which pdbids were successfully imported.
650 StringBuilder errormsgs = new StringBuilder(128);
651 StringBuilder files = new StringBuilder(128);
652 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
653 List<Integer> filePDBpos = new ArrayList<Integer>();
654 PDBEntry thePdbEntry = null;
657 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
658 // TODO: replace with reference fetching/transfer code (validate PDBentry
660 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
663 thePdbEntry = jmb.getPdbEntry(pi);
664 if (thePdbEntry.getFile() == null)
667 * Retrieve PDB data, save to file, attach to PDBEntry
669 file = fetchPdbFile(thePdbEntry);
672 errormsgs.append("'" + thePdbEntry.getId() + "' ");
678 * Got file already - ignore if already loaded in Chimera.
680 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
682 if (curfiles != null && curfiles.length > 0)
684 addingStructures = true; // already files loaded.
685 for (int c = 0; c < curfiles.length; c++)
687 if (curfiles[c].equals(file))
697 filePDB.add(thePdbEntry);
698 filePDBpos.add(Integer.valueOf(pi));
699 files.append(" \"" + Platform.escapeString(file) + "\"");
702 } catch (OutOfMemoryError oomerror)
704 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
706 } catch (Exception ex)
708 ex.printStackTrace();
709 errormsgs.append("When retrieving pdbfiles for '"
710 + thePdbEntry.getId() + "'");
712 if (errormsgs.length() > 0)
715 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
716 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
718 { errormsgs.toString() }), MessageManager
719 .getString("label.couldnt_load_file"),
720 JOptionPane.ERROR_MESSAGE);
723 if (files.length() > 0)
725 if (!addingStructures)
730 } catch (Exception ex)
732 Cache.log.error("Couldn't open Chimera viewer!", ex);
736 for (PDBEntry pe : filePDB)
739 if (pe.getFile() != null)
743 int pos = filePDBpos.get(num).intValue();
744 long startTime = startProgressBar("Chimera "
745 + MessageManager.getString("status.opening_file"));
747 jmb.addSequence(pos, jmb.getSequence()[pos]);
748 File fl = new File(pe.getFile());
749 String protocol = AppletFormatAdapter.URL;
754 protocol = AppletFormatAdapter.FILE;
756 } catch (Throwable e)
760 stopProgressBar("", startTime);
762 // Explicitly map to the filename used by Chimera ;
763 // TODO: use pe.getId() instead of pe.getFile() ?
764 jmb.getSsm().setMapping(jmb.getSequence()[pos], null,
767 } catch (OutOfMemoryError oomerror)
770 "When trying to open and map structures from Chimera!",
772 } catch (Exception ex)
774 Cache.log.error("Couldn't open " + pe.getFile()
775 + " in Chimera viewer!", ex);
778 Cache.log.debug("File locations are " + files);
782 jmb.setFinishedInit(true);
783 jmb.setLoadingFromArchive(false);
785 // refresh the sequence colours for the new structure(s)
786 for (AlignmentPanel ap : _colourwith)
788 jmb.updateColours(ap);
790 // do superposition if asked to
791 if (alignAddedStructures)
793 new Thread(new Runnable()
797 alignStructs_withAllAlignPanels();
800 alignAddedStructures = false;
802 addingStructures = false;
809 * Fetch PDB data and save to a local file. Returns the full path to the file,
810 * or null if fetch fails.
812 * @param processingEntry
816 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
818 String filePath = null;
819 Pdb pdbclient = new Pdb();
820 AlignmentI pdbseq = null;
821 String pdbid = processingEntry.getId();
822 long hdl = startProgressBar(MessageManager.formatMessage(
823 "status.fetching_pdb", new Object[]
827 pdbseq = pdbclient.getSequenceRecords(pdbid);
828 } catch (OutOfMemoryError oomerror)
830 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
833 String msg = pdbid + " "
834 + MessageManager.getString("label.state_completed");
835 stopProgressBar(msg, hdl);
838 * If PDB data were saved and are not invalid (empty alignment), return the
841 if (pdbseq != null && pdbseq.getHeight() > 0)
843 // just use the file name from the first sequence's first PDBEntry
844 filePath = new File(pdbseq.getSequenceAt(0).getPDBId()
845 .elementAt(0).getFile()).getAbsolutePath();
846 processingEntry.setFile(filePath);
852 * Convenience method to update the progress bar if there is one. Be sure to
853 * call stopProgressBar with the returned handle to remove the message.
858 public long startProgressBar(String msg)
860 // TODO would rather have startProgress/stopProgress as the
861 // IProgressIndicator interface
862 long tm = random.nextLong();
863 if (progressBar != null)
865 progressBar.setProgressBar(msg, tm);
870 public void stopProgressBar(String msg, long handle)
872 if (progressBar != null)
874 progressBar.setProgressBar(msg, handle);
879 public void pdbFile_actionPerformed(ActionEvent actionEvent)
881 JalviewFileChooser chooser = new JalviewFileChooser(
882 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
884 chooser.setFileView(new JalviewFileView());
885 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
886 chooser.setToolTipText(MessageManager.getString("action.save"));
888 int value = chooser.showSaveDialog(this);
890 if (value == JalviewFileChooser.APPROVE_OPTION)
892 BufferedReader in = null;
895 // TODO: cope with multiple PDB files in view
896 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
897 File outFile = chooser.getSelectedFile();
899 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
901 while ((data = in.readLine()) != null)
903 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
909 } catch (Exception ex)
911 ex.printStackTrace();
919 } catch (IOException e)
929 public void viewMapping_actionPerformed(ActionEvent actionEvent)
931 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
934 cap.appendText(jmb.printMappings());
935 } catch (OutOfMemoryError e)
938 "composing sequence-structure alignments for display in text box.",
943 jalview.gui.Desktop.addInternalFrame(cap,
944 MessageManager.getString("label.pdb_sequence_mapping"), 550,
949 public void eps_actionPerformed(ActionEvent e)
953 .getString("error.eps_generation_not_implemented"));
957 public void png_actionPerformed(ActionEvent e)
961 .getString("error.png_generation_not_implemented"));
965 public void viewerColour_actionPerformed(ActionEvent actionEvent)
967 if (viewerColour.isSelected())
969 // disable automatic sequence colouring.
970 jmb.setColourBySequence(false);
975 public void seqColour_actionPerformed(ActionEvent actionEvent)
977 jmb.setColourBySequence(seqColour.isSelected());
978 if (_colourwith == null)
980 _colourwith = new Vector<AlignmentPanel>();
982 if (jmb.isColourBySequence())
984 if (!jmb.isLoadingFromArchive())
986 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
988 // Make the currently displayed alignment panel the associated view
989 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
992 // Set the colour using the current view for the associated alignframe
993 for (AlignmentPanel ap : _colourwith)
995 jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
1001 public void chainColour_actionPerformed(ActionEvent actionEvent)
1003 chainColour.setSelected(true);
1004 jmb.colourByChain();
1008 public void chargeColour_actionPerformed(ActionEvent actionEvent)
1010 chargeColour.setSelected(true);
1011 jmb.colourByCharge();
1015 public void zappoColour_actionPerformed(ActionEvent actionEvent)
1017 zappoColour.setSelected(true);
1018 jmb.setJalviewColourScheme(new ZappoColourScheme());
1022 public void taylorColour_actionPerformed(ActionEvent actionEvent)
1024 taylorColour.setSelected(true);
1025 jmb.setJalviewColourScheme(new TaylorColourScheme());
1029 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1031 hydroColour.setSelected(true);
1032 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1036 public void helixColour_actionPerformed(ActionEvent actionEvent)
1038 helixColour.setSelected(true);
1039 jmb.setJalviewColourScheme(new HelixColourScheme());
1043 public void strandColour_actionPerformed(ActionEvent actionEvent)
1045 strandColour.setSelected(true);
1046 jmb.setJalviewColourScheme(new StrandColourScheme());
1050 public void turnColour_actionPerformed(ActionEvent actionEvent)
1052 turnColour.setSelected(true);
1053 jmb.setJalviewColourScheme(new TurnColourScheme());
1057 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1059 buriedColour.setSelected(true);
1060 jmb.setJalviewColourScheme(new BuriedColourScheme());
1064 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1066 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1070 public void userColour_actionPerformed(ActionEvent actionEvent)
1072 userColour.setSelected(true);
1073 new UserDefinedColours(this, null);
1077 public void backGround_actionPerformed(ActionEvent actionEvent)
1079 java.awt.Color col = JColorChooser
1080 .showDialog(this, MessageManager
1081 .getString("label.select_backgroud_colour"), null);
1084 jmb.setBackgroundColour(col);
1089 public void showHelp_actionPerformed(ActionEvent actionEvent)
1093 jalview.util.BrowserLauncher
1094 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1095 } catch (Exception ex)
1100 public void updateTitleAndMenus()
1102 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1107 setChainMenuItems(jmb.getChainNames());
1109 this.setTitle(jmb.getViewerTitle("Chimera", true));
1110 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1112 viewerActionMenu.setVisible(true);
1114 if (!jmb.isLoadingFromArchive())
1116 seqColour_actionPerformed(null);
1124 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1128 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1130 alignStructs_withAllAlignPanels();
1133 private void alignStructs_withAllAlignPanels()
1135 if (getAlignmentPanel() == null)
1140 if (_alignwith.size() == 0)
1142 _alignwith.add(getAlignmentPanel());
1147 AlignmentI[] als = new Alignment[_alignwith.size()];
1148 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1149 int[] alm = new int[_alignwith.size()];
1152 for (AlignmentPanel ap : _alignwith)
1154 als[a] = ap.av.getAlignment();
1156 alc[a++] = ap.av.getColumnSelection();
1158 jmb.superposeStructures(als, alm, alc);
1159 } catch (Exception e)
1161 StringBuffer sp = new StringBuffer();
1162 for (AlignmentPanel ap : _alignwith)
1164 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1166 Cache.log.info("Couldn't align structures with the " + sp.toString()
1167 + "associated alignment panels.", e);
1173 public void setJalviewColourScheme(ColourSchemeI ucs)
1175 jmb.setJalviewColourScheme(ucs);
1182 * @return first alignment panel displaying given alignment, or the default
1185 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1187 for (AlignmentPanel ap : getAllAlignmentPanels())
1189 if (ap.av.getAlignment() == alignment)
1194 return getAlignmentPanel();
1198 public AAStructureBindingModel getBinding()
1204 * Ask Chimera to save its session to the designated file path. Returns true
1205 * if successful, else false.
1210 public boolean saveSession(String filepath)
1212 boolean result = jmb.saveSession(filepath);
1215 this.chimeraSessionFile = filepath;
1221 * Returns the file path of the Chimera session file the last time it was
1222 * saved. If it was never saved, returns an empty string. There is no
1223 * guarantee that the Chimera session has not changed since it was saved.
1226 public String getStateInfo()
1228 return this.chimeraSessionFile;
1232 protected void fitToWindow_actionPerformed()