org.jscience.chemistry.gui.extended.molecule
Class Molecule

java.lang.Object
  extended by org.jscience.chemistry.gui.extended.molecule.Molecule

public class Molecule
extends java.lang.Object

Tripos base molecule class

See Also:
AtomVector, BondVector, Atom, Bond, Matrix3D

Field Summary
protected  java.util.Hashtable atomIdToIndex
          Atom id to index map.
protected  AtomVector highlightAtoms
          List of highlighted atom
protected  int id
          Molecule id
protected  Matrix3D mat
          The transformation matrix
protected  AtomVector myAtoms
          Atom list
protected  BondVector myBonds
          Bond list
protected  RingVector myRings
          Ring list
protected  java.lang.String name
          Molecule name
protected  int numAtoms
          Number of atoms
protected  int numBonds
          Number of bonds
protected  int numRings
          Number of rings
protected  java.util.Hashtable properties
          Properties list
protected static Renderer rendererDefault
          Default renderer so that pre-existing programs can still call Molecule.draw( Graphics )
protected  AtomVector selectAtoms
          List of selected atoms
protected  float xmax
          The bounding extents of the molecule
protected  float xmin
          The bounding extents of the molecule
protected  float ymax
          The bounding extents of the molecule
protected  float ymin
          The bounding extents of the molecule
protected  float zmax
          The bounding extents of the molecule
protected  float zmin
          The bounding extents of the molecule
 
Constructor Summary
Molecule()
          Default constructor
Molecule(int id, java.lang.String name)
          Id/Name constructor
Molecule(Molecule jmol)
          Copy constructor
 
Method Summary
 void addAtom(Atom a)
          Add an atom to this molecule
 void addBond(Bond b)
          Add a bond to this molecule
 void addMolecule(Molecule jmol)
          Add a molecule to this molecule
 void addProperty(java.lang.String name, java.lang.String value)
          Add a property (i.e. a "name"/"value" pair) to this molecule.
 void addRing(Ring r)
          Add a ring to this molecule
 void calcPerpUnitVec(float x1, float y1, float x2, float y2, float[] pex, float[] pey)
          Calculates 2D vector perpendicular to bond
 boolean contains(Atom a)
          Return true iff the atom in the parameter is one of the atoms in this molecule
 boolean contains(Bond b)
          Return true iff the bond in the parameter is one of the bonds in this molecule
 void dehighlight()
          Dehighlighted all highlighted atoms.
 void deleteAtom(Atom a)
          Delete an atom and its bonds from this molecule
 void deleteBond(Bond b)
          Delete a bond from this molecule
 void deleteProperty(java.lang.String name)
          Remove a property from this molecule.
 void deleteRing(Ring r)
          Delete a ring from this molecule
 void deselect()
          Deselects all selected atoms
 void deselect(Atom a)
          Deselect one selected atom
 void draw(java.awt.Graphics g)
          Draw the molecule recommend to avoid, but to use renderer approach
 boolean equals(Molecule jmol)
          Compares this molecule with another
 Atom findAtom(float x, float y, float z, float FINDRADIUS)
          Returns closest atom to point within FINDRADIUS, null if nothing is found,
 void findBB()
          Determines bounding box of a molecule (sets xmax,xmin,ymax,ymin,zmax,zmin)
 Atom getAtomFromId(int atomId)
          Return an atom in this molecule whose id matches the input id
 java.util.Hashtable getAtomIdToIndex()
          Return atomIdToIndex
 Bond getBondFromId(int bondId)
          Return a bond in this molecule whose id matches the input id
 AtomVector getHighlightAtoms()
          Return the highlighted atoms vector
 int getId()
          Returns id of this molecule
 Matrix3D getMatrix3D()
          Return 3D transformation matrix
 AtomVector getMyAtoms()
          Returns atom vector of this molecule
 BondVector getMyBonds()
          Return bond vector of this molecule
 RingVector getMyRings()
          Return ring vector of this molecule
 java.lang.String getName()
          Returns name of molecule
 int getNumAtoms()
          Return number of atoms in this molecule
 int getNumBonds()
          Return number of bonds in this molecule
 int getNumRings()
          Return number of rings in this molecule
 java.util.Hashtable getProperties()
          Return property table in this molecule
 java.lang.String getPropertyValue(java.lang.String name)
          Get the property value associated with specified property name.
protected static Renderer getRenderer()
          Return the Renderer which draws this molecule
 AtomVector getSelectAtoms()
          Return the selected atoms vector
 float getXmax()
          Return the maxmum x coordinate
 float getXmin()
          Return the minimum x coordinate of this molelcule
 float getYmax()
          Return the maxmum y coordinate
 float getYmin()
          Return the minimum y coordinate
 float getZmax()
          Return the maxmum z coordinate
 float getZmin()
          Return the minimum z coordinate
