diff --git a/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java b/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java index 7268bb402f..7ec042d6fd 100644 --- a/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java +++ b/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java @@ -670,7 +670,8 @@ public static IAtomContainer suppressHydrogens(IAtomContainer org) { // we need fast adjacency checks (to check for suppression and // update hydrogen counts) - final int[][] graph = GraphUtil.toAdjList(org); + GraphUtil.EdgeToBondMap bondmap = GraphUtil.EdgeToBondMap.withSpaceFor(org); + final int[][] graph = GraphUtil.toAdjList(org, bondmap); final int nOrgAtoms = org.getAtomCount(); final int nOrgBonds = org.getBondCount(); @@ -685,7 +686,7 @@ public static IAtomContainer suppressHydrogens(IAtomContainer org) { // be suppressed for (int v = 0; v < nOrgAtoms; v++) { final IAtom atom = org.getAtom(v); - if (suppressibleHydrogen(org, graph, v)) { + if (suppressibleHydrogen(org, graph, bondmap, v)) { hydrogens.add(atom); incrementImplHydrogenCount(org.getAtom(graph[v][0])); } else { @@ -891,7 +892,7 @@ private static void incrementImplHydrogenCount(final IAtom atom) { * @param v vertex (atom index) * @return the atom is a hydrogen and it can be suppressed (implicit) */ - private static boolean suppressibleHydrogen(final IAtomContainer container, final int[][] graph, final int v) { + private static boolean suppressibleHydrogen(final IAtomContainer container, final int[][] graph, final GraphUtil.EdgeToBondMap bondmap, final int v) { IAtom atom = container.getAtom(v); @@ -903,6 +904,8 @@ private static boolean suppressibleHydrogen(final IAtomContainer container, fina if (atom.getMassNumber() != null && atom.getMassNumber() != 1) return false; // hydrogen is either not attached to 0 or 2 neighbors if (graph[v].length != 1) return false; + // non-single bond + if (bondmap.get(v, graph[v][0]).getOrder() != Order.SINGLE) return false; // okay the hydrogen has one neighbor, if that neighbor is a // hydrogen (i.e. molecular hydrogen) then we can not suppress it diff --git a/display/render/src/main/java/org/openscience/cdk/renderer/SymbolVisibility.java b/display/render/src/main/java/org/openscience/cdk/renderer/SymbolVisibility.java index dc8ed6131b..c6ad88be0c 100644 --- a/display/render/src/main/java/org/openscience/cdk/renderer/SymbolVisibility.java +++ b/display/render/src/main/java/org/openscience/cdk/renderer/SymbolVisibility.java @@ -128,10 +128,12 @@ public boolean visible(IAtom atom, List bonds, RendererModel model) { if (mass != null && !isMajorIsotope(element.number(), mass)) return true; // no kink between bonds to imply the presence of a carbon and it must - // be displayed - if (hasParallelBonds(atom, bonds)) { - // TODO only when both bonds are single? - return true; + // be displayed if the bonds have the same bond order + if (bonds.size() == 2 && + bonds.get(0).getOrder() == bonds.get(1).getOrder()) { + IBond.Order bndord = bonds.get(0).getOrder(); + if (bndord == IBond.Order.DOUBLE || hasParallelBonds(atom, bonds)) + return true; } // special case ethane