Package org.openscience.cdk.silent
Class AtomContainerSet
- java.lang.Object
-
- org.openscience.cdk.silent.ChemObject
-
- org.openscience.cdk.silent.AtomContainerSet
-
- All Implemented Interfaces:
Serializable
,Cloneable
,IAtomContainerSet
,ICDKObject
,IChemObject
,IChemObjectListener
public class AtomContainerSet extends ChemObject implements Serializable, IAtomContainerSet, IChemObjectListener, Cloneable
A set of AtomContainers.- Author:
- hel
- See Also:
- Serialized Form
- Source code:
- main
- Belongs to CDK module:
- silent
-
-
Field Summary
Fields Modifier and Type Field Description protected int
atomContainerCount
Number of AtomContainers contained by this container.protected IAtomContainer[]
atomContainers
Array of AtomContainers.protected int
growArraySize
Amount by which the AtomContainers array grows when elements are added and the array is not large enough for that.protected Double[]
multipliers
Defines the number of instances of a certain molecule in the set.
-
Constructor Summary
Constructors Constructor Description AtomContainerSet()
Constructs an empty AtomContainerSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(IAtomContainerSet atomContainerSet)
Adds all atomContainers in the AtomContainerSet to this container.void
addAtomContainer(IAtomContainer atomContainer)
Adds an atomContainer to this container.void
addAtomContainer(IAtomContainer atomContainer, double multiplier)
Adds an atomContainer to this container with the given multiplier.Iterable<IAtomContainer>
atomContainers()
Get an iterator for this AtomContainerSet.Object
clone()
Clones this AtomContainerSet and its content.IAtomContainer
getAtomContainer(int number)
Returns the AtomContainer at positionnumber
in the container.int
getAtomContainerCount()
Returns the number of AtomContainers in this Container.Double
getMultiplier(int number)
Returns the multiplier for the AtomContainer at positionnumber
in the container.Double
getMultiplier(IAtomContainer container)
Returns the multiplier of the given AtomContainer.Double[]
getMultipliers()
Returns an array of double with the stoichiometric coefficients of the products.protected void
growAtomContainerArray()
Grows the atomContainer array by a given size.boolean
isEmpty()
Returns true if this IAtomContainerSet is empty.void
removeAllAtomContainers()
Removes all AtomContainer from this container.void
removeAtomContainer(int pos)
Removes an AtomContainer from this container.void
removeAtomContainer(IAtomContainer atomContainer)
Removes an AtomContainer from this container.void
replaceAtomContainer(int position, IAtomContainer container)
Replace the AtomContainer at a specific position (array has to be large enough).void
setMultiplier(int position, Double multiplier)
Sets the coefficient of a AtomContainer to a given value.boolean
setMultiplier(IAtomContainer container, Double multiplier)
Sets the coefficient of a AtomContainer to a given value.boolean
setMultipliers(Double[] newMultipliers)
Sets the multipliers of the AtomContainers.void
sortAtomContainers(Comparator<IAtomContainer> comparator)
Sort the AtomContainers and multipliers using a provided Comparatorvoid
stateChanged(IChemObjectChangeEvent event)
Called by objects to which this object has registered as a listener.String
toString()
Returns the String representation of this AtomContainerSet.-
Methods inherited from class org.openscience.cdk.silent.ChemObject
addListener, addProperties, compare, getBuilder, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setProperty, shallowCopy
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.interfaces.ICDKObject
getBuilder
-
Methods inherited from interface org.openscience.cdk.interfaces.IChemObject
addListener, addProperties, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setProperty
-
-
-
-
Field Detail
-
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.
-
-
Method Detail
-
addAtomContainer
public void addAtomContainer(IAtomContainer atomContainer)
Adds an atomContainer to this container.- Specified by:
addAtomContainer
in interfaceIAtomContainerSet
- 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 interfaceIAtomContainerSet
- Parameters:
atomContainer
- The atomContainer to be removed from this container
-
removeAllAtomContainers
public void removeAllAtomContainers()
Removes all AtomContainer from this container.- Specified by:
removeAllAtomContainers
in interfaceIAtomContainerSet
-
removeAtomContainer
public void removeAtomContainer(int pos)
Removes an AtomContainer from this container.- Specified by:
removeAtomContainer
in interfaceIAtomContainerSet
- 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 interfaceIAtomContainerSet
- Parameters:
position
- position in array for AtomContainercontainer
- 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 interfaceIAtomContainerSet
- Parameters:
container
- The AtomContainer for which the multiplier is setmultiplier
- The new multiplier for the AtomContatiner- Returns:
- true if multiplier has been set
- See Also:
getMultiplier(IAtomContainer)
-
setMultiplier
public void setMultiplier(int position, Double multiplier)
Sets the coefficient of a AtomContainer to a given value.- Specified by:
setMultiplier
in interfaceIAtomContainerSet
- Parameters:
position
- The position of the AtomContainer for which the multiplier is set in [0,..]multiplier
- The new multiplier for the AtomContatiner atposition
- See Also:
getMultiplier(int)
-
getMultipliers
public Double[] getMultipliers()
Returns an array of double with the stoichiometric coefficients of the products.- Specified by:
getMultipliers
in interfaceIAtomContainerSet
- Returns:
- The multipliers for the AtomContainer's in this set
- See Also:
setMultipliers(java.lang.Double[])
-
setMultipliers
public boolean setMultipliers(Double[] newMultipliers)
Sets the multipliers of the AtomContainers.- Specified by:
setMultipliers
in interfaceIAtomContainerSet
- Parameters:
newMultipliers
- The new multipliers for the AtomContainers in this set- Returns:
- true if multipliers have been set.
- See Also:
getMultipliers()
-
addAtomContainer
public void addAtomContainer(IAtomContainer atomContainer, double multiplier)
Adds an atomContainer to this container with the given multiplier.- Specified by:
addAtomContainer
in interfaceIAtomContainerSet
- Parameters:
atomContainer
- The atomContainer to be added to this containermultiplier
- The multiplier of this atomContainer
-
add
public void add(IAtomContainerSet atomContainerSet)
Adds all atomContainers in the AtomContainerSet to this container.- Specified by:
add
in interfaceIAtomContainerSet
- Parameters:
atomContainerSet
- The AtomContainerSet
-
atomContainers
public Iterable<IAtomContainer> atomContainers()
Get an iterator for this AtomContainerSet.- Specified by:
atomContainers
in interfaceIAtomContainerSet
- Returns:
- A new Iterator for this AtomContainerSet.
-
getAtomContainer
public IAtomContainer getAtomContainer(int number)
Returns the AtomContainer at positionnumber
in the container.- Specified by:
getAtomContainer
in interfaceIAtomContainerSet
- 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 positionnumber
in the container.- Specified by:
getMultiplier
in interfaceIAtomContainerSet
- Parameters:
number
- The position of the multiplier of the AtomContainer to be returned.- Returns:
- The multiplier for the AtomContainer at position
number
. - See Also:
setMultiplier(int, Double)
-
getMultiplier
public Double getMultiplier(IAtomContainer container)
Returns the multiplier of the given AtomContainer.- Specified by:
getMultiplier
in interfaceIAtomContainerSet
- 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:
setMultiplier(IAtomContainer, Double)
-
growAtomContainerArray
protected void growAtomContainerArray()
Grows the atomContainer array by a given size.- See Also:
growArraySize
-
getAtomContainerCount
public int getAtomContainerCount()
Returns the number of AtomContainers in this Container.- Specified by:
getAtomContainerCount
in interfaceIAtomContainerSet
- Returns:
- The number of AtomContainers in this Container
-
toString
public String toString()
Returns the String representation of this AtomContainerSet.- Specified by:
toString
in interfaceIChemObject
- Overrides:
toString
in classObject
- Returns:
- The String representation of this AtomContainerSet
-
clone
public Object clone() throws CloneNotSupportedException
Clones this AtomContainerSet and its content.- Specified by:
clone
in interfaceIChemObject
- Overrides:
clone
in classChemObject
- 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 interfaceIChemObjectListener
- 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 interfaceIAtomContainerSet
- Parameters:
comparator
- defines the sorting method
-
isEmpty
public boolean isEmpty()
Returns true if this IAtomContainerSet is empty.- Specified by:
isEmpty
in interfaceIAtomContainerSet
- Returns:
- a boolean indicating if this ring set no atom containers
-
-