/** * Configures atoms in an AtomContainer to * carry all the correct data according to their element type. * *@param container The AtomContainer to be configured */ public void configureAtoms(IAtomContainer container) { for (int f = 0; f < container.getAtomCount(); f++) { configure(container.getAtom(f)); } }
/** * Configures atoms in an AtomContainer to * carry all the correct data according to their element type. * *@param container The AtomContainer to be configured */ public void configureAtoms(IAtomContainer container) { for (int f = 0; f < container.getAtomCount(); f++) { configure(container.getAtom(f)); } }
/** * Configures an atom. Finds the correct element type * by looking at the atoms element symbol. If the element symbol is not recognised, it will * throw an {@link IllegalArgumentException}. * * @param atom The atom to be configured * @return The configured atom */ public IAtom configure(IAtom atom) { IIsotope isotope; if (atom.getMassNumber() == null) return atom; else isotope = getIsotope(atom.getSymbol(), atom.getMassNumber()); if (isotope == null) throw new IllegalArgumentException("Cannot configure an unrecognized element/mass: " + atom.getMassNumber() + " " + atom); return configure(atom, isotope); }
/** * Configures an atom. Finds the correct element type * by looking at the atoms element symbol. If the element symbol is not recognised, it will * throw an {@link IllegalArgumentException}. * * @param atom The atom to be configured * @return The configured atom */ public IAtom configure(IAtom atom) { IIsotope isotope; if (atom.getMassNumber() == null) return atom; else isotope = getIsotope(atom.getSymbol(), atom.getMassNumber()); if (isotope == null) throw new IllegalArgumentException("Cannot configure an unrecognized element/mass: " + atom.getMassNumber() + " " + atom); return configure(atom, isotope); }
public void undo() throws CannotUndoException { this.atom.setSymbol(formerSymbol); try { IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder()); this.atom.setMassNumber(ifac.getMajorIsotope(formerSymbol).getMassNumber()); chemModelRelay.updateAtom(atom); ifac.configure(atom); } catch (OptionalDataException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void redo() throws CannotRedoException { this.atom.setSymbol(symbol); try { IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder()); this.atom.setMassNumber(ifac.getMajorIsotope(symbol).getMassNumber()); chemModelRelay.updateAtom(atom); ifac.configure(atom); } catch (OptionalDataException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void fixHydrogenIsotopes(IAtomContainer molecule, IsotopeFactory isotopeFactory) { for (IAtom atom : AtomContainerManipulator.getAtomArray(molecule)) { if (atom instanceof IPseudoAtom) { IPseudoAtom pseudo = (IPseudoAtom) atom; if ("D".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 2)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } else if ("T".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 3)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } } } }
private void fixHydrogenIsotopes(IAtomContainer molecule, IsotopeFactory isotopeFactory) { for (IAtom atom : AtomContainerManipulator.getAtomArray(molecule)) { if (atom instanceof IPseudoAtom) { IPseudoAtom pseudo = (IPseudoAtom) atom; if ("D".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 2)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } else if ("T".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 3)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } } } }
IsotopeFactory isotopeFactory = Isotopes.getInstance(); if (isotopeFactory.isElement(element)) { atom = isotopeFactory.configure(builder.newInstance(IAtom.class, element)); } else if ("A".equals(element)) { atom = builder.newInstance(IPseudoAtom.class, element);
IsotopeFactory isotopeFactory = Isotopes.getInstance(); if (isotopeFactory.isElement(element)) { atom = isotopeFactory.configure(builder.newInstance(IAtom.class, element)); } else if ("A".equals(element)) { atom = builder.newInstance(IPseudoAtom.class, element);
atom = isotopeFactory.configure(molecule.getBuilder().newInstance(IAtom.class, element)); } else if ("A".equals(element)) { atom = molecule.getBuilder().newInstance(IPseudoAtom.class, element);
if (isotopeFactory.isElement(element)) { atom.setSymbol(element); isotopeFactory.configure(atom); // ? } else if ("A".equals(element)) { atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);