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.ext.rbvi.chimera.JalviewChimeraBinding;
30 import jalview.gui.StructureViewer.ViewerType;
31 import jalview.io.DataSourceType;
32 import jalview.io.JalviewFileChooser;
33 import jalview.io.JalviewFileView;
34 import jalview.io.StructureFile;
35 import jalview.schemes.BuriedColourScheme;
36 import jalview.schemes.ColourSchemeI;
37 import jalview.schemes.HelixColourScheme;
38 import jalview.schemes.HydrophobicColourScheme;
39 import jalview.schemes.PurinePyrimidineColourScheme;
40 import jalview.schemes.StrandColourScheme;
41 import jalview.schemes.TaylorColourScheme;
42 import jalview.schemes.TurnColourScheme;
43 import jalview.schemes.ZappoColourScheme;
44 import jalview.structures.models.AAStructureBindingModel;
45 import jalview.util.MessageManager;
46 import jalview.util.Platform;
47 import jalview.ws.dbsources.Pdb;
49 import java.awt.event.ActionEvent;
50 import java.awt.event.ItemEvent;
51 import java.awt.event.ItemListener;
52 import java.io.BufferedReader;
54 import java.io.FileInputStream;
55 import java.io.FileOutputStream;
56 import java.io.FileReader;
57 import java.io.IOException;
58 import java.io.InputStream;
59 import java.io.PrintWriter;
60 import java.util.ArrayList;
61 import java.util.List;
62 import java.util.Random;
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.event.InternalFrameAdapter;
70 import javax.swing.event.InternalFrameEvent;
71 import javax.swing.event.MenuEvent;
72 import javax.swing.event.MenuListener;
75 * GUI elements for handling an external chimera display
80 public class ChimeraViewFrame extends StructureViewerBase
82 private JalviewChimeraBinding jmb;
84 private boolean allChainsSelected = false;
86 private IProgressIndicator progressBar = null;
89 * Path to Chimera session file. This is set when an open Jalview/Chimera
90 * session is saved, or on restore from a Jalview project (if it holds the
91 * filename of any saved Chimera sessions).
93 private String chimeraSessionFile = null;
95 private Random random = new Random();
98 * Initialise menu options.
100 private void initMenus()
102 viewerActionMenu.setText(MessageManager.getString("label.chimera"));
103 viewerColour.setText(MessageManager
104 .getString("label.colour_with_chimera"));
105 viewerColour.setToolTipText(MessageManager
106 .getString("label.let_chimera_manage_structure_colours"));
107 helpItem.setText(MessageManager.getString("label.chimera_help"));
108 seqColour.setSelected(jmb.isColourBySequence());
109 viewerColour.setSelected(!jmb.isColourBySequence());
110 if (_colourwith == null)
112 _colourwith = new Vector<AlignmentPanel>();
114 if (_alignwith == null)
116 _alignwith = new Vector<AlignmentPanel>();
119 // save As not yet implemented
120 savemenu.setVisible(false);
122 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
123 MessageManager.getString("label.colour_by"), this, _colourwith,
127 public void itemStateChanged(ItemEvent e)
129 if (!seqColour.isSelected())
135 // update the Chimera display now.
136 seqColour_actionPerformed(null);
140 viewMenu.add(seqColourBy);
141 viewMenu.add(fitToWindow);
143 final ItemListener handler;
144 JMenu alpanels = new ViewSelectionMenu(
145 MessageManager.getString("label.superpose_with"), this,
146 _alignwith, handler = new ItemListener()
149 public void itemStateChanged(ItemEvent e)
151 alignStructs.setEnabled(_alignwith.size() > 0);
152 alignStructs.setToolTipText(MessageManager
154 "label.align_structures_using_linked_alignment_views",
155 new Object[] { new Integer(_alignwith
156 .size()).toString() }));
159 handler.itemStateChanged(null);
160 viewerActionMenu.add(alpanels);
161 viewerActionMenu.addMenuListener(new MenuListener()
165 public void menuSelected(MenuEvent e)
167 handler.itemStateChanged(null);
171 public void menuDeselected(MenuEvent e)
173 // TODO Auto-generated method stub
177 public void menuCanceled(MenuEvent e)
179 // TODO Auto-generated method stub
185 * add a single PDB structure to a new or existing Chimera view
192 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
193 String[] chains, final AlignmentPanel ap)
196 String pdbId = pdbentry.getId();
199 * If the PDB file is already loaded, the user may just choose to add to an
200 * existing viewer (or cancel)
202 if (addAlreadyLoadedFile(seq, chains, ap, pdbId))
208 * Check if there are other Chimera views involving this alignment and give
209 * user the option to add and align this molecule to one of them (or cancel)
211 if (addToExistingViewer(pdbentry, seq, chains, ap, pdbId))
217 * If the options above are declined or do not apply, show the structure in
220 openNewChimera(ap, new PDBEntry[] { pdbentry },
221 new SequenceI[][] { seq });
225 * Create a helper to manage progress bar display
227 protected void createProgressBar()
229 if (progressBar == null)
231 progressBar = new ProgressBar(statusPanel, statusBar);
236 * Answers true if this viewer already involves the given PDB ID
239 protected boolean hasPdbId(String pdbId)
241 return jmb.hasPdbId(pdbId);
244 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
248 // FIXME extractChains needs pdbentries to match IDs to PDBEntry(s) on seqs
249 jmb = new JalviewChimeraBindingModel(this,
250 ap.getStructureSelectionManager(), pdbentrys, seqs, null);
251 addAlignmentPanel(ap);
252 useAlignmentPanelForColourbyseq(ap);
253 if (pdbentrys.length > 1)
255 alignAddedStructures = true;
256 useAlignmentPanelForSuperposition(ap);
258 jmb.setColourBySequence(true);
259 setSize(400, 400); // probably should be a configurable/dynamic default here
262 addingStructures = false;
263 worker = new Thread(this);
266 this.addInternalFrameListener(new InternalFrameAdapter()
269 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
280 * Create a new viewer from saved session state data including Chimera session
283 * @param chimeraSessionFile
287 * @param colourByChimera
288 * @param colourBySequence
291 public ChimeraViewFrame(String chimeraSessionFile,
292 AlignmentPanel alignPanel, PDBEntry[] pdbArray,
293 SequenceI[][] seqsArray, boolean colourByChimera,
294 boolean colourBySequence, String newViewId)
297 setViewId(newViewId);
298 this.chimeraSessionFile = chimeraSessionFile;
299 openNewChimera(alignPanel, pdbArray, seqsArray);
302 jmb.setColourBySequence(false);
303 seqColour.setSelected(false);
304 viewerColour.setSelected(true);
306 else if (colourBySequence)
308 jmb.setColourBySequence(true);
309 seqColour.setSelected(true);
310 viewerColour.setSelected(false);
315 * create a new viewer containing several structures superimposed using the
322 public ChimeraViewFrame(PDBEntry[] pe, SequenceI[][] seqs,
326 openNewChimera(ap, pe, seqs);
330 * Default constructor
332 public ChimeraViewFrame()
337 * closeViewer will decide whether or not to close this frame
338 * depending on whether user chooses to Cancel or not
340 setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
345 * Launch Chimera. If we have a chimera session file name, send Chimera the
346 * command to open its saved session file.
350 jmb.setFinishedInit(false);
351 jalview.gui.Desktop.addInternalFrame(this,
352 jmb.getViewerTitle("Chimera", true), getBounds().width,
355 if (!jmb.launchChimera())
357 JvOptionPane.showMessageDialog(Desktop.desktop,
358 MessageManager.getString("label.chimera_failed"),
359 MessageManager.getString("label.error_loading_file"),
360 JvOptionPane.ERROR_MESSAGE);
365 if (this.chimeraSessionFile != null)
367 boolean opened = jmb.openSession(chimeraSessionFile);
371 .println("An error occurred opening Chimera session file "
372 + chimeraSessionFile);
375 jmb.setFinishedInit(true);
377 jmb.startChimeraListener();
382 * Show only the selected chain(s) in the viewer
385 void showSelectedChains()
387 List<String> toshow = new ArrayList<String>();
388 for (int i = 0; i < chainMenu.getItemCount(); i++)
390 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
392 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
393 if (item.isSelected())
395 toshow.add(item.getText());
399 jmb.showChains(toshow);
403 * Close down this instance of Jalview's Chimera viewer, giving the user the
404 * option to close the associated Chimera window (process). They may wish to
405 * keep it open until they have had an opportunity to save any work.
407 * @param forceCloseChimera
408 * if true, close any linked Chimera process; if false, prompt first
411 public void closeViewer(boolean forceCloseChimera)
415 if (jmb.isChimeraRunning())
418 * force close, or prompt to close, Chimera
420 if (!forceCloseChimera)
422 String prompt = MessageManager.formatMessage(
423 "label.confirm_close_chimera",
424 new Object[] { jmb.getViewerTitle("Chimera", false) });
425 prompt = JvSwingUtils.wrapTooltip(true, prompt);
426 int confirm = JvOptionPane.showConfirmDialog(this, prompt,
427 MessageManager.getString("label.close_viewer"),
428 JvOptionPane.YES_NO_CANCEL_OPTION);
430 * abort closure if user hits escape or Cancel
432 if (confirm == JvOptionPane.CANCEL_OPTION
433 || confirm == JvOptionPane.CLOSED_OPTION)
437 forceCloseChimera = confirm == JvOptionPane.YES_OPTION;
442 * close the viewer plus any side-effects e.g. remove mappings
443 * note we do this also if closing Chimera triggered this method
445 jmb.closeViewer(forceCloseChimera);
448 setAlignmentPanel(null);
452 // TODO: check for memory leaks where instance isn't finalised because jmb
453 // holds a reference to the window
459 * Open any newly added PDB structures in Chimera, having first fetched data
460 * from PDB (if not already saved).
466 // todo - record which pdbids were successfully imported.
467 StringBuilder errormsgs = new StringBuilder(128);
468 StringBuilder files = new StringBuilder(128);
469 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
470 List<Integer> filePDBpos = new ArrayList<Integer>();
471 PDBEntry thePdbEntry = null;
472 StructureFile pdb = null;
475 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
476 // TODO: replace with reference fetching/transfer code (validate PDBentry
478 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
481 thePdbEntry = jmb.getPdbEntry(pi);
482 if (thePdbEntry.getFile() == null)
485 * Retrieve PDB data, save to file, attach to PDBEntry
487 file = fetchPdbFile(thePdbEntry);
490 errormsgs.append("'" + thePdbEntry.getId() + "' ");
496 * Got file already - ignore if already loaded in Chimera.
498 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
500 if (curfiles != null && curfiles.length > 0)
502 addingStructures = true; // already files loaded.
503 for (int c = 0; c < curfiles.length; c++)
505 if (curfiles[c].equals(file))
515 filePDB.add(thePdbEntry);
516 filePDBpos.add(Integer.valueOf(pi));
517 files.append(" \"" + Platform.escapeString(file) + "\"");
520 } catch (OutOfMemoryError oomerror)
522 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
524 } catch (Exception ex)
526 ex.printStackTrace();
527 errormsgs.append("When retrieving pdbfiles for '"
528 + thePdbEntry.getId() + "'");
530 if (errormsgs.length() > 0)
533 JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
534 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
535 new Object[] { errormsgs.toString() }),
536 MessageManager.getString("label.couldnt_load_file"),
537 JvOptionPane.ERROR_MESSAGE);
540 if (files.length() > 0)
542 if (!addingStructures)
547 } catch (Exception ex)
549 Cache.log.error("Couldn't open Chimera viewer!", ex);
553 for (PDBEntry pe : filePDB)
556 if (pe.getFile() != null)
560 int pos = filePDBpos.get(num).intValue();
561 long startTime = startProgressBar("Chimera "
562 + MessageManager.getString("status.opening_file_for")
565 jmb.addSequence(pos, jmb.getSequence()[pos]);
566 File fl = new File(pe.getFile());
567 DataSourceType protocol = DataSourceType.URL;
572 protocol = DataSourceType.FILE;
574 } catch (Throwable e)
578 stopProgressBar("", startTime);
580 // Explicitly map to the filename used by Chimera ;
581 pdb = jmb.getSsm().setMapping(jmb.getSequence()[pos],
582 jmb.getChains()[pos], pe.getFile(), protocol);
583 stashFoundChains(pdb, pe.getFile());
584 } catch (OutOfMemoryError oomerror)
587 "When trying to open and map structures from Chimera!",
589 } catch (Exception ex)
591 Cache.log.error("Couldn't open " + pe.getFile()
592 + " in Chimera viewer!", ex);
595 Cache.log.debug("File locations are " + files);
600 jmb.setFinishedInit(true);
601 jmb.setLoadingFromArchive(false);
603 // refresh the sequence colours for the new structure(s)
604 for (AlignmentPanel ap : _colourwith)
606 jmb.updateColours(ap);
608 // do superposition if asked to
609 if (Cache.getDefault("AUTOSUPERIMPOSE", true) && alignAddedStructures)
611 new Thread(new Runnable()
616 alignStructs_withAllAlignPanels();
619 alignAddedStructures = false;
621 addingStructures = false;
628 * Fetch PDB data and save to a local file. Returns the full path to the file,
629 * or null if fetch fails.
631 * @param processingEntry
636 private void stashFoundChains(StructureFile pdb, String file)
638 for (int i = 0; i < pdb.getChains().size(); i++)
640 String chid = new String(pdb.getId() + ":"
641 + pdb.getChains().elementAt(i).id);
642 jmb.getChainNames().add(chid);
643 jmb.getChainFile().put(chid, file);
646 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
648 // FIXME: this is duplicated code with Jmol frame ?
649 String filePath = null;
650 Pdb pdbclient = new Pdb();
651 AlignmentI pdbseq = null;
652 String pdbid = processingEntry.getId();
653 long handle = System.currentTimeMillis()
654 + Thread.currentThread().hashCode();
657 * Write 'fetching PDB' progress on AlignFrame as we are not yet visible
659 String msg = MessageManager.formatMessage("status.fetching_pdb",
660 new Object[] { pdbid });
661 getAlignmentPanel().alignFrame.setProgressBar(msg, handle);
662 // long hdl = startProgressBar(MessageManager.formatMessage(
663 // "status.fetching_pdb", new Object[]
667 pdbseq = pdbclient.getSequenceRecords(pdbid);
668 } catch (OutOfMemoryError oomerror)
670 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
673 msg = pdbid + " " + MessageManager.getString("label.state_completed");
674 getAlignmentPanel().alignFrame.setProgressBar(msg, handle);
675 // stopProgressBar(msg, hdl);
678 * If PDB data were saved and are not invalid (empty alignment), return the
681 if (pdbseq != null && pdbseq.getHeight() > 0)
683 // just use the file name from the first sequence's first PDBEntry
684 filePath = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
685 .elementAt(0).getFile()).getAbsolutePath();
686 processingEntry.setFile(filePath);
692 * Convenience method to update the progress bar if there is one. Be sure to
693 * call stopProgressBar with the returned handle to remove the message.
698 public long startProgressBar(String msg)
700 // TODO would rather have startProgress/stopProgress as the
701 // IProgressIndicator interface
702 long tm = random.nextLong();
703 if (progressBar != null)
705 progressBar.setProgressBar(msg, tm);
711 * End the progress bar with the specified handle, leaving a message (if not
712 * null) on the status bar
717 public void stopProgressBar(String msg, long handle)
719 if (progressBar != null)
721 progressBar.setProgressBar(msg, handle);
726 public void pdbFile_actionPerformed(ActionEvent actionEvent)
728 JalviewFileChooser chooser = new JalviewFileChooser(
729 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
731 chooser.setFileView(new JalviewFileView());
732 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
733 chooser.setToolTipText(MessageManager.getString("action.save"));
735 int value = chooser.showSaveDialog(this);
737 if (value == JalviewFileChooser.APPROVE_OPTION)
739 BufferedReader in = null;
742 // TODO: cope with multiple PDB files in view
743 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
744 File outFile = chooser.getSelectedFile();
746 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
748 while ((data = in.readLine()) != null)
750 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
756 } catch (Exception ex)
758 ex.printStackTrace();
766 } catch (IOException e)
776 public void viewMapping_actionPerformed(ActionEvent actionEvent)
778 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
781 cap.appendText(jmb.printMappings());
782 } catch (OutOfMemoryError e)
785 "composing sequence-structure alignments for display in text box.",
790 jalview.gui.Desktop.addInternalFrame(cap,
791 MessageManager.getString("label.pdb_sequence_mapping"), 550,
796 public void eps_actionPerformed(ActionEvent e)
800 .getString("error.eps_generation_not_implemented"));
804 public void png_actionPerformed(ActionEvent e)
808 .getString("error.png_generation_not_implemented"));
812 public void viewerColour_actionPerformed(ActionEvent actionEvent)
814 if (viewerColour.isSelected())
816 // disable automatic sequence colouring.
817 jmb.setColourBySequence(false);
822 public void seqColour_actionPerformed(ActionEvent actionEvent)
824 jmb.setColourBySequence(seqColour.isSelected());
825 if (_colourwith == null)
827 _colourwith = new Vector<AlignmentPanel>();
829 if (jmb.isColourBySequence())
831 if (!jmb.isLoadingFromArchive())
833 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
835 // Make the currently displayed alignment panel the associated view
836 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
839 // Set the colour using the current view for the associated alignframe
840 for (AlignmentPanel ap : _colourwith)
842 jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
848 public void chainColour_actionPerformed(ActionEvent actionEvent)
850 chainColour.setSelected(true);
855 public void chargeColour_actionPerformed(ActionEvent actionEvent)
857 chargeColour.setSelected(true);
858 jmb.colourByCharge();
862 public void zappoColour_actionPerformed(ActionEvent actionEvent)
864 zappoColour.setSelected(true);
865 jmb.setJalviewColourScheme(new ZappoColourScheme());
869 public void taylorColour_actionPerformed(ActionEvent actionEvent)
871 taylorColour.setSelected(true);
872 jmb.setJalviewColourScheme(new TaylorColourScheme());
876 public void hydroColour_actionPerformed(ActionEvent actionEvent)
878 hydroColour.setSelected(true);
879 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
883 public void helixColour_actionPerformed(ActionEvent actionEvent)
885 helixColour.setSelected(true);
886 jmb.setJalviewColourScheme(new HelixColourScheme());
890 public void strandColour_actionPerformed(ActionEvent actionEvent)
892 strandColour.setSelected(true);
893 jmb.setJalviewColourScheme(new StrandColourScheme());
897 public void turnColour_actionPerformed(ActionEvent actionEvent)
899 turnColour.setSelected(true);
900 jmb.setJalviewColourScheme(new TurnColourScheme());
904 public void buriedColour_actionPerformed(ActionEvent actionEvent)
906 buriedColour.setSelected(true);
907 jmb.setJalviewColourScheme(new BuriedColourScheme());
911 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
913 setJalviewColourScheme(new PurinePyrimidineColourScheme());
917 public void userColour_actionPerformed(ActionEvent actionEvent)
919 userColour.setSelected(true);
920 new UserDefinedColours(this, null);
924 public void backGround_actionPerformed(ActionEvent actionEvent)
926 java.awt.Color col = JColorChooser
927 .showDialog(this, MessageManager
928 .getString("label.select_backgroud_colour"), null);
931 jmb.setBackgroundColour(col);
936 public void showHelp_actionPerformed(ActionEvent actionEvent)
940 jalview.util.BrowserLauncher
941 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
942 } catch (Exception ex)
947 public void updateTitleAndMenus()
949 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
954 setChainMenuItems(jmb.getChainNames());
956 this.setTitle(jmb.getViewerTitle("Chimera", true));
957 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
959 viewerActionMenu.setVisible(true);
961 if (!jmb.isLoadingFromArchive())
963 seqColour_actionPerformed(null);
971 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
975 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
977 alignStructs_withAllAlignPanels();
980 private void alignStructs_withAllAlignPanels()
982 if (getAlignmentPanel() == null)
987 if (_alignwith.size() == 0)
989 _alignwith.add(getAlignmentPanel());
994 AlignmentI[] als = new Alignment[_alignwith.size()];
995 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
996 int[] alm = new int[_alignwith.size()];
999 for (AlignmentPanel ap : _alignwith)
1001 als[a] = ap.av.getAlignment();
1003 alc[a++] = ap.av.getColumnSelection();
1005 jmb.superposeStructures(als, alm, alc);
1006 } catch (Exception e)
1008 StringBuffer sp = new StringBuffer();
1009 for (AlignmentPanel ap : _alignwith)
1011 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1013 Cache.log.info("Couldn't align structures with the " + sp.toString()
1014 + "associated alignment panels.", e);
1019 public void setJalviewColourScheme(ColourSchemeI ucs)
1021 jmb.setJalviewColourScheme(ucs);
1028 * @return first alignment panel displaying given alignment, or the default
1031 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1033 for (AlignmentPanel ap : getAllAlignmentPanels())
1035 if (ap.av.getAlignment() == alignment)
1040 return getAlignmentPanel();
1044 public AAStructureBindingModel getBinding()
1050 * Ask Chimera to save its session to the designated file path, or to a
1051 * temporary file if the path is null. Returns the file path if successful,
1057 protected String saveSession(String filepath)
1059 String pathUsed = filepath;
1062 if (pathUsed == null)
1064 File tempFile = File.createTempFile("chimera", ".py");
1065 tempFile.deleteOnExit();
1066 pathUsed = tempFile.getPath();
1068 boolean result = jmb.saveSession(pathUsed);
1071 this.chimeraSessionFile = pathUsed;
1074 } catch (IOException e)
1081 * Returns a string representing the state of the Chimera session. This is
1082 * done by requesting Chimera to save its session to a temporary file, then
1083 * reading the file contents. Returns an empty string on any error.
1086 public String getStateInfo()
1088 String sessionFile = saveSession(null);
1089 if (sessionFile == null)
1093 InputStream is = null;
1096 File f = new File(sessionFile);
1097 byte[] bytes = new byte[(int) f.length()];
1098 is = new FileInputStream(sessionFile);
1100 return new String(bytes);
1101 } catch (IOException e)
1111 } catch (IOException e)
1120 protected void fitToWindow_actionPerformed()
1126 public ViewerType getViewerType()
1128 return ViewerType.CHIMERA;
1132 protected AAStructureBindingModel getBindingModel()