Search in sources :

Example 31 with Parameter

use of cbit.vcell.model.Parameter in project vcell by virtualcell.

the class SpatialProcessParameterTableModel method setValueAt.

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Parameter parameter = getValueAt(rowIndex);
    switch(columnIndex) {
        case COLUMN_NAME:
            {
                try {
                    if (aValue instanceof String) {
                        String newName = (String) aValue;
                        if (!parameter.getName().equals(newName)) {
                            parameter.setName(newName);
                        }
                    }
                } catch (java.beans.PropertyVetoException e) {
                    e.printStackTrace(System.out);
                    PopupGenerator.showErrorDialog(ownerTable, "error changing parameter name\n" + e.getMessage());
                }
                break;
            }
        case COLUMN_VALUE:
            {
                try {
                    if (aValue instanceof String) {
                        String newExpressionString = (String) aValue;
                        Expression newExp = null;
                        if (newExpressionString == null || newExpressionString.trim().length() == 0) {
                            newExp = new Expression(0.0);
                        } else {
                            newExp = new Expression(newExpressionString);
                        }
                        parameter.setExpression(newExp);
                    }
                } catch (ExpressionException e) {
                    e.printStackTrace(System.out);
                    PopupGenerator.showErrorDialog(ownerTable, "expression error\n" + e.getMessage());
                }
                break;
            }
    }
}
Also used : ScopedExpression(cbit.gui.ScopedExpression) Expression(cbit.vcell.parser.Expression) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) Parameter(cbit.vcell.model.Parameter) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 32 with Parameter

use of cbit.vcell.model.Parameter in project vcell by virtualcell.

the class SpeciesContextSpecParameterTableModel method setValueAt.

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Parameter parameter = getValueAt(rowIndex);
    switch(columnIndex) {
        case COLUMN_NAME:
            {
                try {
                    if (aValue instanceof String) {
                        String newName = (String) aValue;
                        if (!parameter.getName().equals(newName)) {
                            if (parameter instanceof SpeciesContextSpec.SpeciesContextSpecParameter) {
                                SpeciesContextSpec.SpeciesContextSpecParameter scsParm = (SpeciesContextSpec.SpeciesContextSpecParameter) parameter;
                                scsParm.setName(newName);
                            }
                        }
                    }
                } catch (java.beans.PropertyVetoException e) {
                    e.printStackTrace(System.out);
                    PopupGenerator.showErrorDialog(ownerTable, "error changing parameter name\n" + e.getMessage());
                }
                break;
            }
        case COLUMN_VALUE:
            {
                try {
                    if (aValue instanceof String) {
                        String newExpressionString = (String) aValue;
                        if (parameter instanceof SpeciesContextSpec.SpeciesContextSpecParameter) {
                            SpeciesContextSpec.SpeciesContextSpecParameter scsParm = (SpeciesContextSpec.SpeciesContextSpecParameter) parameter;
                            Expression newExp = null;
                            if (newExpressionString == null || newExpressionString.trim().length() == 0) {
                                if (scsParm.getRole() == SpeciesContextSpec.ROLE_InitialConcentration || scsParm.getRole() == SpeciesContextSpec.ROLE_DiffusionRate || scsParm.getRole() == SpeciesContextSpec.ROLE_InitialCount) {
                                    newExp = new Expression(0.0);
                                }
                            } else {
                                newExp = new Expression(newExpressionString);
                            }
                            scsParm.setExpression(newExp);
                        }
                    }
                } catch (ExpressionException e) {
                    e.printStackTrace(System.out);
                    PopupGenerator.showErrorDialog(ownerTable, "expression error\n" + e.getMessage());
                }
                break;
            }
    }
}
Also used : ScopedExpression(cbit.gui.ScopedExpression) Expression(cbit.vcell.parser.Expression) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) Parameter(cbit.vcell.model.Parameter) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) ExpressionException(cbit.vcell.parser.ExpressionException) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)

Example 33 with Parameter

use of cbit.vcell.model.Parameter in project vcell by virtualcell.

the class StructureMappingTableModel method getColumnCount.

/**
 * getColumnCount method comment.
 */