protected  boolean hasHighlightedAtoms()
          Returns true if molecule has highlighted atoms
 boolean hasSelectedAtoms()
          Returns true if molecule has selected atoms
 void highlight(Atom a)
          Designates an atom as highlighted.
 void highlight(AtomVector av)
          Designates an atom list as highlighted.
 boolean isAProperty(java.lang.String name)
          Indicate if the molecule contains the specified property.
 boolean isOuterBond(Bond b, float tx1, float ty1, float tx2, float ty2)
          Returns true if bond is oriented counterclockwise with respect to the centroid of the ring, else returns false.
 void select(Atom a)
          Flags specified atom as selected
 void setAtomIdToIndex(java.util.Hashtable index)
          Set atomIdToIndex
 void setHighlightAtoms(AtomVector av)
          Set highlighted atoms vector
 void setId(int id)
          Set id of this molecule
 void setMatrix3D(Matrix3D mat)
          Set 3D transformation matrix
 void setMyAtoms(AtomVector atoms)
          Set atom vector
 void setMyBonds(BondVector bv)
          Set bond vector
 void setMyRings(RingVector rv)
          Set ring vector
 void setName(java.lang.String s)
          Set name of this molecule
 void setNumAtoms(int numAtoms)
          Set number of atoms
 void setNumRings(int numRings)
          Set number of rings
 void setProperties(java.util.Hashtable prop)
          Set property table
protected static void setRenderer(Renderer r)
          Set renderer which draws this molecule
 void setSelectAtoms(AtomVector av)
          Set selected atoms vector
 void setXmax(float xmax)
          Set maxmum of X-coordinate
 void setXmin(float xmin)
          Set minimum of X-coordinate of this molecule
 void setYmax(float ymax)
          Set maxmum of Y-coordinate
 void setYmin(float ymin)
          Set minimum of Y-coordinate
 void setZmax(float zmax)
          Set maxmum of Z-coordinate
 void setZmin(float zmin)
          Set minimum of Z-coordinate
 java.lang.String toString()
          Returns a String representation of molecule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rendererDefault

protected static Renderer rendererDefault
Default renderer so that pre-existing programs can still call Molecule.draw( Graphics )


id

protected int id
Molecule id


name

protected java.lang.String name
Molecule name


myAtoms

protected AtomVector myAtoms
Atom list


atomIdToIndex

protected java.util.Hashtable atomIdToIndex
Atom id to index map. Does not require atom ids to start at 1 or be sequential.


myBonds

protected BondVector myBonds
Bond list


myRings

protected RingVector myRings
Ring list


numAtoms

protected int numAtoms
Number of atoms


numBonds

protected int numBonds
Number of bonds


numRings

protected int numRings
Number of rings


properties

protected java.util.Hashtable properties
Properties list


mat

protected Matrix3D mat
The transformation matrix


xmin

protected float xmin
The bounding extents of the molecule


ymin

protected float ymin
The bounding extents of the molecule


zmin

protected float zmin
The bounding extents of the molecule


xmax

protected float xmax
The bounding extents of the molecule


ymax

protected float ymax
The bounding extents of the molecule


zmax

protected float zmax
The bounding extents of the molecule


selectAtoms

protected AtomVector selectAtoms
List of selected atoms


highlightAtoms

protected AtomVector highlightAtoms
List of highlighted atom

Constructor Detail

Molecule

public Molecule(int id,
                java.lang.String name)
Id/Name constructor

Parameters:
id - molecule id
name - molecule name

Molecule

public Molecule()
Default constructor


Molecule

public Molecule(Molecule jmol)
Copy constructor

Parameters:
jmol - molecule to be copied
Method Detail

addAtom

public void addAtom(Atom a)
Add an atom to this molecule

Parameters:
a - atom to be added
See Also:
deleteAtom(org.jscience.chemistry.gui.extended.molecule.Atom)

addBond

public void addBond(Bond b)
Add a bond to this molecule

Parameters:
b - bond to be added
See Also:
deleteBond(org.jscience.chemistry.gui.extended.molecule.Bond)

addRing

public void addRing(Ring r)
Add a ring to this molecule

Parameters:
r - ring to be added
See Also:
deleteRing(org.jscience.chemistry.gui.extended.molecule.Ring)

addMolecule

public void addMolecule(Molecule jmol)
Add a molecule to this molecule

