Source code: joelib/desc/types/AtomMass.java
1 ///////////////////////////////////////////////////////////////////////////////
2 // Filename: $RCSfile: AtomMass.java,v $
3 // Purpose: Atom mass.
4 // Language: Java
5 // Compiler: JDK 1.4
6 // Authors: Joerg K. Wegner
7 // Version: $Revision: 1.7 $
8 // $Date: 2003/08/19 13:11:25 $
9 // $Author: wegner $
10 //
11 // Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation version 2 of the License.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 ///////////////////////////////////////////////////////////////////////////////
22 package joelib.desc.types;
23
24
25 /*==========================================================================*
26 * IMPORTS
27 *==========================================================================*/
28 import joelib.data.JOEElementTable;
29
30 import joelib.desc.DescriptorHelper;
31 import joelib.desc.DescriptorInfo;
32 import joelib.desc.SimpleDynamicAtomProperty;
33
34 import joelib.desc.result.DynamicArrayResult;
35
36 import joelib.molecule.JOEAtom;
37 import joelib.molecule.JOEMol;
38
39 import joelib.util.iterator.AtomIterator;
40
41 import org.apache.log4j.Category;
42
43
44 /*==========================================================================*
45 * CLASS DECLARATION
46 *==========================================================================*/
47
48 /**
49 * Atom mass.
50 *
51 * @author wegnerj
52 * @license GPL
53 * @cvsversion $Revision: 1.7 $, $Date: 2003/08/19 13:11:25 $
54 */
55 public class AtomMass extends SimpleDynamicAtomProperty
56 {
57 //~ Static fields/initializers /////////////////////////////////////////////
58
59 /*-------------------------------------------------------------------------*
60 * public static member variables
61 *-------------------------------------------------------------------------*/
62
63 /**
64 * Obtain a suitable logger.
65 */
66 private static Category logger = Category.getInstance(
67 "joelib.desc.types.AtomMass");
68 public static final String DESC_KEY = "Atom_mass";
69
70 //~ Constructors ///////////////////////////////////////////////////////////
71
72 /*-------------------------------------------------------------------------*
73 * private variables
74 *-------------------------------------------------------------------------*/
75 /*-------------------------------------------------------------------------*
76 * constructor
77 *-------------------------------------------------------------------------*/
78
79 /**
80 * Constructor for the KierShape1 object
81 */
82 public AtomMass()
83 {
84 if (logger.isDebugEnabled())
85 {
86 logger.debug("Initialize " + this.getClass().getName());
87 }
88
89 descInfo = DescriptorHelper.generateDescInfo(DESC_KEY, this.getClass(),
90 DescriptorInfo.TYPE_NO_COORDINATES, null,
91 "joelib.desc.result.AtomDynamicResult");
92 }
93
94 //~ Methods ////////////////////////////////////////////////////////////////
95
96 /*-------------------------------------------------------------------------*
97 * public methods
98 *------------------------------------------------------------------------- */
99 public Object getAtomPropertiesArray(JOEMol mol)
100 {
101 // get mass for all atoms
102 JOEAtom atom;
103 AtomIterator ait = mol.atomIterator();
104 double[] masses = (double[]) DynamicArrayResult.getNewArray(DynamicArrayResult.DOUBLE,
105 mol.numAtoms());
106 int i = 0;
107
108 while (ait.hasNext())
109 {
110 atom = ait.nextAtom();
111 masses[i++] = JOEElementTable.instance().getMass(atom.getAtomicNum());
112 }
113
114 return masses;
115 }
116 }
117 ///////////////////////////////////////////////////////////////////////////////
118 // END OF FILE.
119 ///////////////////////////////////////////////////////////////////////////////