use of cbit.vcell.mapping.SpeciesContextSpec 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);
}
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class SpeciesContextSpecParameterTableModel method setSpeciesContextSpec.
/**
* Sets the speciesContextSpec property (cbit.vcell.mapping.SpeciesContextSpec) value.
* @param speciesContextSpec The new value for the property.
* @see #getSpeciesContextSpec
*/
public void setSpeciesContextSpec(SpeciesContextSpec speciesContextSpec) {
SpeciesContextSpec oldValue = fieldSpeciesContextSpec;
fieldSpeciesContextSpec = speciesContextSpec;
firePropertyChange("speciesContextSpec", oldValue, speciesContextSpec);
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class SpeciesContextSpecsTableModel method isCellEditable.
/**
* Insert the method's description here.
* Creation date: (2/24/01 12:27:46 AM)
* @return boolean
* @param rowIndex int
* @param columnIndex int
*/
public boolean isCellEditable(int rowIndex, int columnIndex) {
SpeciesContextSpec speciesContextSpec = getValueAt(rowIndex);
ColumnType columnType = columns.get(columnIndex);
switch(columnType) {
case COLUMN_SPECIESCONTEXT:
{
return false;
}
case COLUMN_STRUCTURE:
{
return false;
}
case COLUMN_DEPICTION:
{
return false;
}
case COLUMN_CLAMPED:
{
return true;
}
case COLUMN_WELLMIXED:
{
return !speciesContextSpec.isConstant() && !getSimulationContext().isStoch();
}
case COLUMN_FORCECONTINUOUS:
{
return !speciesContextSpec.isConstant() && getSimulationContext().isStoch();
}
case COLUMN_INITIAL:
{
return true;
}
case COLUMN_DIFFUSION:
{
return !speciesContextSpec.isConstant() && (!speciesContextSpec.isWellMixed() || getSimulationContext().isStoch());
}
default:
{
return false;
}
}
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class SpeciesContextSpecsTableModel method setValueAt.
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
SpeciesContextSpec scSpec = getValueAt(rowIndex);
ColumnType columnType = columns.get(columnIndex);
switch(columnType) {
case COLUMN_CLAMPED:
{
boolean bFixed = ((Boolean) aValue).booleanValue();
if (bFixed) {
scSpec.setConstant(true);
} else {
scSpec.setConstant(false);
}
fireTableRowsUpdated(rowIndex, rowIndex);
break;
}
case COLUMN_WELLMIXED:
{
boolean bWellMixed = ((Boolean) aValue).booleanValue();
scSpec.setWellMixed(bWellMixed);
fireTableRowsUpdated(rowIndex, rowIndex);
break;
}
case COLUMN_FORCECONTINUOUS:
{
boolean bForceContinuous = ((Boolean) aValue).booleanValue();
scSpec.setForceContinuous(bForceContinuous);
fireTableRowsUpdated(rowIndex, rowIndex);
break;
}
case COLUMN_INITIAL:
{
try {
if (aValue instanceof String) {
String newExpressionString = (String) aValue;
if (getSimulationContext().isUsingConcentration()) {
scSpec.getInitialConcentrationParameter().setExpression(new Expression(newExpressionString));
} else {
scSpec.getInitialCountParameter().setExpression(new Expression(newExpressionString));
}
}
fireTableRowsUpdated(rowIndex, rowIndex);
} catch (ExpressionException e) {
e.printStackTrace(System.out);
//
// don't handle exception here, InitialConditionsPanel needs it.
//
PopupGenerator.showErrorDialog(ownerTable, "Wrong Expression:\n" + e.getMessage());
// throw new RuntimeException(e.getMessage());
}
break;
}
case COLUMN_DIFFUSION:
{
try {
if (aValue instanceof String) {
String newExpressionString = (String) aValue;
scSpec.getDiffusionParameter().setExpression(new Expression(newExpressionString));
}
fireTableRowsUpdated(rowIndex, rowIndex);
} catch (ExpressionException e) {
e.printStackTrace(System.out);
//
// don't handle exception here, InitialConditionsPanel needs it.
//
PopupGenerator.showErrorDialog(ownerTable, "Wrong Expression:\n" + e.getMessage());
// throw new RuntimeException(e.getMessage());
}
break;
}
}
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class SpeciesContextSpecsTableModel method getComparator.
public Comparator<SpeciesContextSpec> getComparator(final int col, final boolean ascending) {
return new Comparator<SpeciesContextSpec>() {
/**
* Compares its two arguments for order. Returns a negative integer,
* zero, or a positive integer as the first argument is less than, equal
* to, or greater than the second.<p>
*/
public int compare(SpeciesContextSpec speciesContextSpec1, SpeciesContextSpec speciesContextSpec2) {
SpeciesContext speciesContext1 = speciesContextSpec1.getSpeciesContext();
SpeciesContext speciesContext2 = speciesContextSpec2.getSpeciesContext();
ColumnType columnType = columns.get(col);
switch(columnType) {
case COLUMN_SPECIESCONTEXT:
{
String name1 = speciesContext1.getName();
String name2 = speciesContext2.getName();
if (ascending) {
return name1.compareToIgnoreCase(name2);
} else {
return name2.compareToIgnoreCase(name1);
}
}
case COLUMN_STRUCTURE:
{
String name1 = speciesContext1.getStructure().getName();
String name2 = speciesContext2.getStructure().getName();
if (ascending) {
return name1.compareToIgnoreCase(name2);
} else {
return name2.compareToIgnoreCase(name1);
}
}
case COLUMN_CLAMPED:
{
Boolean bClamped1 = new Boolean(speciesContextSpec1.isConstant());
Boolean bClamped2 = new Boolean(speciesContextSpec2.isConstant());
if (ascending) {
return bClamped1.compareTo(bClamped2);
} else {
return bClamped2.compareTo(bClamped1);
}
}
case COLUMN_FORCECONTINUOUS:
{
Boolean bForceContinuous1 = new Boolean(speciesContextSpec1.isForceContinuous());
Boolean bForceContinuous2 = new Boolean(speciesContextSpec2.isForceContinuous());
if (ascending) {
return bForceContinuous1.compareTo(bForceContinuous2);
} else {
return bForceContinuous2.compareTo(bForceContinuous1);
}
}
case COLUMN_WELLMIXED:
{
Boolean bWellMixed1 = new Boolean(speciesContextSpec1.isWellMixed());
Boolean bWellMixed2 = new Boolean(speciesContextSpec2.isWellMixed());
if (ascending) {
return bWellMixed1.compareTo(bWellMixed2);
} else {
return bWellMixed2.compareTo(bWellMixed1);
}
}
case COLUMN_INITIAL:
{
Expression initExp1 = speciesContextSpec1.getInitialConditionParameter().getExpression();
Expression initExp2 = speciesContextSpec2.getInitialConditionParameter().getExpression();
return TableUtil.expressionCompare(initExp1, initExp2, ascending);
}
case COLUMN_DIFFUSION:
{
Expression diffExp1 = speciesContextSpec1.getDiffusionParameter().getExpression();
Expression diffExp2 = speciesContextSpec2.getDiffusionParameter().getExpression();
return TableUtil.expressionCompare(diffExp1, diffExp2, ascending);
}
}
return 1;
}
};
}
Aggregations