Search in sources :

Example 1 with BioModelCategoryType

use of cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method updateChoices.

/**
 * Insert the method's description here.
 * Creation date: (2/8/2001 4:56:15 PM)
 * @param cbit.vcell.solver.ode.ODESolverResultSet
 */
private synchronized void updateChoices(ODEDataInterface odedi) throws ExpressionException, ObjectNotFoundException {
    if (odedi == null) {
        return;
    }
    Object xAxisSelection = getXAxisComboBox_frm().getSelectedItem();
    Object[] yAxisSelections = getYAxisChoice().getSelectedValues();
    ArrayList<ColumnDescription> variableColumnDescriptions = new ArrayList<ColumnDescription>();
    ArrayList<ColumnDescription> sensitivityColumnDescriptions = new ArrayList<ColumnDescription>();
    ColumnDescription timeColumnDescription = null;
    // find TIME columnDescription
    ColumnDescription[] columnDescriptions = odedi.getAllColumnDescriptions();
    for (int i = 0; i < columnDescriptions.length; i++) {
        if (columnDescriptions[i].getName().equals(ReservedVariable.TIME.getName())) {
            timeColumnDescription = columnDescriptions[i];
        }
    }
    // find filtered columnDescriptions
    columnDescriptions = odedi.getFilteredColumnDescriptions();
    DataSymbolMetadataResolver damdr = odedi.getDataSymbolMetadataResolver();
    for (int i = 0; i < columnDescriptions.length; i++) {
        ColumnDescription cd = columnDescriptions[i];
        // If the column is "_initConnt" generated when using concentration as initial condition, we dont' put the function in list. amended again in August, 2008.
        if (cd.getParameterName() == null) {
            String name = cd.getName();
            DataSymbolMetadata damd = damdr.getDataSymbolMetadata(name);
            // filter entities measured as count vs concentration, based on the checkbox settings
            ModelCategoryType filterCategory = null;
            if (damd != null) {
                filterCategory = damd.filterCategory;
            }
            if (countCheckBox != null && concentrationCheckBox != null) {
                if (filterCategory instanceof BioModelCategoryType && filterCategory == BioModelCategoryType.Species && cd.getName().endsWith(AbstractMathMapping.MATH_VAR_SUFFIX_SPECIES_COUNT) && !countCheckBox.isSelected()) {
                    continue;
                } else if (filterCategory instanceof BioModelCategoryType && filterCategory == BioModelCategoryType.Species && !cd.getName().endsWith(AbstractMathMapping.MATH_VAR_SUFFIX_SPECIES_COUNT) && !concentrationCheckBox.isSelected()) {
                    continue;
                }
            }
            // filter out entities starting with "UnitFactor_" prefix
            if (filterCategory instanceof BioModelCategoryType && filterCategory == BioModelCategoryType.Other && cd.getName().startsWith(AbstractMathMapping.PARAMETER_K_UNITFACTOR_PREFIX)) {
                continue;
            }
            if (!cd.getName().equals(SimDataConstants.HISTOGRAM_INDEX_NAME) && !cd.getName().contains(DiffEquMathMapping.MATH_FUNC_SUFFIX_SPECIES_INIT_COUNT)) {
                variableColumnDescriptions.add(cd);
            }
        } else {
            sensitivityColumnDescriptions.add(cd);
        }
    }
    sortColumnDescriptions(variableColumnDescriptions);
    sortColumnDescriptions(sensitivityColumnDescriptions);
    // Hack this here, Later we can use an array utility...
    ArrayList<ColumnDescription> sortedColumndDescriptions = new ArrayList<ColumnDescription>();
    if (timeColumnDescription != null) {
        // add time first
        sortedColumndDescriptions.add(timeColumnDescription);
    }
    boolean bMultiTrialData = odedi.isMultiTrialData();
    sortedColumndDescriptions.addAll(variableColumnDescriptions);
    if (!bMultiTrialData) {
        sortedColumndDescriptions.addAll(sensitivityColumnDescriptions);
    }
    // finally, update widgets
    try {
        getXAxisComboBox_frm().removeItemListener(ivjEventHandler);
        getYAxisChoice().removeListSelectionListener(ivjEventHandler);
        getComboBoxModelX_frm().removeAllElements();
        if (!bMultiTrialData) {
            // Don't put anything in X Axis, if the results of multiple trials are being displayed.
            ArrayList<ColumnDescription> xColumnDescriptions = new ArrayList<ColumnDescription>(Arrays.asList(odedi.getAllColumnDescriptions()));
            sortColumnDescriptions(xColumnDescriptions);
            if (timeColumnDescription != null) {
                getComboBoxModelX_frm().addElement(timeColumnDescription.getName());
            }
            for (ColumnDescription columnDescription : xColumnDescriptions) {
                if (!columnDescription.getName().equals((timeColumnDescription == null ? null : timeColumnDescription.getName()))) {
                    getComboBoxModelX_frm().addElement(columnDescription.getName());
                }
            }
        }
        getDefaultListModelY().removeAllElements();
        for (int i = 0; i < sortedColumndDescriptions.size(); i++) {
            if (sortedColumndDescriptions.get(i).getName().equals(ReservedVariable.TIME.getName())) {
                continue;
            }
            getDefaultListModelY().addElement(sortedColumndDescriptions.get(i).getName());
        }
        if (sortedColumndDescriptions.size() > 0) {
            // Don't put anything in X Axis, if the results of multifple trials are being displayed.
            if (!bMultiTrialData) {
                getXAxisComboBox_frm().setSelectedItem(xAxisSelection);
                if (getXAxisComboBox_frm().getSelectedIndex() == -1) {
                    getXAxisComboBox_frm().setSelectedIndex(0);
                }
            }
            if (yAxisSelections != null && yAxisSelections.length > 0) {
                ArrayList<Integer> carryoverSelections = new ArrayList<Integer>();
                for (int i = 0; i < getYAxisChoice().getModel().getSize(); i++) {
                    for (int j = 0; j < yAxisSelections.length; j++) {
                        if (getYAxisChoice().getModel().getElementAt(i).equals(yAxisSelections[j])) {
                            carryoverSelections.add(i);
                            break;
                        }
                    }
                }
                if (carryoverSelections.size() > 0) {
                    int[] carryoverInts = new int[carryoverSelections.size()];
                    for (int i = 0; i < carryoverInts.length; i++) {
                        carryoverInts[i] = carryoverSelections.get(i);
                    }
                    getYAxisChoice().setSelectedIndices(carryoverInts);
                } else {
                    getYAxisChoice().setSelectedIndex((getYAxisChoice().getModel().getSize() > 1 ? 1 : 0));
                }
            } else {
                getYAxisChoice().setSelectedIndex(sortedColumndDescriptions.size() > 1 ? 1 : 0);
            }
        }
    } finally {
        getXAxisComboBox_frm().addItemListener(ivjEventHandler);
        getYAxisChoice().addListSelectionListener(ivjEventHandler);
    }
    regeneratePlot2D();
}
Also used : DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) BioModelCategoryType(cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType) ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) ArrayList(java.util.ArrayList) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata) BioModelCategoryType(cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType)

Aggregations

BioModelCategoryType (cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType)1 FunctionColumnDescription (cbit.vcell.math.FunctionColumnDescription)1 DataSymbolMetadata (cbit.vcell.solver.DataSymbolMetadata)1 DataSymbolMetadataResolver (cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver)1 ModelCategoryType (cbit.vcell.solver.SimulationModelInfo.ModelCategoryType)1 ColumnDescription (cbit.vcell.util.ColumnDescription)1 ArrayList (java.util.ArrayList)1