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();
}
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;
}
}
}
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();
}
Aggregations