Search in sources :

Example 26 with DefaultListCellRenderer

use of javax.swing.DefaultListCellRenderer 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 27 with DefaultListCellRenderer

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

the class ParameterEstimationPanel method getAnalysisTaskComboBox.

private javax.swing.JComboBox getAnalysisTaskComboBox() {
    if (taskComboBox == null) {
        taskComboBox = new javax.swing.JComboBox();
        taskComboBox.setRenderer(new DefaultListCellRenderer() {

            public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                if (value instanceof AnalysisTask) {
                    AnalysisTask analysisTask = (AnalysisTask) value;
                    setText(analysisTask.getName());
                } else {
                    setText((value == null) ? "" : value.toString());
                }
                return this;
            }
        });
        taskComboBox.setEnabled(false);
        analysisTaskComboBoxModel = new AnalysisTaskComboBoxModel();
        taskComboBox.setModel(analysisTaskComboBoxModel);
    }
    return taskComboBox;
}
Also used : DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) AnalysisTask(cbit.vcell.modelopt.AnalysisTask) JComboBox(javax.swing.JComboBox) AnalysisTaskComboBoxModel(org.vcell.optimization.gui.AnalysisTaskComboBoxModel)

Example 28 with DefaultListCellRenderer

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

the class ReactionRuleKineticsPropertiesPanel method getKineticsTypeComboBox.

@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
private JComboBox<RateLawType> getKineticsTypeComboBox() {
    if (kineticsTypeComboBox == null) {
        kineticsTypeComboBox = new JComboBox();
        kineticsTypeComboBox.setName("JComboBox1");
        kineticsTypeComboBox.setRenderer(new DefaultListCellRenderer() {

            private static final String PI = "\u03A0";

            private static final String MU = "\u03BC";

            private static final String SQUARED = "\u00B2";

            private static final String PIs = "<strong>\u03A0</strong>";

            private static final String PIsb = "<strong><big>\u03A0</big></strong>";

            private static final String pi = "\u03C0";

            private static final String MULT = "\u22C5";

            private static final String MICROMOLAR = MU + "M";

            private static final String SQUAREMICRON = MU + "m" + SQUARED;

            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                java.awt.Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                if (value == RateLawType.Saturable) {
                    String str = "<html>Saturable";
                    str += "</html>";
                    setText(str);
                } else if (value == RateLawType.MichaelisMenten) {
                    String str = "<html>";
                    if (reactionRule != null && reactionRule.getStructure() instanceof Feature) {
                        str += "Henri-Michaelis-Menten (Irreversible) [" + MICROMOLAR + "/s]";
                    } else if (reactionRule != null && reactionRule.getStructure() instanceof Membrane) {
                        str += "Henri-Michaelis-Menten (Irreversible) [molecules/(" + SQUAREMICRON + " s)]";
                    }
                    str += "</html>";
                    setText(str);
                } else if (value == RateLawType.MassAction) {
                    String str = "<html>Mass Action ( for each reaction:  ";
                    str += "Kf" + MULT + PIs + " <small>reactants</small> - Kr" + MULT + PIs + " <small>products</small> )</html>";
                    setText(str);
                }
                return component;
            }
        });
    }
    return kineticsTypeComboBox;
}
Also used : JComboBox(javax.swing.JComboBox) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Membrane(cbit.vcell.model.Membrane) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) Component(java.awt.Component) Feature(cbit.vcell.model.Feature) JList(javax.swing.JList)

Example 29 with DefaultListCellRenderer

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

the class ReactionPropertiesPanel method getKineticsTypeComboBox.

