Hi together,
I am new to JMol and I want to use it to visualize results from a
Molecular Fragment Dynamics simulation. The idea is to handle the
fragments as atoms thus I have to define my own elements.
1) Is it possible to define your own elements with their own names,
colors , size(radius/volume), ... using the JMol scripting abilities.
2) I want to use the XYZ-File format to code my fragment data. May I
load several XYZ-Files in a single JMol view.
3) When I use the attached class to access a JMol panel and the
JmolSimpleViewer openStringInline method. I cant see any rendered atoms
although the output console writes that atoms have been created:
The Resolver thinks Xyz
reading 9000 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 Babel
9000 atoms created
Many thanks in advance.
Kind regards,
Andreas
package de.truszkowski.fragment3d;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JPanel;
import org.jmol.adapter.smarter.SmarterJmolAdapter;
import org.jmol.api.JmolAdapter;
import org.jmol.api.JmolSimpleViewer;
public class JmolViewer{
static class JmolPanel extends JPanel {
private static final long serialVersionUID = -3661941083797644242L;
JmolSimpleViewer viewer;
JmolAdapter adapter;
JmolPanel() {
adapter = new SmarterJmolAdapter();
viewer = JmolSimpleViewer.allocateSimpleViewer(this, adapter);
}
public JmolSimpleViewer getViewer() {
return viewer;
}
public void executeCmd(String rasmolScript){
viewer.evalString(rasmolScript);
}
final Dimension currentSize = new Dimension();
final Rectangle rectClip = new Rectangle();
@Override
public void paint(Graphics g) {
getSize(currentSize);
g.getClipBounds(rectClip);
viewer.renderScreenImage(g, currentSize.width, currentSize.height);
}
public void setStructure(String mol) {
// Jmol could also read the file directly from your file system
//viewer.openFile("/Path/To/PDB/1tim.pdb");
// send the PDB file to Jmol.
// there are also other ways to interact with Jmol, but they require
more
// code. See the link to SPICE above...
viewer.openStringInline(mol);
viewer.evalString("select all; color red;");
}
}
private JmolPanel jmolPanel = new JmolPanel();
public JmolViewer() {
try {
} catch (Exception e) {
}
}
public JmolPanel getJMolPanel() {
return new JmolPanel();
}
}package de.truszkowski.fragment3d;
import java.util.Random;
import javax.swing.JDialog;
import junit.framework.TestCase;
/**
*
* @author Andreas Truszkowski
*/
public class Fragment3DTest extends TestCase {
public void test_Fragment3D() {
try {
JDialog fragment3DTest = new JDialog();
fragment3DTest.setSize(800, 600);
JmolViewer viewer = new JmolViewer();
Random rnd = new Random();
StringBuilder strWriter = new StringBuilder();
strWriter.append("9000\n");
strWriter.append("Test\n");
for(int i = 0; i < 4500; i++) {
strWriter.append("C " + (rnd.nextDouble() * 200 - 100) + " " +
(rnd.nextDouble() * 200 - 100)+ " " + (rnd.nextDouble() * 200 - 100) + "\n");
strWriter.append("N " + (rnd.nextDouble() * 200 - 100) + " " +
(rnd.nextDouble() * 200 - 100)+ " " + (rnd.nextDouble() * 200 - 100) + "\n");
}
viewer.getJMolPanel().setStructure(strWriter.toString());
fragment3DTest.add(viewer.getJMolPanel());
fragment3DTest.setVisible(true);
System.out.println();Thread.sleep(1000000);
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
}
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users