Search in sources :

Example 1 with ModelCategoryType

use of cbit.vcell.solver.SimulationModelInfo.ModelCategoryType in project vcell by virtualcell.

the class DefaultDataIdentifierFilter method getFilterSetNames.

public String[] getFilterSetNames() {
    ArrayList<String> allFilterNames = new ArrayList<String>();
    allFilterNames.addAll(Arrays.asList(BUILTIN_FILTER_SET_NAMES));
    if (this.dataSymbolMetadataResolver != null) {
        ModelCategoryType[] uniqueCategories = dataSymbolMetadataResolver.getUniqueFilterCategories();
        for (ModelCategoryType catType : uniqueCategories) {
            allFilterNames.add(catType.getName());
        }
    }
    return allFilterNames.toArray(new String[0]);
}
Also used : ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) ArrayList(java.util.ArrayList)

Example 2 with ModelCategoryType

use of cbit.vcell.solver.SimulationModelInfo.ModelCategoryType 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)

Example 3 with ModelCategoryType

use of cbit.vcell.solver.SimulationModelInfo.ModelCategoryType in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method getFilterSetting.

private JCheckBox getFilterSetting(ModelCategoryType filterCategory) {
    if (filterSettings == null) {
        filterSettings = new HashMap<JCheckBox, ModelCategoryType>();
    }
    for (JCheckBox jCheckBox : filterSettings.keySet()) {
        if (filterSettings.get(jCheckBox).equals(filterCategory)) {
            return jCheckBox;
        }
    }
    JCheckBox newJCheckBox = new JCheckBox(filterCategory.toString()) {

        @Override
        public Dimension getMaximumSize() {
            // super.getMaximumSize();
            return new Dimension(super.getMaximumSize().width, 17);
        }

        @Override
        public Dimension getPreferredSize() {
            // super.getPreferredSize();
            return getMaximumSize();
        }
    };
    newJCheckBox.setSelected(filterCategory.isInitialSelect());
    newJCheckBox.setEnabled(filterCategory.isEnabled());
    filterSettings.put(newJCheckBox, filterCategory);
    return newJCheckBox;
}
Also used : JCheckBox(javax.swing.JCheckBox) BioModelCategoryType(cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType) ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) Dimension(java.awt.Dimension)

Example 4 with ModelCategoryType

use of cbit.vcell.solver.SimulationModelInfo.ModelCategoryType in project vcell by virtualcell.

the class ODESolverPlotSpecificationPanel method showFilterSettings.

private void showFilterSettings() {
    if (getMyDataInterface() != null && getMyDataInterface().getSupportedFilterCategories() != null && getMyDataInterface().getSupportedFilterCategories().length > 0) {
        getFilterPanel().getContentPanel().removeAll();
        getFilterPanel().getContentPanel().setLayout(null);
        HashMap<JCheckBox, ModelCategoryType> oldFilterSettings = filterSettings;
        filterSettings = null;
        ModelCategoryType[] filterCategories = getMyDataInterface().getSupportedFilterCategories();
        for (int i = 0; i < filterCategories.length; i++) {
            // generate filter set
            JCheckBox newFiltersJCheckBox = getFilterSetting(filterCategories[i]);
            if (oldFilterSettings != null) {
                for (JCheckBox jCheckBox : oldFilterSettings.keySet()) {
                    if (filterSettings.get(newFiltersJCheckBox).equals(oldFilterSettings.get(jCheckBox))) {
                        newFiltersJCheckBox.setSelected(jCheckBox.isSelected());
                        break;
                    }
                }
            }
        }
    } else {
        // DialogUtils.showWarningDialog(this, "Cannot display filter, no filter categories set.");
        getFilterPanel().getContentPanel().setLayout(new BorderLayout());
        getFilterPanel().getContentPanel().add(new JLabel("No Filters"));
        return;
    }
    boolean hasCount = false;
    ColumnDescription[] columnDescriptions = getMyDataInterface().getAllColumnDescriptions();
    if (columnDescriptions != null) {
        for (ColumnDescription cd : columnDescriptions) {
            if (cd.getName().endsWith(AbstractMathMapping.MATH_VAR_SUFFIX_SPECIES_COUNT)) {
                hasCount = true;
                break;
            }
        }
    }
    // filterPanel.setBorder(new LineBorder(Color.black));
    JCheckBox[] sortedJCheckBoxes = filterSettings.keySet().toArray(new JCheckBox[0]);
    Arrays.sort(sortedJCheckBoxes, new Comparator<JCheckBox>() {

        @Override
        public int compare(JCheckBox o1, JCheckBox o2) {
            // TODO Auto-generated method stub
            return o1.getText().compareToIgnoreCase(o2.getText());
        }
    });
    for (int i = 0; i < sortedJCheckBoxes.length; i++) {
        sortedJCheckBoxes[i].removeItemListener(ivjEventHandler);
        sortedJCheckBoxes[i].addItemListener(ivjEventHandler);
    }
    JPanel filterContentPanel = getFilterPanel().getContentPanel();
    filterContentPanel.setLayout(new GridBagLayout());
    int gridx = 0;
    int gridy = 0;
    for (int i = 0; i < sortedJCheckBoxes.length; i++) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = gridx;
        gbc.gridy = gridy;
        if (!hasCount && (i == sortedJCheckBoxes.length - 1)) {
            gbc.insets = new Insets(4, 2, 4, 0);
        } else {
            gbc.insets = new Insets(4, 2, 0, 0);
        }
        gbc.weightx = 1;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        filterContentPanel.add(sortedJCheckBoxes[i], gbc);
        gridy++;
    }
    if (hasCount) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = gridx;
        gbc.gridy = gridy;
        gbc.insets = new Insets(1, 10, 3, 0);
        gbc.anchor = GridBagConstraints.WEST;
        filterContentPanel.add(getSpeciesOptionsPanel(), gbc);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BioModelCategoryType(cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType) ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout)

