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.JMenu;
68 import javax.swing.JPanel;
69 import javax.swing.JSplitPane;
70 import javax.swing.SwingUtilities;
71 import javax.swing.event.InternalFrameAdapter;
72 import javax.swing.event.InternalFrameEvent;
73 import javax.swing.event.MenuEvent;
74 import javax.swing.event.MenuListener;
76 public class AppJmol extends StructureViewerBase
78 // ms to wait for Jmol to load files
79 private static final int JMOL_LOAD_TIMEOUT = 20000;
81 private static final String SPACE = " ";
83 private static final String BACKSLASH = "\"";
91 RenderPanel renderPanel;
93 ViewSelectionMenu seqColourBy;
102 * - add the alignment panel to the list used for colouring these
105 * - add the alignment panel to the list used for aligning these
107 * @param leaveColouringToJmol
108 * - do not update the colours from any other source. Jmol is
114 public AppJmol(String[] files, String[] ids, SequenceI[][] seqs,
115 AlignmentPanel ap, boolean usetoColour, boolean useToAlign,
116 boolean leaveColouringToJmol, String loadStatus,
117 Rectangle bounds, String viewid)
119 PDBEntry[] pdbentrys = new PDBEntry[files.length];
120 for (int i = 0; i < pdbentrys.length; i++)
122 // PDBEntry pdbentry = new PDBEntry(files[i], ids[i]);
123 PDBEntry pdbentry = new PDBEntry(ids[i], null, PDBEntry.Type.PDB,
125 pdbentrys[i] = pdbentry;
127 // / TODO: check if protocol is needed to be set, and if chains are
129 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
130 pdbentrys, seqs, null);
132 jmb.setLoadingFromArchive(true);
133 addAlignmentPanel(ap);
136 useAlignmentPanelForSuperposition(ap);
138 if (leaveColouringToJmol || !usetoColour)
140 jmb.setColourBySequence(false);
141 seqColour.setSelected(false);
142 viewerColour.setSelected(true);
144 else if (usetoColour)
146 useAlignmentPanelForColourbyseq(ap);
147 jmb.setColourBySequence(true);
148 seqColour.setSelected(true);
149 viewerColour.setSelected(false);
151 this.setBounds(bounds);
154 // jalview.gui.Desktop.addInternalFrame(this, "Loading File",
155 // bounds.width,bounds.height);
157 this.addInternalFrameListener(new InternalFrameAdapter()
160 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
165 initJmol(loadStatus); // pdbentry, seq, JBPCHECK!
169 private void initMenus()
171 seqColour.setSelected(jmb.isColourBySequence());
172 viewerColour.setSelected(!jmb.isColourBySequence());
173 if (_colourwith == null)
175 _colourwith = new Vector<AlignmentPanel>();
177 if (_alignwith == null)
179 _alignwith = new Vector<AlignmentPanel>();
182 seqColourBy = new ViewSelectionMenu(
183 MessageManager.getString("label.colour_by"), this, _colourwith,
188 public void itemStateChanged(ItemEvent e)
190 if (!seqColour.isSelected())
196 // update the jmol display now.
197 seqColour_actionPerformed(null);
201 viewMenu.add(seqColourBy);
202 final ItemListener handler;
203 JMenu alpanels = new ViewSelectionMenu(
204 MessageManager.getString("label.superpose_with"), this,
205 _alignwith, handler = new ItemListener()
209 public void itemStateChanged(ItemEvent e)
211 alignStructs.setEnabled(_alignwith.size() > 0);
212 alignStructs.setToolTipText(MessageManager
214 "label.align_structures_using_linked_alignment_views",
215 new String[] { new Integer(_alignwith
216 .size()).toString() }));
219 handler.itemStateChanged(null);
220 viewerActionMenu.add(alpanels);
221 viewerActionMenu.addMenuListener(new MenuListener()
225 public void menuSelected(MenuEvent e)
227 handler.itemStateChanged(null);
231 public void menuDeselected(MenuEvent e)
233 // TODO Auto-generated method stub
238 public void menuCanceled(MenuEvent e)
240 // TODO Auto-generated method stub
246 IProgressIndicator progressBar = null;
249 * add a single PDB structure to a new or existing Jmol view
256 public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
257 final AlignmentPanel ap)
259 progressBar = ap.alignFrame;
260 String pdbId = pdbentry.getId();
263 * If the PDB file is already loaded, the user may just choose to add to an
264 * existing viewer (or cancel)
266 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
272 * Check if there are other Jmol views involving this alignment and prompt
273 * user about adding this molecule to one of them
275 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
281 * If the options above are declined or do not apply, open a new viewer
283 openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
287 * Answers true if this viewer already involves the given PDB ID
290 protected boolean hasPdbId(String pdbId)
292 return jmb.hasPdbId(pdbId);
295 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
298 progressBar = ap.alignFrame;
299 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
300 pdbentrys, seqs, null);
301 addAlignmentPanel(ap);
302 useAlignmentPanelForColourbyseq(ap);
303 if (pdbentrys.length > 1)
305 alignAddedStructures = true;
306 useAlignmentPanelForSuperposition(ap);
308 jmb.setColourBySequence(true);
309 setSize(400, 400); // probably should be a configurable/dynamic default here
311 addingStructures = false;
312 worker = new Thread(this);
315 this.addInternalFrameListener(new InternalFrameAdapter()
318 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
327 * create a new Jmol containing several structures superimposed using the
334 public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
336 openNewJmol(ap, pe, seqs);
339 void initJmol(String command)
341 jmb.setFinishedInit(false);
342 renderPanel = new RenderPanel();
343 // TODO: consider waiting until the structure/view is fully loaded before
345 this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
346 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
347 getBounds().width, getBounds().height);
348 if (scriptWindow == null)
350 BorderLayout bl = new BorderLayout();
353 scriptWindow = new JPanel(bl);
354 scriptWindow.setVisible(false);
357 jmb.allocateViewer(renderPanel, true, "", null, null, "",
359 // jmb.newJmolPopup("Jmol");
364 jmb.evalStateCommand(command);
365 jmb.evalStateCommand("set hoverDelay=0.1");
366 jmb.setFinishedInit(true);
371 boolean allChainsSelected = false;
374 void showSelectedChains()
376 Vector<String> toshow = new Vector<String>();
377 for (int i = 0; i < chainMenu.getItemCount(); i++)
379 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
381 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
382 if (item.isSelected())
384 toshow.addElement(item.getText());
388 jmb.centerViewer(toshow);
392 public void closeViewer(boolean closeExternalViewer)
394 // Jmol does not use an external viewer
399 setAlignmentPanel(null);
403 // TODO: check for memory leaks where instance isn't finalised because jmb
404 // holds a reference to the window
414 List<String> files = fetchPdbFiles();
415 if (files.size() > 0)
417 showFilesInViewer(files);
427 * Either adds the given files to a structure viewer or opens a new viewer to
431 * list of absolute paths to structure files
433 void showFilesInViewer(List<String> files)
435 long lastnotify = jmb.getLoadNotifiesHandled();
436 StringBuilder fileList = new StringBuilder();
437 for (String s : files)
439 fileList.append(SPACE).append(BACKSLASH)
440 .append(Platform.escapeString(s)).append(BACKSLASH);
442 String filesString = fileList.toString();
444 if (!addingStructures)
448 initJmol("load FILES " + filesString);
449 } catch (OutOfMemoryError oomerror)
451 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
452 Cache.log.debug("File locations are " + filesString);
453 } catch (Exception ex)
455 Cache.log.error("Couldn't open Jmol viewer!", ex);
460 StringBuilder cmd = new StringBuilder();
461 cmd.append("loadingJalviewdata=true\nload APPEND ");
462 cmd.append(filesString);
463 cmd.append("\nloadingJalviewdata=null");
464 final String command = cmd.toString();
465 lastnotify = jmb.getLoadNotifiesHandled();
469 jmb.evalStateCommand(command);
470 } catch (OutOfMemoryError oomerror)
472 new OOMWarning("When trying to add structures to the Jmol viewer!",
474 Cache.log.debug("File locations are " + filesString);
475 } catch (Exception ex)
477 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
481 // need to wait around until script has finished
482 int waitMax = JMOL_LOAD_TIMEOUT;
485 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
486 : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
487 .getPdbFile().length == files.size()))
491 Cache.log.debug("Waiting around for jmb notify.");
492 Thread.sleep(waitFor);
493 waitTotal += waitFor;
494 } catch (Exception e)
497 if (waitTotal > waitMax)
500 .println("Timed out waiting for Jmol to load files after "
502 // System.err.println("finished: " + jmb.isFinishedInit()
503 // + "; loaded: " + Arrays.toString(jmb.getPdbFile())
504 // + "; files: " + files.toString());
510 // refresh the sequence colours for the new structure(s)
511 for (AlignmentPanel ap : _colourwith)
513 jmb.updateColours(ap);
515 // do superposition if asked to
516 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
518 alignAddedStructures();
520 addingStructures = false;
524 * Queues a thread to align structures with Jalview alignments
526 void alignAddedStructures()
528 javax.swing.SwingUtilities.invokeLater(new Runnable()
533 if (jmb.viewer.isScriptExecuting())
535 SwingUtilities.invokeLater(this);
539 } catch (InterruptedException q)
546 alignStructs_withAllAlignPanels();
550 alignAddedStructures = false;
554 * Retrieves and saves as file any modelled PDB entries for which we do not
555 * already have a file saved. Returns a list of absolute paths to structure
556 * files which were either retrieved, or already stored but not modelled in
557 * the structure viewer (i.e. files to add to the viewer display).
561 List<String> fetchPdbFiles()
563 // todo - record which pdbids were successfully imported.
564 StringBuilder errormsgs = new StringBuilder();
566 List<String> files = new ArrayList<String>();
570 String[] filesInViewer = jmb.getPdbFile();
571 // TODO: replace with reference fetching/transfer code (validate PDBentry
573 Pdb pdbclient = new Pdb();
574 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
576 String file = jmb.getPdbEntry(pi).getFile();
579 // retrieve the pdb and store it locally
580 AlignmentI pdbseq = null;
581 pdbid = jmb.getPdbEntry(pi).getId();
582 long hdl = pdbid.hashCode() - System.currentTimeMillis();
583 if (progressBar != null)
585 progressBar.setProgressBar(MessageManager.formatMessage(
586 "status.fetching_pdb", new String[] { pdbid }), hdl);
590 pdbseq = pdbclient.getSequenceRecords(pdbid);
591 } catch (OutOfMemoryError oomerror)
593 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
594 } catch (Exception ex)
596 ex.printStackTrace();
597 errormsgs.append("'").append(pdbid).append("'");
600 if (progressBar != null)
602 progressBar.setProgressBar(
603 MessageManager.getString("label.state_completed"),
609 // just transfer the file name from the first sequence's first
611 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
612 .elementAt(0).getFile()).getAbsolutePath();
613 jmb.getPdbEntry(pi).setFile(file);
618 errormsgs.append("'").append(pdbid).append("' ");
623 if (filesInViewer != null && filesInViewer.length > 0)
625 addingStructures = true; // already files loaded.
626 for (int c = 0; c < filesInViewer.length; c++)
628 if (filesInViewer[c].equals(file))
641 } catch (OutOfMemoryError oomerror)
643 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
644 } catch (Exception ex)
646 ex.printStackTrace();
647 errormsgs.append("When retrieving pdbfiles : current was: '")
648 .append(pdbid).append("'");
650 if (errormsgs.length() > 0)
652 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
653 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
654 new String[] { errormsgs.toString() }),
655 MessageManager.getString("label.couldnt_load_file"),
656 JvOptionPane.ERROR_MESSAGE);
662 public void pdbFile_actionPerformed(ActionEvent actionEvent)
664 JalviewFileChooser chooser = new JalviewFileChooser(
665 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
667 chooser.setFileView(new JalviewFileView());
668 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
669 chooser.setToolTipText(MessageManager.getString("action.save"));
671 int value = chooser.showSaveDialog(this);
673 if (value == JalviewFileChooser.APPROVE_OPTION)
675 BufferedReader in = null;
678 // TODO: cope with multiple PDB files in view
679 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
680 File outFile = chooser.getSelectedFile();
682 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
684 while ((data = in.readLine()) != null)
686 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
692 } catch (Exception ex)
694 ex.printStackTrace();
702 } catch (IOException e)
712 public void viewMapping_actionPerformed(ActionEvent actionEvent)
714 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
717 cap.appendText(jmb.printMappings());
718 } catch (OutOfMemoryError e)
721 "composing sequence-structure alignments for display in text box.",
726 jalview.gui.Desktop.addInternalFrame(cap,
727 MessageManager.getString("label.pdb_sequence_mapping"), 550,
732 public void eps_actionPerformed(ActionEvent e)
734 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
738 public void png_actionPerformed(ActionEvent e)
740 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
743 void makePDBImage(jalview.util.ImageMaker.TYPE type)
745 int width = getWidth();
746 int height = getHeight();
748 jalview.util.ImageMaker im;
750 if (type == jalview.util.ImageMaker.TYPE.PNG)
752 im = new jalview.util.ImageMaker(this,
753 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
754 width, height, null, null, null, 0, false);
756 else if (type == jalview.util.ImageMaker.TYPE.EPS)
758 im = new jalview.util.ImageMaker(this,
759 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
760 width, height, null, this.getTitle(), null, 0, false);
765 im = new jalview.util.ImageMaker(this,
766 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
767 width, height, null, this.getTitle(), null, 0, false);
770 if (im.getGraphics() != null)
772 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
778 public void viewerColour_actionPerformed(ActionEvent actionEvent)
780 if (viewerColour.isSelected())
782 // disable automatic sequence colouring.
783 jmb.setColourBySequence(false);
788 public void seqColour_actionPerformed(ActionEvent actionEvent)
790 jmb.setColourBySequence(seqColour.isSelected());
791 if (_colourwith == null)
793 _colourwith = new Vector<AlignmentPanel>();
795 if (jmb.isColourBySequence())
797 if (!jmb.isLoadingFromArchive())
799 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
801 // Make the currently displayed alignment panel the associated view
802 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
805 // Set the colour using the current view for the associated alignframe
806 for (AlignmentPanel ap : _colourwith)
808 jmb.colourBySequence(ap);
814 public void chainColour_actionPerformed(ActionEvent actionEvent)
816 chainColour.setSelected(true);
821 public void chargeColour_actionPerformed(ActionEvent actionEvent)
823 chargeColour.setSelected(true);
824 jmb.colourByCharge();
828 public void zappoColour_actionPerformed(ActionEvent actionEvent)
830 zappoColour.setSelected(true);
831 jmb.setJalviewColourScheme(new ZappoColourScheme());
835 public void taylorColour_actionPerformed(ActionEvent actionEvent)
837 taylorColour.setSelected(true);
838 jmb.setJalviewColourScheme(new TaylorColourScheme());
842 public void hydroColour_actionPerformed(ActionEvent actionEvent)
844 hydroColour.setSelected(true);
845 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
849 public void helixColour_actionPerformed(ActionEvent actionEvent)
851 helixColour.setSelected(true);
852 jmb.setJalviewColourScheme(new HelixColourScheme());
856 public void strandColour_actionPerformed(ActionEvent actionEvent)
858 strandColour.setSelected(true);
859 jmb.setJalviewColourScheme(new StrandColourScheme());
863 public void turnColour_actionPerformed(ActionEvent actionEvent)
865 turnColour.setSelected(true);
866 jmb.setJalviewColourScheme(new TurnColourScheme());
870 public void buriedColour_actionPerformed(ActionEvent actionEvent)
872 buriedColour.setSelected(true);
873 jmb.setJalviewColourScheme(new BuriedColourScheme());
877 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
879 setJalviewColourScheme(new PurinePyrimidineColourScheme());
883 public void userColour_actionPerformed(ActionEvent actionEvent)
885 userColour.setSelected(true);
886 new UserDefinedColours(this, null);
890 public void backGround_actionPerformed(ActionEvent actionEvent)
892 java.awt.Color col = JColorChooser
893 .showDialog(this, MessageManager
894 .getString("label.select_backgroud_colour"), null);
897 jmb.setBackgroundColour(col);
902 public void showHelp_actionPerformed(ActionEvent actionEvent)
906 jalview.util.BrowserLauncher
907 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
908 } catch (Exception ex)
913 public void showConsole(boolean showConsole)
918 if (splitPane == null)
920 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
921 splitPane.setTopComponent(renderPanel);
922 splitPane.setBottomComponent(scriptWindow);
923 this.getContentPane().add(splitPane, BorderLayout.CENTER);
924 splitPane.setDividerLocation(getHeight() - 200);
925 scriptWindow.setVisible(true);
926 scriptWindow.validate();
927 splitPane.validate();
933 if (splitPane != null)
935 splitPane.setVisible(false);
940 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
946 class RenderPanel extends JPanel
948 final Dimension currentSize = new Dimension();
951 public void paintComponent(Graphics g)
953 getSize(currentSize);
955 if (jmb != null && jmb.fileLoadingError != null)
957 g.setColor(Color.black);
958 g.fillRect(0, 0, currentSize.width, currentSize.height);
959 g.setColor(Color.white);
960 g.setFont(new Font("Verdana", Font.BOLD, 14));
961 g.drawString(MessageManager.getString("label.error_loading_file")
962 + "...", 20, currentSize.height / 2);
963 StringBuffer sb = new StringBuffer();
965 for (int e = 0; e < jmb.getPdbCount(); e++)
967 sb.append(jmb.getPdbEntry(e).getId());
968 if (e < jmb.getPdbCount() - 1)
973 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
976 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
977 * g.getFontMetrics().getHeight());
981 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
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.retrieving_pdb_data"),
988 20, currentSize.height / 2);
992 jmb.viewer.renderScreenImage(g, currentSize.width,
998 public void updateTitleAndMenus()
1000 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1005 setChainMenuItems(jmb.getChainNames());
1007 this.setTitle(jmb.getViewerTitle());
1008 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1010 viewerActionMenu.setVisible(true);
1012 if (!jmb.isLoadingFromArchive())
1014 seqColour_actionPerformed(null);
1022 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1026 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1028 alignStructs_withAllAlignPanels();
1031 private void alignStructs_withAllAlignPanels()
1033 if (getAlignmentPanel() == null)
1038 if (_alignwith.size() == 0)
1040 _alignwith.add(getAlignmentPanel());
1045 AlignmentI[] als = new Alignment[_alignwith.size()];
1046 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1047 int[] alm = new int[_alignwith.size()];
1050 for (AlignmentPanel ap : _alignwith)
1052 als[a] = ap.av.getAlignment();
1054 alc[a++] = ap.av.getColumnSelection();
1056 jmb.superposeStructures(als, alm, alc);
1057 } catch (Exception e)
1059 StringBuffer sp = new StringBuffer();
1060 for (AlignmentPanel ap : _alignwith)
1062 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1064 Cache.log.info("Couldn't align structures with the " + sp.toString()
1065 + "associated alignment panels.", e);
1072 public void setJalviewColourScheme(ColourSchemeI ucs)
1074 jmb.setJalviewColourScheme(ucs);
1081 * @return first alignment panel displaying given alignment, or the default
1084 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1086 for (AlignmentPanel ap : getAllAlignmentPanels())
1088 if (ap.av.getAlignment() == alignment)
1093 return getAlignmentPanel();
1097 public AAStructureBindingModel getBinding()
1103 public String getStateInfo()
1105 return jmb == null ? null : jmb.viewer.getStateInfo();
1109 public ViewerType getViewerType()
1111 return ViewerType.JMOL;
1115 protected AAStructureBindingModel getBindingModel()