Parameters:
jmol - molecule to be added

deleteAtom

public void deleteAtom(Atom a)
Delete an atom and its bonds from this molecule

Parameters:
a - atom to be deleted
See Also:
deleteBond(org.jscience.chemistry.gui.extended.molecule.Bond), addAtom(org.jscience.chemistry.gui.extended.molecule.Atom)

deleteBond

public void deleteBond(Bond b)
Delete a bond from this molecule

Parameters:
b - bond to be deleted
See Also:
addBond(org.jscience.chemistry.gui.extended.molecule.Bond)

deleteRing

public void deleteRing(Ring r)
Delete a ring from this molecule

Parameters:
r - ring to be deleted
See Also:
addRing(org.jscience.chemistry.gui.extended.molecule.Ring)

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Add a property (i.e. a "name"/"value" pair) to this molecule.

Parameters:
name - name of property to be added
value - value associated with "name"

deleteProperty

public void deleteProperty(java.lang.String name)
Remove a property from this molecule.

Parameters:
name - name of property to be removed

getPropertyValue

public java.lang.String getPropertyValue(java.lang.String name)
Get the property value associated with specified property name.

Parameters:
name - name of property whose value is sought

isAProperty

public boolean isAProperty(java.lang.String name)
Indicate if the molecule contains the specified property.

Parameters:
name - name of property to check for

select

public void select(Atom a)
Flags specified atom as selected

Parameters:
a - atom to be selected

deselect

public void deselect()
Deselects all selected atoms

See Also:
select(org.jscience.chemistry.gui.extended.molecule.Atom)

deselect

public void deselect(Atom a)
Deselect one selected atom

See Also:
select(org.jscience.chemistry.gui.extended.molecule.Atom), deselect()

hasSelectedAtoms

public boolean hasSelectedAtoms()
Returns true if molecule has selected atoms

See Also:
select(org.jscience.chemistry.gui.extended.molecule.Atom)

hasHighlightedAtoms

protected boolean hasHighlightedAtoms()
Returns true if molecule has highlighted atoms

See Also:
highlight(org.jscience.chemistry.gui.extended.molecule.Atom)

setName

public void setName(java.lang.String s)
Set name of this molecule

Parameters:
s - name of molecule
See Also:
getName()

getName

public java.lang.String getName()
Returns name of molecule

See Also:
setName(java.lang.String)

findBB

public void findBB()
Determines bounding box of a molecule (sets xmax,xmin,ymax,ymin,zmax,zmin)


equals

public boolean equals(Molecule jmol)
Compares this molecule with another

Parameters:
jmol - molecule to compare with
Returns:
true if they are equal, else false

highlight

public void highlight(Atom a)
Designates an atom as highlighted. The specified atom gets appended to the current highlight list.

Parameters:
a - atom to highlight

highlight

public void highlight(AtomVector av)
Designates an atom list as highlighted. The new list replaces any current list of highlighted atoms.

Parameters:
av - list (vector) of atoms to highlight

dehighlight

public void dehighlight()
Dehighlighted all highlighted atoms.


isOuterBond

public boolean isOuterBond(Bond b,
                           float tx1,
                           float ty1,
                           float tx2,
                           float ty2)
Returns true if bond is oriented counterclockwise with respect to the centroid of the ring, else returns false.

Parameters:
b - potential ring bond to be checked
tx1 - transformed x coordinate of bond's from atom
ty1 - transformed y coordinate of bond's from atom
tx2 - transformed x coordinate of bond's to atom
ty2 - transformed y coordinate of bond's to atom

calcPerpUnitVec

public void calcPerpUnitVec(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float[] pex,
                            float[] pey)
Calculates 2D vector perpendicular to bond


findAtom

public Atom findAtom(float x,
                     float y,
                     float z,
                     float FINDRADIUS)
Returns closest atom to point within FINDRADIUS, null if nothing is found,

See Also:
#FINDRADIUS

draw

public void draw(java.awt.Graphics g)
Draw the molecule recommend to avoid, but to use renderer approach

Parameters:
g - Graphics

toString

public java.lang.String toString()
Returns a String representation of molecule

Overrides:
toString in class java.lang.Object

getId

public int getId()
Returns id of this molecule


getMyAtoms

public AtomVector getMyAtoms()
Returns atom vector of this molecule


getAtomIdToIndex

public java.util.Hashtable getAtomIdToIndex()
Return atomIdToIndex


getMyBonds

public BondVector getMyBonds()
Return bond vector of this molecule


getMyRings

public RingVector getMyRings()
Return ring vector of this molecule


getNumAtoms

