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 protected IProgressIndicator getIProgressIndicator()
256 * add a single PDB structure to a new or existing Jmol view
263 public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
264 final AlignmentPanel ap)
266 progressBar = ap.alignFrame;
267 String pdbId = pdbentry.getId();
270 * If the PDB file is already loaded, the user may just choose to add to an
271 * existing viewer (or cancel)
273 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
279 * Check if there are other Jmol views involving this alignment and prompt
280 * user about adding this molecule to one of them
282 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
288 * If the options above are declined or do not apply, open a new viewer
290 openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
294 * Answers true if this viewer already involves the given PDB ID
297 protected boolean hasPdbId(String pdbId)
299 return jmb.hasPdbId(pdbId);
302 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
305 progressBar = ap.alignFrame;
306 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
307 pdbentrys, seqs, null);
308 addAlignmentPanel(ap);
309 useAlignmentPanelForColourbyseq(ap);
310 if (pdbentrys.length > 1)
312 alignAddedStructures = true;
313 useAlignmentPanelForSuperposition(ap);
315 jmb.setColourBySequence(true);
316 setSize(400, 400); // probably should be a configurable/dynamic default here
318 addingStructures = false;
319 worker = new Thread(this);
322 this.addInternalFrameListener(new InternalFrameAdapter()
325 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
334 * create a new Jmol containing several structures superimposed using the
341 public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
343 openNewJmol(ap, pe, seqs);
347 * Returns a list of any Jmol viewers. The list is restricted to those linked
348 * to the given alignment panel if it is not null.
351 protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
353 List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
354 JInternalFrame[] frames = Desktop.instance.getAllFrames();
356 for (JInternalFrame frame : frames)
358 if (frame instanceof AppJmol)
361 || ((StructureViewerBase) frame).isLinkedWith(apanel))
363 result.add((StructureViewerBase) frame);
370 void initJmol(String command)
372 jmb.setFinishedInit(false);
373 renderPanel = new RenderPanel();
374 // TODO: consider waiting until the structure/view is fully loaded before
376 this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
377 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
378 getBounds().width, getBounds().height);
379 if (scriptWindow == null)
381 BorderLayout bl = new BorderLayout();
384 scriptWindow = new JPanel(bl);
385 scriptWindow.setVisible(false);
388 jmb.allocateViewer(renderPanel, true, "", null, null, "",
390 // jmb.newJmolPopup("Jmol");
395 jmb.evalStateCommand(command);
396 jmb.evalStateCommand("set hoverDelay=0.1");
397 jmb.setFinishedInit(true);
402 boolean allChainsSelected = false;
405 void showSelectedChains()
407 Vector<String> toshow = new Vector<String>();
408 for (int i = 0; i < chainMenu.getItemCount(); i++)
410 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
412 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
413 if (item.isSelected())
415 toshow.addElement(item.getText());
419 jmb.centerViewer(toshow);
423 public void closeViewer(boolean closeExternalViewer)
425 // Jmol does not use an external viewer
430 setAlignmentPanel(null);
434 // TODO: check for memory leaks where instance isn't finalised because jmb
435 // holds a reference to the window
445 List<String> files = fetchPdbFiles();
446 if (files.size() > 0)
448 showFilesInViewer(files);
458 * Either adds the given files to a structure viewer or opens a new viewer to
462 * list of absolute paths to structure files
464 void showFilesInViewer(List<String> files)
466 long lastnotify = jmb.getLoadNotifiesHandled();
467 StringBuilder fileList = new StringBuilder();
468 for (String s : files)
470 fileList.append(SPACE).append(BACKSLASH)
471 .append(Platform.escapeString(s)).append(BACKSLASH);
473 String filesString = fileList.toString();
475 if (!addingStructures)
479 initJmol("load FILES " + filesString);
480 } catch (OutOfMemoryError oomerror)
482 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
483 Cache.log.debug("File locations are " + filesString);
484 } catch (Exception ex)
486 Cache.log.error("Couldn't open Jmol viewer!", ex);
491 StringBuilder cmd = new StringBuilder();
492 cmd.append("loadingJalviewdata=true\nload APPEND ");
493 cmd.append(filesString);
494 cmd.append("\nloadingJalviewdata=null");
495 final String command = cmd.toString();
496 lastnotify = jmb.getLoadNotifiesHandled();
500 jmb.evalStateCommand(command);
501 } catch (OutOfMemoryError oomerror)
503 new OOMWarning("When trying to add structures to the Jmol viewer!",
505 Cache.log.debug("File locations are " + filesString);
506 } catch (Exception ex)
508 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
512 // need to wait around until script has finished
513 int waitMax = JMOL_LOAD_TIMEOUT;
516 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
517 : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
518 .getPdbFile().length == files.size()))
522 Cache.log.debug("Waiting around for jmb notify.");
523 Thread.sleep(waitFor);
524 waitTotal += waitFor;
525 } catch (Exception e)
528 if (waitTotal > waitMax)
531 .println("Timed out waiting for Jmol to load files after "
533 // System.err.println("finished: " + jmb.isFinishedInit()
534 // + "; loaded: " + Arrays.toString(jmb.getPdbFile())
535 // + "; files: " + files.toString());
541 // refresh the sequence colours for the new structure(s)
542 for (AlignmentPanel ap : _colourwith)
544 jmb.updateColours(ap);
546 // do superposition if asked to
547 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
549 alignAddedStructures();
551 addingStructures = false;
555 * Queues a thread to align structures with Jalview alignments
557 void alignAddedStructures()
559 javax.swing.SwingUtilities.invokeLater(new Runnable()
564 if (jmb.viewer.isScriptExecuting())
566 SwingUtilities.invokeLater(this);
570 } catch (InterruptedException q)
577 alignStructs_withAllAlignPanels();
581 alignAddedStructures = false;
585 * Retrieves and saves as file any modelled PDB entries for which we do not
586 * already have a file saved. Returns a list of absolute paths to structure
587 * files which were either retrieved, or already stored but not modelled in
588 * the structure viewer (i.e. files to add to the viewer display).
592 List<String> fetchPdbFiles()
594 // todo - record which pdbids were successfully imported.
595 StringBuilder errormsgs = new StringBuilder();
597 List<String> files = new ArrayList<String>();
601 String[] filesInViewer = jmb.getPdbFile();
602 // TODO: replace with reference fetching/transfer code (validate PDBentry
604 Pdb pdbclient = new Pdb();
605 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
607 String file = jmb.getPdbEntry(pi).getFile();
610 // retrieve the pdb and store it locally
611 AlignmentI pdbseq = null;
612 pdbid = jmb.getPdbEntry(pi).getId();
613 long hdl = pdbid.hashCode() - System.currentTimeMillis();
614 if (progressBar != null)
616 progressBar.setProgressBar(MessageManager.formatMessage(
617 "status.fetching_pdb", new String[] { pdbid }), hdl);
621 pdbseq = pdbclient.getSequenceRecords(pdbid);
622 } catch (OutOfMemoryError oomerror)
624 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
625 } catch (Exception ex)
627 ex.printStackTrace();
628 errormsgs.append("'").append(pdbid).append("'");
631 if (progressBar != null)
633 progressBar.setProgressBar(
634 MessageManager.getString("label.state_completed"),
640 // just transfer the file name from the first sequence's first
642 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
643 .elementAt(0).getFile()).getAbsolutePath();
644 jmb.getPdbEntry(pi).setFile(file);
649 errormsgs.append("'").append(pdbid).append("' ");
654 if (filesInViewer != null && filesInViewer.length > 0)
656 addingStructures = true; // already files loaded.
657 for (int c = 0; c < filesInViewer.length; c++)
659 if (filesInViewer[c].equals(file))
672 } catch (OutOfMemoryError oomerror)
674 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
675 } catch (Exception ex)
677 ex.printStackTrace();
678 errormsgs.append("When retrieving pdbfiles : current was: '")
679 .append(pdbid).append("'");
681 if (errormsgs.length() > 0)
683 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
684 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
685 new String[] { errormsgs.toString() }),
686 MessageManager.getString("label.couldnt_load_file"),
687 JvOptionPane.ERROR_MESSAGE);
693 public void pdbFile_actionPerformed(ActionEvent actionEvent)
695 JalviewFileChooser chooser = new JalviewFileChooser(
696 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
698 chooser.setFileView(new JalviewFileView());
699 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
700 chooser.setToolTipText(MessageManager.getString("action.save"));
702 int value = chooser.showSaveDialog(this);
704 if (value == JalviewFileChooser.APPROVE_OPTION)
706 BufferedReader in = null;
709 // TODO: cope with multiple PDB files in view
710 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
711 File outFile = chooser.getSelectedFile();
713 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
715 while ((data = in.readLine()) != null)
717 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
723 } catch (Exception ex)
725 ex.printStackTrace();
733 } catch (IOException e)
743 public void viewMapping_actionPerformed(ActionEvent actionEvent)
745 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
748 cap.appendText(jmb.printMappings());
749 } catch (OutOfMemoryError e)
752 "composing sequence-structure alignments for display in text box.",
757 jalview.gui.Desktop.addInternalFrame(cap,
758 MessageManager.getString("label.pdb_sequence_mapping"), 550,
763 public void eps_actionPerformed(ActionEvent e)
765 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
769 public void png_actionPerformed(ActionEvent e)
771 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
774 void makePDBImage(jalview.util.ImageMaker.TYPE type)
776 int width = getWidth();
777 int height = getHeight();
779 jalview.util.ImageMaker im;
781 if (type == jalview.util.ImageMaker.TYPE.PNG)
783 im = new jalview.util.ImageMaker(this,
784 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
785 width, height, null, null, null, 0, false);
787 else if (type == jalview.util.ImageMaker.TYPE.EPS)
789 im = new jalview.util.ImageMaker(this,
790 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
791 width, height, null, this.getTitle(), null, 0, false);
796 im = new jalview.util.ImageMaker(this,
797 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
798 width, height, null, this.getTitle(), null, 0, false);
801 if (im.getGraphics() != null)
803 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
809 public void viewerColour_actionPerformed(ActionEvent actionEvent)
811 if (viewerColour.isSelected())
813 // disable automatic sequence colouring.
814 jmb.setColourBySequence(false);
819 public void seqColour_actionPerformed(ActionEvent actionEvent)
821 jmb.setColourBySequence(seqColour.isSelected());
822 if (_colourwith == null)
824 _colourwith = new Vector<AlignmentPanel>();
826 if (jmb.isColourBySequence())
828 if (!jmb.isLoadingFromArchive())
830 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
832 // Make the currently displayed alignment panel the associated view
833 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
836 // Set the colour using the current view for the associated alignframe
837 for (AlignmentPanel ap : _colourwith)
839 jmb.colourBySequence(ap);
845 public void chainColour_actionPerformed(ActionEvent actionEvent)
847 chainColour.setSelected(true);
852 public void chargeColour_actionPerformed(ActionEvent actionEvent)
854 chargeColour.setSelected(true);
855 jmb.colourByCharge();
859 public void zappoColour_actionPerformed(ActionEvent actionEvent)
861 zappoColour.setSelected(true);
862 jmb.setJalviewColourScheme(new ZappoColourScheme());
866 public void taylorColour_actionPerformed(ActionEvent actionEvent)
868 taylorColour.setSelected(true);
869 jmb.setJalviewColourScheme(new TaylorColourScheme());
873 public void hydroColour_actionPerformed(ActionEvent actionEvent)
875 hydroColour.setSelected(true);
876 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
880 public void helixColour_actionPerformed(ActionEvent actionEvent)
882 helixColour.setSelected(true);
883 jmb.setJalviewColourScheme(new HelixColourScheme());
887 public void strandColour_actionPerformed(ActionEvent actionEvent)
889 strandColour.setSelected(true);
890 jmb.setJalviewColourScheme(new StrandColourScheme());
894 public void turnColour_actionPerformed(ActionEvent actionEvent)
896 turnColour.setSelected(true);
897 jmb.setJalviewColourScheme(new TurnColourScheme());
901 public void buriedColour_actionPerformed(ActionEvent actionEvent)
903 buriedColour.setSelected(true);
904 jmb.setJalviewColourScheme(new BuriedColourScheme());
908 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
910 setJalviewColourScheme(new PurinePyrimidineColourScheme());
914 public void userColour_actionPerformed(ActionEvent actionEvent)
916 userColour.setSelected(true);
917 new UserDefinedColours(this, null);
921 public void backGround_actionPerformed(ActionEvent actionEvent)
923 java.awt.Color col = JColorChooser
924 .showDialog(this, MessageManager
925 .getString("label.select_backgroud_colour"), null);
928 jmb.setBackgroundColour(col);
933 public void showHelp_actionPerformed(ActionEvent actionEvent)
937 jalview.util.BrowserLauncher
938 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
939 } catch (Exception ex)
944 public void showConsole(boolean showConsole)
949 if (splitPane == null)
951 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
952 splitPane.setTopComponent(renderPanel);
953 splitPane.setBottomComponent(scriptWindow);
954 this.getContentPane().add(splitPane, BorderLayout.CENTER);
955 splitPane.setDividerLocation(getHeight() - 200);
956 scriptWindow.setVisible(true);
957 scriptWindow.validate();
958 splitPane.validate();
964 if (splitPane != null)
966 splitPane.setVisible(false);
971 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
977 class RenderPanel extends JPanel
979 final Dimension currentSize = new Dimension();
982 public void paintComponent(Graphics g)
984 getSize(currentSize);
986 if (jmb != null && jmb.fileLoadingError != null)
988 g.setColor(Color.black);
989 g.fillRect(0, 0, currentSize.width, currentSize.height);
990 g.setColor(Color.white);
991 g.setFont(new Font("Verdana", Font.BOLD, 14));
992 g.drawString(MessageManager.getString("label.error_loading_file")
993 + "...", 20, currentSize.height / 2);
994 StringBuffer sb = new StringBuffer();
996 for (int e = 0; e < jmb.getPdbCount(); e++)
998 sb.append(jmb.getPdbEntry(e).getId());
999 if (e < jmb.getPdbCount() - 1)
1004 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
1007 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
1008 * g.getFontMetrics().getHeight());
1012 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
1014 g.setColor(Color.black);
1015 g.fillRect(0, 0, currentSize.width, currentSize.height);
1016 g.setColor(Color.white);
1017 g.setFont(new Font("Verdana", Font.BOLD, 14));
1018 g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
1019 20, currentSize.height / 2);
1023 jmb.viewer.renderScreenImage(g, currentSize.width,
1024 currentSize.height);
1029 public void updateTitleAndMenus()
1031 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1036 setChainMenuItems(jmb.getChainNames());
1038 this.setTitle(jmb.getViewerTitle());
1039 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1041 viewerActionMenu.setVisible(true);
1043 if (!jmb.isLoadingFromArchive())
1045 seqColour_actionPerformed(null);
1053 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1057 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1059 alignStructs_withAllAlignPanels();
1062 private void alignStructs_withAllAlignPanels()
1064 if (getAlignmentPanel() == null)
1069 if (_alignwith.size() == 0)
1071 _alignwith.add(getAlignmentPanel());
1076 AlignmentI[] als = new Alignment[_alignwith.size()];
1077 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1078 int[] alm = new int[_alignwith.size()];
1081 for (AlignmentPanel ap : _alignwith)
1083 als[a] = ap.av.getAlignment();
1085 alc[a++] = ap.av.getColumnSelection();
1087 jmb.superposeStructures(als, alm, alc);
1088 } catch (Exception e)
1090 StringBuffer sp = new StringBuffer();
1091 for (AlignmentPanel ap : _alignwith)
1093 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1095 Cache.log.info("Couldn't align structures with the " + sp.toString()
1096 + "associated alignment panels.", e);
1103 public void setJalviewColourScheme(ColourSchemeI ucs)
1105 jmb.setJalviewColourScheme(ucs);
1112 * @return first alignment panel displaying given alignment, or the default
1115 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1117 for (AlignmentPanel ap : getAllAlignmentPanels())
1119 if (ap.av.getAlignment() == alignment)
1124 return getAlignmentPanel();
1128 public AAStructureBindingModel getBinding()
1134 public String getStateInfo()
1136 return jmb == null ? null : jmb.viewer.getStateInfo();
1140 public ViewerType getViewerType()
1142 return ViewerType.JMOL;
1146 protected AAStructureBindingModel getBindingModel()