From: Egon W. <eg...@us...> - 2003-08-27 18:59:56
|
Update of /cvsroot/cdk/cdk/src/org/openscience/cdk/layout In directory sc8-pr-cvs1:/tmp/cvs-serv20151/src/org/openscience/cdk/layout Modified Files: StructureDiagramGenerator.java Log Message: Added experimental method to generate coordinates which first deletes the hydrogens, then does the layout, and then adds the hydrogens again, and lays out those. BUT, it does not remember yet how many hydrogens it needs to add again, which should be the same as the number it removed. Index: StructureDiagramGenerator.java =================================================================== RCS file: /cvsroot/cdk/cdk/src/org/openscience/cdk/layout/StructureDiagramGenerator.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- StructureDiagramGenerator.java 5 Aug 2003 11:27:11 -0000 1.13 +++ StructureDiagramGenerator.java 22 Aug 2003 15:00:46 -0000 1.14 @@ -129,6 +129,39 @@ return molecule; } + /** + * This method uses generateCoordinates, but it removes the hydrogens first, + * lays out the structuren and then adds them again. Note that it will add hydrogens + * based on CDK's idea on how many hydrogens should be attached, and not as many + * as were removed. + * + * <p>The method is rather experimental. + * + * @see @generateCoordinates + */ + public void generateExperimentalCoordinates() throws java.lang.Exception { + generateCoordinates(new Vector2d(0, 1)); + } + + public void generateExperimentalCoordinates(Vector2d firstBondVector) throws java.lang.Exception { + // delete atoms + Atom[] atoms = molecule.getAtoms(); + for (int j=0; j<atoms.length; j++) { + logger.debug("Checking atom: " + j); + if (atoms[j].getSymbol().equals("H")) { + logger.debug("Atom is a hydrogen"); + molecule.removeAtomAndConnectedElectronContainers(atoms[j]); + } + } + // do layout + generateCoordinates(firstBondVector); + // add hydrogens + new HydrogenAdder().addExplicitHydrogensToSatisfyValency(molecule); + // create coordinates for new hydrogens + double bondLength = GeometryTools.getBondLengthAverage(molecule); + HydrogenPlacer.placeHydrogens2D(molecule, bondLength); + } + /** * The main method of this StructurDiagramGenerator. * Assign a molecule to the StructurDiagramGenerator, call |