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;
48 import java.awt.Component;
49 import java.awt.event.ActionEvent;
50 import java.awt.event.ActionListener;
51 import java.awt.event.ItemEvent;
52 import java.awt.event.ItemListener;
53 import java.io.BufferedReader;
55 import java.io.FileOutputStream;
56 import java.io.FileReader;
57 import java.io.PrintWriter;
58 import java.util.ArrayList;
59 import java.util.Enumeration;
60 import java.util.List;
61 import java.util.Vector;
63 import javax.swing.JCheckBoxMenuItem;
64 import javax.swing.JColorChooser;
65 import javax.swing.JInternalFrame;
66 import javax.swing.JMenu;
67 import javax.swing.JMenuItem;
68 import javax.swing.JOptionPane;
69 import javax.swing.event.InternalFrameAdapter;
70 import javax.swing.event.InternalFrameEvent;
71 import javax.swing.event.MenuEvent;
72 import javax.swing.event.MenuListener;
75 * GUI elements for handlnig an external chimera display
80 public class ChimeraViewFrame extends GStructureViewer implements Runnable,
81 ViewSetProvider, JalviewStructureDisplayI
84 JalviewChimeraBindingModel jmb;
88 Vector atomsPicked = new Vector();
90 private boolean addingStructures = false;
92 ViewSelectionMenu seqColourBy;
101 * - add the alignment panel to the list used for colouring these
104 * - add the alignment panel to the list used for aligning these
106 * @param leaveColouringToJmol
107 * - do not update the colours from any other source. Jmol is
113 * public ChimeraViewFrame(String[] files, String[] ids,
114 * SequenceI[][] seqs, AlignmentPanel ap, boolean usetoColour,
115 * boolean useToAlign, boolean leaveColouringToJmol, String
116 * loadStatus, Rectangle bounds, String viewid) { PDBEntry[]
117 * pdbentrys = new PDBEntry[files.length]; for (int i = 0; i <
118 * pdbentrys.length; i++) { PDBEntry pdbentry = new PDBEntry();
119 * pdbentry.setFile(files[i]); pdbentry.setId(ids[i]); pdbentrys[i] =
120 * pdbentry; } // / TODO: check if protocol is needed to be set, and
121 * if chains are // autodiscovered. jmb = new
122 * JalviewChimeraBindingModel(this,
123 * ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
125 * jmb.setLoadingFromArchive(true); addAlignmentPanel(ap); if
126 * (useToAlign) { useAlignmentPanelForSuperposition(ap); } if
127 * (leaveColouringToJmol || !usetoColour) {
128 * jmb.setColourBySequence(false); seqColour.setSelected(false);
129 * jmolColour.setSelected(true); } if (usetoColour) {
130 * useAlignmentPanelForColourbyseq(ap);
131 * jmb.setColourBySequence(true); seqColour.setSelected(true);
132 * jmolColour.setSelected(false); } this.setBounds(bounds);
133 * initMenus(); viewId = viewid; //
134 * jalview.gui.Desktop.addInternalFrame(this, "Loading File", //
135 * bounds.width,bounds.height);
137 * this.addInternalFrameListener(new InternalFrameAdapter() { public
138 * void internalFrameClosing(InternalFrameEvent internalFrameEvent) {
139 * closeViewer(); } }); initJmol(loadStatus); // pdbentry, seq,
144 private void initMenus()
146 seqColour.setSelected(jmb.isColourBySequence());
147 jmolColour.setSelected(!jmb.isColourBySequence());
148 if (_colourwith == null)
150 _colourwith = new Vector<AlignmentPanel>();
152 if (_alignwith == null)
154 _alignwith = new Vector<AlignmentPanel>();
157 seqColourBy = new ViewSelectionMenu("Colour by ..", this, _colourwith,
162 public void itemStateChanged(ItemEvent e)
164 if (!seqColour.isSelected())
170 // update the jmol display now.
171 seqColour_actionPerformed(null);
175 viewMenu.add(seqColourBy);
176 final ItemListener handler;
177 JMenu alpanels = new ViewSelectionMenu("Superpose with ..", this,
178 _alignwith, handler = new ItemListener()
182 public void itemStateChanged(ItemEvent e)
184 alignStructs.setEnabled(_alignwith.size() > 0);
185 alignStructs.setToolTipText(MessageManager
187 "label.align_structures_using_linked_alignment_views",
189 { new Integer(_alignwith.size()).toString() }));
192 handler.itemStateChanged(null);
193 jmolActionMenu.add(alpanels);
194 jmolActionMenu.addMenuListener(new MenuListener()
198 public void menuSelected(MenuEvent e)
200 handler.itemStateChanged(null);
204 public void menuDeselected(MenuEvent e)
206 // TODO Auto-generated method stub
211 public void menuCanceled(MenuEvent e)
213 // TODO Auto-generated method stub
219 IProgressIndicator progressBar = null;
222 * add a single PDB structure to a new or existing Jmol view
229 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
230 String[] chains, final AlignmentPanel ap)
232 progressBar = ap.alignFrame;
233 // ////////////////////////////////
234 // Is the pdb file already loaded?
235 String alreadyMapped = ap.getStructureSelectionManager()
236 .alreadyMappedToFile(pdbentry.getId());
238 if (alreadyMapped != null)
240 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
241 MessageManager.formatMessage(
242 "label.pdb_entry_is_already_displayed", new String[]
243 { pdbentry.getId() }), MessageManager.formatMessage(
244 "label.map_sequences_to_visible_window", new String[]
245 { pdbentry.getId() }), JOptionPane.YES_NO_OPTION);
247 if (option == JOptionPane.YES_OPTION)
249 // TODO : Fix multiple seq to one chain issue here.
250 ap.getStructureSelectionManager().setMapping(seq, chains,
251 alreadyMapped, AppletFormatAdapter.FILE);
252 if (ap.seqPanel.seqCanvas.fr != null)
254 ap.seqPanel.seqCanvas.fr.featuresAdded();
255 ap.paintAlignment(true);
258 // Now this AppJmol is mapped to new sequences. We must add them to
259 // the exisiting array
260 JInternalFrame[] frames = Desktop.instance.getAllFrames();
262 for (int i = 0; i < frames.length; i++)
264 if (frames[i] instanceof ChimeraViewFrame)
266 final ChimeraViewFrame topJmol = ((ChimeraViewFrame) frames[i]);
267 // JBPNOTE: this looks like a binding routine, rather than a gui
269 for (int pe = 0; pe < topJmol.jmb.pdbentry.length; pe++)
271 if (topJmol.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
273 topJmol.jmb.addSequence(pe, seq);
274 topJmol.addAlignmentPanel(ap);
275 // add it to the set used for colouring
276 topJmol.useAlignmentPanelForColourbyseq(ap);
277 topJmol.buildChimeraActionMenu();
278 ap.getStructureSelectionManager()
279 .sequenceColoursChanged(ap);
289 // /////////////////////////////////
290 // Check if there are other Jmol views involving this alignment
291 // and prompt user about adding this molecule to one of them
292 Vector existingViews = getJmolsFor(ap);
293 if (existingViews.size() > 0)
295 Enumeration jm = existingViews.elements();
296 while (jm.hasMoreElements())
298 ChimeraViewFrame topJmol = (ChimeraViewFrame) jm.nextElement();
299 // TODO: highlight topJmol in view somehow
300 int option = JOptionPane
301 .showInternalConfirmDialog(
303 MessageManager.formatMessage(
304 "label.add_pdbentry_to_view", new String[]
305 { pdbentry.getId(), topJmol.getTitle() }),
307 .getString("label.align_to_existing_structure_view"),
308 JOptionPane.YES_NO_OPTION);
309 if (option == JOptionPane.YES_OPTION)
311 topJmol.useAlignmentPanelForSuperposition(ap);
312 topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
317 // /////////////////////////////////
318 openNewJmol(ap, new PDBEntry[]
319 { pdbentry }, new SequenceI[][]
323 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
326 progressBar = ap.alignFrame;
327 jmb = new JalviewChimeraBindingModel(this,
328 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
329 addAlignmentPanel(ap);
330 useAlignmentPanelForColourbyseq(ap);
331 if (pdbentrys.length > 1)
333 alignAddedStructures = true;
334 useAlignmentPanelForSuperposition(ap);
336 jmb.setColourBySequence(true);
337 setSize(400, 400); // probably should be a configurable/dynamic default here
341 addingStructures = false;
342 worker = new Thread(this);
345 this.addInternalFrameListener(new InternalFrameAdapter()
347 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
356 * create a new Jmol containing several structures superimposed using the
363 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
366 openNewJmol(ap, pe, seqs);
370 * list of sequenceSet ids associated with the view
372 ArrayList<String> _aps = new ArrayList();
374 public AlignmentPanel[] getAllAlignmentPanels()
376 AlignmentPanel[] t, list = new AlignmentPanel[0];
377 for (String setid : _aps)
379 AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid);
382 t = new AlignmentPanel[list.length + panels.length];
383 System.arraycopy(list, 0, t, 0, list.length);
384 System.arraycopy(panels, 0, t, list.length, panels.length);
393 * list of alignment panels to use for superposition
395 Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
398 * list of alignment panels that are used for colouring structures by aligned
401 Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
404 * set the primary alignmentPanel reference and add another alignPanel to the
405 * list of ones to use for colouring and aligning
409 public void addAlignmentPanel(AlignmentPanel nap)
415 if (!_aps.contains(nap.av.getSequenceSetId()))
417 _aps.add(nap.av.getSequenceSetId());
422 * remove any references held to the given alignment panel
426 public void removeAlignmentPanel(AlignmentPanel nap)
430 _alignwith.remove(nap);
431 _colourwith.remove(nap);
435 for (AlignmentPanel aps : getAllAlignmentPanels())
444 } catch (Exception ex)
449 buildChimeraActionMenu();
453 public void useAlignmentPanelForSuperposition(AlignmentPanel nap)
455 addAlignmentPanel(nap);
456 if (!_alignwith.contains(nap))
462 public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap)
464 if (_alignwith.contains(nap))
466 _alignwith.remove(nap);
470 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap,
471 boolean enableColourBySeq)
473 useAlignmentPanelForColourbyseq(nap);
474 jmb.setColourBySequence(enableColourBySeq);
475 seqColour.setSelected(enableColourBySeq);
476 jmolColour.setSelected(!enableColourBySeq);
479 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
481 addAlignmentPanel(nap);
482 if (!_colourwith.contains(nap))
484 _colourwith.add(nap);
488 public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap)
490 if (_colourwith.contains(nap))
492 _colourwith.remove(nap);
497 * pdb retrieval thread.
499 private Thread worker = null;
502 * add a new structure (with associated sequences and chains) to this viewer,
503 * retrieving it if necessary first.
510 * if true, new structure(s) will be align using associated alignment
512 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
513 final String[] chains, final boolean b,
514 final IProgressIndicator alignFrame)
516 if (pdbentry.getFile() == null)
518 if (worker != null && worker.isAlive())
520 // a retrieval is in progress, wait around and add ourselves to the
522 new Thread(new Runnable()
526 while (worker != null && worker.isAlive() && _started)
530 Thread.sleep(100 + ((int) Math.random() * 100));
532 } catch (Exception e)
537 // and call ourselves again.
538 addStructure(pdbentry, seq, chains, b, alignFrame);
544 // otherwise, start adding the structure.
545 jmb.addSequenceAndChain(new PDBEntry[]
546 { pdbentry }, new SequenceI[][]
547 { seq }, new String[][]
549 addingStructures = true;
551 alignAddedStructures = b;
552 progressBar = alignFrame; // visual indication happens on caller frame.
553 (worker = new Thread(this)).start();
557 private Vector getJmolsFor(AlignmentPanel ap2)
559 Vector otherJmols = new Vector();
560 // Now this AppJmol is mapped to new sequences. We must add them to
561 // the exisiting array
562 JInternalFrame[] frames = Desktop.instance.getAllFrames();
564 for (int i = 0; i < frames.length; i++)
566 if (frames[i] instanceof ChimeraViewFrame)
568 ChimeraViewFrame topJmol = ((ChimeraViewFrame) frames[i]);
569 if (topJmol.isLinkedWith(ap2))
571 otherJmols.addElement(topJmol);
578 void initChimera(String command)
580 jmb.setFinishedInit(false);
581 // TODO: consider waiting until the structure/view is fully loaded before
583 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
584 getBounds().width, getBounds().height);
589 jmb.evalStateCommand(command);
590 jmb.setFinishedInit(true);
593 void setChainMenuItems(Vector chains)
595 chainMenu.removeAll();
600 JMenuItem menuItem = new JMenuItem(
601 MessageManager.getString("label.all"));
602 menuItem.addActionListener(new ActionListener()
604 public void actionPerformed(ActionEvent evt)
606 allChainsSelected = true;
607 for (int i = 0; i < chainMenu.getItemCount(); i++)
609 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
610 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
613 allChainsSelected = false;
617 chainMenu.add(menuItem);
619 for (int c = 0; c < chains.size(); c++)
621 menuItem = new JCheckBoxMenuItem(chains.elementAt(c).toString(), true);
622 menuItem.addItemListener(new ItemListener()
624 public void itemStateChanged(ItemEvent evt)
626 if (!allChainsSelected)
631 chainMenu.add(menuItem);
635 boolean allChainsSelected = false;
637 private boolean alignAddedStructures = false;
641 Vector toshow = new Vector();
643 int mlength, p, mnum;
644 for (int i = 0; i < chainMenu.getItemCount(); i++)
646 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
648 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
649 if (item.isSelected())
651 toshow.addElement(item.getText());
655 jmb.centerViewer(toshow);
658 public void closeViewer()
665 // TODO: check for memory leaks where instance isn't finalised because jmb
666 // holds a reference to the window
671 * state flag for PDB retrieval thread
673 private boolean _started = false;
679 // todo - record which pdbids were successfuly imported.
680 StringBuffer errormsgs = new StringBuffer(), files = new StringBuffer();
681 List<String> fileToLoad=new ArrayList<String>();
682 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
683 List<Integer> filePDBpos =new ArrayList<Integer>();
686 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
687 // TODO: replace with reference fetching/transfer code (validate PDBentry
689 jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb();
690 for (int pi = 0; pi < jmb.pdbentry.length; pi++)
692 String file = new File(jmb.pdbentry[pi].getFile())
693 .getAbsoluteFile().getPath();
696 // retrieve the pdb and store it locally
697 AlignmentI pdbseq = null;
698 pdbid = jmb.pdbentry[pi].getId();
699 long hdl = pdbid.hashCode() - System.currentTimeMillis();
700 if (progressBar != null)
702 progressBar.setProgressBar("Fetching PDB " + pdbid, hdl);
706 pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.pdbentry[pi]
708 } catch (OutOfMemoryError oomerror)
710 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
711 } catch (Exception ex)
713 ex.printStackTrace();
714 errormsgs.append("'" + pdbid + "'");
716 if (progressBar != null)
718 progressBar.setProgressBar("Finished.", hdl);
722 // just transfer the file name from the first sequence's first
724 file = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
725 .elementAt(0)).getFile()).getAbsolutePath();
726 jmb.pdbentry[pi].setFile(file);
728 files.append(" \"" + Platform.escapeString(file) + "\"");
732 errormsgs.append("'" + pdbid + "' ");
737 if (curfiles != null && curfiles.length > 0)
739 addingStructures = true; // already files loaded.
740 for (int c = 0; c < curfiles.length; c++)
742 if (curfiles[c].equals(file))
752 fileToLoad.add(file);
753 filePDB.add(jmb.pdbentry[pi]);
754 filePDBpos.add(Integer.valueOf(pi));
755 files.append(" \"" + Platform.escapeString(file) + "\"");
759 } catch (OutOfMemoryError oomerror)
761 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
762 } catch (Exception ex)
764 ex.printStackTrace();
765 errormsgs.append("When retrieving pdbfiles : current was: '" + pdbid
768 if (errormsgs.length() > 0)
771 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
772 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
774 { errormsgs.toString() }), MessageManager
775 .getString("label.couldnt_load_file"),
776 JOptionPane.ERROR_MESSAGE);
779 long lastnotify = jmb.getLoadNotifiesHandled();
780 if (files.length() > 0)
782 if (!addingStructures)
787 } catch (Exception ex)
789 Cache.log.error("Couldn't open Chimera viewer!", ex);
793 for (PDBEntry pe : filePDB)
796 if (pe.getFile() != null)
800 int pos=filePDBpos.get(num).intValue();
802 jmb.addSequence(pos, jmb.sequence[pos]);
803 File fl=new File(pe.getFile());
804 String protocol = AppletFormatAdapter.URL;
809 protocol = AppletFormatAdapter.FILE;
811 } catch (Exception e)
816 // Explicitly map to the filename used by Jmol ;
817 jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
819 // pdbentry[pe].getFile(), protocol);
820 } catch (OutOfMemoryError oomerror)
823 "When trying to open and map structures from Chimera!",
825 } catch (Exception ex)
827 Cache.log.error("Couldn't open " + pe.getFile()
828 + " in Chimera viewer!", ex);
831 Cache.log.debug("File locations are " + files);
836 jmb.setFinishedInit(true);
837 jmb.setLoadingFromArchive(false);
839 // refresh the sequence colours for the new structure(s)
840 for (AlignmentPanel ap : _colourwith)
842 jmb.updateColours(ap);
844 // do superposition if asked to
845 if (alignAddedStructures)
847 javax.swing.SwingUtilities.invokeLater(new Runnable()
851 alignStructs_withAllAlignPanels();
854 alignAddedStructures = false;
856 addingStructures = false;
862 public void pdbFile_actionPerformed(ActionEvent actionEvent)
864 JalviewFileChooser chooser = new JalviewFileChooser(
865 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
867 chooser.setFileView(new JalviewFileView());
868 chooser.setDialogTitle("Save PDB File");
869 chooser.setToolTipText(MessageManager.getString("action.save"));
871 int value = chooser.showSaveDialog(this);
873 if (value == JalviewFileChooser.APPROVE_OPTION)
877 // TODO: cope with multiple PDB files in view
878 BufferedReader in = new BufferedReader(new FileReader(
879 jmb.getPdbFile()[0]));
880 File outFile = chooser.getSelectedFile();
882 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
884 while ((data = in.readLine()) != null)
886 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
892 } catch (Exception ex)
894 ex.printStackTrace();
899 public void viewMapping_actionPerformed(ActionEvent actionEvent)
901 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
904 for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
906 cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
907 cap.appendText("\n");
909 } catch (OutOfMemoryError e)
912 "composing sequence-structure alignments for display in text box.",
917 jalview.gui.Desktop.addInternalFrame(cap,
918 MessageManager.getString("label.pdb_sequence_mapping"), 550,
928 public void eps_actionPerformed(ActionEvent e)
930 throw new Error("EPS Generation not yet implemented.");
939 public void png_actionPerformed(ActionEvent e)
941 throw new Error("PNG Generation not yet implemented.");
944 public void jmolColour_actionPerformed(ActionEvent actionEvent)
946 if (jmolColour.isSelected())
948 // disable automatic sequence colouring.
949 jmb.setColourBySequence(false);
953 public void seqColour_actionPerformed(ActionEvent actionEvent)
955 jmb.setColourBySequence(seqColour.isSelected());
956 if (_colourwith == null)
958 _colourwith = new Vector<AlignmentPanel>();
960 if (jmb.isColourBySequence())
962 if (!jmb.isLoadingFromArchive())
964 if (_colourwith.size() == 0 && ap != null)
966 // Make the currently displayed alignment panel the associated view
967 _colourwith.add(ap.alignFrame.alignPanel);
970 // Set the colour using the current view for the associated alignframe
971 for (AlignmentPanel ap : _colourwith)
973 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
978 public void chainColour_actionPerformed(ActionEvent actionEvent)
980 chainColour.setSelected(true);
984 public void chargeColour_actionPerformed(ActionEvent actionEvent)
986 chargeColour.setSelected(true);
987 jmb.colourByCharge();
990 public void zappoColour_actionPerformed(ActionEvent actionEvent)
992 zappoColour.setSelected(true);
993 jmb.setJalviewColourScheme(new ZappoColourScheme());
996 public void taylorColour_actionPerformed(ActionEvent actionEvent)
998 taylorColour.setSelected(true);
999 jmb.setJalviewColourScheme(new TaylorColourScheme());
1002 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1004 hydroColour.setSelected(true);
1005 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1008 public void helixColour_actionPerformed(ActionEvent actionEvent)
1010 helixColour.setSelected(true);
1011 jmb.setJalviewColourScheme(new HelixColourScheme());
1014 public void strandColour_actionPerformed(ActionEvent actionEvent)
1016 strandColour.setSelected(true);
1017 jmb.setJalviewColourScheme(new StrandColourScheme());
1020 public void turnColour_actionPerformed(ActionEvent actionEvent)
1022 turnColour.setSelected(true);
1023 jmb.setJalviewColourScheme(new TurnColourScheme());
1026 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1028 buriedColour.setSelected(true);
1029 jmb.setJalviewColourScheme(new BuriedColourScheme());
1032 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1034 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1037 public void userColour_actionPerformed(ActionEvent actionEvent)
1039 userColour.setSelected(true);
1040 new UserDefinedColours(this, null);
1043 public void backGround_actionPerformed(ActionEvent actionEvent)
1045 java.awt.Color col = JColorChooser.showDialog(this,
1046 "Select Background Colour", null);
1049 jmb.setBackgroundColour(col);
1053 public void jmolHelp_actionPerformed(ActionEvent actionEvent)
1057 jalview.util.BrowserLauncher
1058 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1059 } catch (Exception ex)
1064 String viewId = null;
1066 public String getViewId()
1070 viewId = System.currentTimeMillis() + "." + this.hashCode();
1075 public void updateTitleAndMenus()
1077 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1082 setChainMenuItems(jmb.chainNames);
1084 this.setTitle(jmb.getViewerTitle());
1085 if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
1087 jmolActionMenu.setVisible(true);
1089 if (!jmb.isLoadingFromArchive())
1091 seqColour_actionPerformed(null);
1095 protected void buildChimeraActionMenu()
1097 if (_alignwith == null)
1099 _alignwith = new Vector<AlignmentPanel>();
1101 if (_alignwith.size() == 0 && ap != null)
1106 for (Component c : jmolActionMenu.getMenuComponents())
1108 if (c != alignStructs)
1110 jmolActionMenu.remove((JMenuItem) c);
1113 final ItemListener handler;
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 Jmol 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 isColouredByJmol()
1220 return !jmb.isColourBySequence();
1223 public SequenceStructureBinding getBinding()