私はコンソールにものを出力する次のJavaコードを持っています
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.jmol.adapter.smarter.SmarterJmolAdapter;
import org.jmol.api.JmolViewer;
import org.jmol.util.Logger;
import org.openscience.jmol.app.jmolpanel.AppConsole;
public class Integrate {
public static void main(String[] argv) throws IOException {
JFrame frame = new JFrame("JMOL_WS_V1");
frame.addWindowListener(new ApplicationCloser());
frame.setSize(410, 700);
Container contentPane = frame.getContentPane();
JmolPanel jmolPanel = new JmolPanel();
jmolPanel.setPreferredSize(new Dimension(400, 400));
// main panel -- Jmol panel on top
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(jmolPanel);
// main panel -- console panel on bottom
JPanel panel2 = new JPanel();
panel2.setLayout(new BorderLayout());
panel2.setPreferredSize(new Dimension(400, 300));
AppConsole console = new AppConsole(jmolPanel.viewer, panel2,
"History State Clear");
jmolPanel.viewer.setJmolCallbackListener(console);
panel.add("South", panel2);
contentPane.add(panel);
frame.setVisible(true);
//STARTUP SCRIPT
String strError = jmolPanel.viewer.openFile("1644_____.pdb");
if (strError == null){
//THIS IS THE COMMAND THAT CALCULATES STUFF
jmolPanel.viewer.evalString("measure 3 4");
jmolPanel.viewer.evalString("measure 2 4");
}else{
Logger.error(strError);
}
}
static class ApplicationCloser extends WindowAdapter {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
static class JmolPanel extends JPanel {
JmolViewer viewer;
private final Dimension currentSize = new Dimension();
JmolPanel() {
viewer = JmolViewer.allocateViewer(this, new SmarterJmolAdapter(),
null, null, null, null, null);
}
@Override
public void paint(Graphics g) {
getSize(currentSize);
viewer.renderScreenImage(g, currentSize.width, currentSize.height);
}
}
}
これをコンソールに出力します。
(C) 2012 Jmol Development
Jmol Version: 13.0.12 2013-01-23 21:55
java.vendor: Apple Inc.
java.version: 1.6.0_41
os.name: Mac OS X
Access: ALL
memory: 10.8/85.0
processors available: 4
useCommandThread: false
FileManager.getAtomSetCollectionFromFile(1644_____.pdb)
FileManager opening /Users/juliofdiaz/Dropbox/CF/1644_____.pdb
The Resolver thinks Pdb
openFile(1644_____.pdb): 119 ms
reading 2602 atoms
ModelSet: haveSymmetry:false haveUnitcells:false haveFractionalCoord:false
1 model in this collection. Use getProperty "modelInfo" or getProperty "auxiliaryInfo" to inspect them.
Default Van der Waals type for model set to Jmol
2602 atoms created
Time to autoBond: 58 ms
ModelSet: autobonding; use autobond=false to not generate bonds automatically
Jmol 13.0.12 2013-01-23 21:55 DSSP analysis for model 1.1 - null
W. Kabsch and C. Sander, Biopolymers, vol 22, 1983, pp 2577-2637
We thank Wolfgang Kabsch and Chris Sander for writing the DSSP software,
and we thank the CMBI for maintaining it to the extent that it was easy to
re-engineer for our purposes. At this point in time, we make no guarantee
that this code gives precisely the same analysis as the code available via license
from CMBI at http://swift.cmbi.ru.nl/gv/dssp
All bioshapes have been deleted and must be regenerated.
measurement[0] = [[MET]1.CB #3, [MET]1.C #4, 0.219 nm]
measurement[1] = [[MET]1.CA #2, [MET]1.C #4, 0.143 nm]
このプログラムからのすべての出力を文字列の配列にキャプチャしたいと思います(各文字列項目は各行になります)。このプロセスのBufferedReaderを取得することで遊んだことがありますが、このクラスでの経験が不足しているため、現在のランタイムをプロセスに割り当てる方法がわかりません。アドバイスありがとうございます。