Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.xmlcml.cmlimpl.subset
Class AtomSetImpl  view AtomSetImpl download AtomSetImpl.java

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.HashSet
              extended byorg.xmlcml.cmlimpl.subset.ToolHashSetImpl
                  extended byorg.xmlcml.cmlimpl.subset.AtomSetImpl
All Implemented Interfaces:
org.xmlcml.cml.subset.AtomSet, java.lang.Cloneable, java.util.Collection, java.lang.Iterable, java.io.Serializable, java.util.Set, org.xmlcml.cml.subset.ToolHashSet

public class AtomSetImpl
extends ToolHashSetImpl
implements org.xmlcml.cml.subset.AtomSet

a set of atoms. Counts number of times an atom has been added (e.g. for bonds). An AtomSet may have coordinates associated with it which may or may not be related to the molecule. This should make calcuation of fragment geometries easier and therefore assembly less painful


Field Summary
(package private)  java.util.HashMap atomCountTable
           
protected  java.util.HashMap coordinate2Map
           
 
Fields inherited from class org.xmlcml.cmlimpl.subset.ToolHashSetImpl
id
 
Fields inherited from class java.util.HashSet
 
Constructor Summary
AtomSetImpl()
           
AtomSetImpl(org.xmlcml.cml.CMLMolecule molecule)
          creates atom set from CMLMolecule
AtomSetImpl(java.util.Vector vector)
          creates atom set from Vector of Atoms; if Vector has no elements or they are not Atoms throws CIFException
 
