Search in sources :

Example 6 with ParameterMappingSpec

use of cbit.vcell.modelopt.ParameterMappingSpec in project vcell by virtualcell.

the class ParameterMappingTableModel method setValueAt.

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    if (columnIndex < 0 || columnIndex >= getColumnCount()) {
        throw new RuntimeException("ParameterTableModel.setValueAt(), column = " + columnIndex + " out of range [" + 0 + "," + (getColumnCount() - 1) + "]");
    }
    ParameterMappingSpec parameterMappingSpec = getValueAt(rowIndex);
    switch(columnIndex) {
        case COLUMN_LOWVALUE:
            {
                if (aValue instanceof Double) {
                    double value = ((Double) aValue).doubleValue();
                    parameterMappingSpec.setLow(value);
                    fireTableRowsUpdated(rowIndex, rowIndex);
                } else if (aValue instanceof String) {
                    String newDoubleString = (String) aValue;
                    try {
                        parameterMappingSpec.setLow(Double.parseDouble(newDoubleString));
                        fireTableRowsUpdated(rowIndex, rowIndex);
                    } catch (NumberFormatException e) {
                        if (newDoubleString.equals("") || newDoubleString.equalsIgnoreCase("-Infinity") || newDoubleString.equalsIgnoreCase("-Inf")) {
                            parameterMappingSpec.setLow(Double.NEGATIVE_INFINITY);
                            fireTableRowsUpdated(rowIndex, rowIndex);
                        }
                    }
                }
                break;
            }
        case COLUMN_HIGHVALUE:
            {
                if (aValue instanceof Double) {
                    double value = ((Double) aValue).doubleValue();
                    parameterMappingSpec.setHigh(value);
                    fireTableRowsUpdated(rowIndex, rowIndex);
                } else if (aValue instanceof String) {
                    String newDoubleString = (String) aValue;
                    try {
                        parameterMappingSpec.setHigh(Double.parseDouble(newDoubleString));
                        fireTableRowsUpdated(rowIndex, rowIndex);
                    } catch (NumberFormatException e) {
                        if (newDoubleString.equals("") || newDoubleString.equalsIgnoreCase("Infinity") || newDoubleString.equalsIgnoreCase("Inf")) {
                            parameterMappingSpec.setHigh(Double.POSITIVE_INFINITY);
                            fireTableRowsUpdated(rowIndex, rowIndex);
                        }
                    }
                }
                break;
            }
        case COLUMN_CURRENTVALUE:
            {
                if (aValue instanceof Double) {
                    double value = ((Double) aValue).doubleValue();
                    parameterMappingSpec.setCurrent(value);
                    fireTableRowsUpdated(rowIndex, rowIndex);
                } else if (aValue instanceof String) {
                    parameterMappingSpec.setCurrent(Double.parseDouble((String) aValue));
                    fireTableRowsUpdated(rowIndex, rowIndex);
                }
                break;
            }
    }
}
Also used : ParameterMappingSpec(cbit.vcell.modelopt.ParameterMappingSpec)

Example 7 with ParameterMappingSpec

use of cbit.vcell.modelopt.ParameterMappingSpec in project vcell by virtualcell.

the class ParameterMappingTableModel method setParameterEstimationTask.

/**
 * Sets the parameterEstimationTask property (cbit.vcell.modelopt.ParameterEstimationTask) value.
 * @param parameterEstimationTask The new value for the property.
 * @see #getParameterEstimationTask
 */
public void setParameterEstimationTask(ParameterEstimationTask newValue) {
    if (fieldParameterEstimationTask == newValue) {
        return;
    }
    ParameterEstimationTask oldValue = fieldParameterEstimationTask;
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(this);
        oldValue.getModelOptimizationSpec().removePropertyChangeListener(this);
        ParameterMappingSpec[] oldPMS = oldValue.getModelOptimizationSpec().getParameterMappingSpecs();
        for (int i = 0; oldPMS != null && i < oldPMS.length; i++) {
            oldPMS[i].removePropertyChangeListener(this);
        }
    }
    fieldParameterEstimationTask = newValue;
    if (newValue != null) {
        newValue.addPropertyChangeListener(this);
        newValue.getModelOptimizationSpec().addPropertyChangeListener(this);
        ParameterMappingSpec[] newPMS = newValue.getModelOptimizationSpec().getParameterMappingSpecs();
        for (int i = 0; newPMS != null && i < newPMS.length; i++) {
            newPMS[i].addPropertyChangeListener(this);
        }
    }
    refreshData();
}
Also used : ParameterEstimationTask(cbit.vcell.modelopt.ParameterEstimationTask) ParameterMappingSpec(cbit.vcell.modelopt.ParameterMappingSpec)

Aggregations

ParameterMappingSpec (cbit.vcell.modelopt.ParameterMappingSpec)7 ArrayList (java.util.ArrayList)3 VCellTransferable (cbit.vcell.desktop.VCellTransferable)2 MathMapping (cbit.vcell.mapping.MathMapping)2 MathSymbolMapping (cbit.vcell.mapping.MathSymbolMapping)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2 Expression (cbit.vcell.parser.Expression)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 Variable (cbit.vcell.math.Variable)1 UnresolvedParameter (cbit.vcell.model.Kinetics.UnresolvedParameter)1 ModelParameter (cbit.vcell.model.Model.ModelParameter)1 Parameter (cbit.vcell.model.Parameter)1 ParameterEstimationTask (cbit.vcell.modelopt.ParameterEstimationTask)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 ScrollTable (org.vcell.util.gui.ScrollTable)1