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.api.SequenceStructureBinding;
24 import jalview.api.structures.JalviewStructureDisplayI;
25 import jalview.bin.Cache;
26 import jalview.datamodel.Alignment;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.ColumnSelection;
29 import jalview.datamodel.PDBEntry;
30 import jalview.datamodel.SequenceI;
31 import jalview.gui.ViewSelectionMenu.ViewSetProvider;
32 import jalview.io.AppletFormatAdapter;
33 import jalview.io.JalviewFileChooser;
34 import jalview.io.JalviewFileView;
35 import jalview.jbgui.GStructureViewer;
36 import jalview.schemes.BuriedColourScheme;
37 import jalview.schemes.ColourSchemeI;
38 import jalview.schemes.HelixColourScheme;
39 import jalview.schemes.HydrophobicColourScheme;
40 import jalview.schemes.PurinePyrimidineColourScheme;
41 import jalview.schemes.StrandColourScheme;
42 import jalview.schemes.TaylorColourScheme;
43 import jalview.schemes.TurnColourScheme;
44 import jalview.schemes.ZappoColourScheme;
45 import jalview.util.MessageManager;
46 import jalview.util.Platform;
47 import jalview.ws.dbsources.Pdb;
49 import java.awt.Component;
50 import java.awt.event.ActionEvent;
51 import java.awt.event.ActionListener;
52 import java.awt.event.ItemEvent;
53 import java.awt.event.ItemListener;
54 import java.io.BufferedReader;
56 import java.io.FileOutputStream;
57 import java.io.FileReader;
58 import java.io.IOException;
59 import java.io.PrintWriter;
60 import java.util.ArrayList;
61 import java.util.List;
62 import java.util.Vector;
64 import javax.swing.JCheckBoxMenuItem;
65 import javax.swing.JColorChooser;
66 import javax.swing.JInternalFrame;
67 import javax.swing.JMenu;
68 import javax.swing.JMenuItem;
69 import javax.swing.JOptionPane;
70 import javax.swing.event.InternalFrameAdapter;
71 import javax.swing.event.InternalFrameEvent;
72 import javax.swing.event.MenuEvent;
73 import javax.swing.event.MenuListener;
76 * GUI elements for handlnig an external chimera display
81 public class ChimeraViewFrame extends GStructureViewer implements Runnable,
82 ViewSetProvider, JalviewStructureDisplayI
85 private JalviewChimeraBindingModel jmb;
88 * list of sequenceSet ids associated with the view
90 private ArrayList<String> _aps = new ArrayList<String>();
93 * list of alignment panels to use for superposition
95 private Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
98 * list of alignment panels that are used for colouring structures by aligned
101 private Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
103 private boolean allChainsSelected = false;
105 private boolean alignAddedStructures = false;
110 * state flag for PDB retrieval thread
112 private boolean _started = false;
114 private boolean addingStructures = false;
116 private IProgressIndicator progressBar = null;
118 private String viewId = null;
121 * pdb retrieval thread.
123 private Thread worker = null;
126 * Initialise menu options.
128 private void initMenus()
130 viewerActionMenu.setText(MessageManager.getString("label.chimera"));
131 viewerColour.setText(MessageManager
132 .getString("label.colour_with_chimera"));
133 viewerColour.setToolTipText(MessageManager
134 .getString("label.let_chimera_manage_structure_colours"));
135 helpItem.setText(MessageManager.getString("label.chimera_help"));
136 seqColour.setSelected(jmb.isColourBySequence());
137 viewerColour.setSelected(!jmb.isColourBySequence());
138 if (_colourwith == null)
140 _colourwith = new Vector<AlignmentPanel>();
142 if (_alignwith == null)
144 _alignwith = new Vector<AlignmentPanel>();
147 // no colour by chain command in Chimera?
148 chainColour.setVisible(false);
150 // save As not yet implemented
151 savemenu.setVisible(false);
153 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
154 MessageManager.getString("label.colour_by"), this, _colourwith,
158 public void itemStateChanged(ItemEvent e)
160 if (!seqColour.isSelected())
166 // update the Chimera display now.
167 seqColour_actionPerformed(null);
171 viewMenu.add(seqColourBy);
172 final ItemListener handler;
173 JMenu alpanels = new ViewSelectionMenu(
174 MessageManager.getString("label.superpose_with"), this,
175 _alignwith, handler = new ItemListener()
178 public void itemStateChanged(ItemEvent e)
180 alignStructs.setEnabled(_alignwith.size() > 0);
181 alignStructs.setToolTipText(MessageManager
183 "label.align_structures_using_linked_alignment_views",
185 { new Integer(_alignwith.size()).toString() }));
188 handler.itemStateChanged(null);
189 viewerActionMenu.add(alpanels);
190 viewerActionMenu.addMenuListener(new MenuListener()
194 public void menuSelected(MenuEvent e)
196 handler.itemStateChanged(null);
200 public void menuDeselected(MenuEvent e)
202 // TODO Auto-generated method stub
206 public void menuCanceled(MenuEvent e)
208 // TODO Auto-generated method stub
214 * add a single PDB structure to a new or existing Chimera view
221 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
222 String[] chains, final AlignmentPanel ap)
225 progressBar = ap.alignFrame;
226 // ////////////////////////////////
227 // Is the pdb file already loaded?
228 String alreadyMapped = ap.getStructureSelectionManager()
229 .alreadyMappedToFile(pdbentry.getId());
231 if (alreadyMapped != null)
233 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
234 MessageManager.formatMessage(
235 "label.pdb_entry_is_already_displayed", new Object[]
236 { pdbentry.getId() }), MessageManager.formatMessage(
237 "label.map_sequences_to_visible_window", new Object[]
238 { pdbentry.getId() }),
239 JOptionPane.YES_NO_CANCEL_OPTION);
241 if (option == JOptionPane.CANCEL_OPTION)
245 if (option == JOptionPane.YES_OPTION)
247 // TODO : Fix multiple seq to one chain issue here.
248 ap.getStructureSelectionManager().setMapping(seq, chains,
249 alreadyMapped, AppletFormatAdapter.FILE);
250 if (ap.seqPanel.seqCanvas.fr != null)
252 ap.seqPanel.seqCanvas.fr.featuresAdded();
253 ap.paintAlignment(true);
256 // Now this ChimeraViewFrame is mapped to new sequences. We must add
257 // them to the existing array
258 JInternalFrame[] frames = Desktop.instance.getAllFrames();
260 for (JInternalFrame frame : frames)
262 if (frame instanceof ChimeraViewFrame)
264 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
265 // JBPNOTE: this looks like a binding routine, rather than a gui
267 for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
269 if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
271 topView.jmb.addSequence(pe, seq);
272 topView.addAlignmentPanel(ap);
273 // add it to the set used for colouring
274 topView.useAlignmentPanelForColourbyseq(ap);
275 topView.buildChimeraActionMenu();
276 ap.getStructureSelectionManager()
277 .sequenceColoursChanged(ap);
287 // /////////////////////////////////
288 // Check if there are other Chimera views involving this alignment
289 // and prompt user about adding this molecule to one of them
290 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
291 for (ChimeraViewFrame topView : existingViews)
293 // TODO: highlight topView in view somehow
294 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
295 MessageManager.formatMessage("label.add_pdbentry_to_view",
297 { pdbentry.getId(), topView.getTitle() }),
299 .getString("label.align_to_existing_structure_view"),
300 JOptionPane.YES_NO_CANCEL_OPTION);
301 if (option == JOptionPane.CANCEL_OPTION)
305 if (option == JOptionPane.YES_OPTION)
307 topView.useAlignmentPanelForSuperposition(ap);
308 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
312 // /////////////////////////////////
313 openNewChimera(ap, new PDBEntry[]
314 { pdbentry }, new SequenceI[][]
318 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
321 progressBar = ap.alignFrame;
322 jmb = new JalviewChimeraBindingModel(this,
323 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
324 addAlignmentPanel(ap);
325 useAlignmentPanelForColourbyseq(ap);
326 if (pdbentrys.length > 1)
328 alignAddedStructures = true;
329 useAlignmentPanelForSuperposition(ap);
331 jmb.setColourBySequence(true);
332 setSize(400, 400); // probably should be a configurable/dynamic default here
336 addingStructures = false;
337 worker = new Thread(this);
340 this.addInternalFrameListener(new InternalFrameAdapter()
342 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
351 * create a new viewer containing several structures superimposed using the
358 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
362 openNewChimera(ap, pe, seqs);
365 public AlignmentPanel[] getAllAlignmentPanels()
367 AlignmentPanel[] t, list = new AlignmentPanel[0];
368 for (String setid : _aps)
370 AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid);
373 t = new AlignmentPanel[list.length + panels.length];
374 System.arraycopy(list, 0, t, 0, list.length);
375 System.arraycopy(panels, 0, t, list.length, panels.length);
384 * set the primary alignmentPanel reference and add another alignPanel to the
385 * list of ones to use for colouring and aligning
389 public void addAlignmentPanel(AlignmentPanel nap)
395 if (!_aps.contains(nap.av.getSequenceSetId()))
397 _aps.add(nap.av.getSequenceSetId());
402 * remove any references held to the given alignment panel
406 public void removeAlignmentPanel(AlignmentPanel nap)
410 _alignwith.remove(nap);
411 _colourwith.remove(nap);
415 for (AlignmentPanel aps : getAllAlignmentPanels())
424 } catch (Exception ex)
429 buildChimeraActionMenu();
433 public void useAlignmentPanelForSuperposition(AlignmentPanel nap)
435 addAlignmentPanel(nap);
436 if (!_alignwith.contains(nap))
442 public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap)
444 if (_alignwith.contains(nap))
446 _alignwith.remove(nap);
450 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap,
451 boolean enableColourBySeq)
453 useAlignmentPanelForColourbyseq(nap);
454 jmb.setColourBySequence(enableColourBySeq);
455 seqColour.setSelected(enableColourBySeq);
456 viewerColour.setSelected(!enableColourBySeq);
459 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
461 addAlignmentPanel(nap);
462 if (!_colourwith.contains(nap))
464 _colourwith.add(nap);
468 public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap)
470 if (_colourwith.contains(nap))
472 _colourwith.remove(nap);
477 * add a new structure (with associated sequences and chains) to this viewer,
478 * retrieving it if necessary first.
485 * if true, new structure(s) will be align using associated alignment
487 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
488 final String[] chains, final boolean b,
489 final IProgressIndicator alignFrame)
491 if (pdbentry.getFile() == null)
493 if (worker != null && worker.isAlive())
495 // a retrieval is in progress, wait around and add ourselves to the
497 new Thread(new Runnable()
501 while (worker != null && worker.isAlive() && _started)
505 Thread.sleep(100 + ((int) Math.random() * 100));
507 } catch (Exception e)
512 // and call ourselves again.
513 addStructure(pdbentry, seq, chains, b, alignFrame);
519 // otherwise, start adding the structure.
520 jmb.addSequenceAndChain(new PDBEntry[]
521 { pdbentry }, new SequenceI[][]
522 { seq }, new String[][]
524 addingStructures = true;
526 alignAddedStructures = b;
527 progressBar = alignFrame; // visual indication happens on caller frame.
528 (worker = new Thread(this)).start();
532 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
534 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
535 JInternalFrame[] frames = Desktop.instance.getAllFrames();
537 for (JInternalFrame frame : frames)
539 if (frame instanceof ChimeraViewFrame)
541 if (((ChimeraViewFrame) frame).isLinkedWith(apanel))
543 result.add((ChimeraViewFrame) frame);
550 void initChimera(String command)
552 jmb.setFinishedInit(false);
553 // TODO: consider waiting until the structure/view is fully loaded before
555 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(true),
556 getBounds().width, getBounds().height);
561 jmb.evalStateCommand(command, false);
562 jmb.setFinishedInit(true);
565 void setChainMenuItems(List<String> chainNames)
567 chainMenu.removeAll();
568 if (chainNames == null)
572 JMenuItem menuItem = new JMenuItem(
573 MessageManager.getString("label.all"));
574 menuItem.addActionListener(new ActionListener()
576 public void actionPerformed(ActionEvent evt)
578 allChainsSelected = true;
579 for (int i = 0; i < chainMenu.getItemCount(); i++)
581 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
583 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
587 allChainsSelected = false;
591 chainMenu.add(menuItem);
593 for (String chainName : chainNames)
595 menuItem = new JCheckBoxMenuItem(chainName, true);
596 menuItem.addItemListener(new ItemListener()
598 public void itemStateChanged(ItemEvent evt)
600 if (!allChainsSelected)
607 chainMenu.add(menuItem);
613 List<String> toshow = new ArrayList<String>();
614 for (int i = 0; i < chainMenu.getItemCount(); i++)
616 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
618 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
619 if (item.isSelected())
621 toshow.add(item.getText());
625 jmb.centerViewer(toshow);
629 * Close down this instance of Jalview's Chimera viewer, giving the user the
630 * option to close the associated Chimera window (process). They may wish to
631 * keep it open until they have had an opportunity to save any work.
633 public void closeViewer()
635 if (jmb.isChimeraRunning())
637 String prompt = MessageManager
638 .formatMessage("label.confirm_close_chimera", new Object[]
639 { jmb.getViewerTitle(false) });
640 prompt = JvSwingUtils.wrapTooltip(true, prompt);
641 int confirm = JOptionPane.showConfirmDialog(this, prompt,
642 MessageManager.getString("label.close_viewer"),
643 JOptionPane.YES_NO_OPTION);
644 jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
650 // TODO: check for memory leaks where instance isn't finalised because jmb
651 // holds a reference to the window
656 * Open any newly added PDB structures in Chimera, having first fetched data
657 * from PDB (if not already saved).
662 // todo - record which pdbids were successfully imported.
663 StringBuilder errormsgs = new StringBuilder(128);
664 StringBuilder files = new StringBuilder(128);
665 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
666 List<Integer> filePDBpos = new ArrayList<Integer>();
667 PDBEntry thePdbEntry = null;
670 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
671 // TODO: replace with reference fetching/transfer code (validate PDBentry
673 for (int pi = 0; pi < jmb.pdbentry.length; pi++)
676 thePdbEntry = jmb.pdbentry[pi];
677 if (thePdbEntry.getFile() == null)
680 * Retrieve PDB data, save to file, attach to PDBEntry
682 file = fetchPdbFile(thePdbEntry);
685 errormsgs.append("'" + thePdbEntry.getId() + "' ");
691 * Got file already - ignore if already loaded in Chimera.
693 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
695 if (curfiles != null && curfiles.length > 0)
697 addingStructures = true; // already files loaded.
698 for (int c = 0; c < curfiles.length; c++)
700 if (curfiles[c].equals(file))
710 filePDB.add(thePdbEntry);
711 filePDBpos.add(Integer.valueOf(pi));
712 files.append(" \"" + Platform.escapeString(file) + "\"");
715 } catch (OutOfMemoryError oomerror)
717 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
719 } catch (Exception ex)
721 ex.printStackTrace();
722 errormsgs.append("When retrieving pdbfiles for '"
723 + thePdbEntry.getId() + "'");
725 if (errormsgs.length() > 0)
728 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
729 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
731 { errormsgs.toString() }), MessageManager
732 .getString("label.couldnt_load_file"),
733 JOptionPane.ERROR_MESSAGE);
736 if (files.length() > 0)
738 if (!addingStructures)
743 } catch (Exception ex)
745 Cache.log.error("Couldn't open Chimera viewer!", ex);
749 for (PDBEntry pe : filePDB)
752 if (pe.getFile() != null)
756 int pos = filePDBpos.get(num).intValue();
758 jmb.addSequence(pos, jmb.sequence[pos]);
759 File fl = new File(pe.getFile());
760 String protocol = AppletFormatAdapter.URL;
765 protocol = AppletFormatAdapter.FILE;
767 } catch (Throwable e)
770 // Explicitly map to the filename used by Chimera ;
771 // TODO: use pe.getId() instead of pe.getFile() ?
772 jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
774 } catch (OutOfMemoryError oomerror)
777 "When trying to open and map structures from Chimera!",
779 } catch (Exception ex)
781 Cache.log.error("Couldn't open " + pe.getFile()
782 + " in Chimera viewer!", ex);
785 Cache.log.debug("File locations are " + files);
789 jmb.setFinishedInit(true);
790 jmb.setLoadingFromArchive(false);
792 // refresh the sequence colours for the new structure(s)
793 for (AlignmentPanel ap : _colourwith)
795 jmb.updateColours(ap);
797 // do superposition if asked to
798 if (alignAddedStructures)
800 new Thread(new Runnable()
804 alignStructs_withAllAlignPanels();
807 alignAddedStructures = false;
809 addingStructures = false;
816 * Fetch PDB data and save to a local file. Returns the full path to the file,
817 * or null if fetch fails.
819 * @param processingEntry
823 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
825 String filePath = null;
826 Pdb pdbclient = new Pdb();
827 AlignmentI pdbseq = null;
828 String pdbid = processingEntry.getId();
829 long hdl = pdbid.hashCode() - System.currentTimeMillis();
830 if (progressBar != null)
832 progressBar.setProgressBar(MessageManager.formatMessage(
833 "status.fetching_pdb", new Object[]
838 pdbseq = pdbclient.getSequenceRecords(pdbid);
839 } catch (OutOfMemoryError oomerror)
841 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
844 if (progressBar != null)
846 progressBar.setProgressBar(
847 MessageManager.getString("label.state_completed"), hdl);
851 * If PDB data were saved and are not invalid (empty alignment), return the
854 if (pdbseq != null && pdbseq.getHeight() > 0)
856 // just use the file name from the first sequence's first PDBEntry
857 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
858 .elementAt(0)).getFile()).getAbsolutePath();
859 processingEntry.setFile(filePath);
865 public void pdbFile_actionPerformed(ActionEvent actionEvent)
867 JalviewFileChooser chooser = new JalviewFileChooser(
868 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
870 chooser.setFileView(new JalviewFileView());
871 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
872 chooser.setToolTipText(MessageManager.getString("action.save"));
874 int value = chooser.showSaveDialog(this);
876 if (value == JalviewFileChooser.APPROVE_OPTION)
878 BufferedReader in = null;
881 // TODO: cope with multiple PDB files in view
882 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
883 File outFile = chooser.getSelectedFile();
885 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
887 while ((data = in.readLine()) != null)
889 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
895 } catch (Exception ex)
897 ex.printStackTrace();
905 } catch (IOException e)
915 public void viewMapping_actionPerformed(ActionEvent actionEvent)
917 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
920 for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
922 cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
923 cap.appendText("\n");
925 } catch (OutOfMemoryError e)
928 "composing sequence-structure alignments for display in text box.",
933 jalview.gui.Desktop.addInternalFrame(cap,
934 MessageManager.getString("label.pdb_sequence_mapping"), 550,
939 public void eps_actionPerformed(ActionEvent e)
943 .getString("error.eps_generation_not_implemented"));
947 public void png_actionPerformed(ActionEvent e)
951 .getString("error.png_generation_not_implemented"));
955 public void viewerColour_actionPerformed(ActionEvent actionEvent)
957 if (viewerColour.isSelected())
959 // disable automatic sequence colouring.
960 jmb.setColourBySequence(false);
965 public void seqColour_actionPerformed(ActionEvent actionEvent)
967 jmb.setColourBySequence(seqColour.isSelected());
968 if (_colourwith == null)
970 _colourwith = new Vector<AlignmentPanel>();
972 if (jmb.isColourBySequence())
974 if (!jmb.isLoadingFromArchive())
976 if (_colourwith.size() == 0 && ap != null)
978 // Make the currently displayed alignment panel the associated view
979 _colourwith.add(ap.alignFrame.alignPanel);
982 // Set the colour using the current view for the associated alignframe
983 for (AlignmentPanel ap : _colourwith)
985 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
991 public void chainColour_actionPerformed(ActionEvent actionEvent)
993 chainColour.setSelected(true);
998 public void chargeColour_actionPerformed(ActionEvent actionEvent)
1000 chargeColour.setSelected(true);
1001 jmb.colourByCharge();
1005 public void zappoColour_actionPerformed(ActionEvent actionEvent)
1007 zappoColour.setSelected(true);
1008 jmb.setJalviewColourScheme(new ZappoColourScheme());
1012 public void taylorColour_actionPerformed(ActionEvent actionEvent)
1014 taylorColour.setSelected(true);
1015 jmb.setJalviewColourScheme(new TaylorColourScheme());
1019 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1021 hydroColour.setSelected(true);
1022 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1026 public void helixColour_actionPerformed(ActionEvent actionEvent)
1028 helixColour.setSelected(true);
1029 jmb.setJalviewColourScheme(new HelixColourScheme());
1033 public void strandColour_actionPerformed(ActionEvent actionEvent)
1035 strandColour.setSelected(true);
1036 jmb.setJalviewColourScheme(new StrandColourScheme());
1040 public void turnColour_actionPerformed(ActionEvent actionEvent)
1042 turnColour.setSelected(true);
1043 jmb.setJalviewColourScheme(new TurnColourScheme());
1047 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1049 buriedColour.setSelected(true);
1050 jmb.setJalviewColourScheme(new BuriedColourScheme());
1054 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1056 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1060 public void userColour_actionPerformed(ActionEvent actionEvent)
1062 userColour.setSelected(true);
1063 new UserDefinedColours(this, null);
1067 public void backGround_actionPerformed(ActionEvent actionEvent)
1069 java.awt.Color col = JColorChooser
1070 .showDialog(this, MessageManager
1071 .getString("label.select_backgroud_colour"), null);
1074 jmb.setBackgroundColour(col);
1079 public void showHelp_actionPerformed(ActionEvent actionEvent)
1083 jalview.util.BrowserLauncher
1084 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1085 } catch (Exception ex)
1090 public String getViewId()
1094 viewId = System.currentTimeMillis() + "." + this.hashCode();
1099 public void updateTitleAndMenus()
1101 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1106 setChainMenuItems(jmb.chainNames);
1108 this.setTitle(jmb.getViewerTitle(true));
1109 if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
1111 viewerActionMenu.setVisible(true);
1113 if (!jmb.isLoadingFromArchive())
1115 seqColour_actionPerformed(null);
1119 protected void buildChimeraActionMenu()
1121 if (_alignwith == null)
1123 _alignwith = new Vector<AlignmentPanel>();
1125 if (_alignwith.size() == 0 && ap != null)
1130 for (Component c : viewerActionMenu.getMenuComponents())
1132 if (c != alignStructs)
1134 viewerActionMenu.remove((JMenuItem) c);
1143 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1147 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1149 alignStructs_withAllAlignPanels();
1152 private void alignStructs_withAllAlignPanels()
1159 if (_alignwith.size() == 0)
1166 AlignmentI[] als = new Alignment[_alignwith.size()];
1167 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1168 int[] alm = new int[_alignwith.size()];
1171 for (AlignmentPanel ap : _alignwith)
1173 als[a] = ap.av.getAlignment();
1175 alc[a++] = ap.av.getColumnSelection();
1177 jmb.superposeStructures(als, alm, alc);
1178 } catch (Exception e)
1180 StringBuffer sp = new StringBuffer();
1181 for (AlignmentPanel ap : _alignwith)
1183 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1185 Cache.log.info("Couldn't align structures with the " + sp.toString()
1186 + "associated alignment panels.", e);
1192 public void setJalviewColourScheme(ColourSchemeI ucs)
1194 jmb.setJalviewColourScheme(ucs);
1201 * @return first alignment panel displaying given alignment, or the default
1204 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1206 for (AlignmentPanel ap : getAllAlignmentPanels())
1208 if (ap.av.getAlignment() == alignment)
1219 * @return true if this Chimera instance is linked with the given alignPanel
1221 public boolean isLinkedWith(AlignmentPanel ap2)
1223 return _aps.contains(ap2.av.getSequenceSetId());
1226 public boolean isUsedforaligment(AlignmentPanel ap2)
1229 return (_alignwith != null) && _alignwith.contains(ap2);
1232 public boolean isUsedforcolourby(AlignmentPanel ap2)
1234 return (_colourwith != null) && _colourwith.contains(ap2);
1239 * @return TRUE if the view is NOT being coloured by sequence associations.
1241 public boolean isColouredByChimera()
1243 return !jmb.isColourBySequence();
1246 public SequenceStructureBinding getBinding()