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;
45 import java.awt.BorderLayout;
46 import java.awt.Color;
47 import java.awt.Dimension;
49 import java.awt.Graphics;
50 import java.awt.Rectangle;
51 import java.awt.event.ActionEvent;
52 import java.awt.event.ActionListener;
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.JMenuItem;
70 import javax.swing.JOptionPane;
71 import javax.swing.JPanel;
72 import javax.swing.JSplitPane;
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
86 RenderPanel renderPanel;
88 ViewSelectionMenu seqColourBy;
97 * - add the alignment panel to the list used for colouring these
100 * - add the alignment panel to the list used for aligning these
102 * @param leaveColouringToJmol
103 * - do not update the colours from any other source. Jmol is
109 public AppJmol(String[] files, String[] ids, SequenceI[][] seqs,
110 AlignmentPanel ap, boolean usetoColour, boolean useToAlign,
111 boolean leaveColouringToJmol, String loadStatus,
112 Rectangle bounds, String viewid)
114 PDBEntry[] pdbentrys = new PDBEntry[files.length];
115 for (int i = 0; i < pdbentrys.length; i++)
117 // PDBEntry pdbentry = new PDBEntry(files[i], ids[i]);
118 PDBEntry pdbentry = new PDBEntry(ids[i], null, PDBEntry.Type.PDB,
120 pdbentrys[i] = pdbentry;
122 // / TODO: check if protocol is needed to be set, and if chains are
124 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
125 pdbentrys, seqs, null, null);
127 jmb.setLoadingFromArchive(true);
128 addAlignmentPanel(ap);
131 useAlignmentPanelForSuperposition(ap);
133 if (leaveColouringToJmol || !usetoColour)
135 jmb.setColourBySequence(false);
136 seqColour.setSelected(false);
137 viewerColour.setSelected(true);
139 else if (usetoColour)
141 useAlignmentPanelForColourbyseq(ap);
142 jmb.setColourBySequence(true);
143 seqColour.setSelected(true);
144 viewerColour.setSelected(false);
146 this.setBounds(bounds);
149 // jalview.gui.Desktop.addInternalFrame(this, "Loading File",
150 // bounds.width,bounds.height);
152 this.addInternalFrameListener(new InternalFrameAdapter()
155 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
160 initJmol(loadStatus); // pdbentry, seq, JBPCHECK!
164 private void initMenus()
166 seqColour.setSelected(jmb.isColourBySequence());
167 viewerColour.setSelected(!jmb.isColourBySequence());
168 if (_colourwith == null)
170 _colourwith = new Vector<AlignmentPanel>();
172 if (_alignwith == null)
174 _alignwith = new Vector<AlignmentPanel>();
177 seqColourBy = new ViewSelectionMenu(
178 MessageManager.getString("label.colour_by"), this, _colourwith,
183 public void itemStateChanged(ItemEvent e)
185 if (!seqColour.isSelected())
191 // update the jmol display now.
192 seqColour_actionPerformed(null);
196 viewMenu.add(seqColourBy);
197 final ItemListener handler;
198 JMenu alpanels = new ViewSelectionMenu(
199 MessageManager.getString("label.superpose_with"), this,
200 _alignwith, handler = new ItemListener()
204 public void itemStateChanged(ItemEvent e)
206 alignStructs.setEnabled(_alignwith.size() > 0);
207 alignStructs.setToolTipText(MessageManager
209 "label.align_structures_using_linked_alignment_views",
210 new String[] { new Integer(_alignwith
211 .size()).toString() }));
214 handler.itemStateChanged(null);
215 viewerActionMenu.add(alpanels);
216 viewerActionMenu.addMenuListener(new MenuListener()
220 public void menuSelected(MenuEvent e)
222 handler.itemStateChanged(null);
226 public void menuDeselected(MenuEvent e)
228 // TODO Auto-generated method stub
233 public void menuCanceled(MenuEvent e)
235 // TODO Auto-generated method stub
241 IProgressIndicator progressBar = null;
244 protected IProgressIndicator getIProgressIndicator()
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, 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
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, "", scriptWindow,
385 // jmb.newJmolPopup("Jmol");
390 jmb.evalStateCommand(command);
391 jmb.evalStateCommand("set hoverDelay=0.1");
392 jmb.setFinishedInit(true);
395 void setChainMenuItems(Vector<String> chains)
397 chainMenu.removeAll();
402 JMenuItem menuItem = new JMenuItem(
403 MessageManager.getString("label.all"));
404 menuItem.addActionListener(new ActionListener()
407 public void actionPerformed(ActionEvent evt)
409 allChainsSelected = true;
410 for (int i = 0; i < chainMenu.getItemCount(); i++)
412 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
414 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
418 allChainsSelected = false;
422 chainMenu.add(menuItem);
424 for (String chain : chains)
426 menuItem = new JCheckBoxMenuItem(chain, true);
427 menuItem.addItemListener(new ItemListener()
430 public void itemStateChanged(ItemEvent evt)
432 if (!allChainsSelected)
439 chainMenu.add(menuItem);
443 boolean allChainsSelected = false;
447 Vector<String> toshow = new Vector<String>();
448 for (int i = 0; i < chainMenu.getItemCount(); i++)
450 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
452 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
453 if (item.isSelected())
455 toshow.addElement(item.getText());
459 jmb.centerViewer(toshow);
463 public void closeViewer(boolean closeExternalViewer)
465 // Jmol does not use an external viewer
470 setAlignmentPanel(null);
474 // TODO: check for memory leaks where instance isn't finalised because jmb
475 // holds a reference to the window
484 // todo - record which pdbids were successfuly imported.
485 StringBuffer errormsgs = new StringBuffer(), files = new StringBuffer();
488 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
489 // TODO: replace with reference fetching/transfer code (validate PDBentry
491 jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb();
492 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
494 String file = jmb.getPdbEntry(pi).getFile();
497 // retrieve the pdb and store it locally
498 AlignmentI pdbseq = null;
499 pdbid = jmb.getPdbEntry(pi).getId();
500 long hdl = pdbid.hashCode() - System.currentTimeMillis();
501 if (progressBar != null)
503 progressBar.setProgressBar(MessageManager.formatMessage(
504 "status.fetching_pdb", new String[] { pdbid }), hdl);
508 pdbseq = pdbclient.getSequenceRecords(pdbid);
509 } catch (OutOfMemoryError oomerror)
511 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
512 } catch (Exception ex)
514 ex.printStackTrace();
515 errormsgs.append("'" + pdbid + "'");
517 if (progressBar != null)
519 progressBar.setProgressBar(
520 MessageManager.getString("label.state_completed"), hdl);
524 // just transfer the file name from the first sequence's first
526 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
527 .elementAt(0).getFile()).getAbsolutePath();
528 jmb.getPdbEntry(pi).setFile(file);
530 files.append(" \"" + Platform.escapeString(file) + "\"");
534 errormsgs.append("'" + pdbid + "' ");
539 if (curfiles != null && curfiles.length > 0)
541 addingStructures = true; // already files loaded.
542 for (int c = 0; c < curfiles.length; c++)
544 if (curfiles[c].equals(file))
553 files.append(" \"" + Platform.escapeString(file) + "\"");
557 } catch (OutOfMemoryError oomerror)
559 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
560 } catch (Exception ex)
562 ex.printStackTrace();
563 errormsgs.append("When retrieving pdbfiles : current was: '" + pdbid
566 if (errormsgs.length() > 0)
569 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
570 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
571 new String[] { errormsgs.toString() }),
572 MessageManager.getString("label.couldnt_load_file"),
573 JOptionPane.ERROR_MESSAGE);
576 long lastnotify = jmb.getLoadNotifiesHandled();
577 if (files.length() > 0)
579 if (!addingStructures)
584 initJmol("load FILES " + files.toString());
585 } catch (OutOfMemoryError oomerror)
587 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
588 Cache.log.debug("File locations are " + files);
589 } catch (Exception ex)
591 Cache.log.error("Couldn't open Jmol viewer!", ex);
596 StringBuffer cmd = new StringBuffer();
597 cmd.append("loadingJalviewdata=true\nload APPEND ");
598 cmd.append(files.toString());
599 cmd.append("\nloadingJalviewdata=null");
600 final String command = cmd.toString();
602 lastnotify = jmb.getLoadNotifiesHandled();
606 jmb.evalStateCommand(command);
607 } catch (OutOfMemoryError oomerror)
610 "When trying to add structures to the Jmol viewer!",
612 Cache.log.debug("File locations are " + files);
613 } catch (Exception ex)
615 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
619 // need to wait around until script has finished
620 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
621 : (!jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
622 .getPdbFile().length != jmb.getPdbCount()))
626 Cache.log.debug("Waiting around for jmb notify.");
628 } catch (Exception e)
633 // refresh the sequence colours for the new structure(s)
634 for (AlignmentPanel ap : _colourwith)
636 jmb.updateColours(ap);
638 // do superposition if asked to
639 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
641 javax.swing.SwingUtilities.invokeLater(new Runnable()
646 if (jmb.viewer.isScriptExecuting())
648 javax.swing.SwingUtilities.invokeLater(this);
652 } catch (InterruptedException q)
660 alignStructs_withAllAlignPanels();
664 alignAddedStructures = false;
666 addingStructures = false;
674 public void pdbFile_actionPerformed(ActionEvent actionEvent)
676 JalviewFileChooser chooser = new JalviewFileChooser(
677 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
679 chooser.setFileView(new JalviewFileView());
680 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
681 chooser.setToolTipText(MessageManager.getString("action.save"));
683 int value = chooser.showSaveDialog(this);
685 if (value == JalviewFileChooser.APPROVE_OPTION)
687 BufferedReader in = null;
690 // TODO: cope with multiple PDB files in view
691 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
692 File outFile = chooser.getSelectedFile();
694 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
696 while ((data = in.readLine()) != null)
698 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
704 } catch (Exception ex)
706 ex.printStackTrace();
714 } catch (IOException e)
724 public void viewMapping_actionPerformed(ActionEvent actionEvent)
726 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
729 cap.appendText(jmb.printMappings());
730 } catch (OutOfMemoryError e)
733 "composing sequence-structure alignments for display in text box.",
738 jalview.gui.Desktop.addInternalFrame(cap,
739 MessageManager.getString("label.pdb_sequence_mapping"), 550,
744 public void eps_actionPerformed(ActionEvent e)
746 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
750 public void png_actionPerformed(ActionEvent e)
752 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
755 void makePDBImage(jalview.util.ImageMaker.TYPE type)
757 int width = getWidth();
758 int height = getHeight();
760 jalview.util.ImageMaker im;
762 if (type == jalview.util.ImageMaker.TYPE.PNG)
764 im = new jalview.util.ImageMaker(this,
765 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
766 width, height, null, null, null, 0, false);
768 else if (type == jalview.util.ImageMaker.TYPE.EPS)
770 im = new jalview.util.ImageMaker(this,
771 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
772 width, height, null, this.getTitle(), null, 0, false);
777 im = new jalview.util.ImageMaker(this,
778 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
779 width, height, null, this.getTitle(), null, 0, false);
782 if (im.getGraphics() != null)
784 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
790 public void viewerColour_actionPerformed(ActionEvent actionEvent)
792 if (viewerColour.isSelected())
794 // disable automatic sequence colouring.
795 jmb.setColourBySequence(false);
800 public void seqColour_actionPerformed(ActionEvent actionEvent)
802 jmb.setColourBySequence(seqColour.isSelected());
803 if (_colourwith == null)
805 _colourwith = new Vector<AlignmentPanel>();
807 if (jmb.isColourBySequence())
809 if (!jmb.isLoadingFromArchive())
811 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
813 // Make the currently displayed alignment panel the associated view
814 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
817 // Set the colour using the current view for the associated alignframe
818 for (AlignmentPanel ap : _colourwith)
820 jmb.colourBySequence(ap);
826 public void chainColour_actionPerformed(ActionEvent actionEvent)
828 chainColour.setSelected(true);
833 public void chargeColour_actionPerformed(ActionEvent actionEvent)
835 chargeColour.setSelected(true);
836 jmb.colourByCharge();
840 public void zappoColour_actionPerformed(ActionEvent actionEvent)
842 zappoColour.setSelected(true);
843 jmb.setJalviewColourScheme(new ZappoColourScheme());
847 public void taylorColour_actionPerformed(ActionEvent actionEvent)
849 taylorColour.setSelected(true);
850 jmb.setJalviewColourScheme(new TaylorColourScheme());
854 public void hydroColour_actionPerformed(ActionEvent actionEvent)
856 hydroColour.setSelected(true);
857 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
861 public void helixColour_actionPerformed(ActionEvent actionEvent)
863 helixColour.setSelected(true);
864 jmb.setJalviewColourScheme(new HelixColourScheme());
868 public void strandColour_actionPerformed(ActionEvent actionEvent)
870 strandColour.setSelected(true);
871 jmb.setJalviewColourScheme(new StrandColourScheme());
875 public void turnColour_actionPerformed(ActionEvent actionEvent)
877 turnColour.setSelected(true);
878 jmb.setJalviewColourScheme(new TurnColourScheme());
882 public void buriedColour_actionPerformed(ActionEvent actionEvent)
884 buriedColour.setSelected(true);
885 jmb.setJalviewColourScheme(new BuriedColourScheme());
889 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
891 setJalviewColourScheme(new PurinePyrimidineColourScheme());
895 public void userColour_actionPerformed(ActionEvent actionEvent)
897 userColour.setSelected(true);
898 new UserDefinedColours(this, null);
902 public void backGround_actionPerformed(ActionEvent actionEvent)
904 java.awt.Color col = JColorChooser
905 .showDialog(this, MessageManager
906 .getString("label.select_backgroud_colour"), null);
909 jmb.setBackgroundColour(col);
914 public void showHelp_actionPerformed(ActionEvent actionEvent)
918 jalview.util.BrowserLauncher
919 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
920 } catch (Exception ex)
925 public void showConsole(boolean showConsole)
930 if (splitPane == null)
932 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
933 splitPane.setTopComponent(renderPanel);
934 splitPane.setBottomComponent(scriptWindow);
935 this.getContentPane().add(splitPane, BorderLayout.CENTER);
936 splitPane.setDividerLocation(getHeight() - 200);
937 scriptWindow.setVisible(true);
938 scriptWindow.validate();
939 splitPane.validate();
945 if (splitPane != null)
947 splitPane.setVisible(false);
952 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
958 class RenderPanel extends JPanel
960 final Dimension currentSize = new Dimension();
963 public void paintComponent(Graphics g)
965 getSize(currentSize);
967 if (jmb != null && jmb.fileLoadingError != null)
969 g.setColor(Color.black);
970 g.fillRect(0, 0, currentSize.width, currentSize.height);
971 g.setColor(Color.white);
972 g.setFont(new Font("Verdana", Font.BOLD, 14));
973 g.drawString(MessageManager.getString("label.error_loading_file")
974 + "...", 20, currentSize.height / 2);
975 StringBuffer sb = new StringBuffer();
977 for (int e = 0; e < jmb.getPdbCount(); e++)
979 sb.append(jmb.getPdbEntry(e).getId());
980 if (e < jmb.getPdbCount() - 1)
985 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
988 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
989 * g.getFontMetrics().getHeight());
993 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
995 g.setColor(Color.black);
996 g.fillRect(0, 0, currentSize.width, currentSize.height);
997 g.setColor(Color.white);
998 g.setFont(new Font("Verdana", Font.BOLD, 14));
999 g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
1000 20, currentSize.height / 2);
1004 jmb.viewer.renderScreenImage(g, currentSize.width,
1005 currentSize.height);
1010 public void updateTitleAndMenus()
1012 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1017 setChainMenuItems(jmb.chainNames);
1019 this.setTitle(jmb.getViewerTitle());
1020 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1022 viewerActionMenu.setVisible(true);
1024 if (!jmb.isLoadingFromArchive())
1026 seqColour_actionPerformed(null);
1034 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1038 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1040 alignStructs_withAllAlignPanels();
1043 private void alignStructs_withAllAlignPanels()
1045 if (getAlignmentPanel() == null)
1050 if (_alignwith.size() == 0)
1052 _alignwith.add(getAlignmentPanel());
1057 AlignmentI[] als = new Alignment[_alignwith.size()];
1058 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1059 int[] alm = new int[_alignwith.size()];
1062 for (AlignmentPanel ap : _alignwith)
1064 als[a] = ap.av.getAlignment();
1066 alc[a++] = ap.av.getColumnSelection();
1068 jmb.superposeStructures(als, alm, alc);
1069 } catch (Exception e)
1071 StringBuffer sp = new StringBuffer();
1072 for (AlignmentPanel ap : _alignwith)
1074 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1076 Cache.log.info("Couldn't align structures with the " + sp.toString()
1077 + "associated alignment panels.", e);
1084 public void setJalviewColourScheme(ColourSchemeI ucs)
1086 jmb.setJalviewColourScheme(ucs);
1093 * @return first alignment panel displaying given alignment, or the default
1096 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1098 for (AlignmentPanel ap : getAllAlignmentPanels())
1100 if (ap.av.getAlignment() == alignment)
1105 return getAlignmentPanel();
1109 public AAStructureBindingModel getBinding()
1115 public String getStateInfo()
1117 return jmb == null ? null : jmb.viewer.getStateInfo();
1121 public ViewerType getViewerType()
1123 return ViewerType.JMOL;
1127 protected AAStructureBindingModel getBindingModel()