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.awt.event.MouseAdapter;
57 import java.awt.event.MouseEvent;
58 import java.io.BufferedReader;
60 import java.io.FileOutputStream;
61 import java.io.FileReader;
62 import java.io.IOException;
63 import java.io.PrintWriter;
64 import java.util.ArrayList;
65 import java.util.List;
66 import java.util.Vector;
68 import javax.swing.JCheckBoxMenuItem;
69 import javax.swing.JColorChooser;
70 import javax.swing.JInternalFrame;
71 import javax.swing.JMenu;
72 import javax.swing.JMenuItem;
73 import javax.swing.JPanel;
74 import javax.swing.JSplitPane;
75 import javax.swing.SwingUtilities;
76 import javax.swing.event.InternalFrameAdapter;
77 import javax.swing.event.InternalFrameEvent;
78 import javax.swing.event.MenuEvent;
79 import javax.swing.event.MenuListener;
81 public class AppJmol extends StructureViewerBase
83 // ms to wait for Jmol to load files
84 private static final int JMOL_LOAD_TIMEOUT = 20000;
86 private static final String SPACE = " ";
88 private static final String BACKSLASH = "\"";
96 RenderPanel renderPanel;
98 ViewSelectionMenu seqColourBy;
107 * - add the alignment panel to the list used for colouring these
110 * - add the alignment panel to the list used for aligning these
112 * @param leaveColouringToJmol
113 * - do not update the colours from any other source. Jmol is
119 public AppJmol(String[] files, String[] ids, SequenceI[][] seqs,
120 AlignmentPanel ap, boolean usetoColour, boolean useToAlign,
121 boolean leaveColouringToJmol, String loadStatus,
122 Rectangle bounds, String viewid)
124 PDBEntry[] pdbentrys = new PDBEntry[files.length];
125 for (int i = 0; i < pdbentrys.length; i++)
127 // PDBEntry pdbentry = new PDBEntry(files[i], ids[i]);
128 PDBEntry pdbentry = new PDBEntry(ids[i], null, PDBEntry.Type.PDB,
130 pdbentrys[i] = pdbentry;
132 // / TODO: check if protocol is needed to be set, and if chains are
134 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
135 pdbentrys, seqs, null);
137 jmb.setLoadingFromArchive(true);
138 addAlignmentPanel(ap);
141 useAlignmentPanelForSuperposition(ap);
143 if (leaveColouringToJmol || !usetoColour)
145 jmb.setColourBySequence(false);
146 seqColour.setSelected(false);
147 viewerColour.setSelected(true);
149 else if (usetoColour)
151 useAlignmentPanelForColourbyseq(ap);
152 jmb.setColourBySequence(true);
153 seqColour.setSelected(true);
154 viewerColour.setSelected(false);
156 this.setBounds(bounds);
159 // jalview.gui.Desktop.addInternalFrame(this, "Loading File",
160 // bounds.width,bounds.height);
162 this.addInternalFrameListener(new InternalFrameAdapter()
165 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
170 initJmol(loadStatus); // pdbentry, seq, JBPCHECK!
174 private void initMenus()
176 String jmol = MessageManager.getString("label.jmol");
177 viewerActionMenu.setText(jmol);
178 seqColour.setSelected(jmb.isColourBySequence());
179 viewerColour.setSelected(!jmb.isColourBySequence());
180 if (_colourwith == null)
182 _colourwith = new Vector<AlignmentPanel>();
184 if (_alignwith == null)
186 _alignwith = new Vector<AlignmentPanel>();
189 seqColourBy = new ViewSelectionMenu(
190 MessageManager.getString("label.colour_by"), this, _colourwith,
195 public void itemStateChanged(ItemEvent e)
197 if (!seqColour.isSelected())
203 // update the jmol display now.
204 seqColour_actionPerformed(null);
208 viewMenu.add(seqColourBy);
209 final ItemListener handler;
210 JMenu alpanels = new ViewSelectionMenu(
211 MessageManager.getString("label.superpose_with"), this,
212 _alignwith, handler = new ItemListener()
216 public void itemStateChanged(ItemEvent e)
218 alignStructs.setEnabled(_alignwith.size() > 0);
219 alignStructs.setToolTipText(MessageManager
221 "label.align_structures_using_linked_alignment_views",
222 new String[] { new Integer(_alignwith
223 .size()).toString() }));
226 handler.itemStateChanged(null);
227 viewerActionMenu.add(alpanels);
228 viewerActionMenu.addMenuListener(new MenuListener()
232 public void menuSelected(MenuEvent e)
234 handler.itemStateChanged(null);
238 public void menuDeselected(MenuEvent e)
240 // TODO Auto-generated method stub
245 public void menuCanceled(MenuEvent e)
247 // TODO Auto-generated method stub
252 JMenuItem writeFeatures = new JMenuItem(
253 MessageManager.getString("label.create_viewer_attributes"));
254 writeFeatures.setToolTipText(MessageManager.formatMessage(
255 "label.create_viewer_attributes_tip", jmol));
256 writeFeatures.addActionListener(new ActionListener()
259 public void actionPerformed(ActionEvent e)
261 sendFeaturesToViewer();
264 viewerActionMenu.add(writeFeatures);
266 final JMenu fetchAttributes = new JMenu(MessageManager.formatMessage(
267 "label.fetch_viewer_attributes", jmol));
268 fetchAttributes.setToolTipText(MessageManager.formatMessage(
269 "label.fetch_viewer_attributes_tip", jmol));
270 fetchAttributes.addMouseListener(new MouseAdapter()
274 public void mouseEntered(MouseEvent e)
276 buildAttributesMenu(fetchAttributes);
279 viewerActionMenu.add(fetchAttributes);
282 IProgressIndicator progressBar = null;
285 * add a single PDB structure to a new or existing Jmol view
292 public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
293 final AlignmentPanel ap)
295 progressBar = ap.alignFrame;
296 String pdbId = pdbentry.getId();
299 * If the PDB file is already loaded, the user may just choose to add to an
300 * existing viewer (or cancel)
302 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
308 * Check if there are other Jmol views involving this alignment and prompt
309 * user about adding this molecule to one of them
311 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
317 * If the options above are declined or do not apply, open a new viewer
319 openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
323 * Answers true if this viewer already involves the given PDB ID
326 protected boolean hasPdbId(String pdbId)
328 return jmb.hasPdbId(pdbId);
331 private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
334 progressBar = ap.alignFrame;
335 jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
336 pdbentrys, seqs, null);
337 addAlignmentPanel(ap);
338 useAlignmentPanelForColourbyseq(ap);
339 if (pdbentrys.length > 1)
341 alignAddedStructures = true;
342 useAlignmentPanelForSuperposition(ap);
344 jmb.setColourBySequence(true);
345 setSize(400, 400); // probably should be a configurable/dynamic default here
347 addingStructures = false;
348 worker = new Thread(this);
351 this.addInternalFrameListener(new InternalFrameAdapter()
354 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
363 * create a new Jmol containing several structures superimposed using the
370 public AppJmol(AlignmentPanel ap, PDBEntry[] pe, SequenceI[][] seqs)
372 openNewJmol(ap, pe, seqs);
376 * Returns a list of any Jmol viewers. The list is restricted to those linked
377 * to the given alignment panel if it is not null.
380 protected List<StructureViewerBase> getViewersFor(AlignmentPanel apanel)
382 List<StructureViewerBase> result = new ArrayList<StructureViewerBase>();
383 JInternalFrame[] frames = Desktop.instance.getAllFrames();
385 for (JInternalFrame frame : frames)
387 if (frame instanceof AppJmol)
390 || ((StructureViewerBase) frame).isLinkedWith(apanel))
392 result.add((StructureViewerBase) frame);
399 void initJmol(String command)
401 jmb.setFinishedInit(false);
402 renderPanel = new RenderPanel();
403 // TODO: consider waiting until the structure/view is fully loaded before
405 this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
406 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
407 getBounds().width, getBounds().height);
408 if (scriptWindow == null)
410 BorderLayout bl = new BorderLayout();
413 scriptWindow = new JPanel(bl);
414 scriptWindow.setVisible(false);
417 jmb.allocateViewer(renderPanel, true, "", null, null, "",
419 // jmb.newJmolPopup("Jmol");
424 jmb.evalStateCommand(command);
425 jmb.evalStateCommand("set hoverDelay=0.1");
426 jmb.setFinishedInit(true);
431 boolean allChainsSelected = false;
434 void showSelectedChains()
436 Vector<String> toshow = new Vector<String>();
437 for (int i = 0; i < chainMenu.getItemCount(); i++)
439 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
441 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
442 if (item.isSelected())
444 toshow.addElement(item.getText());
448 jmb.centerViewer(toshow);
452 public void closeViewer(boolean closeExternalViewer)
454 // Jmol does not use an external viewer
459 setAlignmentPanel(null);
463 // TODO: check for memory leaks where instance isn't finalised because jmb
464 // holds a reference to the window
474 List<String> files = fetchPdbFiles();
475 if (files.size() > 0)
477 showFilesInViewer(files);
487 * Either adds the given files to a structure viewer or opens a new viewer to
491 * list of absolute paths to structure files
493 void showFilesInViewer(List<String> files)
495 long lastnotify = jmb.getLoadNotifiesHandled();
496 StringBuilder fileList = new StringBuilder();
497 for (String s : files)
499 fileList.append(SPACE).append(BACKSLASH)
500 .append(Platform.escapeString(s)).append(BACKSLASH);
502 String filesString = fileList.toString();
504 if (!addingStructures)
508 initJmol("load FILES " + filesString);
509 } catch (OutOfMemoryError oomerror)
511 new OOMWarning("When trying to open the Jmol viewer!", oomerror);
512 Cache.log.debug("File locations are " + filesString);
513 } catch (Exception ex)
515 Cache.log.error("Couldn't open Jmol viewer!", ex);
520 StringBuilder cmd = new StringBuilder();
521 cmd.append("loadingJalviewdata=true\nload APPEND ");
522 cmd.append(filesString);
523 cmd.append("\nloadingJalviewdata=null");
524 final String command = cmd.toString();
525 lastnotify = jmb.getLoadNotifiesHandled();
529 jmb.evalStateCommand(command);
530 } catch (OutOfMemoryError oomerror)
532 new OOMWarning("When trying to add structures to the Jmol viewer!",
534 Cache.log.debug("File locations are " + filesString);
535 } catch (Exception ex)
537 Cache.log.error("Couldn't add files to Jmol viewer!", ex);
541 // need to wait around until script has finished
542 int waitMax = JMOL_LOAD_TIMEOUT;
545 while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
546 : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
547 .getPdbFile().length == files.size()))
551 Cache.log.debug("Waiting around for jmb notify.");
552 Thread.sleep(waitFor);
553 waitTotal += waitFor;
554 } catch (Exception e)
557 if (waitTotal > waitMax)
560 .println("Timed out waiting for Jmol to load files after "
562 // System.err.println("finished: " + jmb.isFinishedInit()
563 // + "; loaded: " + Arrays.toString(jmb.getPdbFile())
564 // + "; files: " + files.toString());
570 // refresh the sequence colours for the new structure(s)
571 for (AlignmentPanel ap : _colourwith)
573 jmb.updateColours(ap);
575 // do superposition if asked to
576 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
578 alignAddedStructures();
580 addingStructures = false;
584 * Queues a thread to align structures with Jalview alignments
586 void alignAddedStructures()
588 javax.swing.SwingUtilities.invokeLater(new Runnable()
593 if (jmb.viewer.isScriptExecuting())
595 SwingUtilities.invokeLater(this);
599 } catch (InterruptedException q)
606 alignStructs_withAllAlignPanels();
610 alignAddedStructures = false;
614 * Retrieves and saves as file any modelled PDB entries for which we do not
615 * already have a file saved. Returns a list of absolute paths to structure
616 * files which were either retrieved, or already stored but not modelled in
617 * the structure viewer (i.e. files to add to the viewer display).
621 List<String> fetchPdbFiles()
623 // todo - record which pdbids were successfully imported.
624 StringBuilder errormsgs = new StringBuilder();
626 List<String> files = new ArrayList<String>();
630 String[] filesInViewer = jmb.getPdbFile();
631 // TODO: replace with reference fetching/transfer code (validate PDBentry
633 Pdb pdbclient = new Pdb();
634 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
636 String file = jmb.getPdbEntry(pi).getFile();
639 // retrieve the pdb and store it locally
640 AlignmentI pdbseq = null;
641 pdbid = jmb.getPdbEntry(pi).getId();
642 long hdl = pdbid.hashCode() - System.currentTimeMillis();
643 if (progressBar != null)
645 progressBar.setProgressBar(MessageManager.formatMessage(
646 "status.fetching_pdb", new String[] { pdbid }), hdl);
650 pdbseq = pdbclient.getSequenceRecords(pdbid);
651 } catch (OutOfMemoryError oomerror)
653 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
654 } catch (Exception ex)
656 ex.printStackTrace();
657 errormsgs.append("'").append(pdbid).append("'");
660 if (progressBar != null)
662 progressBar.setProgressBar(
663 MessageManager.getString("label.state_completed"),
669 // just transfer the file name from the first sequence's first
671 file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
672 .elementAt(0).getFile()).getAbsolutePath();
673 jmb.getPdbEntry(pi).setFile(file);
678 errormsgs.append("'").append(pdbid).append("' ");
683 if (filesInViewer != null && filesInViewer.length > 0)
685 addingStructures = true; // already files loaded.
686 for (int c = 0; c < filesInViewer.length; c++)
688 if (filesInViewer[c].equals(file))
701 } catch (OutOfMemoryError oomerror)
703 new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
704 } catch (Exception ex)
706 ex.printStackTrace();
707 errormsgs.append("When retrieving pdbfiles : current was: '")
708 .append(pdbid).append("'");
710 if (errormsgs.length() > 0)
712 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
713 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
714 new String[] { errormsgs.toString() }),
715 MessageManager.getString("label.couldnt_load_file"),
716 JvOptionPane.ERROR_MESSAGE);
722 public void pdbFile_actionPerformed(ActionEvent actionEvent)
724 JalviewFileChooser chooser = new JalviewFileChooser(
725 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
727 chooser.setFileView(new JalviewFileView());
728 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
729 chooser.setToolTipText(MessageManager.getString("action.save"));
731 int value = chooser.showSaveDialog(this);
733 if (value == JalviewFileChooser.APPROVE_OPTION)
735 BufferedReader in = null;
738 // TODO: cope with multiple PDB files in view
739 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
740 File outFile = chooser.getSelectedFile();
742 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
744 while ((data = in.readLine()) != null)
746 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
752 } catch (Exception ex)
754 ex.printStackTrace();
762 } catch (IOException e)
772 public void viewMapping_actionPerformed(ActionEvent actionEvent)
774 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
777 cap.appendText(jmb.printMappings());
778 } catch (OutOfMemoryError e)
781 "composing sequence-structure alignments for display in text box.",
786 jalview.gui.Desktop.addInternalFrame(cap,
787 MessageManager.getString("label.pdb_sequence_mapping"), 550,
792 public void eps_actionPerformed(ActionEvent e)
794 makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
798 public void png_actionPerformed(ActionEvent e)
800 makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
803 void makePDBImage(jalview.util.ImageMaker.TYPE type)
805 int width = getWidth();
806 int height = getHeight();
808 jalview.util.ImageMaker im;
810 if (type == jalview.util.ImageMaker.TYPE.PNG)
812 im = new jalview.util.ImageMaker(this,
813 jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from view",
814 width, height, null, null, null, 0, false);
816 else if (type == jalview.util.ImageMaker.TYPE.EPS)
818 im = new jalview.util.ImageMaker(this,
819 jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from view",
820 width, height, null, this.getTitle(), null, 0, false);
825 im = new jalview.util.ImageMaker(this,
826 jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
827 width, height, null, this.getTitle(), null, 0, false);
830 if (im.getGraphics() != null)
832 jmb.viewer.renderScreenImage(im.getGraphics(), width, height);
838 public void viewerColour_actionPerformed(ActionEvent actionEvent)
840 if (viewerColour.isSelected())
842 // disable automatic sequence colouring.
843 jmb.setColourBySequence(false);
848 public void seqColour_actionPerformed(ActionEvent actionEvent)
850 jmb.setColourBySequence(seqColour.isSelected());
851 if (_colourwith == null)
853 _colourwith = new Vector<AlignmentPanel>();
855 if (jmb.isColourBySequence())
857 if (!jmb.isLoadingFromArchive())
859 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
861 // Make the currently displayed alignment panel the associated view
862 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
865 // Set the colour using the current view for the associated alignframe
866 for (AlignmentPanel ap : _colourwith)
868 jmb.colourBySequence(ap);
874 public void chainColour_actionPerformed(ActionEvent actionEvent)
876 chainColour.setSelected(true);
881 public void chargeColour_actionPerformed(ActionEvent actionEvent)
883 chargeColour.setSelected(true);
884 jmb.colourByCharge();
888 public void zappoColour_actionPerformed(ActionEvent actionEvent)
890 zappoColour.setSelected(true);
891 jmb.setJalviewColourScheme(new ZappoColourScheme());
895 public void taylorColour_actionPerformed(ActionEvent actionEvent)
897 taylorColour.setSelected(true);
898 jmb.setJalviewColourScheme(new TaylorColourScheme());
902 public void hydroColour_actionPerformed(ActionEvent actionEvent)
904 hydroColour.setSelected(true);
905 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
909 public void helixColour_actionPerformed(ActionEvent actionEvent)
911 helixColour.setSelected(true);
912 jmb.setJalviewColourScheme(new HelixColourScheme());
916 public void strandColour_actionPerformed(ActionEvent actionEvent)
918 strandColour.setSelected(true);
919 jmb.setJalviewColourScheme(new StrandColourScheme());
923 public void turnColour_actionPerformed(ActionEvent actionEvent)
925 turnColour.setSelected(true);
926 jmb.setJalviewColourScheme(new TurnColourScheme());
930 public void buriedColour_actionPerformed(ActionEvent actionEvent)
932 buriedColour.setSelected(true);
933 jmb.setJalviewColourScheme(new BuriedColourScheme());
937 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
939 setJalviewColourScheme(new PurinePyrimidineColourScheme());
943 public void userColour_actionPerformed(ActionEvent actionEvent)
945 userColour.setSelected(true);
946 new UserDefinedColours(this, null);
950 public void backGround_actionPerformed(ActionEvent actionEvent)
952 java.awt.Color col = JColorChooser
953 .showDialog(this, MessageManager
954 .getString("label.select_backgroud_colour"), null);
957 jmb.setBackgroundColour(col);
962 public void showHelp_actionPerformed(ActionEvent actionEvent)
966 jalview.util.BrowserLauncher
967 .openURL("http://jmol.sourceforge.net/docs/JmolUserGuide/");
968 } catch (Exception ex)
973 public void showConsole(boolean showConsole)
978 if (splitPane == null)
980 splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
981 splitPane.setTopComponent(renderPanel);
982 splitPane.setBottomComponent(scriptWindow);
983 this.getContentPane().add(splitPane, BorderLayout.CENTER);
984 splitPane.setDividerLocation(getHeight() - 200);
985 scriptWindow.setVisible(true);
986 scriptWindow.validate();
987 splitPane.validate();
993 if (splitPane != null)
995 splitPane.setVisible(false);
1000 this.getContentPane().add(renderPanel, BorderLayout.CENTER);
1006 class RenderPanel extends JPanel
1008 final Dimension currentSize = new Dimension();
1011 public void paintComponent(Graphics g)
1013 getSize(currentSize);
1015 if (jmb != null && jmb.fileLoadingError != null)
1017 g.setColor(Color.black);
1018 g.fillRect(0, 0, currentSize.width, currentSize.height);
1019 g.setColor(Color.white);
1020 g.setFont(new Font("Verdana", Font.BOLD, 14));
1021 g.drawString(MessageManager.getString("label.error_loading_file")
1022 + "...", 20, currentSize.height / 2);
1023 StringBuffer sb = new StringBuffer();
1025 for (int e = 0; e < jmb.getPdbCount(); e++)
1027 sb.append(jmb.getPdbEntry(e).getId());
1028 if (e < jmb.getPdbCount() - 1)
1033 if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
1036 g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
1037 * g.getFontMetrics().getHeight());
1041 else if (jmb == null || jmb.viewer == null || !jmb.isFinishedInit())
1043 g.setColor(Color.black);
1044 g.fillRect(0, 0, currentSize.width, currentSize.height);
1045 g.setColor(Color.white);
1046 g.setFont(new Font("Verdana", Font.BOLD, 14));
1047 g.drawString(MessageManager.getString("label.retrieving_pdb_data"),
1048 20, currentSize.height / 2);
1052 jmb.viewer.renderScreenImage(g, currentSize.width,
1053 currentSize.height);
1058 public void updateTitleAndMenus()
1060 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1065 setChainMenuItems(jmb.getChainNames());
1067 this.setTitle(jmb.getViewerTitle());
1068 // if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1070 viewerActionMenu.setVisible(true);
1072 if (!jmb.isLoadingFromArchive())
1074 seqColour_actionPerformed(null);
1082 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1086 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1088 alignStructs_withAllAlignPanels();
1091 private void alignStructs_withAllAlignPanels()
1093 if (getAlignmentPanel() == null)
1098 if (_alignwith.size() == 0)
1100 _alignwith.add(getAlignmentPanel());
1105 AlignmentI[] als = new Alignment[_alignwith.size()];
1106 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1107 int[] alm = new int[_alignwith.size()];
1110 for (AlignmentPanel ap : _alignwith)
1112 als[a] = ap.av.getAlignment();
1114 alc[a++] = ap.av.getColumnSelection();
1116 jmb.superposeStructures(als, alm, alc);
1117 } catch (Exception e)
1119 StringBuffer sp = new StringBuffer();
1120 for (AlignmentPanel ap : _alignwith)
1122 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1124 Cache.log.info("Couldn't align structures with the " + sp.toString()
1125 + "associated alignment panels.", e);
1132 public void setJalviewColourScheme(ColourSchemeI ucs)
1134 jmb.setJalviewColourScheme(ucs);
1141 * @return first alignment panel displaying given alignment, or the default
1144 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1146 for (AlignmentPanel ap : getAllAlignmentPanels())
1148 if (ap.av.getAlignment() == alignment)
1153 return getAlignmentPanel();
1157 public AAStructureBindingModel getBinding()
1163 public String getStateInfo()
1165 return jmb == null ? null : jmb.viewer.getStateInfo();
1169 public ViewerType getViewerType()
1171 return ViewerType.JMOL;
1175 protected AAStructureBindingModel getBindingModel()
1181 protected void sendFeaturesToViewer()
1184 * Atom properties may also be set directly using {atom expression}.xxxx = y.
1189 protected void getResidueAttributes(String attName)
1192 * getproperty atominfo returns properties for all atoms
1193 * - could parse this for unique/specific property names?
1195 * _ipt atomID atomIndex atomno bondCount chain clickabilityFlags colix color coord
1196 * element elemno formalCharge groupID info model name occupancy partialCharge
1197 * polymerLength radius resname resno shape spacefill structure sym temp
1198 * visibilityFlags visible x y z
1200 * getproperty chaininfo is residue level info
1201 * no sign of average bfactor for a residue :-(
1206 protected List<String> getResidueAttributeNames()
1208 // TODO Auto-generated method stub