2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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.bin.Cache;
24 import jalview.datamodel.Alignment;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.ColumnSelection;
27 import jalview.datamodel.PDBEntry;
28 import jalview.datamodel.SequenceI;
29 import jalview.gui.StructureViewer.ViewerType;
30 import jalview.io.JalviewFileChooser;
31 import jalview.io.JalviewFileView;
32 import jalview.schemes.BuriedColourScheme;
33 import jalview.schemes.ColourSchemeI;
34 import jalview.schemes.HelixColourScheme;
35 import jalview.schemes.HydrophobicColourScheme;
36 import jalview.schemes.PurinePyrimidineColourScheme;
37 import jalview.schemes.StrandColourScheme;
38 import jalview.schemes.TaylorColourScheme;
39 import jalview.schemes.TurnColourScheme;
40 import jalview.schemes.ZappoColourScheme;
41 import jalview.structures.models.AAStructureBindingModel;
42 import jalview.util.MessageManager;
43 import jalview.util.Platform;
44 import jalview.ws.dbsources.Pdb;
46 import java.awt.BorderLayout;
47 import java.awt.Color;
48 import java.awt.Dimension;
50 import java.awt.Graphics;
51 import java.awt.Rectangle;
52 import java.awt.event.ActionEvent;
53 import java.awt.event.ItemEvent;
54 import java.awt.event.ItemListener;
55 import java.io.BufferedReader;
57 import java.io.FileOutputStream;
58 import java.io.FileReader;
59 import java.io.IOException;
60 import java.io.PrintWriter;
61 import java.util.ArrayList;
62 import java.util.List;
63 import java.util.Vector;
65 import javax.swing.JCheckBoxMenuItem;
66 import javax.swing.JColorChooser;
67 import javax.swing.JInternalFrame;
68 import javax.swing.JMenu;
69 import javax.swing.JOptionPane;
70 import javax.swing.JPanel;
71 import javax.swing.JSplitPane;
72 import javax.swing.SwingUtilities;
73 import javax.swing.event.InternalFrameAdapter;
74 import javax.swing.event.InternalFrameEvent;
75 import javax.swing.event.MenuEvent;
76 import javax.swing.event.MenuListener;
78 public class AppJmol extends StructureViewerBase
80 // ms to wait for Jmol to load files
81 private static final int JMOL_LOAD_TIMEOUT = 20000;
83 private static final String SPACE = " ";
85 private static final String BACKSLASH = "\"";
93 RenderPanel renderPanel;
95 ViewSelectionMenu seqColourBy;
104 * - add the alignment panel to the list used for colouring these
107 * - add the alignment panel to the list used for aligning these
109 * @param leaveColouringToJmol
110 * - do not update the colours from any other source. Jmol is
116 public AppJmol(String[] files, String[] ids, SequenceI[][] seqs,
117 AlignmentPanel ap, boolean usetoColour, boolean useToAlign,
118 boolean leaveColouringToJmol, String loadStatus,
119 Rectangle bounds, String viewid)
121 PDBEntry[] pdbentrys = new PDBEntry[files.length];
122 for (int i = 0; i < pdbentrys.length; i++)
124 // PDBEntry pdbentry = new PDBEntry(files[i], ids[i]);
125 PDBEntry pdbentry = new PDBEntry(ids[i], null, PDBEntry.Type.PDB,
127 pdbentrys[i] = pdbentry;
129 // / TODO: check if protocol is needed to be set, and if chains are
131 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
132 pdbentrys, seqs, null);
134 jmb.setLoadingFromArchive(true);
135 addAlignmentPanel(ap);
138 useAlignmentPanelForSuperposition(ap);
140 if (leaveColouringToJmol || !usetoColour)
142 jmb.setColourBySequence(false);
143 seqColour.setSelected(false);
144 viewerColour.setSelected(true);
146 else if (usetoColour)
148 useAlignmentPanelForColourbyseq(ap);
149 jmb.setColourBySequence(true);
150 seqColour.setSelected(true);
151 viewerColour.setSelected(false);
153 this.setBounds(bounds);
156 // jalview.gui.Desktop.addInternalFrame(this, "Loading File",
157 // bounds.width,bounds.height);
159 this.addInternalFrameListener(new InternalFrameAdapter()
162 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
167 initJmol(loadStatus); // pdbentry, seq, JBPCHECK!
171 private void initMenus()
173 seqColour.setSelected(jmb.isColourBySequence());
174 viewerColour.setSelected(!jmb.isColourBySequence());
175 if (_colourwith == null)
177 _colourwith = new Vector<AlignmentPanel>();
179 if (_alignwith == null)
181 _alignwith = new Vector<AlignmentPanel>();
184 seqColourBy = new ViewSelectionMenu(
185 MessageManager.getString("label.colour_by"), this, _colourwith,
190 public void itemStateChanged(ItemEvent e)
192 if (!seqColour.isSelected())
198 // update the jmol display now.
199 seqColour_actionPerformed(null);
203 viewMenu.add(seqColourBy);
204 final ItemListener handler;
205 JMenu alpanels = new ViewSelectionMenu(
206 MessageManager.getString("label.superpose_with"), this,
207 _alignwith, handler = new ItemListener()
211 public void itemStateChanged(ItemEvent e)
213 alignStructs.setEnabled(_alignwith.size() > 0);
214 alignStructs.setToolTipText(MessageManager
216 "label.align_structures_using_linked_alignment_views",
217 new String[] { new Integer(_alignwith
218 .size()).toString() }));
221 handler.itemStateChanged(null);
222 viewerActionMenu.add(alpanels);
223 viewerActionMenu.addMenuListener(new MenuListener()
227 public void menuSelected(MenuEvent e)
229 handler.itemStateChanged(null);
233 public void menuDeselected(MenuEvent e)
235 // TODO Auto-generated method stub
240 public void menuCanceled(MenuEvent e)
242 // TODO Auto-generated method stub
248 IProgressIndicator progressBar = null;
251 * add a single PDB structure to a new or existing Jmol view
258 public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
259 final AlignmentPanel ap)
261 progressBar = ap.alignFrame;
262 String pdbId = pdbentry.getId();
265 * If the PDB file is already loaded, the user may just choose to add to an
266 * existing viewer (or cancel)
268 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
274 * Check if there are other Jmol views involving this alignment and prompt
275 * user about adding this molecule to one of them
277 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
283 * If the options above are declined or do not apply, open a new viewer
285 openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
289 * Answers true if this viewer already involves the given PDB ID
292 protected boolean hasPdbId(String pdbId)
294 return jmb.hasPdbId(pdbId);
297 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
300 progressBar = ap.alignFrame;
301 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
302 pdbentrys, seqs, null);
303 addAlignmentPanel(ap);
304 useAlignmentPanelForColourbyseq(ap);
305 if (pdbentrys.length > 1)
307 alignAddedStructures = true;
308 useAlignmentPanelForSuperposition(ap);
310 jmb.setColourBySequence(true);
311 setSize(400, 400); // probably should be a configurable/dynamic default here
313 addingStructures = false;
314 worker = new Thread(this);
317 this.addInternalFrameListener(new InternalFrameAdapter()
320 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
329 * create a new Jmol containing several structures superimposed using the
336 public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
338 openNewJmol(ap, pe, seqs);
342 * Returns a list of any Jmol viewers. The list is restricted to those linked
343 * to the given alignment panel if it is not null.
346 protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
348 List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
349 JInternalFrame[] frames = Desktop.instance.getAllFrames();
351 for (JInternalFrame frame : frames)
353 if (frame instanceof AppJmol)
356 || ((StructureViewerBase) frame).isLinkedWith(apanel))
358 result.add((StructureViewerBase) frame);
365 void initJmol(String command)
367 jmb.setFinishedInit(false);
368 renderPanel = new RenderPanel();
369 // TODO: consider waiting until the structure/view is fully loaded before
371 this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
372 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
373 getBounds().width, getBounds().height);
374 if (scriptWindow == null)
376 BorderLayout bl = new BorderLayout();
379 scriptWindow = new JPanel(bl);
380 scriptWindow.setVisible(false);
383 jmb.allocateViewer(renderPanel, true, "", null, null, "",
385 // jmb.newJmolPopup("Jmol");
390 jmb.evalStateCommand(command);
391 jmb.evalStateCommand("set hoverDelay=0.1");
392 jmb.setFinishedInit(true);
397 boolean allChainsSelected = false;
400 void showSelectedChains()
402 Vector<String> toshow = new Vector<String>();
403 for (int i = 0; i < chainMenu.getItemCount(); i++)
405 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
407 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
408 if (item.isSelected())
410 toshow.addElement(item.getText());
414 jmb.centerViewer(toshow);
418 public void closeViewer(boolean closeExternalViewer)
420 // Jmol does not use an external viewer
425 setAlignmentPanel(null);
429 // TODO: check for memory leaks where instance isn't finalised because jmb
430 // holds a reference to the window
440 List<String> files = fetchPdbFiles();
441 if (files.size() > 0)
443 showFilesInViewer(files);
453 * Either adds the given files to a structure viewer or opens a new viewer to
457 * list of absolute paths to structure files
459 void showFilesInViewer(List<String> files)
461 long lastnotify = jmb.getLoadNotifiesHandled();
462 StringBuilder fileList = new StringBuilder();
463 for (String s : files)
465 fileList.append(SPACE).append(BACKSLASH)
466 .append(Platform.escapeString(s)).append(BACKSLASH);
468 String filesString = fileList.toString();
470 if (!addingStructures)
474 initJmol("load FILES " + filesString);
475 } catch (OutOfMemoryError oomerror)
477 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
478 Cache.log.debug("File locations are " + filesString);
479 } catch (Exception ex)
481 Cache.log.error("Couldn't open Jmol viewer!", ex);
486 StringBuilder cmd = new StringBuilder();
487 cmd.append("loadingJalviewdata=true\nload APPEND ");
488 cmd.append(filesString);
489 cmd.append("\nloadingJalviewdata=null");
490 final String command = cmd.toString();
491 lastnotify = jmb.getLoadNotifiesHandled();
495 jmb.evalStateCommand(command);
496 } catch (OutOfMemoryError oomerror)
498 new OOMWarning("When trying to add structures to the Jmol viewer!",
500 Cache.log.debug("File locations are " + filesString);
501 } catch (Exception ex)
503 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
507 // need to wait around until script has finished
508 int waitMax = JMOL_LOAD_TIMEOUT;
511 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
512 : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
513 .getPdbFile().length == files.size()))
517 Cache.log.debug("Waiting around for jmb notify.");
518 Thread.sleep(waitFor);
519 waitTotal += waitFor;
520 } catch (Exception e)
523 if (waitTotal > waitMax)
526 .println("Timed out waiting for Jmol to load files after "
528 // System.err.println("finished: " + jmb.isFinishedInit()
529 // + "; loaded: " + Arrays.toString(jmb.getPdbFile())
530 // + "; files: " + files.toString());
536 // refresh the sequence colours for the new structure(s)
537 for (AlignmentPanel ap : _colourwith)
539 jmb.updateColours(ap);
541 // do superposition if asked to
542 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
544 alignAddedStructures();
546 addingStructures = false;
550 * Queues a thread to align structures with Jalview alignments
552 void alignAddedStructures()
554 javax.swing.SwingUtilities.invokeLater(new Runnable()
559 if (jmb.viewer.isScriptExecuting())
561 SwingUtilities.invokeLater(this);
565 } catch (InterruptedException q)
572 alignStructs_withAllAlignPanels();
576 alignAddedStructures = false;
580 * Retrieves and saves as file any modelled PDB entries for which we do not
581 * already have a file saved. Returns a list of absolute paths to structure
582 * files which were either retrieved, or already stored but not modelled in
583 * the structure viewer (i.e. files to add to the viewer display).
587 List<String> fetchPdbFiles()
589 // todo - record which pdbids were successfully imported.
590 StringBuilder errormsgs = new StringBuilder();
592 List<String> files = new ArrayList<String>();
596 String[] filesInViewer = jmb.getPdbFile();
597 // TODO: replace with reference fetching/transfer code (validate PDBentry
599 Pdb pdbclient = new Pdb();
600 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
602 String file = jmb.getPdbEntry(pi).getFile();
605 // retrieve the pdb and store it locally
606 AlignmentI pdbseq = null;
607 pdbid = jmb.getPdbEntry(pi).getId();
608 long hdl = pdbid.hashCode() - System.currentTimeMillis();
609 if (progressBar != null)
611 progressBar.setProgressBar(MessageManager.formatMessage(
612 "status.fetching_pdb", new String[] { pdbid }), hdl);
616 pdbseq = pdbclient.getSequenceRecords(pdbid);
617 } catch (OutOfMemoryError oomerror)
619 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
620 } catch (Exception ex)
622 ex.printStackTrace();
623 errormsgs.append("'").append(pdbid).append("'");
626 if (progressBar != null)
628 progressBar.setProgressBar(
629 MessageManager.getString("label.state_completed"),
635 // just transfer the file name from the first sequence's first
637 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
638 .elementAt(0).getFile()).getAbsolutePath();
639 jmb.getPdbEntry(pi).setFile(file);
644 errormsgs.append("'").append(pdbid).append("' ");
649 if (filesInViewer != null && filesInViewer.length > 0)
651 addingStructures = true; // already files loaded.
652 for (int c = 0; c < filesInViewer.length; c++)
654 if (filesInViewer[c].equals(file))
667 } catch (OutOfMemoryError oomerror)
669 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
670 } catch (Exception ex)
672 ex.printStackTrace();
673 errormsgs.append("When retrieving pdbfiles : current was: '")
674 .append(pdbid).append("'");
676 if (errormsgs.length() > 0)
678 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
679 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
680 new String[] { errormsgs.toString() }),
681 MessageManager.getString("label.couldnt_load_file"),
682 JOptionPane.ERROR_MESSAGE);
688 public void pdbFile_actionPerformed(ActionEvent actionEvent)
690 JalviewFileChooser chooser = new JalviewFileChooser(
691 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
693 chooser.setFileView(new JalviewFileView());
694 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
695 chooser.setToolTipText(MessageManager.getString("action.save"));
697 int value = chooser.showSaveDialog(this);
699 if (value == JalviewFileChooser.APPROVE_OPTION)
701 BufferedReader in = null;
704 // TODO: cope with multiple PDB files in view
705 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
706 File outFile = chooser.getSelectedFile();
708 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
710 while ((data = in.readLine()) != null)
712 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
718 } catch (Exception ex)
720 ex.printStackTrace();
728 } catch (IOException e)
738 public void viewMapping_actionPerformed(ActionEvent actionEvent)
740 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
743 cap.appendText(jmb.printMappings());
744 } catch (OutOfMemoryError e)
747 "composing sequence-structure alignments for display in text box.",
752 jalview.gui.Desktop.addInternalFrame(cap,
753 MessageManager.getString("label.pdb_sequence_mapping"), 550,
758 public void eps_actionPerformed(ActionEvent e)
760 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
764 public void png_actionPerformed(ActionEvent e)
766 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
769 void makePDBImage(jalview.util.ImageMaker.TYPE type)
771 int width = getWidth();
772 int height = getHeight();
774 jalview.util.ImageMaker im;
776 if (type == jalview.util.ImageMaker.TYPE.PNG)
778 im = new jalview.util.ImageMaker(this,
779 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
780 width, height, null, null, null, 0, false);
782 else if (type == jalview.util.ImageMaker.TYPE.EPS)
784 im = new jalview.util.ImageMaker(this,
785 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
786 width, height, null, this.getTitle(), null, 0, false);
791 im = new jalview.util.ImageMaker(this,
792 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
793 width, height, null, this.getTitle(), null, 0, false);
796 if (im.getGraphics() != null)
798 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
804 public void viewerColour_actionPerformed(ActionEvent actionEvent)
806 if (viewerColour.isSelected())
808 // disable automatic sequence colouring.
809 jmb.setColourBySequence(false);
814 public void seqColour_actionPerformed(ActionEvent actionEvent)
816 jmb.setColourBySequence(seqColour.isSelected());
817 if (_colourwith == null)
819 _colourwith = new Vector<AlignmentPanel>();
821 if (jmb.isColourBySequence())
823 if (!jmb.isLoadingFromArchive())
825 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
827 // Make the currently displayed alignment panel the associated view
828 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
831 // Set the colour using the current view for the associated alignframe
832 for (AlignmentPanel ap : _colourwith)
834 jmb.colourBySequence(ap);
840 public void chainColour_actionPerformed(ActionEvent actionEvent)
842 chainColour.setSelected(true);
847 public void chargeColour_actionPerformed(ActionEvent actionEvent)
849 chargeColour.setSelected(true);
850 jmb.colourByCharge();
854 public void zappoColour_actionPerformed(ActionEvent actionEvent)
856 zappoColour.setSelected(true);
857 jmb.setJalviewColourScheme(new ZappoColourScheme());
861 public void taylorColour_actionPerformed(ActionEvent actionEvent)
863 taylorColour.setSelected(true);
864 jmb.setJalviewColourScheme(new TaylorColourScheme());
868 public void hydroColour_actionPerformed(ActionEvent actionEvent)
870 hydroColour.setSelected(true);
871 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
875 public void helixColour_actionPerformed(ActionEvent actionEvent)
877 helixColour.setSelected(true);
878 jmb.setJalviewColourScheme(new HelixColourScheme());
882 public void strandColour_actionPerformed(ActionEvent actionEvent)
884 strandColour.setSelected(true);
885 jmb.setJalviewColourScheme(new StrandColourScheme());
889 public void turnColour_actionPerformed(ActionEvent actionEvent)
891 turnColour.setSelected(true);
892 jmb.setJalviewColourScheme(new TurnColourScheme());
896 public void buriedColour_actionPerformed(ActionEvent actionEvent)
898 buriedColour.setSelected(true);
899 jmb.setJalviewColourScheme(new BuriedColourScheme());
903 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
905 setJalviewColourScheme(new PurinePyrimidineColourScheme());
909 public void userColour_actionPerformed(ActionEvent actionEvent)
911 userColour.setSelected(true);
912 new UserDefinedColours(this, null);
916 public void backGround_actionPerformed(ActionEvent actionEvent)
918 java.awt.Color col = JColorChooser
919 .showDialog(this, MessageManager
920 .getString("label.select_backgroud_colour"), null);
923 jmb.setBackgroundColour(col);
928 public void showHelp_actionPerformed(ActionEvent actionEvent)
932 jalview.util.BrowserLauncher
933 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
934 } catch (Exception ex)
939 public void showConsole(boolean showConsole)
944 if (splitPane == null)
946 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
947 splitPane.setTopComponent(renderPanel);
948 splitPane.setBottomComponent(scriptWindow);
949 this.getContentPane().add(splitPane, BorderLayout.CENTER);
950 splitPane.setDividerLocation(getHeight() - 200);
951 scriptWindow.setVisible(true);
952 scriptWindow.validate();
953 splitPane.validate();
959 if (splitPane != null)
961 splitPane.setVisible(false);
966 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
972 class RenderPanel extends JPanel
974 final Dimension currentSize = new Dimension();
977 public void paintComponent(Graphics g)
979 getSize(currentSize);
981 if (jmb != null && jmb.fileLoadingError != null)
983 g.setColor(Color.black);
984 g.fillRect(0, 0, currentSize.width, currentSize.height);
985 g.setColor(Color.white);
986 g.setFont(new Font("Verdana", Font.BOLD, 14));
987 g.drawString(MessageManager.getString("label.error_loading_file")
988 + "...", 20, currentSize.height / 2);
989 StringBuffer sb = new StringBuffer();
991 for (int e = 0; e < jmb.getPdbCount(); e++)
993 sb.append(jmb.getPdbEntry(e).getId());
994 if (e < jmb.getPdbCount() - 1)
999 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
1002 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
1003 * g.getFontMetrics().getHeight());
1007 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
1009 g.setColor(Color.black);
1010 g.fillRect(0, 0, currentSize.width, currentSize.height);
1011 g.setColor(Color.white);
1012 g.setFont(new Font("Verdana", Font.BOLD, 14));
1013 g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
1014 20, currentSize.height / 2);
1018 jmb.viewer.renderScreenImage(g, currentSize.width,
1019 currentSize.height);
1024 public void updateTitleAndMenus()
1026 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1031 setChainMenuItems(jmb.getChainNames());
1033 this.setTitle(jmb.getViewerTitle());
1034 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1036 viewerActionMenu.setVisible(true);
1038 if (!jmb.isLoadingFromArchive())
1040 seqColour_actionPerformed(null);
1048 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1052 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1054 alignStructs_withAllAlignPanels();
1057 private void alignStructs_withAllAlignPanels()
1059 if (getAlignmentPanel() == null)
1064 if (_alignwith.size() == 0)
1066 _alignwith.add(getAlignmentPanel());
1071 AlignmentI[] als = new Alignment[_alignwith.size()];
1072 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1073 int[] alm = new int[_alignwith.size()];
1076 for (AlignmentPanel ap : _alignwith)
1078 als[a] = ap.av.getAlignment();
1080 alc[a++] = ap.av.getColumnSelection();
1082 jmb.superposeStructures(als, alm, alc);
1083 } catch (Exception e)
1085 StringBuffer sp = new StringBuffer();
1086 for (AlignmentPanel ap : _alignwith)
1088 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1090 Cache.log.info("Couldn't align structures with the " + sp.toString()
1091 + "associated alignment panels.", e);
1098 public void setJalviewColourScheme(ColourSchemeI ucs)
1100 jmb.setJalviewColourScheme(ucs);
1107 * @return first alignment panel displaying given alignment, or the default
1110 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1112 for (AlignmentPanel ap : getAllAlignmentPanels())
1114 if (ap.av.getAlignment() == alignment)
1119 return getAlignmentPanel();
1123 public AAStructureBindingModel getBinding()
1129 public String getStateInfo()
1131 return jmb == null ? null : jmb.viewer.getStateInfo();
1135 public ViewerType getViewerType()
1137 return ViewerType.JMOL;
1141 protected AAStructureBindingModel getBindingModel()