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(MessageManager.getString("label.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(MessageManager.getString("label.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, false);
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++)
693 if (jmb.pdbentry[pi].getFile()==null)
695 // retrieve the pdb and store it locally
696 AlignmentI pdbseq = null;
697 pdbid = jmb.pdbentry[pi].getId();
698 long hdl = pdbid.hashCode() - System.currentTimeMillis();
699 if (progressBar != null)
701 progressBar.setProgressBar(MessageManager.formatMessage("status.fetching_pdb", new String[]{pdbid}), hdl);
705 pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.pdbentry[pi]
707 } catch (OutOfMemoryError oomerror)
709 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
710 } catch (Exception ex)
712 ex.printStackTrace();
713 errormsgs.append("'" + pdbid + "'");
715 if (progressBar != null)
717 progressBar.setProgressBar(MessageManager.getString("label.state_completed"), hdl);
721 // just transfer the file name from the first sequence's first
723 file = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
724 .elementAt(0)).getFile()).getAbsolutePath();
725 jmb.pdbentry[pi].setFile(file);
727 files.append(" \"" + Platform.escapeString(file) + "\"");
731 errormsgs.append("'" + pdbid + "' ");
736 file = new File(jmb.pdbentry[pi].getFile())
737 .getAbsoluteFile().getPath();
738 if (curfiles != null && curfiles.length > 0)
740 addingStructures = true; // already files loaded.
741 for (int c = 0; c < curfiles.length; c++)
743 if (curfiles[c].equals(file))
753 fileToLoad.add(file);
754 filePDB.add(jmb.pdbentry[pi]);
755 filePDBpos.add(Integer.valueOf(pi));
756 files.append(" \"" + Platform.escapeString(file) + "\"");
760 } catch (OutOfMemoryError oomerror)
762 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
763 } catch (Exception ex)
765 ex.printStackTrace();
766 errormsgs.append("When retrieving pdbfiles : current was: '" + pdbid
769 if (errormsgs.length() > 0)
772 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
773 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
775 { errormsgs.toString() }), MessageManager
776 .getString("label.couldnt_load_file"),
777 JOptionPane.ERROR_MESSAGE);
780 long lastnotify = jmb.getLoadNotifiesHandled();
781 if (files.length() > 0)
783 if (!addingStructures)
788 } catch (Exception ex)
790 Cache.log.error("Couldn't open Chimera viewer!", ex);
794 for (PDBEntry pe : filePDB)
797 if (pe.getFile() != null)
801 int pos=filePDBpos.get(num).intValue();
803 jmb.addSequence(pos, jmb.sequence[pos]);
804 File fl=new File(pe.getFile());
805 String protocol = AppletFormatAdapter.URL;
810 protocol = AppletFormatAdapter.FILE;
812 } catch (Exception e)
817 // Explicitly map to the filename used by Jmol ;
818 jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
820 // pdbentry[pe].getFile(), protocol);
821 } catch (OutOfMemoryError oomerror)
824 "When trying to open and map structures from Chimera!",
826 } catch (Exception ex)
828 Cache.log.error("Couldn't open " + pe.getFile()
829 + " in Chimera viewer!", ex);
832 Cache.log.debug("File locations are " + files);
837 jmb.setFinishedInit(true);
838 jmb.setLoadingFromArchive(false);
840 // refresh the sequence colours for the new structure(s)
841 for (AlignmentPanel ap : _colourwith)
843 jmb.updateColours(ap);
845 // do superposition if asked to
846 if (alignAddedStructures)
848 new Thread(new Runnable()
852 alignStructs_withAllAlignPanels();
855 alignAddedStructures = false;
857 addingStructures = false;
863 public void pdbFile_actionPerformed(ActionEvent actionEvent)
865 JalviewFileChooser chooser = new JalviewFileChooser(
866 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
868 chooser.setFileView(new JalviewFileView());
869 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
870 chooser.setToolTipText(MessageManager.getString("action.save"));
872 int value = chooser.showSaveDialog(this);
874 if (value == JalviewFileChooser.APPROVE_OPTION)
878 // TODO: cope with multiple PDB files in view
879 BufferedReader in = new BufferedReader(new FileReader(
880 jmb.getPdbFile()[0]));
881 File outFile = chooser.getSelectedFile();
883 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
885 while ((data = in.readLine()) != null)
887 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
893 } catch (Exception ex)
895 ex.printStackTrace();
900 public void viewMapping_actionPerformed(ActionEvent actionEvent)
902 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
905 for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
907 cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
908 cap.appendText("\n");
910 } catch (OutOfMemoryError e)
913 "composing sequence-structure alignments for display in text box.",
918 jalview.gui.Desktop.addInternalFrame(cap,
919 MessageManager.getString("label.pdb_sequence_mapping"), 550,
929 public void eps_actionPerformed(ActionEvent e)
931 throw new Error(MessageManager.getString("error.eps_generation_not_implemented"));
940 public void png_actionPerformed(ActionEvent e)
942 throw new Error(MessageManager.getString("error.png_generation_not_implemented"));
945 public void jmolColour_actionPerformed(ActionEvent actionEvent)
947 if (jmolColour.isSelected())
949 // disable automatic sequence colouring.
950 jmb.setColourBySequence(false);
954 public void seqColour_actionPerformed(ActionEvent actionEvent)
956 jmb.setColourBySequence(seqColour.isSelected());
957 if (_colourwith == null)
959 _colourwith = new Vector<AlignmentPanel>();
961 if (jmb.isColourBySequence())
963 if (!jmb.isLoadingFromArchive())
965 if (_colourwith.size() == 0 && ap != null)
967 // Make the currently displayed alignment panel the associated view
968 _colourwith.add(ap.alignFrame.alignPanel);
971 // Set the colour using the current view for the associated alignframe
972 for (AlignmentPanel ap : _colourwith)
974 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
979 public void chainColour_actionPerformed(ActionEvent actionEvent)
981 chainColour.setSelected(true);
985 public void chargeColour_actionPerformed(ActionEvent actionEvent)
987 chargeColour.setSelected(true);
988 jmb.colourByCharge();
991 public void zappoColour_actionPerformed(ActionEvent actionEvent)
993 zappoColour.setSelected(true);
994 jmb.setJalviewColourScheme(new ZappoColourScheme());
997 public void taylorColour_actionPerformed(ActionEvent actionEvent)
999 taylorColour.setSelected(true);
1000 jmb.setJalviewColourScheme(new TaylorColourScheme());
1003 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1005 hydroColour.setSelected(true);
1006 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1009 public void helixColour_actionPerformed(ActionEvent actionEvent)
1011 helixColour.setSelected(true);
1012 jmb.setJalviewColourScheme(new HelixColourScheme());
1015 public void strandColour_actionPerformed(ActionEvent actionEvent)
1017 strandColour.setSelected(true);
1018 jmb.setJalviewColourScheme(new StrandColourScheme());
1021 public void turnColour_actionPerformed(ActionEvent actionEvent)
1023 turnColour.setSelected(true);
1024 jmb.setJalviewColourScheme(new TurnColourScheme());
1027 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1029 buriedColour.setSelected(true);
1030 jmb.setJalviewColourScheme(new BuriedColourScheme());
1033 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1035 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1038 public void userColour_actionPerformed(ActionEvent actionEvent)
1040 userColour.setSelected(true);
1041 new UserDefinedColours(this, null);
1044 public void backGround_actionPerformed(ActionEvent actionEvent)
1046 java.awt.Color col = JColorChooser.showDialog(this,
1047 MessageManager.getString("label.select_backgroud_colour"), null);
1050 jmb.setBackgroundColour(col);
1054 public void jmolHelp_actionPerformed(ActionEvent actionEvent)
1058 jalview.util.BrowserLauncher
1059 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1060 } catch (Exception ex)
1065 String viewId = null;
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 jmolActionMenu.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 : jmolActionMenu.getMenuComponents())
1109 if (c != alignStructs)
1111 jmolActionMenu.remove((JMenuItem) c);
1114 final ItemListener handler;
1121 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1125 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1127 alignStructs_withAllAlignPanels();
1130 private void alignStructs_withAllAlignPanels()
1137 if (_alignwith.size() == 0)
1144 AlignmentI[] als = new Alignment[_alignwith.size()];
1145 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1146 int[] alm = new int[_alignwith.size()];
1149 for (AlignmentPanel ap : _alignwith)
1151 als[a] = ap.av.getAlignment();
1153 alc[a++] = ap.av.getColumnSelection();
1155 jmb.superposeStructures(als, alm, alc);
1156 } catch (Exception e)
1158 StringBuffer sp = new StringBuffer();
1159 for (AlignmentPanel ap : _alignwith)
1161 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1163 Cache.log.info("Couldn't align structures with the " + sp.toString()
1164 + "associated alignment panels.", e);
1170 public void setJalviewColourScheme(ColourSchemeI ucs)
1172 jmb.setJalviewColourScheme(ucs);
1179 * @return first alignment panel displaying given alignment, or the default
1182 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1184 for (AlignmentPanel ap : getAllAlignmentPanels())
1186 if (ap.av.getAlignment() == alignment)
1197 * @return true if this Jmol instance is linked with the given alignPanel
1199 public boolean isLinkedWith(AlignmentPanel ap2)
1201 return _aps.contains(ap2.av.getSequenceSetId());
1204 public boolean isUsedforaligment(AlignmentPanel ap2)
1207 return (_alignwith != null) && _alignwith.contains(ap2);
1210 public boolean isUsedforcolourby(AlignmentPanel ap2)
1212 return (_colourwith != null) && _colourwith.contains(ap2);
1217 * @return TRUE if the view is NOT being coloured by sequence associations.
1219 public boolean isColouredByJmol()
1221 return !jmb.isColourBySequence();
1224 public SequenceStructureBinding getBinding()