public int getColumnCount() {
    if (getGeometryContext() == null) {
        return 0;
    }
    if (bNonSpatial) {
        StructureMapping[] sms = getGeometryContext().getStructureMappings();
        boolean bHasOldSizeRatio = false;
        for (StructureMapping sm : sms) {
            Parameter volFrac = sm.getParameterFromRole(StructureMapping.ROLE_VolumeFraction);
            if (volFrac != null && volFrac.getExpression() != null) {
                bHasOldSizeRatio = true;
                break;
            }
            Parameter surfVolFrac = sm.getParameterFromRole(StructureMapping.ROLE_SurfaceToVolumeRatio);
            if (surfVolFrac != null && surfVolFrac.getExpression() != null) {
                bHasOldSizeRatio = true;
                break;
            }
        }
        return bHasOldSizeRatio ? NONSPATIAL_LABELS.length : NONSPATIAL_LABELS.length - 2;
    } else {
        int dimension = getGeometryContext().getGeometry().getDimension();
        int count = SPATIAL_LABELS.length;
        if (dimension == 1) {
            return count - 4;
        }
        if (dimension == 2) {
            return count - 2;
        }
        return count;
    }
}
Also used : Parameter(cbit.vcell.model.Parameter) StructureMapping(cbit.vcell.mapping.StructureMapping)

Example 34 with Parameter

use of cbit.vcell.model.Parameter in project vcell by virtualcell.

the class SpatialProcessParameterTableModel method propertyChange.

