/** * True, if the AtomContainer contains the given ElectronContainer object. * *@param electronContainer ElectronContainer that is searched for *@return true if the AtomContainer contains the given bond object */ @Override public boolean contains(IElectronContainer electronContainer) { if (electronContainer instanceof IBond) return contains((IBond) electronContainer); if (electronContainer instanceof ILonePair) return contains((ILonePair) electronContainer); if (electronContainer instanceof ISingleElectron) return contains((ISingleElectron) electronContainer); return false; }
/** * Adds an atom to this container. * *@param atom The atom to be added to this container */ @Override public void addAtom(IAtom atom) { if (contains(atom)) { return; } if (atomCount + 1 >= atoms.length) { growAtomArray(); } atom.addListener(this); atoms[atomCount] = atom; atomCount++; notifyChanged(); }
if (atomContainer instanceof QueryAtomContainer) { for (int f = 0; f < atomContainer.getAtomCount(); f++) { if (!contains(atomContainer.getAtom(f))) { addAtom(atomContainer.getAtom(f)); if (!contains(atomContainer.getBond(f))) { addBond(atomContainer.getBond(f)); if (!contains(atomContainer.getLonePair(f))) { addLonePair(atomContainer.getLonePair(f)); if (!contains(atomContainer.getSingleElectron(f))) { addSingleElectron(atomContainer.getSingleElectron(f));
/** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder *@param stereo Stereochemical orientation */ @Override public void addBond(int atom1, int atom2, IBond.Order order, IBond.Stereo stereo) { IBond bond = getBuilder().newInstance(IBond.class, getAtom(atom1), getAtom(atom2), order, stereo); if (contains(bond)) { return; } if (bondCount >= bonds.length) { growBondArray(); } addBond(bond); /* * no notifyChanged() here because addBond(bond) does it already */ }