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.ActionListener;
54 import java.awt.event.ItemEvent;
55 import java.awt.event.ItemListener;
56 import java.io.BufferedReader;
58 import java.io.FileOutputStream;
59 import java.io.FileReader;
60 import java.io.IOException;
61 import java.io.PrintWriter;
62 import java.util.ArrayList;
63 import java.util.List;
64 import java.util.Vector;
66 import javax.swing.JCheckBoxMenuItem;
67 import javax.swing.JColorChooser;
68 import javax.swing.JInternalFrame;
69 import javax.swing.JMenu;
70 import javax.swing.JMenuItem;
71 import javax.swing.JOptionPane;
72 import javax.swing.JPanel;
73 import javax.swing.JSplitPane;
74 import javax.swing.SwingUtilities;
75 import javax.swing.event.InternalFrameAdapter;
76 import javax.swing.event.InternalFrameEvent;
77 import javax.swing.event.MenuEvent;
78 import javax.swing.event.MenuListener;
80 public class AppJmol extends StructureViewerBase
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, 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 * add a single PDB structure to a new or existing Jmol view
257 public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
258 final AlignmentPanel ap)
260 progressBar = ap.alignFrame;
261 String pdbId = pdbentry.getId();
264 * If the PDB file is already loaded, the user may just choose to add to an
265 * existing viewer (or cancel)
267 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
273 * Check if there are other Jmol views involving this alignment and prompt
274 * user about adding this molecule to one of them
276 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
282 * If the options above are declined or do not apply, open a new viewer
284 openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
288 * Answers true if this viewer already involves the given PDB ID
291 protected boolean hasPdbId(String pdbId)
293 return jmb.hasPdbId(pdbId);
296 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
299 progressBar = ap.alignFrame;
300 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
301 pdbentrys, seqs, null, null);
302 addAlignmentPanel(ap);
303 useAlignmentPanelForColourbyseq(ap);
304 if (pdbentrys.length > 1)
306 alignAddedStructures = true;
307 useAlignmentPanelForSuperposition(ap);
309 jmb.setColourBySequence(true);
310 setSize(400, 400); // probably should be a configurable/dynamic default here
314 addingStructures = false;
315 worker = new Thread(this);
318 this.addInternalFrameListener(new InternalFrameAdapter()
321 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
330 * create a new Jmol containing several structures superimposed using the
337 public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
339 openNewJmol(ap, pe, seqs);
343 * Returns a list of any Jmol viewers. The list is restricted to those linked
344 * to the given alignment panel if it is not null.
347 protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
349 List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
350 JInternalFrame[] frames = Desktop.instance.getAllFrames();
352 for (JInternalFrame frame : frames)
354 if (frame instanceof AppJmol)
357 || ((StructureViewerBase) frame).isLinkedWith(apanel))
359 result.add((StructureViewerBase) frame);
366 void initJmol(String command)
368 jmb.setFinishedInit(false);
369 renderPanel = new RenderPanel();
370 // TODO: consider waiting until the structure/view is fully loaded before
372 this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
373 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
374 getBounds().width, getBounds().height);
375 if (scriptWindow == null)
377 BorderLayout bl = new BorderLayout();
380 scriptWindow = new JPanel(bl);
381 scriptWindow.setVisible(false);
385 * -i for no info logging (less verbose)
387 jmb.allocateViewer(renderPanel, true, "", null, null, "-i",
389 // jmb.newJmolPopup("Jmol");
394 jmb.evalStateCommand(command);
395 jmb.evalStateCommand("set hoverDelay=0.1");
396 jmb.setFinishedInit(true);
399 void setChainMenuItems(Vector<String> chains)
401 chainMenu.removeAll();
406 JMenuItem menuItem = new JMenuItem(
407 MessageManager.getString("label.all"));
408 menuItem.addActionListener(new ActionListener()
411 public void actionPerformed(ActionEvent evt)
413 allChainsSelected = true;
414 for (int i = 0; i < chainMenu.getItemCount(); i++)
416 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
418 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
422 allChainsSelected = false;
426 chainMenu.add(menuItem);
428 for (String chain : chains)
430 menuItem = new JCheckBoxMenuItem(chain, true);
431 menuItem.addItemListener(new ItemListener()
434 public void itemStateChanged(ItemEvent evt)
436 if (!allChainsSelected)
443 chainMenu.add(menuItem);
447 boolean allChainsSelected = false;
451 Vector<String> toshow = new Vector<String>();
452 for (int i = 0; i < chainMenu.getItemCount(); i++)
454 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
456 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
457 if (item.isSelected())
459 toshow.addElement(item.getText());
463 jmb.centerViewer(toshow);
467 public void closeViewer(boolean closeExternalViewer)
469 // Jmol does not use an external viewer
474 setAlignmentPanel(null);
478 // TODO: check for memory leaks where instance isn't finalised because jmb
479 // holds a reference to the window
489 List<String> files = fetchPdbFiles();
490 if (files.size() > 0)
492 showFilesInViewer(files);
502 * Either adds the given files to a structure viewer or opens a new viewer to
506 * list of absolute paths to structure files
508 void showFilesInViewer(List<String> files)
510 long lastnotify = jmb.getLoadNotifiesHandled();
511 StringBuilder fileList = new StringBuilder();
512 for (String s : files)
514 fileList.append(SPACE).append(BACKSLASH)
515 .append(Platform.escapeString(s)).append(BACKSLASH);
517 String filesString = fileList.toString();
519 if (!addingStructures)
523 initJmol("load FILES " + filesString);
524 } catch (OutOfMemoryError oomerror)
526 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
527 Cache.log.debug("File locations are " + filesString);
528 } catch (Exception ex)
530 Cache.log.error("Couldn't open Jmol viewer!", ex);
535 StringBuilder cmd = new StringBuilder();
536 cmd.append("loadingJalviewdata=true\nload APPEND ");
537 cmd.append(filesString);
538 cmd.append("\nloadingJalviewdata=null");
539 final String command = cmd.toString();
540 lastnotify = jmb.getLoadNotifiesHandled();
544 jmb.evalStateCommand(command);
545 } catch (OutOfMemoryError oomerror)
547 new OOMWarning("When trying to add structures to the Jmol viewer!",
549 Cache.log.debug("File locations are " + filesString);
550 } catch (Exception ex)
552 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
556 // need to wait around until script has finished
557 int waitMax = 5000; // give up after 5 seconds
560 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
561 : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
562 .getPdbFile().length == files.size()))
566 Cache.log.debug("Waiting around for jmb notify.");
567 Thread.sleep(waitFor);
568 waitTotal += waitFor;
569 } catch (Exception e)
572 if (waitTotal > waitMax)
574 System.err.println("Timed out waiting for Jmol to load files");
579 // refresh the sequence colours for the new structure(s)
580 for (AlignmentPanel ap : _colourwith)
582 jmb.updateColours(ap);
584 // do superposition if asked to
585 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
587 alignAddedStructures();
589 addingStructures = false;
593 * Queues a thread to align structures with Jalview alignments
595 void alignAddedStructures()
597 javax.swing.SwingUtilities.invokeLater(new Runnable()
602 if (jmb.viewer.isScriptExecuting())
604 SwingUtilities.invokeLater(this);
608 } catch (InterruptedException q)
615 alignStructs_withAllAlignPanels();
619 alignAddedStructures = false;
623 * Retrieves and saves as file any modelled PDB entries for which we do not
624 * already have a file saved. Returns a list of absolute paths to structure
625 * files which were either retrieved, or already stored but not modelled in
626 * the structure viewer (i.e. files to add to the viewer display).
630 List<String> fetchPdbFiles()
632 // todo - record which pdbids were successfully imported.
633 StringBuilder errormsgs = new StringBuilder();
635 List<String> files = new ArrayList<String>();
639 String[] filesInViewer = jmb.getPdbFile();
640 // TODO: replace with reference fetching/transfer code (validate PDBentry
642 Pdb pdbclient = new Pdb();
643 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
645 String file = jmb.getPdbEntry(pi).getFile();
648 // retrieve the pdb and store it locally
649 AlignmentI pdbseq = null;
650 pdbid = jmb.getPdbEntry(pi).getId();
651 long hdl = pdbid.hashCode() - System.currentTimeMillis();
652 if (progressBar != null)
654 progressBar.setProgressBar(MessageManager.formatMessage(
655 "status.fetching_pdb", new String[] { pdbid }), hdl);
659 pdbseq = pdbclient.getSequenceRecords(pdbid);
660 } catch (OutOfMemoryError oomerror)
662 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
663 } catch (Exception ex)
665 ex.printStackTrace();
666 errormsgs.append("'").append(pdbid).append("'");
669 if (progressBar != null)
671 progressBar.setProgressBar(
672 MessageManager.getString("label.state_completed"),
678 // just transfer the file name from the first sequence's first
680 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
681 .elementAt(0).getFile()).getAbsolutePath();
682 jmb.getPdbEntry(pi).setFile(file);
687 errormsgs.append("'").append(pdbid).append("' ");
692 if (filesInViewer != null && filesInViewer.length > 0)
694 addingStructures = true; // already files loaded.
695 for (int c = 0; c < filesInViewer.length; c++)
697 if (filesInViewer[c].equals(file))
710 } catch (OutOfMemoryError oomerror)
712 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
713 } catch (Exception ex)
715 ex.printStackTrace();
716 errormsgs.append("When retrieving pdbfiles : current was: '")
717 .append(pdbid).append("'");
719 if (errormsgs.length() > 0)
721 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
722 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
723 new String[] { errormsgs.toString() }),
724 MessageManager.getString("label.couldnt_load_file"),
725 JOptionPane.ERROR_MESSAGE);
731 public void pdbFile_actionPerformed(ActionEvent actionEvent)
733 JalviewFileChooser chooser = new JalviewFileChooser(
734 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
736 chooser.setFileView(new JalviewFileView());
737 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
738 chooser.setToolTipText(MessageManager.getString("action.save"));
740 int value = chooser.showSaveDialog(this);
742 if (value == JalviewFileChooser.APPROVE_OPTION)
744 BufferedReader in = null;
747 // TODO: cope with multiple PDB files in view
748 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
749 File outFile = chooser.getSelectedFile();
751 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
753 while ((data = in.readLine()) != null)
755 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
761 } catch (Exception ex)
763 ex.printStackTrace();
771 } catch (IOException e)
781 public void viewMapping_actionPerformed(ActionEvent actionEvent)
783 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
786 cap.appendText(jmb.printMappings());
787 } catch (OutOfMemoryError e)
790 "composing sequence-structure alignments for display in text box.",
795 jalview.gui.Desktop.addInternalFrame(cap,
796 MessageManager.getString("label.pdb_sequence_mapping"), 550,
801 public void eps_actionPerformed(ActionEvent e)
803 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
807 public void png_actionPerformed(ActionEvent e)
809 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
812 void makePDBImage(jalview.util.ImageMaker.TYPE type)
814 int width = getWidth();
815 int height = getHeight();
817 jalview.util.ImageMaker im;
819 if (type == jalview.util.ImageMaker.TYPE.PNG)
821 im = new jalview.util.ImageMaker(this,
822 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
823 width, height, null, null, null, 0, false);
825 else if (type == jalview.util.ImageMaker.TYPE.EPS)
827 im = new jalview.util.ImageMaker(this,
828 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
829 width, height, null, this.getTitle(), null, 0, false);
834 im = new jalview.util.ImageMaker(this,
835 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
836 width, height, null, this.getTitle(), null, 0, false);
839 if (im.getGraphics() != null)
841 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
847 public void viewerColour_actionPerformed(ActionEvent actionEvent)
849 if (viewerColour.isSelected())
851 // disable automatic sequence colouring.
852 jmb.setColourBySequence(false);
857 public void seqColour_actionPerformed(ActionEvent actionEvent)
859 jmb.setColourBySequence(seqColour.isSelected());
860 if (_colourwith == null)
862 _colourwith = new Vector<AlignmentPanel>();
864 if (jmb.isColourBySequence())
866 if (!jmb.isLoadingFromArchive())
868 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
870 // Make the currently displayed alignment panel the associated view
871 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
874 // Set the colour using the current view for the associated alignframe
875 for (AlignmentPanel ap : _colourwith)
877 jmb.colourBySequence(ap);
883 public void chainColour_actionPerformed(ActionEvent actionEvent)
885 chainColour.setSelected(true);
890 public void chargeColour_actionPerformed(ActionEvent actionEvent)
892 chargeColour.setSelected(true);
893 jmb.colourByCharge();
897 public void zappoColour_actionPerformed(ActionEvent actionEvent)
899 zappoColour.setSelected(true);
900 jmb.setJalviewColourScheme(new ZappoColourScheme());
904 public void taylorColour_actionPerformed(ActionEvent actionEvent)
906 taylorColour.setSelected(true);
907 jmb.setJalviewColourScheme(new TaylorColourScheme());
911 public void hydroColour_actionPerformed(ActionEvent actionEvent)
913 hydroColour.setSelected(true);
914 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
918 public void helixColour_actionPerformed(ActionEvent actionEvent)
920 helixColour.setSelected(true);
921 jmb.setJalviewColourScheme(new HelixColourScheme());
925 public void strandColour_actionPerformed(ActionEvent actionEvent)
927 strandColour.setSelected(true);
928 jmb.setJalviewColourScheme(new StrandColourScheme());
932 public void turnColour_actionPerformed(ActionEvent actionEvent)
934 turnColour.setSelected(true);
935 jmb.setJalviewColourScheme(new TurnColourScheme());
939 public void buriedColour_actionPerformed(ActionEvent actionEvent)
941 buriedColour.setSelected(true);
942 jmb.setJalviewColourScheme(new BuriedColourScheme());
946 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
948 setJalviewColourScheme(new PurinePyrimidineColourScheme());
952 public void userColour_actionPerformed(ActionEvent actionEvent)
954 userColour.setSelected(true);
955 new UserDefinedColours(this, null);
959 public void backGround_actionPerformed(ActionEvent actionEvent)
961 java.awt.Color col = JColorChooser
962 .showDialog(this, MessageManager
963 .getString("label.select_backgroud_colour"), null);
966 jmb.setBackgroundColour(col);
971 public void showHelp_actionPerformed(ActionEvent actionEvent)
975 jalview.util.BrowserLauncher
976 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
977 } catch (Exception ex)
982 public void showConsole(boolean showConsole)
987 if (splitPane == null)
989 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
990 splitPane.setTopComponent(renderPanel);
991 splitPane.setBottomComponent(scriptWindow);
992 this.getContentPane().add(splitPane, BorderLayout.CENTER);
993 splitPane.setDividerLocation(getHeight() - 200);
994 scriptWindow.setVisible(true);
995 scriptWindow.validate();
996 splitPane.validate();
1002 if (splitPane != null)
1004 splitPane.setVisible(false);
1009 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
1015 class RenderPanel extends JPanel
1017 final Dimension currentSize = new Dimension();
1020 public void paintComponent(Graphics g)
1022 getSize(currentSize);
1024 if (jmb != null && jmb.fileLoadingError != null)
1026 g.setColor(Color.black);
1027 g.fillRect(0, 0, currentSize.width, currentSize.height);
1028 g.setColor(Color.white);
1029 g.setFont(new Font("Verdana", Font.BOLD, 14));
1030 g.drawString(MessageManager.getString("label.error_loading_file")
1031 + "...", 20, currentSize.height / 2);
1032 StringBuffer sb = new StringBuffer();
1034 for (int e = 0; e < jmb.getPdbCount(); e++)
1036 sb.append(jmb.getPdbEntry(e).getId());
1037 if (e < jmb.getPdbCount() - 1)
1042 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
1045 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
1046 * g.getFontMetrics().getHeight());
1050 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
1052 g.setColor(Color.black);
1053 g.fillRect(0, 0, currentSize.width, currentSize.height);
1054 g.setColor(Color.white);
1055 g.setFont(new Font("Verdana", Font.BOLD, 14));
1056 g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
1057 20, currentSize.height / 2);
1061 jmb.viewer.renderScreenImage(g, currentSize.width,
1062 currentSize.height);
1067 public void updateTitleAndMenus()
1069 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1074 setChainMenuItems(jmb.chainNames);
1076 this.setTitle(jmb.getViewerTitle());
1077 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1079 viewerActionMenu.setVisible(true);
1081 if (!jmb.isLoadingFromArchive())
1083 seqColour_actionPerformed(null);
1091 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1095 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1097 alignStructs_withAllAlignPanels();
1100 private void alignStructs_withAllAlignPanels()
1102 if (getAlignmentPanel() == null)
1107 if (_alignwith.size() == 0)
1109 _alignwith.add(getAlignmentPanel());
1114 AlignmentI[] als = new Alignment[_alignwith.size()];
1115 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1116 int[] alm = new int[_alignwith.size()];
1119 for (AlignmentPanel ap : _alignwith)
1121 als[a] = ap.av.getAlignment();
1123 alc[a++] = ap.av.getColumnSelection();
1125 jmb.superposeStructures(als, alm, alc);
1126 } catch (Exception e)
1128 StringBuffer sp = new StringBuffer();
1129 for (AlignmentPanel ap : _alignwith)
1131 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1133 Cache.log.info("Couldn't align structures with the " + sp.toString()
1134 + "associated alignment panels.", e);
1141 public void setJalviewColourScheme(ColourSchemeI ucs)
1143 jmb.setJalviewColourScheme(ucs);
1150 * @return first alignment panel displaying given alignment, or the default
1153 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1155 for (AlignmentPanel ap : getAllAlignmentPanels())
1157 if (ap.av.getAlignment() == alignment)
1162 return getAlignmentPanel();
1166 public AAStructureBindingModel getBinding()
1172 public String getStateInfo()
1174 return jmb == null ? null : jmb.viewer.getStateInfo();
1178 public ViewerType getViewerType()
1180 return ViewerType.JMOL;
1184 protected AAStructureBindingModel getBindingModel()