Search in sources :

Example 56 with MathDescription

use of cbit.vcell.math.MathDescription in project vcell by virtualcell.

the class MathDebuggerPanel method flatten.

private void flatten(MathSymbolTableFactory mathSymbolTableFactory) throws PropertyVetoException, MathException, ExpressionException, MappingException, XmlParseException {
    MathDescription math1 = getMathModel1().getMathDescription();
    MathDescription newMath1 = MathDescription.createCanonicalMathDescription(mathSymbolTableFactory, math1);
    MathModel newMathModel1 = new MathModel(null);
    newMathModel1.setName("Math1");
    newMathModel1.setMathDescription(newMath1);
    setMathModel1(newMathModel1);
    MathDescription math2 = getMathModel2().getMathDescription();
    MathDescription newMath2 = MathDescription.createCanonicalMathDescription(mathSymbolTableFactory, math2);
    MathModel newMathModel2 = new MathModel(null);
    newMathModel2.setName("Math2");
    newMathModel2.setMathDescription(newMath2);
    setMathModel2(newMathModel2);
    compareTree();
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription)

Example 57 with MathDescription

use of cbit.vcell.math.MathDescription in project vcell by virtualcell.

the class MathDebuggerPanel method getMathModel1.

public MathModel getMathModel1() throws PropertyVetoException {
    MathDescription mathDesc = mathDescEditor1.getMathDescription();
    if (mathDesc == null) {
        return null;
    } else {
        MathModel mathModel = new MathModel(null);
        mathModel.setName("MATH 1");
        mathModel.setMathDescription(mathDesc);
        return mathModel;
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription)

Example 58 with MathDescription

use of cbit.vcell.math.MathDescription in project vcell by virtualcell.

the class MathDescPanel method setmathDescription1.

/**
 * Set the mathDescription1 to a new value.
 * @param newValue cbit.vcell.math.MathDescription
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setmathDescription1(MathDescription newValue) {
    if (ivjmathDescription1 != newValue) {
        try {
            MathDescription oldValue = getmathDescription1();
            ivjmathDescription1 = newValue;
            connPtoP1SetSource();
            connEtoM2(ivjmathDescription1);
            firePropertyChange("mathDescription", oldValue, newValue);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    ;
// user code begin {3}
// user code end
}
Also used : MathDescription(cbit.vcell.math.MathDescription)

Example 59 with MathDescription

use of cbit.vcell.math.MathDescription in project vcell by virtualcell.

the class MathDescPanel method setMathDescription.

/**
 * Sets the mathDescription property (cbit.vcell.math.MathDescription) value.
 * @param mathDescription The new value for the property.
 * @see #getMathDescription
 */
public void setMathDescription(MathDescription mathDescription) {
    MathDescription oldValue = fieldMathDescription;
    fieldMathDescription = mathDescription;
    firePropertyChange("mathDescription", oldValue, mathDescription);
}
Also used : MathDescription(cbit.vcell.math.MathDescription)

Example 60 with MathDescription

use of cbit.vcell.math.MathDescription in project vcell by virtualcell.

the class MathOverridesPanel method jMenuItemPaste_ActionPerformed.

/**
 * Comment
 */
private void jMenuItemPaste_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
    java.util.Vector<String> pasteDescriptionsV = new java.util.Vector<String>();
    java.util.Vector<Expression> newConstantsV = new java.util.Vector<Expression>();
    java.util.Vector<String> changedParameterNamesV = new java.util.Vector<String>();
    try {
        if (actionEvent.getSource().equals(getJMenuItemPaste()) || actionEvent.getSource().equals(getJMenuItemPasteAll())) {
            int[] rows = null;
            if (actionEvent.getSource() == getJMenuItemPasteAll()) {
                rows = new int[getJTableFixed().getRowCount()];
                for (int i = 0; i < rows.length; i += 1) {
                    rows[i] = i;
                }
            } else {
                rows = getJTableFixed().getSelectedRows();
            }
            Object pasteThis = VCellTransferable.getFromClipboard(VCellTransferable.OBJECT_FLAVOR);
            for (int i = 0; i < rows.length; i += 1) {
                if (pasteThis instanceof VCellTransferable.ResolvedValuesSelection) {
                    VCellTransferable.ResolvedValuesSelection rvs = (VCellTransferable.ResolvedValuesSelection) pasteThis;
                    for (int j = 0; j < rvs.getPrimarySymbolTableEntries().length; j += 1) {
                        Constant pastedConstant = null;
                        if (rvs.getPrimarySymbolTableEntries()[j] instanceof Constant) {
                            pastedConstant = (Constant) rvs.getPrimarySymbolTableEntries()[j];
                        } else if (rvs.getAlternateSymbolTableEntries() != null && rvs.getAlternateSymbolTableEntries()[j] instanceof Constant) {
                            pastedConstant = (Constant) rvs.getAlternateSymbolTableEntries()[j];
                        }
                        // 
                        if (pastedConstant == null && (rvs.getPrimarySymbolTableEntries()[j] instanceof Function) || (rvs.getPrimarySymbolTableEntries()[j] instanceof VolVariable) || (rvs.getPrimarySymbolTableEntries()[j] instanceof VolumeRegionVariable) || (rvs.getPrimarySymbolTableEntries()[j] instanceof MemVariable) || (rvs.getPrimarySymbolTableEntries()[j] instanceof MembraneRegionVariable)) {
                            MathDescription mathDescription = getMathOverrides().getSimulation().getMathDescription();
                            Enumeration<Constant> constants = mathDescription.getConstants();
                            while (constants.hasMoreElements()) {
                                Constant constant = constants.nextElement();
                                if (constant.getName().startsWith(rvs.getPrimarySymbolTableEntries()[j].getName() + DiffEquMathMapping.MATH_FUNC_SUFFIX_SPECIES_INIT_CONC_UNIT_PREFIX)) {
                                    pastedConstant = new Constant(constant.getName(), rvs.getExpressionValues()[j]);
                                }
                            }
                        }
                        // 
                        // find row of math overrides table with the same name as the pastedConstant and propose to change that override to the pasted value
                        // 
                        String rowName = (String) getJTableFixed().getValueAt(rows[i], MathOverridesTableModel.COLUMN_PARAMETER);
                        if (pastedConstant != null && pastedConstant.getName().equals(rowName)) {
                            changedParameterNamesV.add(rowName);
                            newConstantsV.add(rvs.getExpressionValues()[j]);
                            String originalValueDescription = null;
                            if (getMathOverrides().getConstantArraySpec(rowName) != null) {
                                originalValueDescription = getMathOverrides().getConstantArraySpec(rowName).toString();
                            } else if (getMathOverrides().getActualExpression(rowName, 0) != null) {
                                originalValueDescription = getMathOverrides().getActualExpression(rowName, 0).infix();
                            } else {
                                throw new Exception("MathOverridesPanel can't find value for '" + rowName + "'");
                            }
                            pasteDescriptionsV.add(VCellCopyPasteHelper.formatPasteList(rowName, pastedConstant.getName(), originalValueDescription, rvs.getExpressionValues()[j].infix() + ""));
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        PopupGenerator.showErrorDialog(this, "Paste failed during pre-check (no changes made).\n" + e.getClass().getName() + " " + e.getMessage(), e);
        return;
    }
    // Do paste
    try {
        if (pasteDescriptionsV.size() > 0) {
            String[] pasteDescriptionArr = new String[pasteDescriptionsV.size()];
            pasteDescriptionsV.copyInto(pasteDescriptionArr);
            String[] changedParameterNamesArr = new String[changedParameterNamesV.size()];
            changedParameterNamesV.copyInto(changedParameterNamesArr);
            VCellCopyPasteHelper.chooseApplyPaste(this, pasteDescriptionArr, getMathOverrides(), changedParameterNamesArr, newConstantsV);
        } else {
            PopupGenerator.showInfoDialog(this, "No paste items match the destination (no changes made).");
        }
    } catch (Throwable e) {
        PopupGenerator.showErrorDialog(this, "Paste Error\n" + e.getClass().getName() + " " + e.getMessage(), e);
    }
}
Also used : MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) VolVariable(cbit.vcell.math.VolVariable) MathDescription(cbit.vcell.math.MathDescription) Constant(cbit.vcell.math.Constant) VCellTransferable(cbit.vcell.desktop.VCellTransferable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) Function(cbit.vcell.math.Function) MemVariable(cbit.vcell.math.MemVariable) ScopedExpression(cbit.gui.ScopedExpression) Expression(cbit.vcell.parser.Expression)

Aggregations

MathDescription (cbit.vcell.math.MathDescription)120 Simulation (cbit.vcell.solver.Simulation)48 Geometry (cbit.vcell.geometry.Geometry)32 SimulationContext (cbit.vcell.mapping.SimulationContext)32 Variable (cbit.vcell.math.Variable)32 Expression (cbit.vcell.parser.Expression)30 ExpressionException (cbit.vcell.parser.ExpressionException)27 PropertyVetoException (java.beans.PropertyVetoException)25 BioModel (cbit.vcell.biomodel.BioModel)24 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)22 Constant (cbit.vcell.math.Constant)22 MathException (cbit.vcell.math.MathException)21 MathModel (cbit.vcell.mathmodel.MathModel)21 KeyValue (org.vcell.util.document.KeyValue)20 SubDomain (cbit.vcell.math.SubDomain)19 ArrayList (java.util.ArrayList)18 SubVolume (cbit.vcell.geometry.SubVolume)17 Model (cbit.vcell.model.Model)17 DataAccessException (org.vcell.util.DataAccessException)17 Function (cbit.vcell.math.Function)15