Class AtomContainerSet

java.lang.Object
org.openscience.cdk.silent.ChemObject
org.openscience.cdk.silent.AtomContainerSet
All Implemented Interfaces:
Serializable, Cloneable, IAtomContainerSet, ICDKObject, IChemObject, IChemObjectListener
Direct Known Subclasses:
RingSet, Substance

public class AtomContainerSet extends ChemObject implements Serializable, IAtomContainerSet, IChemObjectListener, Cloneable
A set of AtomContainers.
Author:
hel
See Also:
Source code:
main
Belongs to CDK module:
silent
  • Field Details

    • atomContainers

      protected IAtomContainer[] atomContainers
      Array of AtomContainers.
    • atomContainerCount

      protected int atomContainerCount
      Number of AtomContainers contained by this container.
    • multipliers

      protected Double[] multipliers
      Defines the number of instances of a certain molecule in the set. It is 1 by default.
    • growArraySize

      protected int growArraySize
      Amount by which the AtomContainers array grows when elements are added and the array is not large enough for that.
  • Constructor Details

    • AtomContainerSet

      public AtomContainerSet()
      Constructs an empty AtomContainerSet.
  • Method Details

    • addAtomContainer

      public void addAtomContainer(IAtomContainer atomContainer)
      Adds an atomContainer to this container.
      Specified by:
      addAtomContainer in interface IAtomContainerSet
      Parameters:
      atomContainer - The atomContainer to be added to this container
    • removeAtomContainer

      public void removeAtomContainer(IAtomContainer atomContainer)
      Removes an AtomContainer from this container.
      Specified by:
      removeAtomContainer in interface IAtomContainerSet
      Parameters:
      atomContainer - The atomContainer to be removed from this container
    • removeAllAtomContainers

      public void removeAllAtomContainers()
      Removes all AtomContainer from this container.
      Specified by:
      removeAllAtomContainers in interface IAtomContainerSet
    • removeAtomContainer

      public void removeAtomContainer(int pos)
      Removes an AtomContainer from this container.
      Specified by:
      removeAtomContainer in interface IAtomContainerSet
      Parameters:
      pos - The position of the AtomContainer to be removed from this container
    • replaceAtomContainer

      public void replaceAtomContainer(int position, IAtomContainer container)
      Replace the AtomContainer at a specific position (array has to be large enough).
      Specified by:
      replaceAtomContainer in interface IAtomContainerSet
      Parameters:
      position - position in array for AtomContainer
      container - the replacement AtomContainer
    • setMultiplier

      public boolean setMultiplier(IAtomContainer container, Double multiplier)
      Sets the coefficient of a AtomContainer to a given value.
      Specified by:
      setMultiplier in interface IAtomContainerSet
      Parameters:
      container - The AtomContainer for which the multiplier is set
      multiplier - The new multiplier for the AtomContatiner
      Returns:
      true if multiplier has been set
      See Also:
    • setMultiplier

      public void setMultiplier(int position, Double multiplier)
      Sets the coefficient of a AtomContainer to a given value.
      Specified by:
      setMultiplier in interface IAtomContainerSet
      Parameters:
      position - The position of the AtomContainer for which the multiplier is set in [0,..]
      multiplier - The new multiplier for the AtomContatiner at position
      See Also:
    • getMultipliers

      public Double[] getMultipliers()
      Returns an array of double with the stoichiometric coefficients of the products.
      Specified by:
      getMultipliers in interface IAtomContainerSet
      Returns:
      The multipliers for the AtomContainer's in this set
      See Also:
    • setMultipliers

      public boolean setMultipliers(Double[] newMultipliers)
      Sets the multipliers of the AtomContainers.
      Specified by:
      setMultipliers in interface IAtomContainerSet
      Parameters:
      newMultipliers - The new multipliers for the AtomContainers in this set
      Returns:
      true if multipliers have been set.
      See Also:
    • addAtomContainer

      public void addAtomContainer(IAtomContainer atomContainer, double multiplier)
      Adds an atomContainer to this container with the given multiplier.
      Specified by:
      addAtomContainer in interface IAtomContainerSet
      Parameters:
      atomContainer - The atomContainer to be added to this container
      multiplier - The multiplier of this atomContainer
    • add

      public void add(IAtomContainerSet atomContainerSet)
      Adds all atomContainers in the AtomContainerSet to this container.
      Specified by:
      add in interface IAtomContainerSet
      Parameters:
      atomContainerSet - The AtomContainerSet
    • atomContainers

      public Iterable<IAtomContainer> atomContainers()
      Get an iterator for this AtomContainerSet.
      Specified by:
      atomContainers in interface IAtomContainerSet
      Returns:
      A new Iterator for this AtomContainerSet.
    • getAtomContainer

      public IAtomContainer getAtomContainer(int number)
      Returns the AtomContainer at position number in the container.
      Specified by:
      getAtomContainer in interface IAtomContainerSet
      Parameters:
      number - The position of the AtomContainer to be returned.
      Returns:
      The AtomContainer at position number .
    • getMultiplier

      public Double getMultiplier(int number)
      Returns the multiplier for the AtomContainer at position number in the container.
      Specified by:
      getMultiplier in interface IAtomContainerSet
      Parameters:
      number - The position of the multiplier of the AtomContainer to be returned.
      Returns:
      The multiplier for the AtomContainer at position number .
      See Also:
    • getMultiplier

      public Double getMultiplier(IAtomContainer container)
      Returns the multiplier of the given AtomContainer.
      Specified by:
      getMultiplier in interface IAtomContainerSet
      Parameters:
      container - The AtomContainer for which the multiplier is given
      Returns:
      -1, if the given molecule is not a container in this set
      See Also:
    • growAtomContainerArray

      protected void growAtomContainerArray()
      Grows the atomContainer array by a given size.
      See Also:
    • getAtomContainerCount

      public int getAtomContainerCount()
      Returns the number of AtomContainers in this Container.
      Specified by:
      getAtomContainerCount in interface IAtomContainerSet
      Returns:
      The number of AtomContainers in this Container
    • toString

      public String toString()
      Returns the String representation of this AtomContainerSet.
      Specified by:
      toString in interface IChemObject
      Overrides:
      toString in class Object
      Returns:
      The String representation of this AtomContainerSet
    • clone

      public Object clone() throws CloneNotSupportedException
      Clones this AtomContainerSet and its content.
      Specified by:
      clone in interface IChemObject
      Overrides:
      clone in class ChemObject
      Returns:
      the cloned Object
      Throws:
      CloneNotSupportedException - if the IChemObject cannot be cloned
    • stateChanged

      public void stateChanged(IChemObjectChangeEvent event)
      Called by objects to which this object has registered as a listener.
      Specified by:
      stateChanged in interface IChemObjectListener
      Parameters:
      event - A change event pointing to the source of the change
    • sortAtomContainers

      public void sortAtomContainers(Comparator<IAtomContainer> comparator)
      Sort the AtomContainers and multipliers using a provided Comparator
      Specified by:
      sortAtomContainers in interface IAtomContainerSet
      Parameters:
      comparator - defines the sorting method
    • isEmpty

      public boolean isEmpty()
      Returns true if this IAtomContainerSet is empty.
      Specified by:
      isEmpty in interface IAtomContainerSet
      Returns:
      a boolean indicating if this ring set no atom containers