Example 5 with ModelCategoryType

use of cbit.vcell.solver.SimulationModelInfo.ModelCategoryType in project vcell by virtualcell.

the class DefaultDataIdentifierFilter method accept.

public ArrayList<DataIdentifier> accept(String filterSetName, List<AnnotatedFunction> functionList, DataIdentifier[] filterTheseDataIdentifiers) {
    // 
    if (dataSymbolMetadataResolver != null) {
        ArrayList<String> allFilterNames = new ArrayList<String>();
        if (this.dataSymbolMetadataResolver != null) {
            ModelCategoryType[] uniqueCategories = dataSymbolMetadataResolver.getUniqueFilterCategories();
            for (ModelCategoryType catType : uniqueCategories) {
                allFilterNames.add(catType.getName());
            }
        }
        if (allFilterNames.contains(filterSetName)) {
            ArrayList<DataIdentifier> acceptedDataIdentifiers = new ArrayList<DataIdentifier>();
            for (DataIdentifier dataID : filterTheseDataIdentifiers) {
                DataSymbolMetadata metadata = dataSymbolMetadataResolver.getDataSymbolMetadata(dataID.getName());
                if (metadata != null && metadata.filterCategory.getName().equals(filterSetName)) {
                    String varName = dataID.getName();
                    if (varName.startsWith(MathFunctionDefinitions.Function_regionVolume_current.getFunctionName())) {
                        continue;
                    }
                    if (varName.startsWith(MathFunctionDefinitions.Function_regionArea_current.getFunctionName())) {
                        continue;
                    }
                    acceptedDataIdentifiers.add(dataID);
                }
            }
            return acceptedDataIdentifiers;
        }
    }
    ArrayList<DataIdentifier> acceptedDataIdentifiers = new ArrayList<DataIdentifier>();
    for (int i = 0; i < filterTheseDataIdentifiers.length; i++) {
        if (bPostProcessingMode && filterTheseDataIdentifiers[i].getVariableType().equals(VariableType.POSTPROCESSING)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
            continue;
        }
        if (bPostProcessingMode && !filterTheseDataIdentifiers[i].getVariableType().equals(VariableType.POSTPROCESSING)) {
            continue;
        }
        if (!bPostProcessingMode && filterTheseDataIdentifiers[i].getVariableType().equals(VariableType.POSTPROCESSING)) {
            continue;
        }
        String varName = filterTheseDataIdentifiers[i].getName();
        if (varName.startsWith(MathFunctionDefinitions.Function_regionVolume_current.getFunctionName())) {
            continue;
        }
        if (varName.startsWith(MathFunctionDefinitions.Function_regionArea_current.getFunctionName())) {
            continue;
        }
        boolean bSizeVar = varName.startsWith(DiffEquMathMapping.PARAMETER_SIZE_FUNCTION_PREFIX);
        if (filterSetName.equals(REGION_SIZE_FILTER_SET) && bSizeVar) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
            continue;
        }
        if (!filterSetName.equals(REGION_SIZE_FILTER_SET) && bSizeVar) {
            continue;
        }
        if (filterSetName.equals(ALL)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
        } else if (filterSetName.equals(VOLUME_FILTER_SET) && filterTheseDataIdentifiers[i].getVariableType().getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_VOLUME)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
        } else if (filterSetName.equals(MEMBRANE_FILTER_SET) && filterTheseDataIdentifiers[i].getVariableType().getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_MEMBRANE)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
        } else if (filterSetName.equals(USER_DEFINED_FILTER_SET)) {
            if (functionList != null) {
                for (AnnotatedFunction f : functionList) {
                    if (!f.isPredefined() && f.getName().equals(varName)) {
                        acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
                        break;
                    }
                }
            }
        }
    }
    if (acceptedDataIdentifiers.size() > 0) {
        return acceptedDataIdentifiers;
    }
    return null;
}
Also used : DataIdentifier(cbit.vcell.simdata.DataIdentifier) ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) ArrayList(java.util.ArrayList) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

ModelCategoryType (cbit.vcell.solver.SimulationModelInfo.ModelCategoryType)7 ArrayList (java.util.ArrayList)5 BioModelCategoryType (cbit.vcell.client.data.SimulationWorkspaceModelInfo.BioModelCategoryType)4 FunctionColumnDescription (cbit.vcell.math.FunctionColumnDescription)3 DataSymbolMetadata (cbit.vcell.solver.DataSymbolMetadata)3 ColumnDescription (cbit.vcell.util.ColumnDescription)3 JCheckBox (javax.swing.JCheckBox)3 DataSymbolMetadataResolver (cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver)2 DataIdentifier (cbit.vcell.simdata.DataIdentifier)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1