From: Joerg K. W. <we...@in...> - 2002-09-20 10:17:02
|
Hello, two initial comments: 1. this is an easy example and i will be glad to help you 2. This topic would be better placed in the help mailing list (for future request). Look at the appended descriptor class. Copy this file to joelib/src/joelib/desc/types and add joelib.descriptor.9.representation =joelib.desc.types.MolecularWeight to line 102 in joelib/src/joelib.properties The descriptor is accessible by "Molecular_weight". A little bit of programming experience would not be a bad choice. 1. abstract - means that this class needs a child ! That's not the case for this class. 2. The rest seems to be o.k., but the parent class (this is an abstract one) forces you to implement the double value calculation in public double getDoubleValue(JOEMol mol) { double aValue=Double.NaN; return aValue; } if you want it to use with your scheme you can use public double getDoubleValue(JOEMol mol) { return getMolWt(mol); } Regards, Joerg Pekka Suomalainen wrote: > > Trying to use getMolWt to calculate molecular weight. > The code below fails. I have no programming experience so any help would be > appreciated. > > public abstract class MW extends SimpleDoubleDesc > { > /* > * > -------------------------------------------------------------------------* > * public static member variables > * > ------------------------------------------------------------------------- > */ > * Obtain a suitable logger. > */ > private static Category logger = > Category.getInstance("joelib.desc.types.MW"); > > /* > * > -------------------------------------------------------------------------* > * constructor > * > ------------------------------------------------------------------------- > */ > /* > * Constructor for the MW object > */ > public MW() > { > descInfo = DescriptorHelper.generateDescInfo("MW", > this.getClass(), > "topological", > 2, > null, > "joelib.desc.result.AtomDoubleResult"); > } > > /* > * > -------------------------------------------------------------------------* > * public methods > * > ------------------------------------------------------------------------- > */ > * Gets the molWt attribute of the <tt>JOEMol</tt> object > * > * @return The molWt value > */ > public double getMolWt(JOEMol mol) > { > double molwt = 0.0f; > JOEAtom atom; > AtomIterator ait = mol.atomIterator(); > while (ait.hasNext()) > { > atom = ait.nextAtom(); > molwt += JOEElementTable.instance().getMass(atom.getAtomicNum()); > } > > return molwt; > }} > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Joelib-devel mailing list > Joe...@li... > https://lists.sourceforge.net/lists/listinfo/joelib-devel -- Dipl. Chem. Joerg K. Wegner Univ. Tuebingen, Computer Architecture, Sand 1, D-72076 Tuebingen, Germany Tel. (+49/0) 7071 29 78970, Fax (+49/0) 7071 29 5091 E-Mail: mailto:we...@in... WWW: http://www-ra.informatik.uni-tuebingen.de |