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(),
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);
622 public void closeViewer()
629 // TODO: check for memory leaks where instance isn't finalised because jmb
630 // holds a reference to the window
635 * Open any newly added PDB structures in Chimera, having first fetched data
636 * from PDB (if not already saved).
641 // todo - record which pdbids were successfully imported.
642 StringBuilder errormsgs = new StringBuilder(128);
643 StringBuilder files = new StringBuilder(128);
644 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
645 List<Integer> filePDBpos = new ArrayList<Integer>();
646 PDBEntry thePdbEntry = null;
649 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
650 // TODO: replace with reference fetching/transfer code (validate PDBentry
652 for (int pi = 0; pi < jmb.pdbentry.length; pi++)
655 thePdbEntry = jmb.pdbentry[pi];
656 if (thePdbEntry.getFile() == null)
659 * Retrieve PDB data, save to file, attach to PDBEntry
661 file = fetchPdbFile(thePdbEntry);
664 errormsgs.append("'" + thePdbEntry.getId() + "' ");
670 * Got file already - ignore if already loaded in Chimera.
672 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
674 if (curfiles != null && curfiles.length > 0)
676 addingStructures = true; // already files loaded.
677 for (int c = 0; c < curfiles.length; c++)
679 if (curfiles[c].equals(file))
689 filePDB.add(thePdbEntry);
690 filePDBpos.add(Integer.valueOf(pi));
691 files.append(" \"" + Platform.escapeString(file) + "\"");
694 } catch (OutOfMemoryError oomerror)
696 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
698 } catch (Exception ex)
700 ex.printStackTrace();
701 errormsgs.append("When retrieving pdbfiles : current was: '"
702 + thePdbEntry.getId() + "'");
704 if (errormsgs.length() > 0)
707 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
708 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
710 { errormsgs.toString() }), MessageManager
711 .getString("label.couldnt_load_file"),
712 JOptionPane.ERROR_MESSAGE);
715 if (files.length() > 0)
717 if (!addingStructures)
722 } catch (Exception ex)
724 Cache.log.error("Couldn't open Chimera viewer!", ex);
728 for (PDBEntry pe : filePDB)
731 if (pe.getFile() != null)
735 int pos = filePDBpos.get(num).intValue();
737 jmb.addSequence(pos, jmb.sequence[pos]);
738 File fl = new File(pe.getFile());
739 String protocol = AppletFormatAdapter.URL;
744 protocol = AppletFormatAdapter.FILE;
746 } catch (Throwable e)
749 // Explicitly map to the filename used by Chimera ;
750 // TODO: use pe.getId() instead of pe.getFile() ?
751 jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
753 } catch (OutOfMemoryError oomerror)
756 "When trying to open and map structures from Chimera!",
758 } catch (Exception ex)
760 Cache.log.error("Couldn't open " + pe.getFile()
761 + " in Chimera viewer!", ex);
764 Cache.log.debug("File locations are " + files);
768 jmb.setFinishedInit(true);
769 jmb.setLoadingFromArchive(false);
771 // refresh the sequence colours for the new structure(s)
772 for (AlignmentPanel ap : _colourwith)
774 jmb.updateColours(ap);
776 // do superposition if asked to
777 if (alignAddedStructures)
779 new Thread(new Runnable()
783 alignStructs_withAllAlignPanels();
786 alignAddedStructures = false;
788 addingStructures = false;
795 * Fetch PDB data and save to a local file. Returns the full path to the file,
796 * or null if fetch fails.
798 * @param processingEntry
802 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
804 String filePath = null;
805 Pdb pdbclient = new Pdb();
806 AlignmentI pdbseq = null;
807 String pdbid = processingEntry.getId();
808 long hdl = pdbid.hashCode() - System.currentTimeMillis();
809 if (progressBar != null)
811 progressBar.setProgressBar(MessageManager.formatMessage(
812 "status.fetching_pdb", new Object[]
817 pdbseq = pdbclient.getSequenceRecords(pdbid);
818 } catch (OutOfMemoryError oomerror)
820 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
822 if (progressBar != null)
824 progressBar.setProgressBar(
825 MessageManager.getString("label.state_completed"), hdl);
828 * If PDB data were saved and are not invalid (empty alignment), return the
831 if (pdbseq != null && pdbseq.getHeight() > 0)
833 // just use the file name from the first sequence's first PDBEntry
834 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
835 .elementAt(0)).getFile()).getAbsolutePath();
836 processingEntry.setFile(filePath);
842 public void pdbFile_actionPerformed(ActionEvent actionEvent)
844 JalviewFileChooser chooser = new JalviewFileChooser(
845 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
847 chooser.setFileView(new JalviewFileView());
848 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
849 chooser.setToolTipText(MessageManager.getString("action.save"));
851 int value = chooser.showSaveDialog(this);
853 if (value == JalviewFileChooser.APPROVE_OPTION)
855 BufferedReader in = null;
858 // TODO: cope with multiple PDB files in view
859 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
860 File outFile = chooser.getSelectedFile();
862 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
864 while ((data = in.readLine()) != null)
866 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
872 } catch (Exception ex)
874 ex.printStackTrace();
882 } catch (IOException e)
892 public void viewMapping_actionPerformed(ActionEvent actionEvent)
894 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
897 for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
899 cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
900 cap.appendText("\n");
902 } catch (OutOfMemoryError e)
905 "composing sequence-structure alignments for display in text box.",
910 jalview.gui.Desktop.addInternalFrame(cap,
911 MessageManager.getString("label.pdb_sequence_mapping"), 550,
916 public void eps_actionPerformed(ActionEvent e)
920 .getString("error.eps_generation_not_implemented"));
924 public void png_actionPerformed(ActionEvent e)
928 .getString("error.png_generation_not_implemented"));
932 public void viewerColour_actionPerformed(ActionEvent actionEvent)
934 if (viewerColour.isSelected())
936 // disable automatic sequence colouring.
937 jmb.setColourBySequence(false);
942 public void seqColour_actionPerformed(ActionEvent actionEvent)
944 jmb.setColourBySequence(seqColour.isSelected());
945 if (_colourwith == null)
947 _colourwith = new Vector<AlignmentPanel>();
949 if (jmb.isColourBySequence())
951 if (!jmb.isLoadingFromArchive())
953 if (_colourwith.size() == 0 && ap != null)
955 // Make the currently displayed alignment panel the associated view
956 _colourwith.add(ap.alignFrame.alignPanel);
959 // Set the colour using the current view for the associated alignframe
960 for (AlignmentPanel ap : _colourwith)
962 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
968 public void chainColour_actionPerformed(ActionEvent actionEvent)
970 chainColour.setSelected(true);
975 public void chargeColour_actionPerformed(ActionEvent actionEvent)
977 chargeColour.setSelected(true);
978 jmb.colourByCharge();
982 public void zappoColour_actionPerformed(ActionEvent actionEvent)
984 zappoColour.setSelected(true);
985 jmb.setJalviewColourScheme(new ZappoColourScheme());
989 public void taylorColour_actionPerformed(ActionEvent actionEvent)
991 taylorColour.setSelected(true);
992 jmb.setJalviewColourScheme(new TaylorColourScheme());
996 public void hydroColour_actionPerformed(ActionEvent actionEvent)
998 hydroColour.setSelected(true);
999 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1003 public void helixColour_actionPerformed(ActionEvent actionEvent)
1005 helixColour.setSelected(true);
1006 jmb.setJalviewColourScheme(new HelixColourScheme());
1010 public void strandColour_actionPerformed(ActionEvent actionEvent)
1012 strandColour.setSelected(true);
1013 jmb.setJalviewColourScheme(new StrandColourScheme());
1017 public void turnColour_actionPerformed(ActionEvent actionEvent)
1019 turnColour.setSelected(true);
1020 jmb.setJalviewColourScheme(new TurnColourScheme());
1024 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1026 buriedColour.setSelected(true);
1027 jmb.setJalviewColourScheme(new BuriedColourScheme());
1031 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1033 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1037 public void userColour_actionPerformed(ActionEvent actionEvent)
1039 userColour.setSelected(true);
1040 new UserDefinedColours(this, null);
1044 public void backGround_actionPerformed(ActionEvent actionEvent)
1046 java.awt.Color col = JColorChooser
1047 .showDialog(this, MessageManager
1048 .getString("label.select_backgroud_colour"), null);
1051 jmb.setBackgroundColour(col);
1056 public void showHelp_actionPerformed(ActionEvent actionEvent)
1060 jalview.util.BrowserLauncher
1061 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1062 } catch (Exception ex)
1067 public String getViewId()
1071 viewId = System.currentTimeMillis() + "." + this.hashCode();
1076 public void updateTitleAndMenus()
1078 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1083 setChainMenuItems(jmb.chainNames);
1085 this.setTitle(jmb.getViewerTitle());
1086 if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
1088 viewerActionMenu.setVisible(true);
1090 if (!jmb.isLoadingFromArchive())
1092 seqColour_actionPerformed(null);
1096 protected void buildChimeraActionMenu()
1098 if (_alignwith == null)
1100 _alignwith = new Vector<AlignmentPanel>();
1102 if (_alignwith.size() == 0 && ap != null)
1107 for (Component c : viewerActionMenu.getMenuComponents())
1109 if (c != alignStructs)
1111 viewerActionMenu.remove((JMenuItem) c);
1120 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1124 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1126 alignStructs_withAllAlignPanels();
1129 private void alignStructs_withAllAlignPanels()
1136 if (_alignwith.size() == 0)
1143 AlignmentI[] als = new Alignment[_alignwith.size()];
1144 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1145 int[] alm = new int[_alignwith.size()];
1148 for (AlignmentPanel ap : _alignwith)
1150 als[a] = ap.av.getAlignment();
1152 alc[a++] = ap.av.getColumnSelection();
1154 jmb.superposeStructures(als, alm, alc);
1155 } catch (Exception e)
1157 StringBuffer sp = new StringBuffer();
1158 for (AlignmentPanel ap : _alignwith)
1160 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1162 Cache.log.info("Couldn't align structures with the " + sp.toString()
1163 + "associated alignment panels.", e);
1169 public void setJalviewColourScheme(ColourSchemeI ucs)
1171 jmb.setJalviewColourScheme(ucs);
1178 * @return first alignment panel displaying given alignment, or the default
1181 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1183 for (AlignmentPanel ap : getAllAlignmentPanels())
1185 if (ap.av.getAlignment() == alignment)
1196 * @return true if this Chimera instance is linked with the given alignPanel
1198 public boolean isLinkedWith(AlignmentPanel ap2)
1200 return _aps.contains(ap2.av.getSequenceSetId());
1203 public boolean isUsedforaligment(AlignmentPanel ap2)
1206 return (_alignwith != null) && _alignwith.contains(ap2);
1209 public boolean isUsedforcolourby(AlignmentPanel ap2)
1211 return (_colourwith != null) && _colourwith.contains(ap2);
1216 * @return TRUE if the view is NOT being coloured by sequence associations.
1218 public boolean isColouredByChimera()
1220 return !jmb.isColourBySequence();
1223 public SequenceStructureBinding getBinding()