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 // save As not yet implemented
148 savemenu.setVisible(false);
150 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
151 MessageManager.getString("label.colour_by"), this, _colourwith,
155 public void itemStateChanged(ItemEvent e)
157 if (!seqColour.isSelected())
163 // update the Chimera display now.
164 seqColour_actionPerformed(null);
168 viewMenu.add(seqColourBy);
169 final ItemListener handler;
170 JMenu alpanels = new ViewSelectionMenu(
171 MessageManager.getString("label.superpose_with"), this,
172 _alignwith, handler = new ItemListener()
175 public void itemStateChanged(ItemEvent e)
177 alignStructs.setEnabled(_alignwith.size() > 0);
178 alignStructs.setToolTipText(MessageManager
180 "label.align_structures_using_linked_alignment_views",
182 { new Integer(_alignwith.size()).toString() }));
185 handler.itemStateChanged(null);
186 viewerActionMenu.add(alpanels);
187 viewerActionMenu.addMenuListener(new MenuListener()
191 public void menuSelected(MenuEvent e)
193 handler.itemStateChanged(null);
197 public void menuDeselected(MenuEvent e)
199 // TODO Auto-generated method stub
203 public void menuCanceled(MenuEvent e)
205 // TODO Auto-generated method stub
211 * add a single PDB structure to a new or existing Chimera view
218 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
219 String[] chains, final AlignmentPanel ap)
222 progressBar = ap.alignFrame;
223 // ////////////////////////////////
224 // Is the pdb file already loaded?
225 String alreadyMapped = ap.getStructureSelectionManager()
226 .alreadyMappedToFile(pdbentry.getId());
228 if (alreadyMapped != null)
230 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
231 MessageManager.formatMessage(
232 "label.pdb_entry_is_already_displayed", new Object[]
233 { pdbentry.getId() }), MessageManager.formatMessage(
234 "label.map_sequences_to_visible_window", new Object[]
235 { pdbentry.getId() }),
236 JOptionPane.YES_NO_CANCEL_OPTION);
238 if (option == JOptionPane.CANCEL_OPTION)
242 if (option == JOptionPane.YES_OPTION)
244 // TODO : Fix multiple seq to one chain issue here.
245 ap.getStructureSelectionManager().setMapping(seq, chains,
246 alreadyMapped, AppletFormatAdapter.FILE);
247 if (ap.getSeqPanel().seqCanvas.fr != null)
249 ap.getSeqPanel().seqCanvas.fr.featuresAdded();
250 ap.paintAlignment(true);
253 // Now this ChimeraViewFrame is mapped to new sequences. We must add
254 // them to the existing array
255 JInternalFrame[] frames = Desktop.instance.getAllFrames();
257 for (JInternalFrame frame : frames)
259 if (frame instanceof ChimeraViewFrame)
261 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
262 // JBPNOTE: this looks like a binding routine, rather than a gui
264 for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
266 if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
268 topView.jmb.addSequence(pe, seq);
269 topView.addAlignmentPanel(ap);
270 // add it to the set used for colouring
271 topView.useAlignmentPanelForColourbyseq(ap);
272 topView.buildChimeraActionMenu();
273 ap.getStructureSelectionManager()
274 .sequenceColoursChanged(ap);
284 // /////////////////////////////////
285 // Check if there are other Chimera views involving this alignment
286 // and prompt user about adding this molecule to one of them
287 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
288 for (ChimeraViewFrame topView : existingViews)
290 // TODO: highlight topView in view somehow
291 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
292 MessageManager.formatMessage("label.add_pdbentry_to_view",
294 { pdbentry.getId(), topView.getTitle() }),
296 .getString("label.align_to_existing_structure_view"),
297 JOptionPane.YES_NO_CANCEL_OPTION);
298 if (option == JOptionPane.CANCEL_OPTION)
302 if (option == JOptionPane.YES_OPTION)
304 topView.useAlignmentPanelForSuperposition(ap);
305 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
309 // /////////////////////////////////
310 openNewChimera(ap, new PDBEntry[]
311 { pdbentry }, new SequenceI[][]
315 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
318 progressBar = ap.alignFrame;
319 jmb = new JalviewChimeraBindingModel(this,
320 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
321 addAlignmentPanel(ap);
322 useAlignmentPanelForColourbyseq(ap);
323 if (pdbentrys.length > 1)
325 alignAddedStructures = true;
326 useAlignmentPanelForSuperposition(ap);
328 jmb.setColourBySequence(true);
329 setSize(400, 400); // probably should be a configurable/dynamic default here
333 addingStructures = false;
334 worker = new Thread(this);
337 this.addInternalFrameListener(new InternalFrameAdapter()
339 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
348 * create a new viewer containing several structures superimposed using the
355 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
359 openNewChimera(ap, pe, seqs);
362 public AlignmentPanel[] getAllAlignmentPanels()
364 AlignmentPanel[] t, list = new AlignmentPanel[0];
365 for (String setid : _aps)
367 AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid);
370 t = new AlignmentPanel[list.length + panels.length];
371 System.arraycopy(list, 0, t, 0, list.length);
372 System.arraycopy(panels, 0, t, list.length, panels.length);
381 * set the primary alignmentPanel reference and add another alignPanel to the
382 * list of ones to use for colouring and aligning
386 public void addAlignmentPanel(AlignmentPanel nap)
392 if (!_aps.contains(nap.av.getSequenceSetId()))
394 _aps.add(nap.av.getSequenceSetId());
399 * remove any references held to the given alignment panel
403 public void removeAlignmentPanel(AlignmentPanel nap)
407 _alignwith.remove(nap);
408 _colourwith.remove(nap);
412 for (AlignmentPanel aps : getAllAlignmentPanels())
421 } catch (Exception ex)
426 buildChimeraActionMenu();
430 public void useAlignmentPanelForSuperposition(AlignmentPanel nap)
432 addAlignmentPanel(nap);
433 if (!_alignwith.contains(nap))
439 public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap)
441 if (_alignwith.contains(nap))
443 _alignwith.remove(nap);
447 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap,
448 boolean enableColourBySeq)
450 useAlignmentPanelForColourbyseq(nap);
451 jmb.setColourBySequence(enableColourBySeq);
452 seqColour.setSelected(enableColourBySeq);
453 viewerColour.setSelected(!enableColourBySeq);
456 public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
458 addAlignmentPanel(nap);
459 if (!_colourwith.contains(nap))
461 _colourwith.add(nap);
465 public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap)
467 if (_colourwith.contains(nap))
469 _colourwith.remove(nap);
474 * add a new structure (with associated sequences and chains) to this viewer,
475 * retrieving it if necessary first.
482 * if true, new structure(s) will be align using associated alignment
484 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
485 final String[] chains, final boolean b,
486 final IProgressIndicator alignFrame)
488 if (pdbentry.getFile() == null)
490 if (worker != null && worker.isAlive())
492 // a retrieval is in progress, wait around and add ourselves to the
494 new Thread(new Runnable()
498 while (worker != null && worker.isAlive() && _started)
502 Thread.sleep(100 + ((int) Math.random() * 100));
504 } catch (Exception e)
509 // and call ourselves again.
510 addStructure(pdbentry, seq, chains, b, alignFrame);
516 // otherwise, start adding the structure.
517 jmb.addSequenceAndChain(new PDBEntry[]
518 { pdbentry }, new SequenceI[][]
519 { seq }, new String[][]
521 addingStructures = true;
523 alignAddedStructures = b;
524 progressBar = alignFrame; // visual indication happens on caller frame.
525 (worker = new Thread(this)).start();
529 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
531 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
532 JInternalFrame[] frames = Desktop.instance.getAllFrames();
534 for (JInternalFrame frame : frames)
536 if (frame instanceof ChimeraViewFrame)
538 if (((ChimeraViewFrame) frame).isLinkedWith(apanel))
540 result.add((ChimeraViewFrame) frame);
547 void initChimera(String command)
549 jmb.setFinishedInit(false);
550 // TODO: consider waiting until the structure/view is fully loaded before
552 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(true),
553 getBounds().width, getBounds().height);
558 jmb.evalStateCommand(command, false);
559 jmb.setFinishedInit(true);
562 void setChainMenuItems(List<String> chainNames)
564 chainMenu.removeAll();
565 if (chainNames == null)
569 JMenuItem menuItem = new JMenuItem(
570 MessageManager.getString("label.all"));
571 menuItem.addActionListener(new ActionListener()
573 public void actionPerformed(ActionEvent evt)
575 allChainsSelected = true;
576 for (int i = 0; i < chainMenu.getItemCount(); i++)
578 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
580 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
584 allChainsSelected = false;
588 chainMenu.add(menuItem);
590 for (String chainName : chainNames)
592 menuItem = new JCheckBoxMenuItem(chainName, true);
593 menuItem.addItemListener(new ItemListener()
595 public void itemStateChanged(ItemEvent evt)
597 if (!allChainsSelected)
604 chainMenu.add(menuItem);
610 List<String> toshow = new ArrayList<String>();
611 for (int i = 0; i < chainMenu.getItemCount(); i++)
613 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
615 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
616 if (item.isSelected())
618 toshow.add(item.getText());
622 jmb.centerViewer(toshow);
626 * Close down this instance of Jalview's Chimera viewer, giving the user the
627 * option to close the associated Chimera window (process). They may wish to
628 * keep it open until they have had an opportunity to save any work.
630 public void closeViewer()
632 if (jmb.isChimeraRunning())
634 String prompt = MessageManager
635 .formatMessage("label.confirm_close_chimera", new Object[]
636 { jmb.getViewerTitle(false) });
637 prompt = JvSwingUtils.wrapTooltip(true, prompt);
638 int confirm = JOptionPane.showConfirmDialog(this, prompt,
639 MessageManager.getString("label.close_viewer"),
640 JOptionPane.YES_NO_OPTION);
641 jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
647 // TODO: check for memory leaks where instance isn't finalised because jmb
648 // holds a reference to the window
653 * Open any newly added PDB structures in Chimera, having first fetched data
654 * from PDB (if not already saved).
659 // todo - record which pdbids were successfully imported.
660 StringBuilder errormsgs = new StringBuilder(128);
661 StringBuilder files = new StringBuilder(128);
662 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
663 List<Integer> filePDBpos = new ArrayList<Integer>();
664 PDBEntry thePdbEntry = null;
667 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
668 // TODO: replace with reference fetching/transfer code (validate PDBentry
670 for (int pi = 0; pi < jmb.pdbentry.length; pi++)
673 thePdbEntry = jmb.pdbentry[pi];
674 if (thePdbEntry.getFile() == null)
677 * Retrieve PDB data, save to file, attach to PDBEntry
679 file = fetchPdbFile(thePdbEntry);
682 errormsgs.append("'" + thePdbEntry.getId() + "' ");
688 * Got file already - ignore if already loaded in Chimera.
690 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
692 if (curfiles != null && curfiles.length > 0)
694 addingStructures = true; // already files loaded.
695 for (int c = 0; c < curfiles.length; c++)
697 if (curfiles[c].equals(file))
707 filePDB.add(thePdbEntry);
708 filePDBpos.add(Integer.valueOf(pi));
709 files.append(" \"" + Platform.escapeString(file) + "\"");
712 } catch (OutOfMemoryError oomerror)
714 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
716 } catch (Exception ex)
718 ex.printStackTrace();
719 errormsgs.append("When retrieving pdbfiles for '"
720 + thePdbEntry.getId() + "'");
722 if (errormsgs.length() > 0)
725 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
726 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
728 { errormsgs.toString() }), MessageManager
729 .getString("label.couldnt_load_file"),
730 JOptionPane.ERROR_MESSAGE);
733 if (files.length() > 0)
735 if (!addingStructures)
740 } catch (Exception ex)
742 Cache.log.error("Couldn't open Chimera viewer!", ex);
746 for (PDBEntry pe : filePDB)
749 if (pe.getFile() != null)
753 int pos = filePDBpos.get(num).intValue();
755 jmb.addSequence(pos, jmb.sequence[pos]);
756 File fl = new File(pe.getFile());
757 String protocol = AppletFormatAdapter.URL;
762 protocol = AppletFormatAdapter.FILE;
764 } catch (Throwable e)
767 // Explicitly map to the filename used by Chimera ;
768 // TODO: use pe.getId() instead of pe.getFile() ?
769 jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
771 } catch (OutOfMemoryError oomerror)
774 "When trying to open and map structures from Chimera!",
776 } catch (Exception ex)
778 Cache.log.error("Couldn't open " + pe.getFile()
779 + " in Chimera viewer!", ex);
782 Cache.log.debug("File locations are " + files);
786 jmb.setFinishedInit(true);
787 jmb.setLoadingFromArchive(false);
789 // refresh the sequence colours for the new structure(s)
790 for (AlignmentPanel ap : _colourwith)
792 jmb.updateColours(ap);
794 // do superposition if asked to
795 if (alignAddedStructures)
797 new Thread(new Runnable()
801 alignStructs_withAllAlignPanels();
804 alignAddedStructures = false;
806 addingStructures = false;
813 * Fetch PDB data and save to a local file. Returns the full path to the file,
814 * or null if fetch fails.
816 * @param processingEntry
820 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
822 String filePath = null;
823 Pdb pdbclient = new Pdb();
824 AlignmentI pdbseq = null;
825 String pdbid = processingEntry.getId();
826 long hdl = pdbid.hashCode() - System.currentTimeMillis();
827 if (progressBar != null)
829 progressBar.setProgressBar(MessageManager.formatMessage(
830 "status.fetching_pdb", new Object[]
835 pdbseq = pdbclient.getSequenceRecords(pdbid);
836 } catch (OutOfMemoryError oomerror)
838 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
841 if (progressBar != null)
848 .getString("label.state_completed"),
853 * If PDB data were saved and are not invalid (empty alignment), return the
856 if (pdbseq != null && pdbseq.getHeight() > 0)
858 // just use the file name from the first sequence's first PDBEntry
859 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
860 .elementAt(0)).getFile()).getAbsolutePath();
861 processingEntry.setFile(filePath);
867 public void pdbFile_actionPerformed(ActionEvent actionEvent)
869 JalviewFileChooser chooser = new JalviewFileChooser(
870 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
872 chooser.setFileView(new JalviewFileView());
873 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
874 chooser.setToolTipText(MessageManager.getString("action.save"));
876 int value = chooser.showSaveDialog(this);
878 if (value == JalviewFileChooser.APPROVE_OPTION)
880 BufferedReader in = null;
883 // TODO: cope with multiple PDB files in view
884 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
885 File outFile = chooser.getSelectedFile();
887 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
889 while ((data = in.readLine()) != null)
891 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
897 } catch (Exception ex)
899 ex.printStackTrace();
907 } catch (IOException e)
917 public void viewMapping_actionPerformed(ActionEvent actionEvent)
919 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
922 for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
924 cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
925 cap.appendText("\n");
927 } catch (OutOfMemoryError e)
930 "composing sequence-structure alignments for display in text box.",
935 jalview.gui.Desktop.addInternalFrame(cap,
936 MessageManager.getString("label.pdb_sequence_mapping"), 550,
941 public void eps_actionPerformed(ActionEvent e)
945 .getString("error.eps_generation_not_implemented"));
949 public void png_actionPerformed(ActionEvent e)
953 .getString("error.png_generation_not_implemented"));
957 public void viewerColour_actionPerformed(ActionEvent actionEvent)
959 if (viewerColour.isSelected())
961 // disable automatic sequence colouring.
962 jmb.setColourBySequence(false);
967 public void seqColour_actionPerformed(ActionEvent actionEvent)
969 jmb.setColourBySequence(seqColour.isSelected());
970 if (_colourwith == null)
972 _colourwith = new Vector<AlignmentPanel>();
974 if (jmb.isColourBySequence())
976 if (!jmb.isLoadingFromArchive())
978 if (_colourwith.size() == 0 && ap != null)
980 // Make the currently displayed alignment panel the associated view
981 _colourwith.add(ap.alignFrame.alignPanel);
984 // Set the colour using the current view for the associated alignframe
985 for (AlignmentPanel ap : _colourwith)
987 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
993 public void chainColour_actionPerformed(ActionEvent actionEvent)
995 chainColour.setSelected(true);
1000 public void chargeColour_actionPerformed(ActionEvent actionEvent)
1002 chargeColour.setSelected(true);
1003 jmb.colourByCharge();
1007 public void zappoColour_actionPerformed(ActionEvent actionEvent)
1009 zappoColour.setSelected(true);
1010 jmb.setJalviewColourScheme(new ZappoColourScheme());
1014 public void taylorColour_actionPerformed(ActionEvent actionEvent)
1016 taylorColour.setSelected(true);
1017 jmb.setJalviewColourScheme(new TaylorColourScheme());
1021 public void hydroColour_actionPerformed(ActionEvent actionEvent)
1023 hydroColour.setSelected(true);
1024 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
1028 public void helixColour_actionPerformed(ActionEvent actionEvent)
1030 helixColour.setSelected(true);
1031 jmb.setJalviewColourScheme(new HelixColourScheme());
1035 public void strandColour_actionPerformed(ActionEvent actionEvent)
1037 strandColour.setSelected(true);
1038 jmb.setJalviewColourScheme(new StrandColourScheme());
1042 public void turnColour_actionPerformed(ActionEvent actionEvent)
1044 turnColour.setSelected(true);
1045 jmb.setJalviewColourScheme(new TurnColourScheme());
1049 public void buriedColour_actionPerformed(ActionEvent actionEvent)
1051 buriedColour.setSelected(true);
1052 jmb.setJalviewColourScheme(new BuriedColourScheme());
1056 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
1058 setJalviewColourScheme(new PurinePyrimidineColourScheme());
1062 public void userColour_actionPerformed(ActionEvent actionEvent)
1064 userColour.setSelected(true);
1065 new UserDefinedColours(this, null);
1069 public void backGround_actionPerformed(ActionEvent actionEvent)
1071 java.awt.Color col = JColorChooser
1072 .showDialog(this, MessageManager
1073 .getString("label.select_backgroud_colour"), null);
1076 jmb.setBackgroundColour(col);
1081 public void showHelp_actionPerformed(ActionEvent actionEvent)
1085 jalview.util.BrowserLauncher
1086 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1087 } catch (Exception ex)
1092 public String getViewId()
1096 viewId = System.currentTimeMillis() + "." + this.hashCode();
1101 public void updateTitleAndMenus()
1103 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1108 setChainMenuItems(jmb.chainNames);
1110 this.setTitle(jmb.getViewerTitle(true));
1111 if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
1113 viewerActionMenu.setVisible(true);
1115 if (!jmb.isLoadingFromArchive())
1117 seqColour_actionPerformed(null);
1121 protected void buildChimeraActionMenu()
1123 if (_alignwith == null)
1125 _alignwith = new Vector<AlignmentPanel>();
1127 if (_alignwith.size() == 0 && ap != null)
1132 for (Component c : viewerActionMenu.getMenuComponents())
1134 if (c != alignStructs)
1136 viewerActionMenu.remove((JMenuItem) c);
1145 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1149 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1151 alignStructs_withAllAlignPanels();
1154 private void alignStructs_withAllAlignPanels()
1161 if (_alignwith.size() == 0)
1168 AlignmentI[] als = new Alignment[_alignwith.size()];
1169 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1170 int[] alm = new int[_alignwith.size()];
1173 for (AlignmentPanel ap : _alignwith)
1175 als[a] = ap.av.getAlignment();
1177 alc[a++] = ap.av.getColumnSelection();
1179 jmb.superposeStructures(als, alm, alc);
1180 } catch (Exception e)
1182 StringBuffer sp = new StringBuffer();
1183 for (AlignmentPanel ap : _alignwith)
1185 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1187 Cache.log.info("Couldn't align structures with the " + sp.toString()
1188 + "associated alignment panels.", e);
1194 public void setJalviewColourScheme(ColourSchemeI ucs)
1196 jmb.setJalviewColourScheme(ucs);
1203 * @return first alignment panel displaying given alignment, or the default
1206 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1208 for (AlignmentPanel ap : getAllAlignmentPanels())
1210 if (ap.av.getAlignment() == alignment)
1221 * @return true if this Chimera instance is linked with the given alignPanel
1223 public boolean isLinkedWith(AlignmentPanel ap2)
1225 return _aps.contains(ap2.av.getSequenceSetId());
1228 public boolean isUsedforaligment(AlignmentPanel ap2)
1231 return (_alignwith != null) && _alignwith.contains(ap2);
1234 public boolean isUsedforcolourby(AlignmentPanel ap2)
1236 return (_colourwith != null) && _colourwith.contains(ap2);
1241 * @return TRUE if the view is NOT being coloured by sequence associations.
1243 public boolean isColouredByChimera()
1245 return !jmb.isColourBySequence();
1248 public SequenceStructureBinding getBinding()