IPseudoAtom pseudoAtom = container.getBuilder().newInstance(IPseudoAtom.class, atomName); if (prevAtom.getPoint2d() != null) { pseudoAtom.setPoint2d(prevAtom.getPoint2d());
IPseudoAtom pseudoAtom = container.getBuilder().newInstance(IPseudoAtom.class, atomName); if (prevAtom.getPoint2d() != null) { pseudoAtom.setPoint2d(prevAtom.getPoint2d());
/** * Labels the atom at the specified index with the provide label. If the * atom was not already a pseudo atom then the original atom is replaced. * * @param container structure * @param index atom index to replace * @param label the label for the atom * @see IPseudoAtom#setLabel(String) */ static void label(final IAtomContainer container, final int index, final String label) { final IAtom atom = container.getAtom(index); final IPseudoAtom pseudoAtom = atom instanceof IPseudoAtom ? (IPseudoAtom) atom : container.getBuilder() .newInstance(IPseudoAtom.class); if (atom.equals(pseudoAtom)) { pseudoAtom.setLabel(label); } else { pseudoAtom.setSymbol(label); pseudoAtom.setAtomicNumber(0); pseudoAtom.setPoint2d(atom.getPoint2d()); pseudoAtom.setPoint3d(atom.getPoint3d()); pseudoAtom.setMassNumber(atom.getMassNumber()); pseudoAtom.setFormalCharge(atom.getFormalCharge()); pseudoAtom.setValency(atom.getValency()); pseudoAtom.setLabel(label); // XXX: would be faster to track all replacements and do it all in one AtomContainerManipulator.replaceAtomByAtom(container, atom, pseudoAtom); } }
/** * Labels the atom at the specified index with the provide label. If the * atom was not already a pseudo atom then the original atom is replaced. * * @param container structure * @param index atom index to replace * @param label the label for the atom * @see IPseudoAtom#setLabel(String) */ static void label(final IAtomContainer container, final int index, final String label) { final IAtom atom = container.getAtom(index); final IPseudoAtom pseudoAtom = atom instanceof IPseudoAtom ? (IPseudoAtom) atom : container.getBuilder() .newInstance(IPseudoAtom.class); if (atom.equals(pseudoAtom)) { pseudoAtom.setLabel(label); } else { pseudoAtom.setSymbol(label); pseudoAtom.setAtomicNumber(0); pseudoAtom.setPoint2d(atom.getPoint2d()); pseudoAtom.setPoint3d(atom.getPoint3d()); pseudoAtom.setMassNumber(atom.getMassNumber()); pseudoAtom.setFormalCharge(atom.getFormalCharge()); pseudoAtom.setValency(atom.getValency()); pseudoAtom.setLabel(label); // XXX: would be faster to track all replacements and do it all in one AtomContainerManipulator.replaceAtomByAtom(container, atom, pseudoAtom); } }