public void propertyChange(java.beans.PropertyChangeEvent evt) {
    try {
        if (evt.getSource() instanceof SpatialProcess) {
            refreshData();
        }
        if (evt.getSource() == this && evt.getPropertyName().equals(PROPERTY_NAME_SPATIALPROCESS)) {
            SpatialProcess oldValue = (SpatialProcess) evt.getOldValue();
            if (oldValue != null) {
                oldValue.removePropertyChangeListener(this);
                Parameter[] oldParameters = oldValue.getParameters();
                if (oldParameters != null) {
                    for (int i = 0; i < oldParameters.length; i++) {
                        oldParameters[i].removePropertyChangeListener(this);
                    }
                }
            }
            SpatialProcess newValue = (SpatialProcess) evt.getNewValue();
            if (newValue != null) {
                newValue.addPropertyChangeListener(this);
                Parameter[] newParameters = newValue.getParameters();
                if (newParameters != null) {
                    for (int i = 0; i < newParameters.length; i++) {
                        newParameters[i].addPropertyChangeListener(this);
                    }
                }
            }
            refreshData();
        }
        if (evt.getSource() instanceof SpatialProcess) {
            // if parameters changed must update listeners
            if (evt.getPropertyName().equals(SpatialProcess.PROPERTY_NAME_PARAMETERS)) {
                Parameter[] oldParameters = (Parameter[]) evt.getOldValue();
                if (oldParameters != null) {
                    for (int i = 0; i < oldParameters.length; i++) {
                        oldParameters[i].removePropertyChangeListener(this);
                    }
                }
                Parameter[] newParameters = (Parameter[]) evt.getNewValue();
                if (newParameters != null) {
                    for (int i = 0; i < newParameters.length; i++) {
                        newParameters[i].addPropertyChangeListener(this);
                    }
                }
            }
            if (!evt.getPropertyName().equals(SpeciesContextSpec.PARAMETER_NAME_PROXY_PARAMETERS)) {
                // for any change to the SpeciesContextSpec, want to update all.
                // proxy parameters don't affect table
                refreshData();
            }
        }
        if (evt.getSource() instanceof Parameter) {
            refreshData();
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) Parameter(cbit.vcell.model.Parameter) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 35 with Parameter

use of cbit.vcell.model.Parameter in project vcell by virtualcell.

the class SpeciesContextSpecParameterTableModel method propertyChange.

/**
 * This method gets called when a bound property is changed.
 * @param evt A PropertyChangeEvent object describing the event source
 *   and the property that has changed.
 */
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    // 
    try {
        // 
        if (fieldSpeciesContextSpec != null && evt.getSource() == fieldSpeciesContextSpec.getSimulationContext().getGeometryContext() && evt.getPropertyName().equals("geometry")) {
            refreshData();
        }
        // 
        if (fieldSpeciesContextSpec != null && evt.getSource() == fieldSpeciesContextSpec.getSimulationContext().getGeometryContext() && evt.getPropertyName().equals("structureMappings")) {
            StructureMapping[] oldStructureMappings = (StructureMapping[]) evt.getOldValue();
            for (int i = 0; oldStructureMappings != null && i < oldStructureMappings.length; i++) {
                oldStructureMappings[i].removePropertyChangeListener(this);
            }
            StructureMapping[] newStructureMappings = (StructureMapping[]) evt.getNewValue();
            for (int i = 0; newStructureMappings != null && i < newStructureMappings.length; i++) {
                newStructureMappings[i].addPropertyChangeListener(this);
            }
            refreshData();
        }
        // 
        if (evt.getSource() instanceof StructureMapping) {
            refreshData();
        }
        if (evt.getSource() == this && evt.getPropertyName().equals("speciesContextSpec")) {
            SpeciesContextSpec oldValue = (SpeciesContextSpec) evt.getOldValue();
            if (oldValue != null) {
                oldValue.removePropertyChangeListener(this);
                Parameter[] oldParameters = oldValue.getParameters();
                if (oldParameters != null) {
                    for (int i = 0; i < oldParameters.length; i++) {
                        oldParameters[i].removePropertyChangeListener(this);
                    }
                }
                SimulationContext oldSimContext = oldValue.getSimulationContext();
                if (oldSimContext != null) {
                    oldSimContext.getGeometryContext().removePropertyChangeListener(this);
                    StructureMapping[] oldStructureMappings = oldSimContext.getGeometryContext().getStructureMappings();
                    if (oldStructureMappings != null) {
                        for (int i = 0; i < oldStructureMappings.length; i++) {
                            oldStructureMappings[i].removePropertyChangeListener(this);
                        }
                    }
                }
            }
            SpeciesContextSpec newValue = (SpeciesContextSpec) evt.getNewValue();
            if (newValue != null) {
                newValue.addPropertyChangeListener(this);
                Parameter[] newParameters = newValue.getParameters();
                if (newParameters != null) {
                    for (int i = 0; i < newParameters.length; i++) {
                        newParameters[i].addPropertyChangeListener(this);
                    }
                }
                SimulationContext newSimContext = newValue.getSimulationContext();
                if (newSimContext != null) {
                    newSimContext.getGeometryContext().addPropertyChangeListener(this);
                    StructureMapping[] newStructureMappings = newSimContext.getGeometryContext().getStructureMappings();
                    if (newStructureMappings != null) {
                        for (int i = 0; i < newStructureMappings.length; i++) {
                            newStructureMappings[i].addPropertyChangeListener(this);
                        }
                    }
                }
            }
            refreshData();
        }
        if (evt.getSource() instanceof SpeciesContextSpec) {
            // if parameters changed must update listeners
            if (evt.getPropertyName().equals("parameters")) {
                Parameter[] oldParameters = (Parameter[]) evt.getOldValue();
                if (oldParameters != null) {
                    for (int i = 0; i < oldParameters.length; i++) {
                        oldParameters[i].removePropertyChangeListener(this);
                    }
                }
                Parameter[] newParameters = (Parameter[]) evt.getNewValue();
                if (newParameters != null) {
                    for (int i = 0; i < newParameters.length; i++) {
                        newParameters[i].addPropertyChangeListener(this);
                    }
                }
            }
            if (!evt.getPropertyName().equals(SpeciesContextSpec.PARAMETER_NAME_PROXY_PARAMETERS)) {
                // for any change to the SpeciesContextSpec, want to update all.
                // proxy parameters don't affect table
                refreshData();
            }
        }
        if (evt.getSource() instanceof Parameter) {
            refreshData();
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) Parameter(cbit.vcell.model.Parameter) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) SimulationContext(cbit.vcell.mapping.SimulationContext) StructureMapping(cbit.vcell.mapping.StructureMapping) ExpressionException(cbit.vcell.parser.ExpressionException)

Aggregations

Parameter (cbit.vcell.model.Parameter)54 Expression (cbit.vcell.parser.Expression)33 ModelParameter (cbit.vcell.model.Model.ModelParameter)29 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)19 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)19 SpeciesContext (cbit.vcell.model.SpeciesContext)19 ExpressionException (cbit.vcell.parser.ExpressionException)18 Model (cbit.vcell.model.Model)15 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)15 PropertyVetoException (java.beans.PropertyVetoException)15 ReactionStep (cbit.vcell.model.ReactionStep)14 SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)13 ModelUnitSystem (cbit.vcell.model.ModelUnitSystem)12 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)11 Structure (cbit.vcell.model.Structure)11 ArrayList (java.util.ArrayList)10 StructureMapping (cbit.vcell.mapping.StructureMapping)9 MathDescription (cbit.vcell.math.MathDescription)9 ProxyParameter (cbit.vcell.model.ProxyParameter)9 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)9