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 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
148 MessageManager.getString("label.colour_by"), this, _colourwith,
152 public void itemStateChanged(ItemEvent e)
154 if (!seqColour.isSelected())
160 // update the Chimera display now.
161 seqColour_actionPerformed(null);
165 viewMenu.add(seqColourBy);
166 final ItemListener handler;
167 JMenu alpanels = new ViewSelectionMenu(
168 MessageManager.getString("label.superpose_with"), this,
169 _alignwith, handler = new ItemListener()
172 public void itemStateChanged(ItemEvent e)
174 alignStructs.setEnabled(_alignwith.size() > 0);
175 alignStructs.setToolTipText(MessageManager
177 "label.align_structures_using_linked_alignment_views",
179 { new Integer(_alignwith.size()).toString() }));
182 handler.itemStateChanged(null);
183 viewerActionMenu.add(alpanels);
184 viewerActionMenu.addMenuListener(new MenuListener()
188 public void menuSelected(MenuEvent e)
190 handler.itemStateChanged(null);
194 public void menuDeselected(MenuEvent e)
196 // TODO Auto-generated method stub
200 public void menuCanceled(MenuEvent e)
202 // TODO Auto-generated method stub
208 * add a single PDB structure to a new or existing Chimera view
215 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
216 String[] chains, final AlignmentPanel ap)
219 progressBar = ap.alignFrame;
220 // ////////////////////////////////
221 // Is the pdb file already loaded?
222 String alreadyMapped = ap.getStructureSelectionManager()
223 .alreadyMappedToFile(pdbentry.getId());
225 if (alreadyMapped != null)
227 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
228 MessageManager.formatMessage(
229 "label.pdb_entry_is_already_displayed", new Object[]
230 { pdbentry.getId() }), MessageManager.formatMessage(
231 "label.map_sequences_to_visible_window", new Object[]
232 { pdbentry.getId() }),
233 JOptionPane.YES_NO_CANCEL_OPTION);
235 if (option == JOptionPane.CANCEL_OPTION)
239 if (option == JOptionPane.YES_OPTION)
241 // TODO : Fix multiple seq to one chain issue here.
242 ap.getStructureSelectionManager().setMapping(seq, chains,
243 alreadyMapped, AppletFormatAdapter.FILE);
244 if (ap.seqPanel.seqCanvas.fr != null)
246 ap.seqPanel.seqCanvas.fr.featuresAdded();
247 ap.paintAlignment(true);
250 // Now this ChimeraViewFrame is mapped to new sequences. We must add
251 // them to the existing array
252 JInternalFrame[] frames = Desktop.instance.getAllFrames();
254 for (JInternalFrame frame : frames)
256 if (frame instanceof ChimeraViewFrame)
258 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
259 // JBPNOTE: this looks like a binding routine, rather than a gui
261 for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
263 if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
265 topView.jmb.addSequence(pe, seq);
266 topView.addAlignmentPanel(ap);
267 // add it to the set used for colouring
268 topView.useAlignmentPanelForColourbyseq(ap);
269 topView.buildChimeraActionMenu();
270 ap.getStructureSelectionManager()
271 .sequenceColoursChanged(ap);
281 // /////////////////////////////////
282 // Check if there are other Chimera views involving this alignment
283 // and prompt user about adding this molecule to one of them
284 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
285 for (ChimeraViewFrame topView : existingViews)
287 // TODO: highlight topView in view somehow
288 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
289 MessageManager.formatMessage("label.add_pdbentry_to_view",
291 { pdbentry.getId(), topView.getTitle() }),
293 .getString("label.align_to_existing_structure_view"),
294 JOptionPane.YES_NO_CANCEL_OPTION);
295 if (option == JOptionPane.CANCEL_OPTION)
299 if (option == JOptionPane.YES_OPTION)
301 topView.useAlignmentPanelForSuperposition(ap);
302 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
306 // /////////////////////////////////
307 openNewChimera(ap, new PDBEntry[]
308 { pdbentry }, new SequenceI[][]
312 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
315 progressBar = ap.alignFrame;
316 jmb = new JalviewChimeraBindingModel(this,
317 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
318 addAlignmentPanel(ap);
319 useAlignmentPanelForColourbyseq(ap);
320 if (pdbentrys.length > 1)
322 alignAddedStructures = true;
323 useAlignmentPanelForSuperposition(ap);
325 jmb.setColourBySequence(true);
326 setSize(400, 400); // probably should be a configurable/dynamic default here
330 addingStructures = false;
331 worker = new Thread(this);
334 this.addInternalFrameListener(new InternalFrameAdapter()
336 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
345 * create a new viewer containing several structures superimposed using the
352 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
356 openNewChimera(ap, pe, seqs);
359 public AlignmentPanel[] getAllAlignmentPanels()
361 AlignmentPanel[] t, list = new AlignmentPanel[0];
362 for (String setid : _aps)
364 AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid);
367 t = new AlignmentPanel[list.length + panels.length];
368 System.arraycopy(list, 0, t, 0, list.length);
369 System.arraycopy(panels, 0, t, list.length, panels.length);
378 * set the primary alignmentPanel reference and add another alignPanel to the
379 * list of ones to use for colouring and aligning
383 public void addAlignmentPanel(AlignmentPanel nap)
389 if (!_aps.contains(nap.av.getSequenceSetId()))
391 _aps.add(nap.av.getSequenceSetId());
396 * remove any references held to the given alignment panel
400 public void removeAlignmentPanel(AlignmentPanel nap)
404 _alignwith.remove(nap);
405 _colourwith.remove(nap);
409 for (AlignmentPanel aps : getAllAlignmentPanels())
418 } catch (Exception ex)
423 buildChimeraActionMenu();
427 public void useAlignmentPanelForSuperposition(AlignmentPanel nap)
429 addAlignmentPanel(nap);
430 if (!_alignwith.contains(nap))
436 public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap)
438 if (_alignwith.contains(nap))
440 _alignwith.remove(nap);
444 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap,
445 boolean enableColourBySeq)
447 useAlignmentPanelForColourbyseq(nap);
448 jmb.setColourBySequence(enableColourBySeq);
449 seqColour.setSelected(enableColourBySeq);
450 viewerColour.setSelected(!enableColourBySeq);
453 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
455 addAlignmentPanel(nap);
456 if (!_colourwith.contains(nap))
458 _colourwith.add(nap);
462 public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap)
464 if (_colourwith.contains(nap))
466 _colourwith.remove(nap);
471 * add a new structure (with associated sequences and chains) to this viewer,
472 * retrieving it if necessary first.
479 * if true, new structure(s) will be align using associated alignment
481 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
482 final String[] chains, final boolean b,
483 final IProgressIndicator alignFrame)
485 if (pdbentry.getFile() == null)
487 if (worker != null && worker.isAlive())
489 // a retrieval is in progress, wait around and add ourselves to the
491 new Thread(new Runnable()
495 while (worker != null && worker.isAlive() && _started)
499 Thread.sleep(100 + ((int) Math.random() * 100));
501 } catch (Exception e)
506 // and call ourselves again.
507 addStructure(pdbentry, seq, chains, b, alignFrame);
513 // otherwise, start adding the structure.
514 jmb.addSequenceAndChain(new PDBEntry[]
515 { pdbentry }, new SequenceI[][]
516 { seq }, new String[][]
518 addingStructures = true;
520 alignAddedStructures = b;
521 progressBar = alignFrame; // visual indication happens on caller frame.
522 (worker = new Thread(this)).start();
526 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
528 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
529 JInternalFrame[] frames = Desktop.instance.getAllFrames();
531 for (JInternalFrame frame : frames)
533 if (frame instanceof ChimeraViewFrame)
535 if (((ChimeraViewFrame) frame).isLinkedWith(apanel))
537 result.add((ChimeraViewFrame) frame);
544 void initChimera(String command)
546 jmb.setFinishedInit(false);
547 // TODO: consider waiting until the structure/view is fully loaded before
549 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(true),
550 getBounds().width, getBounds().height);
555 jmb.evalStateCommand(command, false);
556 jmb.setFinishedInit(true);
559 void setChainMenuItems(List<String> chainNames)
561 chainMenu.removeAll();
562 if (chainNames == null)
566 JMenuItem menuItem = new JMenuItem(
567 MessageManager.getString("label.all"));
568 menuItem.addActionListener(new ActionListener()
570 public void actionPerformed(ActionEvent evt)
572 allChainsSelected = true;
573 for (int i = 0; i < chainMenu.getItemCount(); i++)
575 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
577 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
581 allChainsSelected = false;
585 chainMenu.add(menuItem);
587 for (String chainName : chainNames)
589 menuItem = new JCheckBoxMenuItem(chainName, true);
590 menuItem.addItemListener(new ItemListener()
592 public void itemStateChanged(ItemEvent evt)
594 if (!allChainsSelected)
601 chainMenu.add(menuItem);
607 List<String> toshow = new ArrayList<String>();
608 for (int i = 0; i < chainMenu.getItemCount(); i++)
610 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
612 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
613 if (item.isSelected())
615 toshow.add(item.getText());
619 jmb.centerViewer(toshow);
623 * Close down this instance of Jalview's Chimera viewer, giving the user the
624 * option to close the associated Chimera window (process). They may wish to
625 * keep it open until they have had an opportunity to save any work.
627 public void closeViewer()
629 if (jmb.isChimeraRunning())
631 String prompt = MessageManager
632 .formatMessage("label.confirm_close_chimera", new Object[]
633 { jmb.getViewerTitle(false) });
634 prompt = JvSwingUtils.wrapTooltip(true, prompt);
635 int confirm = JOptionPane.showConfirmDialog(this, prompt,
636 MessageManager.getString("label.close_viewer"),
637 JOptionPane.YES_NO_OPTION);
638 jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
644 // TODO: check for memory leaks where instance isn't finalised because jmb
645 // holds a reference to the window
650 * Open any newly added PDB structures in Chimera, having first fetched data
651 * from PDB (if not already saved).
656 // todo - record which pdbids were successfully imported.
657 StringBuilder errormsgs = new StringBuilder(128);
658 StringBuilder files = new StringBuilder(128);
659 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
660 List<Integer> filePDBpos = new ArrayList<Integer>();
661 PDBEntry thePdbEntry = null;
664 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
665 // TODO: replace with reference fetching/transfer code (validate PDBentry
667 for (int pi = 0; pi < jmb.pdbentry.length; pi++)
670 thePdbEntry = jmb.pdbentry[pi];
671 if (thePdbEntry.getFile() == null)
674 * Retrieve PDB data, save to file, attach to PDBEntry
676 file = fetchPdbFile(thePdbEntry);
679 errormsgs.append("'" + thePdbEntry.getId() + "' ");
685 * Got file already - ignore if already loaded in Chimera.
687 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
689 if (curfiles != null && curfiles.length > 0)
691 addingStructures = true; // already files loaded.
692 for (int c = 0; c < curfiles.length; c++)
694 if (curfiles[c].equals(file))
704 filePDB.add(thePdbEntry);
705 filePDBpos.add(Integer.valueOf(pi));
706 files.append(" \"" + Platform.escapeString(file) + "\"");
709 } catch (OutOfMemoryError oomerror)
711 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
713 } catch (Exception ex)
715 ex.printStackTrace();
716 errormsgs.append("When retrieving pdbfiles for '"
717 + thePdbEntry.getId() + "'");
719 if (errormsgs.length() > 0)
722 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
723 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
725 { errormsgs.toString() }), MessageManager
726 .getString("label.couldnt_load_file"),
727 JOptionPane.ERROR_MESSAGE);
730 if (files.length() > 0)
732 if (!addingStructures)
737 } catch (Exception ex)
739 Cache.log.error("Couldn't open Chimera viewer!", ex);
743 for (PDBEntry pe : filePDB)
746 if (pe.getFile() != null)
750 int pos = filePDBpos.get(num).intValue();
752 jmb.addSequence(pos, jmb.sequence[pos]);
753 File fl = new File(pe.getFile());
754 String protocol = AppletFormatAdapter.URL;
759 protocol = AppletFormatAdapter.FILE;
761 } catch (Throwable e)
764 // Explicitly map to the filename used by Chimera ;
765 // TODO: use pe.getId() instead of pe.getFile() ?
766 jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
768 } catch (OutOfMemoryError oomerror)
771 "When trying to open and map structures from Chimera!",
773 } catch (Exception ex)
775 Cache.log.error("Couldn't open " + pe.getFile()
776 + " in Chimera viewer!", ex);
779 Cache.log.debug("File locations are " + files);
783 jmb.setFinishedInit(true);
784 jmb.setLoadingFromArchive(false);
786 // refresh the sequence colours for the new structure(s)
787 for (AlignmentPanel ap : _colourwith)
789 jmb.updateColours(ap);
791 // do superposition if asked to
792 if (alignAddedStructures)
794 new Thread(new Runnable()
798 alignStructs_withAllAlignPanels();
801 alignAddedStructures = false;
803 addingStructures = false;
810 * Fetch PDB data and save to a local file. Returns the full path to the file,
811 * or null if fetch fails.
813 * @param processingEntry
817 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
819 String filePath = null;
820 Pdb pdbclient = new Pdb();
821 AlignmentI pdbseq = null;
822 String pdbid = processingEntry.getId();
823 long hdl = pdbid.hashCode() - System.currentTimeMillis();
824 if (progressBar != null)
826 progressBar.setProgressBar(MessageManager.formatMessage(
827 "status.fetching_pdb", new Object[]
832 pdbseq = pdbclient.getSequenceRecords(pdbid);
833 } catch (OutOfMemoryError oomerror)
835 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
838 if (progressBar != null)
840 progressBar.setProgressBar(
841 MessageManager.getString("label.state_completed"), hdl);
845 * If PDB data were saved and are not invalid (empty alignment), return the
848 if (pdbseq != null && pdbseq.getHeight() > 0)
850 // just use the file name from the first sequence's first PDBEntry
851 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
852 .elementAt(0)).getFile()).getAbsolutePath();
853 processingEntry.setFile(filePath);
859 public void pdbFile_actionPerformed(ActionEvent actionEvent)
861 JalviewFileChooser chooser = new JalviewFileChooser(
862 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
864 chooser.setFileView(new JalviewFileView());
865 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
866 chooser.setToolTipText(MessageManager.getString("action.save"));
868 int value = chooser.showSaveDialog(this);
870 if (value == JalviewFileChooser.APPROVE_OPTION)
872 BufferedReader in = null;
875 // TODO: cope with multiple PDB files in view
876 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
877 File outFile = chooser.getSelectedFile();
879 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
881 while ((data = in.readLine()) != null)
883 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
889 } catch (Exception ex)
891 ex.printStackTrace();
899 } catch (IOException e)
909 public void viewMapping_actionPerformed(ActionEvent actionEvent)
911 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
914 for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
916 cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
917 cap.appendText("\n");
919 } catch (OutOfMemoryError e)
922 "composing sequence-structure alignments for display in text box.",
927 jalview.gui.Desktop.addInternalFrame(cap,
928 MessageManager.getString("label.pdb_sequence_mapping"), 550,
933 public void eps_actionPerformed(ActionEvent e)
937 .getString("error.eps_generation_not_implemented"));
941 public void png_actionPerformed(ActionEvent e)
945 .getString("error.png_generation_not_implemented"));
949 public void viewerColour_actionPerformed(ActionEvent actionEvent)
951 if (viewerColour.isSelected())
953 // disable automatic sequence colouring.
954 jmb.setColourBySequence(false);
959 public void seqColour_actionPerformed(ActionEvent actionEvent)
961 jmb.setColourBySequence(seqColour.isSelected());
962 if (_colourwith == null)
964 _colourwith = new Vector<AlignmentPanel>();
966 if (jmb.isColourBySequence())
968 if (!jmb.isLoadingFromArchive())
970 if (_colourwith.size() == 0 && ap != null)
972 // Make the currently displayed alignment panel the associated view
973 _colourwith.add(ap.alignFrame.alignPanel);
976 // Set the colour using the current view for the associated alignframe
977 for (AlignmentPanel ap : _colourwith)
979 jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
985 public void chainColour_actionPerformed(ActionEvent actionEvent)
987 chainColour.setSelected(true);
992 public void chargeColour_actionPerformed(ActionEvent actionEvent)
994 chargeColour.setSelected(true);
995 jmb.colourByCharge();
999 public void zappoColour_actionPerformed(ActionEvent actionEvent)
1001 zappoColour.setSelected(true);
1002 jmb.setJalviewColourScheme(new ZappoColourScheme());
1006 public void taylorColour_actionPerformed(ActionEvent actionEvent)
1008 taylorColour.setSelected(true);
1009 jmb.setJalviewColourScheme(new TaylorColourScheme());
1013 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1015 hydroColour.setSelected(true);
1016 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1020 public void helixColour_actionPerformed(ActionEvent actionEvent)
1022 helixColour.setSelected(true);
1023 jmb.setJalviewColourScheme(new HelixColourScheme());
1027 public void strandColour_actionPerformed(ActionEvent actionEvent)
1029 strandColour.setSelected(true);
1030 jmb.setJalviewColourScheme(new StrandColourScheme());
1034 public void turnColour_actionPerformed(ActionEvent actionEvent)
1036 turnColour.setSelected(true);
1037 jmb.setJalviewColourScheme(new TurnColourScheme());
1041 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1043 buriedColour.setSelected(true);
1044 jmb.setJalviewColourScheme(new BuriedColourScheme());
1048 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1050 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1054 public void userColour_actionPerformed(ActionEvent actionEvent)
1056 userColour.setSelected(true);
1057 new UserDefinedColours(this, null);
1061 public void backGround_actionPerformed(ActionEvent actionEvent)
1063 java.awt.Color col = JColorChooser
1064 .showDialog(this, MessageManager
1065 .getString("label.select_backgroud_colour"), null);
1068 jmb.setBackgroundColour(col);
1073 public void showHelp_actionPerformed(ActionEvent actionEvent)
1077 jalview.util.BrowserLauncher
1078 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1079 } catch (Exception ex)
1084 public String getViewId()
1088 viewId = System.currentTimeMillis() + "." + this.hashCode();
1093 public void updateTitleAndMenus()
1095 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1100 setChainMenuItems(jmb.chainNames);
1102 this.setTitle(jmb.getViewerTitle(true));
1103 if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
1105 viewerActionMenu.setVisible(true);
1107 if (!jmb.isLoadingFromArchive())
1109 seqColour_actionPerformed(null);
1113 protected void buildChimeraActionMenu()
1115 if (_alignwith == null)
1117 _alignwith = new Vector<AlignmentPanel>();
1119 if (_alignwith.size() == 0 && ap != null)
1124 for (Component c : viewerActionMenu.getMenuComponents())
1126 if (c != alignStructs)
1128 viewerActionMenu.remove((JMenuItem) c);
1137 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1141 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1143 alignStructs_withAllAlignPanels();
1146 private void alignStructs_withAllAlignPanels()
1153 if (_alignwith.size() == 0)
1160 AlignmentI[] als = new Alignment[_alignwith.size()];
1161 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1162 int[] alm = new int[_alignwith.size()];
1165 for (AlignmentPanel ap : _alignwith)
1167 als[a] = ap.av.getAlignment();
1169 alc[a++] = ap.av.getColumnSelection();
1171 jmb.superposeStructures(als, alm, alc);
1172 } catch (Exception e)
1174 StringBuffer sp = new StringBuffer();
1175 for (AlignmentPanel ap : _alignwith)
1177 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1179 Cache.log.info("Couldn't align structures with the " + sp.toString()
1180 + "associated alignment panels.", e);
1186 public void setJalviewColourScheme(ColourSchemeI ucs)
1188 jmb.setJalviewColourScheme(ucs);
1195 * @return first alignment panel displaying given alignment, or the default
1198 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1200 for (AlignmentPanel ap : getAllAlignmentPanels())
1202 if (ap.av.getAlignment() == alignment)
1213 * @return true if this Chimera instance is linked with the given alignPanel
1215 public boolean isLinkedWith(AlignmentPanel ap2)
1217 return _aps.contains(ap2.av.getSequenceSetId());
1220 public boolean isUsedforaligment(AlignmentPanel ap2)
1223 return (_alignwith != null) && _alignwith.contains(ap2);
1226 public boolean isUsedforcolourby(AlignmentPanel ap2)
1228 return (_colourwith != null) && _colourwith.contains(ap2);
1233 * @return TRUE if the view is NOT being coloured by sequence associations.
1235 public boolean isColouredByChimera()
1237 return !jmb.isColourBySequence();
1240 public SequenceStructureBinding getBinding()