108108 */
109109public class StructureDiagramGenerator {
110110
111- private static final double DEFAULT_BOND_LENGTH = 1.5 ;
111+ static final double DEFAULT_BOND_LENGTH = 1.5 ;
112112 private static final Vector2d DEFAULT_BOND_VECTOR = new Vector2d (0 , 1 );
113113 private static final IdentityTemplateLibrary DEFAULT_TEMPLATE_LIBRARY = IdentityTemplateLibrary .loadFromResource ("custom-templates.smi" )
114114 .add (IdentityTemplateLibrary .loadFromResource ("chebi-ring-templates.smi" ));
@@ -893,9 +893,9 @@ private void refinePlacement(IAtomContainer molecule) {
893893 }
894894 }
895895
896- // no attachment point, rorate to maximise horizontal spread etc.
896+ // no attachment point, rotate to maximise horizontal spread etc.
897897 if (begAttach == null ) {
898- selectOrientation (molecule , 2 * DEFAULT_BOND_LENGTH , 1 );
898+ selectOrientation (molecule , DEFAULT_BOND_LENGTH , 1 );
899899 }
900900 // use attachment point bond to rotate
901901 else {
@@ -964,6 +964,7 @@ private static void selectOrientation(IAtomContainer mol, double widthDiff, int
964964
965965
966966 double maxWidth = minmax [2 ] - minmax [0 ];
967+ double begWidth = maxWidth ;
967968 int maxAligned = countAlignedBonds (mol );
968969
969970 Point2d [] coords = new Point2d [mol .getAtomCount ()];
@@ -978,11 +979,11 @@ private static void selectOrientation(IAtomContainer mol, double widthDiff, int
978979 minmax = GeometryUtil .getMinMax (mol );
979980
980981 double width = minmax [2 ] - minmax [0 ];
981- double delta = Math .abs (width - maxWidth );
982+ double delta = Math .abs (width - begWidth );
982983
983984 // if this orientation is significantly wider than the
984985 // best so far select it
985- if (delta > widthDiff && width > maxWidth ) {
986+ if (delta >= widthDiff && width > maxWidth ) {
986987 maxWidth = width ;
987988 for (int j = 0 ; j < mol .getAtomCount (); j ++)
988989 coords [j ] = new Point2d (mol .getAtom (j ).getPoint2d ());
0 commit comments