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.JPanel;
70 import javax.swing.JSplitPane;
71 import javax.swing.SwingUtilities;
72 import javax.swing.event.InternalFrameAdapter;
73 import javax.swing.event.InternalFrameEvent;
74 import javax.swing.event.MenuEvent;
75 import javax.swing.event.MenuListener;
77 public class AppJmol extends StructureViewerBase
79 // ms to wait for Jmol to load files
80 private static final int JMOL_LOAD_TIMEOUT = 20000;
82 private static final String SPACE = " ";
84 private static final String BACKSLASH = "\"";
92 RenderPanel renderPanel;
94 ViewSelectionMenu seqColourBy;
103 * - add the alignment panel to the list used for colouring these
106 * - add the alignment panel to the list used for aligning these
108 * @param leaveColouringToJmol
109 * - do not update the colours from any other source. Jmol is
115 public AppJmol(String[] files, String[] ids, SequenceI[][] seqs,
116 AlignmentPanel ap, boolean usetoColour, boolean useToAlign,
117 boolean leaveColouringToJmol, String loadStatus,
118 Rectangle bounds, String viewid)
120 PDBEntry[] pdbentrys = new PDBEntry[files.length];
121 for (int i = 0; i < pdbentrys.length; i++)
123 // PDBEntry pdbentry = new PDBEntry(files[i], ids[i]);
124 PDBEntry pdbentry = new PDBEntry(ids[i], null, PDBEntry.Type.PDB,
126 pdbentrys[i] = pdbentry;
128 // / TODO: check if protocol is needed to be set, and if chains are
130 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
131 pdbentrys, seqs, null);
133 jmb.setLoadingFromArchive(true);
134 addAlignmentPanel(ap);
137 useAlignmentPanelForSuperposition(ap);
139 if (leaveColouringToJmol || !usetoColour)
141 jmb.setColourBySequence(false);
142 seqColour.setSelected(false);
143 viewerColour.setSelected(true);
145 else if (usetoColour)
147 useAlignmentPanelForColourbyseq(ap);
148 jmb.setColourBySequence(true);
149 seqColour.setSelected(true);
150 viewerColour.setSelected(false);
152 this.setBounds(bounds);
155 // jalview.gui.Desktop.addInternalFrame(this, "Loading File",
156 // bounds.width,bounds.height);
158 this.addInternalFrameListener(new InternalFrameAdapter()
161 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
166 initJmol(loadStatus); // pdbentry, seq, JBPCHECK!ˇ
170 private void initMenus()
172 seqColour.setSelected(jmb.isColourBySequence());
173 viewerColour.setSelected(!jmb.isColourBySequence());
174 if (_colourwith == null)
176 _colourwith = new Vector<AlignmentPanel>();
178 if (_alignwith == null)
180 _alignwith = new Vector<AlignmentPanel>();
183 seqColourBy = new ViewSelectionMenu(
184 MessageManager.getString("label.colour_by"), this, _colourwith,
189 public void itemStateChanged(ItemEvent e)
191 if (!seqColour.isSelected())
197 // update the jmol display now.
198 seqColour_actionPerformed(null);
202 viewMenu.add(seqColourBy);
203 final ItemListener handler;
204 JMenu alpanels = new ViewSelectionMenu(
205 MessageManager.getString("label.superpose_with"), this,
206 _alignwith, handler = new ItemListener()
210 public void itemStateChanged(ItemEvent e)
212 alignStructs.setEnabled(_alignwith.size() > 0);
213 alignStructs.setToolTipText(MessageManager
215 "label.align_structures_using_linked_alignment_views",
216 new String[] { new Integer(_alignwith
217 .size()).toString() }));
220 handler.itemStateChanged(null);
221 viewerActionMenu.add(alpanels);
222 viewerActionMenu.addMenuListener(new MenuListener()
226 public void menuSelected(MenuEvent e)
228 handler.itemStateChanged(null);
232 public void menuDeselected(MenuEvent e)
234 // TODO Auto-generated method stub
239 public void menuCanceled(MenuEvent e)
241 // TODO Auto-generated method stub
247 IProgressIndicator progressBar = null;
250 protected IProgressIndicator getIProgressIndicator()
255 * add a single PDB structure to a new or existing Jmol view
262 public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
263 final AlignmentPanel ap)
265 progressBar = ap.alignFrame;
266 String pdbId = pdbentry.getId();
269 * If the PDB file is already loaded, the user may just choose to add to an
270 * existing viewer (or cancel)
272 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
278 * Check if there are other Jmol views involving this alignment and prompt
279 * user about adding this molecule to one of them
281 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
287 * If the options above are declined or do not apply, open a new viewer
289 openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
293 * Answers true if this viewer already involves the given PDB ID
296 protected boolean hasPdbId(String pdbId)
298 return jmb.hasPdbId(pdbId);
301 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
304 progressBar = ap.alignFrame;
305 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
306 pdbentrys, seqs, null);
307 addAlignmentPanel(ap);
308 useAlignmentPanelForColourbyseq(ap);
309 if (pdbentrys.length > 1)
311 alignAddedStructures = true;
312 useAlignmentPanelForSuperposition(ap);
314 jmb.setColourBySequence(true);
315 setSize(400, 400); // probably should be a configurable/dynamic default here
317 addingStructures = false;
318 worker = new Thread(this);
321 this.addInternalFrameListener(new InternalFrameAdapter()
324 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
333 * create a new Jmol containing several structures superimposed using the
340 public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
342 openNewJmol(ap, pe, seqs);
346 * Returns a list of any Jmol viewers. The list is restricted to those linked
347 * to the given alignment panel if it is not null.
350 protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
352 List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
353 JInternalFrame[] frames = Desktop.instance.getAllFrames();
355 for (JInternalFrame frame : frames)
357 if (frame instanceof AppJmol)
360 || ((StructureViewerBase) frame).isLinkedWith(apanel))
362 result.add((StructureViewerBase) frame);
369 void initJmol(String command)
371 jmb.setFinishedInit(false);
372 renderPanel = new RenderPanel();
373 // TODO: consider waiting until the structure/view is fully loaded before
375 this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
376 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
377 getBounds().width, getBounds().height);
378 if (scriptWindow == null)
380 BorderLayout bl = new BorderLayout();
383 scriptWindow = new JPanel(bl);
384 scriptWindow.setVisible(false);
387 jmb.allocateViewer(renderPanel, true, "", null, null, "",
389 // jmb.newJmolPopup("Jmol");
394 jmb.evalStateCommand(command);
395 jmb.evalStateCommand("set hoverDelay=0.1");
396 jmb.setFinishedInit(true);
401 boolean allChainsSelected = false;
404 void showSelectedChains()
406 Vector<String> toshow = new Vector<String>();
407 for (int i = 0; i < chainMenu.getItemCount(); i++)
409 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
411 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
412 if (item.isSelected())
414 toshow.addElement(item.getText());
418 jmb.centerViewer(toshow);
422 public void closeViewer(boolean closeExternalViewer)
424 // Jmol does not use an external viewer
429 setAlignmentPanel(null);
433 // TODO: check for memory leaks where instance isn't finalised because jmb
434 // holds a reference to the window
444 List<String> files = fetchPdbFiles();
445 if (files.size() > 0)
447 showFilesInViewer(files);
457 * Either adds the given files to a structure viewer or opens a new viewer to
461 * list of absolute paths to structure files
463 void showFilesInViewer(List<String> files)
465 long lastnotify = jmb.getLoadNotifiesHandled();
466 StringBuilder fileList = new StringBuilder();
467 for (String s : files)
469 fileList.append(SPACE).append(BACKSLASH)
470 .append(Platform.escapeString(s)).append(BACKSLASH);
472 String filesString = fileList.toString();
474 if (!addingStructures)
478 initJmol("load FILES " + filesString);
479 } catch (OutOfMemoryError oomerror)
481 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
482 Cache.log.debug("File locations are " + filesString);
483 } catch (Exception ex)
485 Cache.log.error("Couldn't open Jmol viewer!", ex);
490 StringBuilder cmd = new StringBuilder();
491 cmd.append("loadingJalviewdata=true\nload APPEND ");
492 cmd.append(filesString);
493 cmd.append("\nloadingJalviewdata=null");
494 final String command = cmd.toString();
495 lastnotify = jmb.getLoadNotifiesHandled();
499 jmb.evalStateCommand(command);
500 } catch (OutOfMemoryError oomerror)
502 new OOMWarning("When trying to add structures to the Jmol viewer!",
504 Cache.log.debug("File locations are " + filesString);
505 } catch (Exception ex)
507 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
511 // need to wait around until script has finished
512 int waitMax = JMOL_LOAD_TIMEOUT;
515 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
516 : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
517 .getPdbFile().length == files.size()))
521 Cache.log.debug("Waiting around for jmb notify.");
522 Thread.sleep(waitFor);
523 waitTotal += waitFor;
524 } catch (Exception e)
527 if (waitTotal > waitMax)
530 .println("Timed out waiting for Jmol to load files after "
532 // System.err.println("finished: " + jmb.isFinishedInit()
533 // + "; loaded: " + Arrays.toString(jmb.getPdbFile())
534 // + "; files: " + files.toString());
540 // refresh the sequence colours for the new structure(s)
541 for (AlignmentPanel ap : _colourwith)
543 jmb.updateColours(ap);
545 // do superposition if asked to
546 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
548 alignAddedStructures();
550 addingStructures = false;
554 * Queues a thread to align structures with Jalview alignments
556 void alignAddedStructures()
558 javax.swing.SwingUtilities.invokeLater(new Runnable()
563 if (jmb.viewer.isScriptExecuting())
565 SwingUtilities.invokeLater(this);
569 } catch (InterruptedException q)
576 alignStructs_withAllAlignPanels();
580 alignAddedStructures = false;
584 * Retrieves and saves as file any modelled PDB entries for which we do not
585 * already have a file saved. Returns a list of absolute paths to structure
586 * files which were either retrieved, or already stored but not modelled in
587 * the structure viewer (i.e. files to add to the viewer display).
591 List<String> fetchPdbFiles()
593 // todo - record which pdbids were successfully imported.
594 StringBuilder errormsgs = new StringBuilder();
596 List<String> files = new ArrayList<String>();
600 String[] filesInViewer = jmb.getPdbFile();
601 // TODO: replace with reference fetching/transfer code (validate PDBentry
603 Pdb pdbclient = new Pdb();
604 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
606 String file = jmb.getPdbEntry(pi).getFile();
609 // retrieve the pdb and store it locally
610 AlignmentI pdbseq = null;
611 pdbid = jmb.getPdbEntry(pi).getId();
612 long hdl = pdbid.hashCode() - System.currentTimeMillis();
613 if (progressBar != null)
615 progressBar.setProgressBar(MessageManager.formatMessage(
616 "status.fetching_pdb", new String[] { pdbid }), hdl);
620 pdbseq = pdbclient.getSequenceRecords(pdbid);
621 } catch (OutOfMemoryError oomerror)
623 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
624 } catch (Exception ex)
626 ex.printStackTrace();
627 errormsgs.append("'").append(pdbid).append("'");
630 if (progressBar != null)
632 progressBar.setProgressBar(
633 MessageManager.getString("label.state_completed"),
639 // just transfer the file name from the first sequence's first
641 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
642 .elementAt(0).getFile()).getAbsolutePath();
643 jmb.getPdbEntry(pi).setFile(file);
648 errormsgs.append("'").append(pdbid).append("' ");
653 if (filesInViewer != null && filesInViewer.length > 0)
655 addingStructures = true; // already files loaded.
656 for (int c = 0; c < filesInViewer.length; c++)
658 if (filesInViewer[c].equals(file))
671 } catch (OutOfMemoryError oomerror)
673 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
674 } catch (Exception ex)
676 ex.printStackTrace();
677 errormsgs.append("When retrieving pdbfiles : current was: '")
678 .append(pdbid).append("'");
680 if (errormsgs.length() > 0)
682 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
683 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
684 new String[] { errormsgs.toString() }),
685 MessageManager.getString("label.couldnt_load_file"),
686 JvOptionPane.ERROR_MESSAGE);
692 public void pdbFile_actionPerformed(ActionEvent actionEvent)
694 JalviewFileChooser chooser = new JalviewFileChooser(
695 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
697 chooser.setFileView(new JalviewFileView());
698 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
699 chooser.setToolTipText(MessageManager.getString("action.save"));
701 int value = chooser.showSaveDialog(this);
703 if (value == JalviewFileChooser.APPROVE_OPTION)
705 BufferedReader in = null;
708 // TODO: cope with multiple PDB files in view
709 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
710 File outFile = chooser.getSelectedFile();
712 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
714 while ((data = in.readLine()) != null)
716 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
722 } catch (Exception ex)
724 ex.printStackTrace();
732 } catch (IOException e)
742 public void viewMapping_actionPerformed(ActionEvent actionEvent)
744 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
747 cap.appendText(jmb.printMappings());
748 } catch (OutOfMemoryError e)
751 "composing sequence-structure alignments for display in text box.",
756 jalview.gui.Desktop.addInternalFrame(cap,
757 MessageManager.getString("label.pdb_sequence_mapping"), 550,
762 public void eps_actionPerformed(ActionEvent e)
764 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
768 public void png_actionPerformed(ActionEvent e)
770 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
773 void makePDBImage(jalview.util.ImageMaker.TYPE type)
775 int width = getWidth();
776 int height = getHeight();
778 jalview.util.ImageMaker im;
780 if (type == jalview.util.ImageMaker.TYPE.PNG)
782 im = new jalview.util.ImageMaker(this,
783 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
784 width, height, null, null, null, 0, false);
786 else if (type == jalview.util.ImageMaker.TYPE.EPS)
788 im = new jalview.util.ImageMaker(this,
789 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
790 width, height, null, this.getTitle(), null, 0, false);
795 im = new jalview.util.ImageMaker(this,
796 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
797 width, height, null, this.getTitle(), null, 0, false);
800 if (im.getGraphics() != null)
802 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
808 public void viewerColour_actionPerformed(ActionEvent actionEvent)
810 if (viewerColour.isSelected())
812 // disable automatic sequence colouring.
813 jmb.setColourBySequence(false);
818 public void seqColour_actionPerformed(ActionEvent actionEvent)
820 jmb.setColourBySequence(seqColour.isSelected());
821 if (_colourwith == null)
823 _colourwith = new Vector<AlignmentPanel>();
825 if (jmb.isColourBySequence())
827 if (!jmb.isLoadingFromArchive())
829 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
831 // Make the currently displayed alignment panel the associated view
832 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
835 // Set the colour using the current view for the associated alignframe
836 for (AlignmentPanel ap : _colourwith)
838 jmb.colourBySequence(ap);
844 public void chainColour_actionPerformed(ActionEvent actionEvent)
846 chainColour.setSelected(true);
851 public void chargeColour_actionPerformed(ActionEvent actionEvent)
853 chargeColour.setSelected(true);
854 jmb.colourByCharge();
858 public void zappoColour_actionPerformed(ActionEvent actionEvent)
860 zappoColour.setSelected(true);
861 jmb.setJalviewColourScheme(new ZappoColourScheme());
865 public void taylorColour_actionPerformed(ActionEvent actionEvent)
867 taylorColour.setSelected(true);
868 jmb.setJalviewColourScheme(new TaylorColourScheme());
872 public void hydroColour_actionPerformed(ActionEvent actionEvent)
874 hydroColour.setSelected(true);
875 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
879 public void helixColour_actionPerformed(ActionEvent actionEvent)
881 helixColour.setSelected(true);
882 jmb.setJalviewColourScheme(new HelixColourScheme());
886 public void strandColour_actionPerformed(ActionEvent actionEvent)
888 strandColour.setSelected(true);
889 jmb.setJalviewColourScheme(new StrandColourScheme());
893 public void turnColour_actionPerformed(ActionEvent actionEvent)
895 turnColour.setSelected(true);
896 jmb.setJalviewColourScheme(new TurnColourScheme());
900 public void buriedColour_actionPerformed(ActionEvent actionEvent)
902 buriedColour.setSelected(true);
903 jmb.setJalviewColourScheme(new BuriedColourScheme());
907 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
909 setJalviewColourScheme(new PurinePyrimidineColourScheme());
913 public void userColour_actionPerformed(ActionEvent actionEvent)
915 userColour.setSelected(true);
916 new UserDefinedColours(this, null);
920 public void backGround_actionPerformed(ActionEvent actionEvent)
922 java.awt.Color col = JColorChooser
923 .showDialog(this, MessageManager
924 .getString("label.select_backgroud_colour"), null);
927 jmb.setBackgroundColour(col);
932 public void showHelp_actionPerformed(ActionEvent actionEvent)
936 jalview.util.BrowserLauncher
937 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
938 } catch (Exception ex)
943 public void showConsole(boolean showConsole)
948 if (splitPane == null)
950 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
951 splitPane.setTopComponent(renderPanel);
952 splitPane.setBottomComponent(scriptWindow);
953 this.getContentPane().add(splitPane, BorderLayout.CENTER);
954 splitPane.setDividerLocation(getHeight() - 200);
955 scriptWindow.setVisible(true);
956 scriptWindow.validate();
957 splitPane.validate();
963 if (splitPane != null)
965 splitPane.setVisible(false);
970 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
976 class RenderPanel extends JPanel
978 final Dimension currentSize = new Dimension();
981 public void paintComponent(Graphics g)
983 getSize(currentSize);
985 if (jmb != null && jmb.fileLoadingError != null)
987 g.setColor(Color.black);
988 g.fillRect(0, 0, currentSize.width, currentSize.height);
989 g.setColor(Color.white);
990 g.setFont(new Font("Verdana", Font.BOLD, 14));
991 g.drawString(MessageManager.getString("label.error_loading_file")
992 + "...", 20, currentSize.height / 2);
993 StringBuffer sb = new StringBuffer();
995 for (int e = 0; e < jmb.getPdbCount(); e++)
997 sb.append(jmb.getPdbEntry(e).getId());
998 if (e < jmb.getPdbCount() - 1)
1003 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
1006 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
1007 * g.getFontMetrics().getHeight());
1011 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
1013 g.setColor(Color.black);
1014 g.fillRect(0, 0, currentSize.width, currentSize.height);
1015 g.setColor(Color.white);
1016 g.setFont(new Font("Verdana", Font.BOLD, 14));
1017 g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
1018 20, currentSize.height / 2);
1022 jmb.viewer.renderScreenImage(g, currentSize.width,
1023 currentSize.height);
1028 public void updateTitleAndMenus()
1030 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1035 setChainMenuItems(jmb.getChainNames());
1037 this.setTitle(jmb.getViewerTitle());
1038 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1040 viewerActionMenu.setVisible(true);
1042 if (!jmb.isLoadingFromArchive())
1044 seqColour_actionPerformed(null);
1052 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1056 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1058 alignStructs_withAllAlignPanels();
1061 private void alignStructs_withAllAlignPanels()
1063 if (getAlignmentPanel() == null)
1068 if (_alignwith.size() == 0)
1070 _alignwith.add(getAlignmentPanel());
1075 AlignmentI[] als = new Alignment[_alignwith.size()];
1076 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1077 int[] alm = new int[_alignwith.size()];
1080 for (AlignmentPanel ap : _alignwith)
1082 als[a] = ap.av.getAlignment();
1084 alc[a++] = ap.av.getColumnSelection();
1086 jmb.superposeStructures(als, alm, alc);
1087 } catch (Exception e)
1089 StringBuffer sp = new StringBuffer();
1090 for (AlignmentPanel ap : _alignwith)
1092 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1094 Cache.log.info("Couldn't align structures with the " + sp.toString()
1095 + "associated alignment panels.", e);
1102 public void setJalviewColourScheme(ColourSchemeI ucs)
1104 jmb.setJalviewColourScheme(ucs);
1111 * @return first alignment panel displaying given alignment, or the default
1114 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1116 for (AlignmentPanel ap : getAllAlignmentPanels())
1118 if (ap.av.getAlignment() == alignment)
1123 return getAlignmentPanel();
1127 public AAStructureBindingModel getBinding()
1133 public String getStateInfo()
1135 return jmb == null ? null : jmb.viewer.getStateInfo();
1139 public ViewerType getViewerType()
1141 return ViewerType.JMOL;
1145 protected AAStructureBindingModel getBindingModel()