private javax.swing.JComboBox getKineticsTypeComboBox() {
    if (kineticsTypeComboBox == null) {
        try {
            kineticsTypeComboBox = new javax.swing.JComboBox();
            kineticsTypeComboBox.setName("JComboBox1");
            kineticsTypeComboBox.setRenderer(new DefaultListCellRenderer() {

                private static final String MU = "\u03BC";

                private static final String MICROMOLAR = MU + "M";

                private static final String SQUARED = "\u00B2";

                private static final String SQUAREMICRON = MU + "m" + SQUARED;

                private static final String MICRON = MU + "m";

                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                    java.awt.Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                    if (value instanceof KineticsDescription) {
                        KineticsDescription kineticsDescription = (KineticsDescription) value;
                        setText(kineticsDescription.getDescription());
                        if (reactionStep != null) {
                            if (reactionStep instanceof SimpleReaction) {
                                if (reactionStep.getStructure() instanceof Feature) {
                                    if (kineticsDescription.equals(KineticsDescription.General)) {
                                        setText("General [" + MICROMOLAR + "/s]");
                                    } else if (kineticsDescription.equals(KineticsDescription.MassAction)) {
                                        setText("Mass Action [" + MICROMOLAR + "/s] (recommended for stochastic application)");
                                    } else if (kineticsDescription.equals(KineticsDescription.GeneralLumped)) {
                                        setText("General [molecules/s]");
                                    } else if (kineticsDescription.equals(KineticsDescription.HMM_irreversible)) {
                                        setText("Henri-Michaelis-Menten (Irreversible) [" + MICROMOLAR + "/s]");
                                    } else if (kineticsDescription.equals(KineticsDescription.HMM_reversible)) {
                                        setText("Henri-Michaelis-Menten (Reversible) [" + MICROMOLAR + "/s]");
                                    } else {
                                        setText(kineticsDescription.getDescription());
                                    }
                                } else if (reactionStep.getStructure() instanceof Membrane) {
                                    if (kineticsDescription.equals(KineticsDescription.General)) {
                                        setText("General [molecules/(" + SQUAREMICRON + " s)]");
                                    } else if (kineticsDescription.equals(KineticsDescription.MassAction)) {
                                        setText("Mass Action [molecules/(" + SQUAREMICRON + " s)]");
                                    } else if (kineticsDescription.equals(KineticsDescription.GeneralLumped)) {
                                        setText("General [molecules/s)]");
                                    } else if (kineticsDescription.equals(KineticsDescription.HMM_irreversible)) {
                                        setText("Henri-Michaelis-Menten (Irreversible) [molecules/(" + SQUAREMICRON + " s)]");
                                    } else if (kineticsDescription.equals(KineticsDescription.HMM_reversible)) {
                                        setText("Henri-Michaelis-Menten (Reversible) [molecules/(" + SQUAREMICRON + " s)]");
                                    } else if (kineticsDescription.equals(KineticsDescription.Macroscopic_irreversible)) {
                                        setText("Macroscopic (Irreversible) [molecules/(" + SQUAREMICRON + " s)]");
                                    } else if (kineticsDescription.equals(KineticsDescription.Microscopic_irreversible)) {
                                        setText("Microscopic (Irreversible) [molecules/(" + SQUAREMICRON + " s)]");
                                    }
                                }
                            } else if (reactionStep instanceof FluxReaction) {
                                if (kineticsDescription.equals(KineticsDescription.General)) {
                                    setText("General Flux Density (" + MICROMOLAR + "-" + MICRON + "/s)");
                                } else if (kineticsDescription.equals(KineticsDescription.GeneralLumped)) {
                                    setText("General Flux (molecules/s)");
                                } else if (kineticsDescription.equals(KineticsDescription.GeneralCurrent)) {
                                    setText("General Current Density (pA/" + SQUAREMICRON + ")");
                                } else if (kineticsDescription.equals(KineticsDescription.GeneralCurrentLumped)) {
                                    setText("General Current (pA)");
                                } else if (kineticsDescription.equals(KineticsDescription.GHK)) {
                                    setText("Goldman-Hodgkin-Katz Current Density (pA/" + SQUAREMICRON + ") - permeability in " + MICRON + "/s");
                                } else if (kineticsDescription.equals(KineticsDescription.Nernst)) {
                                    setText("Nernst Current Density (pA/" + SQUAREMICRON + ") - conductance in nS/" + SQUAREMICRON);
                                } else if (kineticsDescription.equals(KineticsDescription.GeneralPermeability)) {
                                    setText("General Permeability (" + MICROMOLAR + "-" + MICRON + "/s) - permeability in " + MICRON + "/s");
                                }
                            }
                        }
                    }
                    return component;
                }
            });
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return kineticsTypeComboBox;
}
Also used : SimpleReaction(cbit.vcell.model.SimpleReaction) KineticsDescription(cbit.vcell.model.KineticsDescription) FluxReaction(cbit.vcell.model.FluxReaction) Feature(cbit.vcell.model.Feature) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Membrane(cbit.vcell.model.Membrane) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) Component(java.awt.Component) JList(javax.swing.JList)

Example 30 with DefaultListCellRenderer

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

the class PDEExportDataPanel method getROISelections.

/**
 * Return the JListSelections property value.
 * @return javax.swing.JList
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JList<Object> getROISelections() {
    if (ivjJListSelections == null) {
        try {
            ivjJListSelections = new javax.swing.JList<Object>();
            ivjJListSelections.setName("JListSelections");
            ivjJListSelections.setBounds(0, 0, 160, 120);
            ivjJListSelections.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            ivjJListSelections.setCellRenderer(new DefaultListCellRenderer() {

                @Override
                public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                    // TODO Auto-generated method stub
                    // System.out.println(value.getClass().getName()+"   "+value);
                    String curveDescr = "";
                    if (value instanceof SpatialSelectionMembrane) {
                        curveDescr = ((SpatialSelectionMembrane) value).getSelectionSource().getDescription() + " (" + ((SpatialSelectionMembrane) value).getSelectionSource().getBeginningCoordinate() + ")";
                    } else if (value instanceof SpatialSelectionVolume) {
                        curveDescr = ((SpatialSelectionVolume) value).getCurveSelectionInfo().getCurve().getDescription() + " (" + ((SpatialSelectionVolume) value).getCurveSelectionInfo().getCurve().getBeginningCoordinate() + ")";
                    } else {
                        curveDescr = value.toString();
                    }
                    return super.getListCellRendererComponent(list, curveDescr, index, isSelected, cellHasFocus);
                }
            });
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjJListSelections;
}
Also used : SpatialSelectionMembrane(cbit.vcell.simdata.SpatialSelectionMembrane) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) Component(java.awt.Component)

Aggregations

DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)55 Component (java.awt.Component)45 JList (javax.swing.JList)30 JLabel (javax.swing.JLabel)19 JComboBox (javax.swing.JComboBox)18 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)14 JComponent (javax.swing.JComponent)13 JPanel (javax.swing.JPanel)11 JScrollPane (javax.swing.JScrollPane)10 Dimension (java.awt.Dimension)9 GridBagConstraints (java.awt.GridBagConstraints)9 BorderLayout (java.awt.BorderLayout)8 GridBagLayout (java.awt.GridBagLayout)8 Point (java.awt.Point)6 ArrayList (java.util.ArrayList)6 Insets (java.awt.Insets)5 ActionEvent (java.awt.event.ActionEvent)5 Feature (cbit.vcell.model.Feature)4 Membrane (cbit.vcell.model.Membrane)4 SpeciesContext (cbit.vcell.model.SpeciesContext)3