/**
*
*/
package jSimMacs.display;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;
import jSimMacs.jmol.JSimJmolTranslator;
import jSimMacs.jmol.StructureCommandField;
import jSimMacs.jmol.StructurePanel;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import org.biojava.bio.structure.Structure;
import org.biojava.bio.structure.io.PDBFileReader;
/**
* @author sr
*
*/
public class PDBViewer extends JPanel {
private StructurePanel structurePanel;
private StructureCommandField commandField;
private SelectionDisplayPanel selectionPanel;
private JSimJmolTranslator translator;
private File pdbFile;
private Structure structure;
public PDBViewer(File pdbFile) {
this.pdbFile = pdbFile;
initPanel();
}
private void initPanel() {
this.setLayout(new BorderLayout());
structurePanel = new StructurePanel();
try {
openFile();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
return;
}
translator = new JSimJmolTranslator();
structurePanel.addJmolStatusListener(translator);
structurePanel.addJmolSelectionListener(translator);
commandField = new StructureCommandField(structurePanel);
selectionPanel = new SelectionDisplayPanel(structurePanel, structure, translator);
translator.addSequenceListener(selectionPanel);
JPanel southPanel = new JPanel();
southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS));
southPanel.add(commandField);
southPanel.add(Box.createRigidArea(new Dimension(0,5)));
southPanel.add(selectionPanel);
this.add(BorderLayout.CENTER, structurePanel);
this.add(BorderLayout.SOUTH, southPanel);
}
public void openFile() throws IOException {
PDBFileReader pdbReader = new PDBFileReader();
structure = null;
structure = pdbReader.getStructure(pdbFile);
structurePanel.setStructure(structure);
}
/**
* @return the pdbFile
*/
public File getPdbFile() {
return pdbFile;
}
/**
* @param pdbFile
* the pdbFile to set
*/
public void setPdbFile(File pdbFile) {
this.pdbFile = pdbFile;
}
}