public virtual void TestToStringFractionalCoordinates() { IAtom atom = (IAtom)NewChemObject(); atom.FractionalPoint3D = new Vector3(2, 3, 4); string description = atom.ToString(); Assert.IsTrue(description.Contains("F3D")); }
public override void TestToString() { IAtom atom = (IAtom)NewChemObject(); string description = atom.ToString(); for (int i = 0; i < description.Length; i++) { Assert.IsTrue('\n' != description[i]); Assert.IsTrue('\r' != description[i]); } }
/// <summary> Returns a one line string representation of this SingleElectron. /// This method is conform RFC #9. /// /// </summary> /// <returns> The string representation of this SingleElectron /// </returns> public override System.String ToString() { System.Text.StringBuilder stringContent = new System.Text.StringBuilder(); stringContent.Append("SingleElectron("); stringContent.Append(this.GetHashCode()); if (atom != null) { stringContent.Append(", "); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" stringContent.Append(atom.ToString()); } stringContent.Append(')'); return(stringContent.ToString()); }
/// <summary> Configures an atom. Finds the correct element type by looking at the Atom's /// atom type name, and if that fails, picks the first atom type matching /// the Atom's element symbol.. /// /// </summary> /// <param name="atom"> The atom to be configured /// </param> /// <returns> The configured atom /// </returns> /// <throws> CDKException when it could not recognize and configure the </throws> /// <summary> IAtom /// </summary> public virtual IAtom configure(IAtom atom) { if (atom is IPseudoAtom) { // do not try to configure PseudoAtom's return(atom); } try { IAtomType atomType = null; System.String atomTypeName = atom.AtomTypeName; if (atomTypeName == null || atomTypeName.Length == 0) { //logger.debug("Using atom symbol because atom type name is empty..."); IAtomType[] types = getAtomTypes(atom.Symbol); if (types.Length > 0) { //logger.warn("Taking first atom type, but other may exist"); atomType = types[0]; } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String message = "Could not configure atom with unknown ID: " + atom.ToString() + " + (id=" + atom.AtomTypeName + ")"; //logger.warn(message); throw new CDKException(message); } } else { atomType = getAtomType(atom.AtomTypeName); } //logger.debug("Configuring with atomtype: ", atomType); atom.Symbol = atomType.Symbol; atom.MaxBondOrder = atomType.MaxBondOrder; atom.BondOrderSum = atomType.BondOrderSum; atom.VanderwaalsRadius = atomType.VanderwaalsRadius; atom.CovalentRadius = atomType.CovalentRadius; atom.Hybridization = atomType.Hybridization; System.Object color = atomType.getProperty("org.openscience.cdk.renderer.color"); if (color != null) { atom.setProperty("org.openscience.cdk.renderer.color", color); } if (atomType.AtomicNumber != 0) { atom.AtomicNumber = atomType.AtomicNumber; } else { //logger.debug("Did not configure atomic number: AT.an=", atomType.AtomicNumber); } if (atomType.getExactMass() > 0.0) { atom.setExactMass(atomType.getExactMass()); } else { //logger.debug("Did not configure mass: AT.mass=", atomType.AtomicNumber); } } catch (System.Exception exception) { //logger.warn("Could not configure atom with unknown ID: ", atom, " + (id=", atom.AtomTypeName, ")"); //logger.debug(exception); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new CDKException(exception.ToString()); } //logger.debug("Configured: ", atom); return(atom); }
public override string ToString() => $"Atom: {Atom.ToString()}";
/// <inheritdoc/> public override string ToString() { return($"{nameof(AtomRef)}({atom.ToString()})"); }
/// <summary> Configures an atom. Finds the correct element type by looking at the Atom's /// atom type name, and if that fails, picks the first atom type matching /// the Atom's element symbol.. /// /// </summary> /// <param name="atom"> The atom to be configured /// </param> /// <returns> The configured atom /// </returns> /// <throws> CDKException when it could not recognize and configure the </throws> /// <summary> IAtom /// </summary> public virtual IAtom configure(IAtom atom) { if (atom is IPseudoAtom) { // do not try to configure PseudoAtom's return atom; } try { IAtomType atomType = null; System.String atomTypeName = atom.AtomTypeName; if (atomTypeName == null || atomTypeName.Length == 0) { //logger.debug("Using atom symbol because atom type name is empty..."); IAtomType[] types = getAtomTypes(atom.Symbol); if (types.Length > 0) { //logger.warn("Taking first atom type, but other may exist"); atomType = types[0]; } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String message = "Could not configure atom with unknown ID: " + atom.ToString() + " + (id=" + atom.AtomTypeName + ")"; //logger.warn(message); throw new CDKException(message); } } else { atomType = getAtomType(atom.AtomTypeName); } //logger.debug("Configuring with atomtype: ", atomType); atom.Symbol = atomType.Symbol; atom.MaxBondOrder = atomType.MaxBondOrder; atom.BondOrderSum = atomType.BondOrderSum; atom.VanderwaalsRadius = atomType.VanderwaalsRadius; atom.CovalentRadius = atomType.CovalentRadius; atom.Hybridization = atomType.Hybridization; System.Object color = atomType.getProperty("org.openscience.cdk.renderer.color"); if (color != null) { atom.setProperty("org.openscience.cdk.renderer.color", color); } if (atomType.AtomicNumber != 0) { atom.AtomicNumber = atomType.AtomicNumber; } else { //logger.debug("Did not configure atomic number: AT.an=", atomType.AtomicNumber); } if (atomType.getExactMass() > 0.0) { atom.setExactMass(atomType.getExactMass()); } else { //logger.debug("Did not configure mass: AT.mass=", atomType.AtomicNumber); } } catch (System.Exception exception) { //logger.warn("Could not configure atom with unknown ID: ", atom, " + (id=", atom.AtomTypeName, ")"); //logger.debug(exception); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new CDKException(exception.ToString()); } //logger.debug("Configured: ", atom); return atom; }