public int getNumAtoms()
Return number of atoms in this molecule


getNumBonds

public int getNumBonds()
Return number of bonds in this molecule


getNumRings

public int getNumRings()
Return number of rings in this molecule


getProperties

public java.util.Hashtable getProperties()
Return property table in this molecule


getMatrix3D

public Matrix3D getMatrix3D()
Return 3D transformation matrix


getXmin

public float getXmin()
Return the minimum x coordinate of this molelcule


getYmin

public float getYmin()
Return the minimum y coordinate


getZmin

public float getZmin()
Return the minimum z coordinate


getXmax

public float getXmax()
Return the maxmum x coordinate


getYmax

public float getYmax()
Return the maxmum y coordinate


getZmax

public float getZmax()
Return the maxmum z coordinate


getSelectAtoms

public AtomVector getSelectAtoms()
Return the selected atoms vector


getHighlightAtoms

public AtomVector getHighlightAtoms()
Return the highlighted atoms vector


getRenderer

protected static Renderer getRenderer()
Return the Renderer which draws this molecule


contains

public boolean contains(Atom a)
Return true iff the atom in the parameter is one of the atoms in this molecule

Parameters:
a - atom in this query
See Also:
contains( Bond )

contains

public boolean contains(Bond b)
Return true iff the bond in the parameter is one of the bonds in this molecule

Parameters:
b - bond in this query
See Also:
contains( Atom )

getAtomFromId

public Atom getAtomFromId(int atomId)
Return an atom in this molecule whose id matches the input id

Parameters:
atomId - id of queried atom
See Also:
getBondFromId

getBondFromId

public Bond getBondFromId(int bondId)
Return a bond in this molecule whose id matches the input id

Parameters:
bondId - id of queried bond
See Also:
getAtomFromId

setId

public void setId(int id)
Set id of this molecule

Parameters:
id - molecule id
See Also:
getId()

setMyAtoms

public void setMyAtoms(AtomVector atoms)
Set atom vector

Parameters:
id - molecule id
See Also:
getMyAtoms()

setAtomIdToIndex

public void setAtomIdToIndex(java.util.Hashtable index)
Set atomIdToIndex

Parameters:
index - atomIdToIndex
See Also:
getAtomIdToIndex()

setMyBonds

public void setMyBonds(BondVector bv)
Set bond vector

Parameters:
bv - bond vector
See Also:
getMyBonds()

setMyRings

public void setMyRings(RingVector rv)
Set ring vector

Parameters:
rv - ring vector
See Also:
getMyRings()

setNumAtoms

public void setNumAtoms(int numAtoms)
Set number of atoms

Parameters:
numAtoms - number of atoms
See Also:
getNumAtoms()

setNumRings

public void setNumRings(int numRings)
Set number of rings

Parameters:
numRings - number of rings
See Also:
getNumRings()

setProperties

public void setProperties(java.util.Hashtable prop)
Set property table

Parameters:
prop - property table
See Also:
getProperties()

setMatrix3D

public void setMatrix3D(Matrix3D mat)
Set 3D transformation matrix

Parameters:
mat - Matrix3D
See Also:
getMatrix3D()

setXmin

public void setXmin(float xmin)
Set minimum of X-coordinate of this molecule

Parameters:
prop - property table
See Also:
getProperties()

setYmin

public void setYmin(float ymin)
Set minimum of Y-coordinate

Parameters:
ymin - minimum Y-coordinate
See Also:
getYmin()

setZmin

public void setZmin(float zmin)
Set minimum of Z-coordinate

Parameters:
ymin - minimum Z-coordinate
See Also:
getZmin()

setXmax

public void setXmax(float xmax)
Set maxmum of X-coordinate

Parameters:
xmax - maximum X-coordinate
See Also:
getXmax()

setYmax

public void setYmax(float ymax)
Set maxmum of Y-coordinate

Parameters:
ymax - maximum Y-coordinate
See Also:
getYmax()

setZmax

public void setZmax(float zmax)
Set maxmum of Z-coordinate

Parameters:
zmax - maximum Z-coordinate
See Also:
getYmax()

setSelectAtoms

public void setSelectAtoms(AtomVector av)
Set selected atoms vector

Parameters:
av - atom vector
See Also:
getSelectAtoms()

setHighlightAtoms

public void setHighlightAtoms(AtomVector av)
Set highlighted atoms vector

Parameters:
av - atom vector
See Also:
getHighlightAtoms()

setRenderer

protected static void setRenderer(Renderer r)
Set renderer which draws this molecule

Parameters:
ir - Renderer
See Also:
getRenderer()