⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reaction.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        /**     * Adds a product to this reaction.     *     * @param product     Molecule added as product to this reaction     * @param coefficient Stoichiometry coefficient for this molecule     * @see   #getProducts     */    public void addProduct(org.openscience.cdk.interfaces.IMolecule product, double coefficient) {        products.addAtomContainer(product, coefficient);	/* notifyChanged() is called by 	   addReactant(Molecule reactant, double coefficient) */    }        /**     * Returns the stoichiometry coefficient of the given reactant.     *     * @param  reactant Reactant for which the coefficient is returned.     * @return -1, if the given molecule is not a product in this Reaction     * @see    #setReactantCoefficient     */    public double getReactantCoefficient(org.openscience.cdk.interfaces.IMolecule reactant) {        return reactants.getMultiplier(reactant);    }        /**     * Returns the stoichiometry coefficient of the given product.     *     * @param  product Product for which the coefficient is returned.     * @return -1, if the given molecule is not a product in this Reaction     * @see    #setProductCoefficient     */    public double getProductCoefficient(org.openscience.cdk.interfaces.IMolecule product) {        return products.getMultiplier(product);    }		/**     * Sets the coefficient of a a reactant to a given value.     *     * @param   reactant    Reactant for which the coefficient is set     * @param   coefficient The new coefficient for the given reactant     * @return  true if Molecule has been found and stoichiometry has been set.     * @see     #getReactantCoefficient     */    public boolean setReactantCoefficient(org.openscience.cdk.interfaces.IMolecule reactant, double coefficient) {	notifyChanged();        return reactants.setMultiplier(reactant, coefficient);    }		    	/**     * Sets the coefficient of a a product to a given value.     *     * @param   product     Product for which the coefficient is set     * @param   coefficient The new coefficient for the given product     * @return  true if Molecule has been found and stoichiometry has been set.     * @see     #getProductCoefficient     */    public boolean setProductCoefficient(org.openscience.cdk.interfaces.IMolecule product, double coefficient) {	notifyChanged();        return products.setMultiplier(product, coefficient);    }		/**     * Returns an array of double with the stoichiometric coefficients	 * of the reactants.     *     * @return An array of double's containing the coefficients of the reactants     * @see    #setReactantCoefficients     */    public double[] getReactantCoefficients() {        return reactants.getMultipliers();    }		/**     * Returns an array of double with the stoichiometric coefficients	 * of the products.     *     * @return An array of double's containing the coefficients of the products     * @see    #setProductCoefficients     */    public double[] getProductCoefficients() {        return products.getMultipliers();    }			/**     * Sets the coefficients of the reactants.     *     * @param   coefficients An array of double's containing the coefficients of the reactants     * @return  true if coefficients have been set.     * @see     #getReactantCoefficients     */    public boolean setReactantCoefficients(double[] coefficients) {	notifyChanged();        return reactants.setMultipliers(coefficients);    }		/**     * Sets the coefficient of the products.     *     * @param   coefficients An array of double's containing the coefficients of the products     * @return  true if coefficients have been set.     * @see     #getProductCoefficients     */    public boolean setProductCoefficients(double[] coefficients) {	notifyChanged();        return products.setMultipliers(coefficients);    }	    /**     * Sets the direction of the reaction.     *     * @param direction The new reaction direction     * @see   #getDirection     */    public void setDirection(int direction) {	reactionDirection = direction;	notifyChanged();    }        /**     * Returns the direction of the reaction.     *     * @return The direction of this reaction (FORWARD, BACKWARD or BIDIRECTIONAL).     * @see    #BIDIRECTIONAL     * @see    #setDirection     */    public int getDirection() {        return reactionDirection;    }        /**     * Adds a mapping between the reactant and product side to this     * Reaction.     *     * @param mapping Mapping to add.     * @see   #mappings     */    public void addMapping(org.openscience.cdk.interfaces.IMapping mapping) {        if (mappingCount + 1 >= map.length) growMappingArray();        map[mappingCount] = mapping;        mappingCount++;        notifyChanged();    }        /**     * Removes a mapping between the reactant and product side to this     * Reaction.     *     * @param  pos  Position of the Mapping to remove.     * @see   #mappings     */    public void removeMapping(int pos) {		for (int i = pos; i < mappingCount - 1; i++) {			map[i] = map[i + 1];		}		map[mappingCount - 1] = null;		mappingCount--;		notifyChanged();	}        /**     * Retrieves a mapping between the reactant and product side to this     * Reaction.     *     * @param pos Position of Mapping to get.     */    public IMapping getMapping(int pos) {    	return map[pos];    }        /**     * Get the number of mappings between the reactant and product side to this     * Reaction.     *     * @return Number of stored Mappings.     */    public int getMappingCount() {    	return mappingCount;    }        protected void growMappingArray() {        Mapping[] newMap = new Mapping[map.length + growArraySize];        System.arraycopy(map, 0, newMap, 0, map.length);        map = newMap;    }    /**     * Returns a one line string representation of this Atom.     * Methods is conform RFC #9.     *     * @return  The string representation of this Atom     */    public String toString() {        StringBuffer description = new StringBuffer(64);        description.append("Reaction(");        description.append(getID());        description.append(", #M:").append(mappingCount);        description.append(", reactants=").append(reactants.toString());        description.append(", products=").append(products.toString());        description.append(", agents=").append(agents.toString());        description.append(')');        return description.toString();    }    	/**	 * Clones this <code>Reaction</code> and its content.	 *	 * @return  The cloned object	 */	public Object clone() throws CloneNotSupportedException {		Reaction clone = (Reaction)super.clone();        // clone the reactants, products and agents        clone.reactants = (MoleculeSet)((MoleculeSet)reactants).clone();        clone.agents = (MoleculeSet)((MoleculeSet)agents).clone();        clone.products = (MoleculeSet)((MoleculeSet)products).clone();        // create a Map of corresponding atoms for molecules (key: original Atom,         // value: clone Atom)        Hashtable atomatom = new Hashtable();        for (int i = 0; i < ((MoleculeSet)reactants).getMoleculeCount(); ++i) {            Molecule mol = (Molecule)((MoleculeSet)reactants).getMolecule(i);            Molecule mol2 = (Molecule)clone.reactants.getMolecule(i);            for (int j = 0; j < mol.getAtomCount(); ++j) atomatom.put(mol.getAtom(j), mol2.getAtom(j));        }                // clone the maps		clone.map = new Mapping[map.length];		for (int f = 0; f < mappingCount; f++) {			clone.map[f] = new Mapping((ChemObject)atomatom.get(map[f].getChemObject(0)), (ChemObject)atomatom.get(map[f].getChemObject(1)));		}		return clone;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -