001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.nbio.structure.align.gui;
022
023import org.biojava.nbio.structure.Structure;
024import org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol;
025import org.biojava.nbio.structure.io.PDBFileReader;
026
027import javax.swing.*;
028import java.awt.event.ActionEvent;
029import java.awt.event.ActionListener;
030import java.io.File;
031
032public class MyOpenPdbFileListener
033implements ActionListener {
034        @Override
035        public void actionPerformed(ActionEvent e) {
036                String cmd = e.getActionCommand();
037                if ( cmd.equals("Open PDB file")){
038                        final JFileChooser fc = new JFileChooser();
039
040                        //                                      In response to a button click:
041                        int returnVal = fc.showOpenDialog(null);
042                        if ( returnVal == JFileChooser.APPROVE_OPTION) {
043                                File file = fc.getSelectedFile();
044
045                                PDBFileReader reader = new PDBFileReader();
046                                try {
047                                        Structure s = reader.getStructure(file);
048                                        StructureAlignmentJmol jmol = new StructureAlignmentJmol(null,null,null);
049                                        jmol.setStructure(s);
050
051                                        jmol.evalString("set antialiasDisplay on; select all;spacefill off; wireframe off; backbone off; cartoon;color cartoon chain; select ligand;wireframe 0.16;spacefill 0.5; select all; color cartoon structure;");
052                                        jmol.evalString("save STATE state_1");
053                                } catch (Exception ex){
054                                        ex.printStackTrace();
055                                }
056
057
058                        }
059                }
060        }
061}
062