Skip to content

Commit

Permalink
Subtle bug, the provision of a start vector means chains were not bei…
Browse files Browse the repository at this point in the history
…ng placed horizontal. By setting the default bond vector as static we can check if the caller has really provided a vector to use. If the default was provided we can now still place the chain horizontal.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Sep 9, 2014
1 parent 06abb91 commit a1f55e9
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -99,7 +99,9 @@ public class StructureDiagramGenerator
private boolean useTemplates = true;
private boolean useIdentTemplates = true;

/** Atoms of the molecule that mapped a template */
public static Vector2d DEFAULT_BOND_VECTOR = new Vector2d(0, 1);

/** Atoms of the molecule that mapped a template */
private IAtomContainerSet mappedSubstructures;

/** Identity templates - for laying out primary ring system. */
Expand Down Expand Up @@ -261,7 +263,7 @@ public IAtomContainer getMolecule()
*/
public void generateExperimentalCoordinates() throws CDKException
{
generateExperimentalCoordinates(new Vector2d(0, 1));
generateExperimentalCoordinates(DEFAULT_BOND_VECTOR);
}


Expand Down Expand Up @@ -456,7 +458,7 @@ public void generateCoordinates(Vector2d firstBondVector) throws CDKException
*/
angle = Math.toRadians(-30);
logger.debug("Attempting to place the first bond such that the whole chain will be horizontally alligned on the x axis");
if (firstBondVector != null)
if (firstBondVector != null && firstBondVector != DEFAULT_BOND_VECTOR)
atomPlacer.placeLinearChain(longestChain, firstBondVector, bondLength);
else
atomPlacer.placeLinearChain(longestChain, new Vector2d(Math.cos(angle), Math.sin(angle)), bondLength);
Expand Down Expand Up @@ -504,7 +506,7 @@ public void generateCoordinates(Vector2d firstBondVector) throws CDKException
*/
public void generateCoordinates() throws CDKException
{
generateCoordinates(new Vector2d(0, 1));
generateCoordinates(DEFAULT_BOND_VECTOR);
}

/**
Expand Down

0 comments on commit a1f55e9

Please sign in to comment.