/** * Called by objects to which this object has * registered as a listener. * *@param event A change event pointing to the source of the change */ @Override public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); }
/** * Adds a single electron to this AtomContainer. * *@param singleElectron The SingleElectron to added to this container */ @Override public void addSingleElectron(ISingleElectron singleElectron) { if (singleElectronCount >= singleElectrons.length) growSingleElectronArray(); singleElectrons[singleElectronCount] = singleElectron; ++singleElectronCount; notifyChanged(); }
/** * Adds a Bond to this AtomContainer. * *@param bond The bond to added to this container */ @Override public void addBond(IBond bond) { if (bondCount >= bonds.length) growBondArray(); bonds[bondCount] = bond; ++bondCount; notifyChanged(); }
/** * Adds a lone pair to this AtomContainer. * *@param lonePair The LonePair to added to this container */ @Override public void addLonePair(ILonePair lonePair) { if (lonePairCount >= lonePairs.length) growLonePairArray(); lonePairs[lonePairCount] = lonePair; ++lonePairCount; notifyChanged(); }
/** * Sets the array of atoms of this AtomContainer. * *@param atoms The array of atoms to be assigned to this AtomContainer *@see #getAtom */ @Override public void setAtoms(IAtom[] atoms) { this.atoms = atoms; for (IAtom atom : atoms) { atom.addListener(this); } this.atomCount = atoms.length; notifyChanged(); }
/** * Removes the lone pair at the given position from the AtomContainer. * *@param position The position of the LonePair to be removed. */ @Override public ILonePair removeLonePair(int position) { ILonePair lp = lonePairs[position]; lp.removeListener(this); for (int i = position; i < lonePairCount - 1; i++) { lonePairs[i] = lonePairs[i + 1]; } lonePairs[lonePairCount - 1] = null; lonePairCount--; notifyChanged(); return lp; }
/** * Removes the atom at the given position from the AtomContainer. Note that * the electronContainers are unaffected: you also have to take care of * removing all electronContainers to this atom from the container manually. * *@param position The position of the atom to be removed. */ @Override public void removeAtomOnly(int position) { atoms[position].removeListener(this); for (int i = position; i < atomCount - 1; i++) { atoms[i] = atoms[i + 1]; } atoms[atomCount - 1] = null; atomCount--; notifyChanged(); }
/** * Removes the bond at the given position from the AtomContainer. * *@param position The position of the bond to be removed. */ @Override public IBond removeBond(int position) { IBond bond = bonds[position]; bond.removeListener(this); for (int i = position; i < bondCount - 1; i++) { bonds[i] = bonds[i + 1]; } bonds[bondCount - 1] = null; bondCount--; notifyChanged(); return bond; }
/** * Removes the single electron at the given position from the AtomContainer. * *@param position The position of the SingleElectron to be removed. */ @Override public ISingleElectron removeSingleElectron(int position) { ISingleElectron se = singleElectrons[position]; se.removeListener(this); for (int i = position; i < singleElectronCount - 1; i++) { singleElectrons[i] = singleElectrons[i + 1]; } singleElectrons[singleElectronCount - 1] = null; singleElectronCount--; notifyChanged(); return se; }
/** * Removes all Bonds from this container. */ @Override public void removeAllBonds() { for (int f = 0; f < getBondCount(); f++) { getBond(f).removeListener(this); } bonds = new IBond[growArraySize]; bondCount = 0; notifyChanged(); }
/** * 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(); }
/** * Removes all atoms and bond from this container. */ @Override public void removeAllElements() { removeAllElectronContainers(); for (int f = 0; f < getAtomCount(); f++) { getAtom(f).removeListener(this); } atoms = new IAtom[growArraySize]; atomCount = 0; notifyChanged(); }
/** * Removes electronContainers from this container. */ @Override public void removeAllElectronContainers() { removeAllBonds(); for (int f = 0; f < getLonePairCount(); f++) { getLonePair(f).removeListener(this); } for (int f = 0; f < getSingleElectronCount(); f++) { getSingleElectron(f).removeListener(this); } lonePairs = new ILonePair[growArraySize]; singleElectrons = new ISingleElectron[growArraySize]; lonePairCount = 0; singleElectronCount = 0; notifyChanged(); }
notifyChanged(); } else { throw new IllegalArgumentException("AtomContainer is not of type QueryAtomContainer");