From a1f55e9af3b7504fecd5b2df96a3e07c5459a7cc Mon Sep 17 00:00:00 2001 From: John May Date: Mon, 18 Aug 2014 17:20:18 +0100 Subject: [PATCH] Subtle bug, the provision of a start vector means chains were not being 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 --- .../cdk/layout/StructureDiagramGenerator.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java b/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java index 692bb5c4ae3..15ff2ad7549 100644 --- a/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java +++ b/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java @@ -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. */ @@ -261,7 +263,7 @@ public IAtomContainer getMolecule() */ public void generateExperimentalCoordinates() throws CDKException { - generateExperimentalCoordinates(new Vector2d(0, 1)); + generateExperimentalCoordinates(DEFAULT_BOND_VECTOR); } @@ -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); @@ -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); } /**