Search in sources :

Example 66 with AnnotatedFunction

use of cbit.vcell.solver.AnnotatedFunction in project vcell by virtualcell.

the class OutputFunctionsPanel method addFunction.

private void addFunction() throws Exception {
    String funcName = getFunctionNameTextField().getText();
    Expression funcExp = null;
    funcExp = new Expression(getFunctionExpressionTextField().getText());
    Domain domain = null;
    VariableType newFunctionVariableType = null;
    boolean bSpatial = simulationWorkspace.getSimulationOwner().getGeometry().getDimension() > 0;
    if (bSpatial) {
        Object selectedItem = getSubdomainComboBox().getSelectedItem();
        if (selectedItem instanceof GeometryClass) {
            GeometryClass geoClass = (GeometryClass) selectedItem;
            domain = new Domain(geoClass);
            if (selectedItem instanceof SubVolume) {
                newFunctionVariableType = VariableType.VOLUME;
            } else if (selectedItem instanceof SurfaceClass) {
                newFunctionVariableType = VariableType.MEMBRANE;
            }
        } else if (selectedItem instanceof VariableType) {
            newFunctionVariableType = (VariableType) selectedItem;
        } else {
            newFunctionVariableType = VariableType.UNKNOWN;
        }
    } else {
        newFunctionVariableType = VariableType.NONSPATIAL;
    }
    AnnotatedFunction tempFunction = new AnnotatedFunction(funcName, funcExp, domain, null, newFunctionVariableType, FunctionCategory.OUTPUTFUNCTION);
    VariableType vt = outputFunctionContext.computeFunctionTypeWRTExpression(tempFunction, funcExp);
    FunctionCategory category = FunctionCategory.OUTPUTFUNCTION;
    if (vt.equals(VariableType.POSTPROCESSING)) {
        category = FunctionCategory.POSTPROCESSFUNCTION;
    }
    AnnotatedFunction newFunction = new AnnotatedFunction(funcName, funcExp, domain, null, vt, category);
    outputFunctionContext.addOutputFunction(newFunction);
    setSelectedObjects(new Object[] { newFunction });
    enableDeleteFnButton();
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) VariableType(cbit.vcell.math.VariableType) Expression(cbit.vcell.parser.Expression) SurfaceClass(cbit.vcell.geometry.SurfaceClass) SubVolume(cbit.vcell.geometry.SubVolume) Domain(cbit.vcell.math.Variable.Domain) FunctionCategory(cbit.vcell.solver.AnnotatedFunction.FunctionCategory) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 67 with AnnotatedFunction

use of cbit.vcell.solver.AnnotatedFunction in project vcell by virtualcell.

the class OutputFunctionsListTableModel method setValueAt.

/**
 * Insert the method's description here.
 * Creation date: (7/12/2004 2:01:23 PM)
 * @param aValue java.lang.Object
 * @param rowIndex int
 * @param columnIndex int
 */
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    AnnotatedFunction outputFunction = getValueAt(rowIndex);
    switch(columnIndex) {
        case COLUMN_OUTPUTFN_EXPRESSION:
            {
                try {
                    Expression exp = new Expression((String) aValue);
                    if (exp.compareEqual(outputFunction.getExpression())) {
                        return;
                    }
                    exp.bindExpression(outputFunctionContext);
                    VariableType vt = outputFunctionContext.computeFunctionTypeWRTExpression(outputFunction, exp);
                    if (!vt.compareEqual(outputFunction.getFunctionType())) {
                    }
                    outputFunction.setExpression(exp);
                    fireTableRowsUpdated(rowIndex, rowIndex);
                    outputFunctionContext.firePropertyChange("outputFunctions", null, outputFunctionContext.getOutputFunctionsList());
                } catch (ExpressionException e) {
                    e.printStackTrace(System.out);
                    PopupGenerator.showErrorDialog(ownerTable, "Expression error:\n" + e.getMessage());
                } catch (InconsistentDomainException e) {
                    e.printStackTrace(System.out);
                    PopupGenerator.showErrorDialog(ownerTable, "Expression error:\n" + e.getMessage());
                }
                break;
            }
        case COLUMN_OUTPUTFN_VARIABLETYPE:
            {
                for (int i = 0; i < availableGeometryClasses.length; i++) {
                    if (availableGeometryClasses[i].getName().equals(aValue)) {
                        Domain newDomain = new Domain(availableGeometryClasses[i]);
                        outputFunction.setDomain(newDomain);
                        fireTableRowsUpdated(rowIndex, rowIndex);
                        outputFunctionContext.firePropertyChange("outputFunctions", null, outputFunctionContext.getOutputFunctionsList());
                        break;
                    }
                }
                break;
            }
    }
}
Also used : VariableType(cbit.vcell.math.VariableType) ScopedExpression(cbit.gui.ScopedExpression) Expression(cbit.vcell.parser.Expression) InconsistentDomainException(cbit.vcell.math.InconsistentDomainException) Domain(cbit.vcell.math.Variable.Domain) ExpressionException(cbit.vcell.parser.ExpressionException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 68 with AnnotatedFunction

use of cbit.vcell.solver.AnnotatedFunction in project vcell by virtualcell.

the class OutputFunctionsPanel method deleteOutputFunction.

private void deleteOutputFunction() {
    if (getSelectedFunction() != null) {
        AnnotatedFunction function = getSelectedFunction();
        String confirm = PopupGenerator.showOKCancelWarningDialog(this, "Deleting Output Function", "You are going to delete the Output Function '" + function.getName() + "'. Continue?");
        if (confirm.equals(UserMessage.OPTION_CANCEL)) {
            return;
        }
        try {
            outputFunctionContext.removeOutputFunction(function);
        } catch (PropertyVetoException e1) {
            e1.printStackTrace(System.out);
            DialogUtils.showErrorDialog(this, " Deletion of function '" + function.getName() + "' failed." + e1.getMessage());
        }
    }
    enableDeleteFnButton();
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)68 ExpressionException (cbit.vcell.parser.ExpressionException)24 DataAccessException (org.vcell.util.DataAccessException)23 Expression (cbit.vcell.parser.Expression)20 ArrayList (java.util.ArrayList)20 IOException (java.io.IOException)18 OutputContext (cbit.vcell.simdata.OutputContext)17 Simulation (cbit.vcell.solver.Simulation)17 SimulationContext (cbit.vcell.mapping.SimulationContext)14 MathException (cbit.vcell.math.MathException)14 DataIdentifier (cbit.vcell.simdata.DataIdentifier)12 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)12 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)11 FileNotFoundException (java.io.FileNotFoundException)11 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)10 XmlParseException (cbit.vcell.xml.XmlParseException)10 BioModel (cbit.vcell.biomodel.BioModel)9 Domain (cbit.vcell.math.Variable.Domain)8 PropertyVetoException (java.beans.PropertyVetoException)8 File (java.io.File)8