private BaseAtomRef newAtomRef(IAtom atom) { // most common implementation we'll encounter.. if (atom.getClass() == Atom.class) return new BaseAtomRef(this, atom); atom = unbox(atom); // re-check the common case now we've un-boxed if (atom.getClass() == Atom.class) { return new BaseAtomRef(this, atom); } else if (atom instanceof IPseudoAtom) { return new PsuedoAtomRef(this, (IPseudoAtom) atom); } else if (atom instanceof IQueryAtom) { return new QueryAtomRef(this, (IQueryAtom) atom); } else if (atom instanceof IPDBAtom) { return new PdbAtomRef(this, (IPDBAtom) atom); } else { return new BaseAtomRef(this, atom); } }
BaseAtomRef org = atoms[idx]; atoms[idx] = rep; atoms[idx].setIndex(idx); for (IBond bond : new ArrayList<>(org.bonds)) { if (bond.getBegin().equals(org)) if (org.equals(ec.getAtom())) ec.setAtom(rep); if (org.equals(lp.getAtom())) lp.setAtom(rep); org.removeListener(this); rep.addListener(this); notifyChanged();
atoms[i] = this.atoms[i].deref().clone();
atoms[i] = this.atoms[i].deref().clone();
atoms[i].setIndex(i); } else atoms[i].removeListener(this); atoms[i] = newAtomRef(newatoms[i]); atoms[i].setIndex(i); atoms[i].addListener(this); reindexBonds = true; atoms[i].removeListener(this); Arrays.fill(this.atoms, newatoms.length, numAtoms, null);
atoms[i].setIndex(i); } else atoms[i].removeListener(this); atoms[i] = newAtomRef(newatoms[i]); atoms[i].setIndex(i); atoms[i].addListener(this); reindexBonds = true; atoms[i].removeListener(this); Arrays.fill(this.atoms, newatoms.length, numAtoms, null);
BaseAtomRef org = atoms[idx]; atoms[idx] = rep; atoms[idx].setIndex(idx); for (IBond bond : new ArrayList<>(org.bonds)) { if (bond.getBegin().equals(org)) if (org.equals(ec.getAtom())) ec.setAtom(rep); if (org.equals(lp.getAtom())) lp.setAtom(rep); org.removeListener(this); rep.addListener(this); notifyChanged();
/** * {@inheritDoc} */ @Override public Order getMinimumBondOrder(IAtom atom) { Order min = null; for (IBond bond : getAtomRef(atom).bonds()) { if (min == null || bond.getOrder().numeric() < min.numeric()) { min = bond.getOrder(); } } if (min == null) { if (atom.getImplicitHydrogenCount() != null && atom.getImplicitHydrogenCount() > 0) min = Order.SINGLE; else min = Order.UNSET; } return min; }
/** * {@inheritDoc} */ @Override public Order getMinimumBondOrder(IAtom atom) { Order min = null; for (IBond bond : getAtomRef(atom).bonds()) { if (min == null || bond.getOrder().numeric() < min.numeric()) { min = bond.getOrder(); } } if (min == null) { if (atom.getImplicitHydrogenCount() != null && atom.getImplicitHydrogenCount() > 0) min = Order.SINGLE; else min = Order.UNSET; } return min; }
/** * {@inheritDoc} */ @Override public Order getMaximumBondOrder(IAtom atom) { Order max = null; for (IBond bond : getAtomRef(atom).bonds()) { if (max == null || bond.getOrder().numeric() > max.numeric()) { max = bond.getOrder(); } } if (max == null) { if (atom.getImplicitHydrogenCount() != null && atom.getImplicitHydrogenCount() > 0) max = Order.SINGLE; else max = Order.UNSET; } return max; }
/** * {@inheritDoc} */ @Override public Order getMaximumBondOrder(IAtom atom) { Order max = null; for (IBond bond : getAtomRef(atom).bonds()) { if (max == null || bond.getOrder().numeric() > max.numeric()) { max = bond.getOrder(); } } if (max == null) { if (atom.getImplicitHydrogenCount() != null && atom.getImplicitHydrogenCount() > 0) max = Order.SINGLE; else max = Order.UNSET; } return max; }
private BaseAtomRef newAtomRef(IAtom atom) { // most common implementation we'll encounter.. if (atom.getClass() == Atom.class) return new BaseAtomRef(this, atom); atom = unbox(atom); // re-check the common case now we've un-boxed if (atom.getClass() == Atom.class) { return new BaseAtomRef(this, atom); } else if (atom instanceof IPseudoAtom) { return new PsuedoAtomRef(this, (IPseudoAtom) atom); } else if (atom instanceof IQueryAtom) { return new QueryAtomRef(this, (IQueryAtom) atom); } else if (atom instanceof IPDBAtom) { return new PdbAtomRef(this, (IPDBAtom) atom); } else { return new BaseAtomRef(this, atom); } }
/** * {@inheritDoc} */ @Override public void removeAtomOnly(int idx) { if (idx >= 0 && idx < numAtoms) { numAtoms--; atoms[idx].removeListener(this); for (int i = idx; i < numAtoms; i++) { atoms[i] = atoms[i + 1]; atoms[i].setIndex(i); } atoms[numAtoms] = null; notifyChanged(); } }
/** * {@inheritDoc} */ @Override public void removeAtomOnly(int idx) { if (idx >= 0 && idx < numAtoms) { numAtoms--; atoms[idx].removeListener(this); for (int i = idx; i < numAtoms; i++) { atoms[i] = atoms[i + 1]; atoms[i].setIndex(i); } atoms[numAtoms] = null; notifyChanged(); } }
/** * {@inheritDoc} */ @Override public void addAtom(IAtom atom) { if (contains(atom)) return; ensureAtomCapacity(numAtoms + 1); final BaseAtomRef aref = newAtomRef(atom); aref.setIndex(numAtoms); atoms[numAtoms++] = aref; aref.addListener(this); notifyChanged(); }
/** * {@inheritDoc} */ @Override public double getBondOrderSum(IAtom atom) { double count = 0; for (IBond bond : getAtomRef(atom).bonds()) { Order order = bond.getOrder(); if (order != null) { count += order.numeric(); } } return count; }
@Override public int hashCode() { return deref().hashCode(); }
/** * {@inheritDoc} */ @Override public double getBondOrderSum(IAtom atom) { double count = 0; for (IBond bond : getAtomRef(atom).bonds()) { Order order = bond.getOrder(); if (order != null) { count += order.numeric(); } } return count; }