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