Skip to content

Instantly share code, notes, and snippets.

IRenderingElement diagram = this.generator.generate(atomCon);
double width = bounds.getWidth();
this.dy = bounds.getCenterY();
// draw once
this.dx = bounds.getCenterX() - (width / 4);
diagram.accept(this);
// draw again
this.dx += (width / 2);
@gilleain
gilleain / gist:47967
Created January 16, 2009 15:36
SMILES to JCP in one line
//create a molecule from a smiles, generate 2D coords, and load it into jcp in one line
ui.open(cdk.generate2dCoordinates(cdk.fromSMILES("C1=C(=O)CC=C(N)C1")), "net.bioclipse.cdk.ui.editors.jchempaint")
// replace the molecule with a new one (cubane)
jcp.setModel(cdk.generate2dCoordinates(cdk.fromSMILES("C12C3C4C1C5C4C3C25")))
@gilleain
gilleain / alter_jchempaint.js
Created January 23, 2009 17:15
make and save a benzene, then fuse it with another
// showing off the scripting potential of the jchempaint editor
// create a benzene ring, and save it in the /Vitrual folder
cdk.saveMolecule(cdk.generate2dCoordinates(cdk.fromSMILES("c1ccccc1")), "/Virtual/benzene.cml")
// open this file in a jchempaint editor
ui.open("/Virtual/benzene.cml")
// fuse this benzene with another
jcp.addPhenyl(jcp.getModel().atomContainer.getBond(0))
// in one line
jcp.getRenderingOptions().setBondWidth(2)
// save for multiple use
r = jcp.getRenderingOptions()
r.setIsCompact(true)
// use properties instead of get/set
r.wedgeWidth = 2
import java.awt.Color;
import javax.vecmath.Point2d;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.renderer.RendererModel;
import org.openscience.cdk.renderer.elements.ElementGroup;
import org.openscience.cdk.renderer.elements.IRenderingElement;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
public void clone(IAtomContainer source, IAtomContainer target) {
for (int i = 0; i < source.getAtomCount(); i++) {
IAtom atom = (IAtom) source.getAtom(i).clone();
target.addAtom(atom);
}
for (IBond bond : source.bonds()) {
IBond newBond = (IBond)bond.clone();
IAtom[] newAtoms = new IAtom[bond.getAtomCount()];
for (int j = 0; j < bond.getAtomCount(); ++j) {
package tailor.app;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
package stereo;
import java.util.ArrayList;
import java.util.List;
import org.openscience.cdk.graph.invariant.MorganNumbersTools;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomParity;
package stereo;
import java.util.List;
import org.junit.Assert;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomParity;