Search in sources :

Example 51 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class KineticsTypeTemplatePanel method initKineticChoices.

private void initKineticChoices() {
    KineticsDescription[] kineticTypes = reactionStep == null || reactionStep instanceof SimpleReaction ? Simple_Reaction_Kinetic_Types : Flux_Reaction_KineticTypes;
    javax.swing.DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (int i = 0; i < kineticTypes.length; i++) {
        model.addElement(kineticTypes[i]);
    }
    getKineticsTypeComboBox().setModel(model);
    return;
}
Also used : SimpleReaction(cbit.vcell.model.SimpleReaction) KineticsDescription(cbit.vcell.model.KineticsDescription) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 52 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class ObservableTableModel method updateObservableTypeComboBox.

protected void updateObservableTypeComboBox() {
    @SuppressWarnings("unchecked") JComboBox<RbmObservable.ObservableType> typeComboBoxCellEditor = (JComboBox<RbmObservable.ObservableType>) getObservableTypeComboBoxEditor().getComponent();
    if (typeComboBoxCellEditor == null) {
        typeComboBoxCellEditor = new JComboBox<RbmObservable.ObservableType>();
    }
    DefaultComboBoxModel<RbmObservable.ObservableType> aModel = new DefaultComboBoxModel<RbmObservable.ObservableType>();
    for (RbmObservable.ObservableType ot : RbmObservable.ObservableType.values()) {
        aModel.addElement(ot);
    }
    DefaultListCellRenderer defaultListCellRenderer = new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setHorizontalTextPosition(SwingConstants.LEFT);
            if (value instanceof RbmObservable.ObservableType) {
                setText(((RbmObservable.ObservableType) value).name());
            }
            return this;
        }
    };
    typeComboBoxCellEditor.setRenderer(defaultListCellRenderer);
    typeComboBoxCellEditor.setModel(aModel);
    typeComboBoxCellEditor.setSelectedIndex(0);
}
Also used : ObservableType(cbit.vcell.model.RbmObservable.ObservableType) JComboBox(javax.swing.JComboBox) ObservableType(cbit.vcell.model.RbmObservable.ObservableType) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) RbmObservable(cbit.vcell.model.RbmObservable) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JList(javax.swing.JList)

Example 53 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class ReactionPropertiesPanel method initKineticChoices.

private void initKineticChoices() {
    KineticsDescription[] kineticTypes = reactionStep == null || reactionStep instanceof SimpleReaction ? Simple_Reaction_Kinetic_Types : Flux_Reaction_KineticTypes;
    javax.swing.DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (int i = 0; i < kineticTypes.length; i++) {
        if (!(kineticTypes[i].equals(KineticsDescription.Macroscopic_irreversible) || kineticTypes[i].equals(KineticsDescription.Microscopic_irreversible))) {
            model.addElement(kineticTypes[i]);
        } else // macroscopic/microscopic irreversible
        {
            // reactions on membrane in a 3D geometry
            if (reactionStep != null && reactionStep.getStructure() != null && reactionStep.getStructure() instanceof Membrane) {
                // check if reactants are all on membrane and calculate sum of reactants' stoichiometry
                ReactionParticipant[] rps = reactionStep.getReactionParticipants();
                int order = 0;
                boolean bAllMembraneReactants = true;
                for (ReactionParticipant rp : rps) {
                    if (rp instanceof Reactant) {
                        if (!(rp.getStructure() instanceof Membrane)) {
                            bAllMembraneReactants = false;
                            break;
                        }
                        order += rp.getStoichiometry();
                    }
                }
                // add only if 2nd order membrane reaction
                if (order == 2 && bAllMembraneReactants && !reactionStep.hasCatalyst()) {
                    model.addElement(kineticTypes[i]);
                }
            }
        }
    }
    getKineticsTypeComboBox().setModel(model);
    return;
}
Also used : SimpleReaction(cbit.vcell.model.SimpleReaction) KineticsDescription(cbit.vcell.model.KineticsDescription) Membrane(cbit.vcell.model.Membrane) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Reactant(cbit.vcell.model.Reactant)

Example 54 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class StructurePropertiesPanel method setModel.

public void setModel(Model model) {
    fieldModel = model;
    DefaultComboBoxModel<String> dataModelPos = new DefaultComboBoxModel<String>();
    DefaultComboBoxModel<String> dataModelNeg = new DefaultComboBoxModel<String>();
    dataModelPos.addElement("");
    dataModelNeg.addElement("");
    for (Structure s : model.getStructures()) {
        if (s instanceof Feature) {
            dataModelPos.addElement(s.getName());
            dataModelNeg.addElement(s.getName());
        }
    }
    // fill the comboBoxes with feature names from the model.
    positiveFeatureComboBox.setModel(dataModelPos);
    // if selected structure is a membrane, if it has +ve/-ve feature set, set the comboBox with that selection.
    if (structure instanceof Membrane) {
        Membrane membrane = (Membrane) structure;
        if (fieldModel.getElectricalTopology().getPositiveFeature(membrane) != null) {
            positiveFeatureComboBox.setSelectedItem(fieldModel.getElectricalTopology().getPositiveFeature(membrane).getName());
        }
    }
    negativeFeatureComboBox.setModel(dataModelNeg);
    if (structure instanceof Membrane) {
        Membrane membrane = (Membrane) structure;
        if (fieldModel.getElectricalTopology().getNegativeFeature(membrane) != null) {
            negativeFeatureComboBox.setSelectedItem(fieldModel.getElectricalTopology().getNegativeFeature(membrane).getName());
        }
    }
}
Also used : Membrane(cbit.vcell.model.Membrane) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Structure(cbit.vcell.model.Structure) Feature(cbit.vcell.model.Feature)

Example 55 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class OutputFunctionsPanel method nextButtonClicked.

private void nextButtonClicked() throws ExpressionException, InconsistentDomainException {
    boolean bSpatial = simulationWorkspace.getSimulationOwner().getGeometry().getDimension() > 0;
    if (bSpatial) {
        DefaultComboBoxModel aModel = new DefaultComboBoxModel();
        ArrayList<Object> objectsList = null;
        String exprStr = getFunctionExpressionTextField().getText();
        if (exprStr == null) {
            throw new ExpressionException("No expression provided for output function.");
        }
        Expression expr = new Expression(exprStr);
        objectsList = getPossibleGeometryClassesAndVariableTypes(expr);
        for (Object ob : objectsList) {
            aModel.addElement(ob);
        }
        getSubdomainComboBox().setModel(aModel);
        getSubdomainComboBox().setSelectedIndex(0);
    }
    cardLayout.show(functionPanel, geometryClassPanel.getName());
}
Also used : Expression(cbit.vcell.parser.Expression) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ExpressionException(cbit.vcell.parser.ExpressionException)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)119 JComboBox (javax.swing.JComboBox)22 JPanel (javax.swing.JPanel)21 JLabel (javax.swing.JLabel)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 JButton (javax.swing.JButton)15 Insets (java.awt.Insets)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)12 Dimension (java.awt.Dimension)11 JTextField (javax.swing.JTextField)11 JCheckBox (javax.swing.JCheckBox)10 JScrollPane (javax.swing.JScrollPane)10 ArrayList (java.util.ArrayList)9 Vector (java.util.Vector)9 JList (javax.swing.JList)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 BorderLayout (java.awt.BorderLayout)8 ItemEvent (java.awt.event.ItemEvent)8