Method Summary
 void addAtom(org.xmlcml.cml.CMLAtom atom)
          add an atom.
 void addBond(org.xmlcml.cml.CMLBond bond)
          adds both atoms in the bond
 org.xmlcml.cml.subset.AtomSet and(org.xmlcml.cml.subset.AtomSet atomSet)
          combines this with AtomSet to find common elements, else null.
 org.xmlcml.cml.CMLCoordinate2 getCoord2(org.xmlcml.cml.CMLAtom atom)
          convenience get coordinates for atom
 java.util.HashMap getCoordinate2Map()
          get atom coordinate map
 int getCount(org.xmlcml.cml.CMLAtom atom)
          how many times has atom been added (0 means atom is not in set
 org.xmlcml.cml.CMLAtom getStartingAtom()
          get any atom (convenience method for iterative processing) This is not reproducible.
(package private)  void incrementCount(org.xmlcml.cml.CMLAtom atom)
           
private  void init(org.xmlcml.cml.CMLMolecule molecule)
           
 org.xmlcml.cml.subset.AtomSet not(org.xmlcml.cml.subset.AtomSet atomSet)
          combines this with AtomSet to find elements NOT in AtomSet, else null.
 org.xmlcml.cml.subset.AtomSet or(org.xmlcml.cml.subset.AtomSet atomSet)
          combines this with AtomSet to find all elements.
 void setCoord2(org.xmlcml.cml.CMLAtom atom, org.xmlcml.cml.CMLCoordinate2 c)
          convenience set coordinates for atom
 java.lang.String toString()
          Creates a String representation of the Collection.
 void transformBy(Transform2 t2)
          transform coordinates of all atoms in the set (rather inefficient)
 void translateBy(org.xmlcml.cml.CMLCoordinate2 offset)
          translate coordinates of all atoms in the set
 org.xmlcml.cml.subset.AtomSet xor(org.xmlcml.cml.subset.AtomSet atomSet)
          combines this with AtomSet to find elements NOT in common, else null.
 
Methods inherited from class org.xmlcml.cmlimpl.subset.ToolHashSetImpl
and, clone, debug, getId, main, not, or, setId, xor
 
Methods inherited from class java.util.HashSet
add, clear, contains, isEmpty, iterator, remove, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xmlcml.cml.subset.ToolHashSet
add, addAll, and, clone, contains, debug, getId, iterator, not, or, remove, removeAll, retainAll, setId, size, xor
 
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Field Detail

atomCountTable

java.util.HashMap atomCountTable

coordinate2Map

protected java.util.HashMap coordinate2Map
Constructor Detail

AtomSetImpl

public AtomSetImpl()

AtomSetImpl

public AtomSetImpl(org.xmlcml.cml.CMLMolecule molecule)
creates atom set from CMLMolecule


AtomSetImpl

public AtomSetImpl(java.util.Vector vector)
            throws org.xmlcml.cml.CMLException
creates atom set from Vector of Atoms; if Vector has no elements or they are not Atoms throws CIFException

Method Detail

init

private void init(org.xmlcml.cml.CMLMolecule molecule)

addAtom

public void addAtom(org.xmlcml.cml.CMLAtom atom)
             throws org.xmlcml.cml.CMLException
add an atom. If atom already present, increments count

Specified by:
addAtom in interface org.xmlcml.cml.subset.AtomSet

addBond

public void addBond(org.xmlcml.cml.CMLBond bond)
             throws org.xmlcml.cml.CMLException
adds both atoms in the bond

Specified by:
addBond in interface org.xmlcml.cml.subset.AtomSet

and

public org.xmlcml.cml.subset.AtomSet and(org.xmlcml.cml.subset.AtomSet atomSet)
                                  throws org.xmlcml.cml.CMLException
combines this with AtomSet to find common elements, else null.

Specified by:
and in interface org.xmlcml.cml.subset.AtomSet

xor

public org.xmlcml.cml.subset.AtomSet xor(org.xmlcml.cml.subset.AtomSet atomSet)
                                  throws org.xmlcml.cml.CMLException
combines this with AtomSet to find elements NOT in common, else null.

Specified by:
xor in interface org.xmlcml.cml.subset.AtomSet

not

public org.xmlcml.cml.subset.AtomSet not(org.xmlcml.cml.subset.AtomSet atomSet)
                                  throws org.xmlcml.cml.CMLException
combines this with AtomSet to find elements NOT in AtomSet, else null.

Specified by:
not in interface org.xmlcml.cml.subset.AtomSet

or

public org.xmlcml.cml.subset.AtomSet or(org.xmlcml.cml.subset.AtomSet atomSet)
                                 throws org.xmlcml.cml.CMLException
combines this with AtomSet to find all elements.

Specified by:
or in interface org.xmlcml.cml.subset.AtomSet

getCount

public int getCount(org.xmlcml.cml.CMLAtom atom)
how many times has atom been added (0 means atom is not in set

Specified by:
getCount in interface org.xmlcml.cml.subset.AtomSet

incrementCount

void incrementCount(org.xmlcml.cml.CMLAtom atom)

getCoordinate2Map

public java.util.HashMap getCoordinate2Map()
get atom coordinate map

Specified by:
getCoordinate2Map in interface org.xmlcml.cml.subset.AtomSet

setCoord2

public void setCoord2(org.xmlcml.cml.CMLAtom atom,
                      org.xmlcml.cml.CMLCoordinate2 c)
               throws org.xmlcml.cml.CMLException
convenience set coordinates for atom

Specified by:
setCoord2 in interface org.xmlcml.cml.subset.AtomSet

getCoord2

public org.xmlcml.cml.CMLCoordinate2 getCoord2(org.xmlcml.cml.CMLAtom atom)
convenience get coordinates for atom

Specified by:
getCoord2 in interface org.xmlcml.cml.subset.AtomSet

transformBy

public void transformBy(Transform2 t2)
transform coordinates of all atoms in the set (rather inefficient)

Specified by:
transformBy in interface org.xmlcml.cml.subset.AtomSet

translateBy

public void translateBy(org.xmlcml.cml.CMLCoordinate2 offset)
translate coordinates of all atoms in the set

Specified by:
translateBy in interface org.xmlcml.cml.subset.AtomSet

getStartingAtom

public org.xmlcml.cml.CMLAtom getStartingAtom()
get any atom (convenience method for iterative processing) This is not reproducible. If none left,return null

Specified by:
getStartingAtom in interface org.xmlcml.cml.subset.AtomSet

toString

public java.lang.String toString()
Description copied from class: java.util.AbstractCollection
Creates a String representation of the Collection. The string returned is of the form "[a, b, ...]" where a and b etc are the results of calling toString on the elements of the collection. This implementation obtains an Iterator over the Collection and adds each element to a StringBuffer as it is returned by the iterator. "" is inserted when the collection contains itself (only works for direct containment, not for collections inside collections).