//package nt; import javax.swing.*; import java.awt.*; import java.net.URL; import java.awt.event.*; import java.applet.*; public class P35 extends JPanel implements ActionListener { JTextPane salida; JScrollPane ssalida; JPanel botpanel; JButton B1, B2, B3; JLabel l1; MoleculaT M1, M2, M3; String inf; public P35 (MoleculaT A, MoleculaT B, MoleculaT C) { M1 = A; M2 = B; M3 = C; setLayout (new BorderLayout ()); salida = new JTextPane (); salida.setEditable (false); Font fon = new Font ("Courier", 1, 12); salida.setFont (fon); inf = ""; ssalida = new JScrollPane (salida); ssalida.setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); ssalida.setBorder (BorderFactory. createCompoundBorder (BorderFactory.createTitledBorder ("Output PDB structure"), BorderFactory.createEtchedBorder (1))); botpanel = new JPanel (); botpanel.setLayout (new FlowLayout ()); B1 = new JButton ("Heterojunction"); B1.addActionListener (this); botpanel.add (B1); B2 = new JButton ("Single-Walled Nanotube"); B2.addActionListener (this); botpanel.add (B2); B3 = new JButton ("Multi-Walled Nanotube"); B3.addActionListener (this); botpanel.add (B3); l1 = new JLabel ("The ouput is also echoed in the Java console. If you cannot copy the text from here, copy the PDB from the Java console."); add (l1, BorderLayout.NORTH); add (ssalida, BorderLayout.CENTER); add (botpanel, BorderLayout.SOUTH); } public void actionPerformed (ActionEvent ev) { String etiq = ev.getActionCommand (); if (etiq == "Heterojunction") { inf = M1.getInfo (); printpdb (M1); } else if (etiq == "Single-Walled Nanotube") { inf = M2.getInfo (); printpdb (M2); } else if (etiq == "Multi-Walled Nanotube") { inf = M3.getInfo (); printpdb (M3); } } public void printpdb (String s) { salida.setText (s + " " + this.getRootPane ().getUIClassID ()); } public void printpdb (MoleculaT mol) { formato fo = new formato (8, "#0.000"); formato fdec = new formato (7, "#0.000"); //para los doble precision formato fi = new formato (5, "#####"); //para los enteros StringBuffer pdb = new StringBuffer ("REMARK ==============================================================================\n" + "REMARK " + inf + "\n" + "REMARK File generated by CoNTub 1.0 build 22. July 26th 2004\n" + "REMARK Cite as: S.Melchor, J.A. Dobado. J. Chem. Inf. Comp. Sci. 44, 1639-1646 (2004)\n" + "AUTHOR Software available at http://www.ugr.es/local/gmdm/java/contub/contub.html\n" + "AUTHOR For questions and comments: http://www.ugr.es/local/gmdm\n" + "REMARK ==============================================================================\n"); Minimol mmol = new Minimol (mol); for (int i = 0; i < mmol.nvert; i++) { String lab = mmol.minietiqs[i]; pdb.append ("HETATM" + fi.aCadena (i + 1) + " " + lab + " " + fi.aCadena (i + 1) + " " + fdec.aCadena (mmol.miniverts[i].x) + fdec.aCadena (mmol.miniverts[i].y) + fdec.aCadena (mmol.miniverts[i].z) + "\n"); } for (int i = 0; i < mmol.nvert; i++) //CONECTIVIDAD { pdb.append ("CONECT" + fi.aCadena (i + 1)); for (int j = 1; j <= mmol.miniconec[i][0]; j++) pdb.append (fi.aCadena (mmol.miniconec[i][j] + 1)); pdb.append ("\n"); } pdb = pdb.append ("END"); if (mmol.nvert >= 1) { salida.setText (pdb + ""); System.out.print (pdb + ""); } else if (mmol.nvert == 0) salida.setText ("Hmm.. It seems there is no molecule at all. Just use the Create Button"); else salida.setText ("Error raro"); } }