package affectors; import java.io.PrintWriter; import java.util.Enumeration; import java.util.Vector; import main.Node; import main.Cell; import main.Globals; /** This is a special "meta-affector". Rather than calculating something on its own, the ProductAff is a container for other affectors. It simply multiplies together the values of each affector contained within it. For instance, to add an inhibition to some other term, you might wrap the term in a ProductAff along with the PsiAff

Formula
dnodex/dt = SubAffector1 * SubAffector2 * ... * SubAffectorN

Parameters
No Parameters

Usage
&NODEX

&ProductAff
&[some_affector]
&[some_other_affector]
&endProductAff
&endNODEX */ public class Product extends EnhancerRegionAff implements Cloneable { static final String desc = "Product of several other affectors"; static final int [] whichSides = { -1 }; public Product() { } protected void setLabelsAndTypes() { setDescriptions(this.desc, null, null); setSided(true, whichSides); this.Type[GUI_CAPABLE] = 0; this.Type[CERTIFICATION] = Affector.RETURNS_DERIV; this.Type[MATHTYPE] = Affector.FF; // ???? None really fit this.Type[TERMTYPE] = Affector.PRODUCTION; } public void setParameterNumbers(int [] param_nums) {} // Keep compiler happy /** Overrides Affector.getValue() to multiply together the values from all the subsidiary affectors. */ public float getValue(Node which_node) { float value = 1; for(int i = 0; i < numAffectors; i++) value *= affectors[i].getValue(which_node); return value; } /** Overrides Affector.getNCValue() to multiply together the values from all the subsidiary affectors. */ public float getNCValue(Node which_node) { if(containsTarget) { float value = 1; for(int i = 0; i < numAffectors; i++) value *= affectors[i].getNCValue(which_node); return value; } else return super.getNCValue(which_node); } /* The rest of these functions are overrides of Affector functions so that they work right for this class. */ public Affector copy() { ProductAff element = null; try { element = (ProductAff)this.clone(); } catch(CloneNotSupportedException e) { System.out.println("Error cloning ProductAff: " + e.toString()); } element.affectors = new Affector[numAffectors]; element.numAffectors = 0; for(int i = 0; i < numAffectors; i++) { element.addAffector(affectors[i].copy()); } return element; } }