Search in sources :

Example 16 with DefaultListCellRenderer

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

the class MovingBoundarySolverOptionsPanel method getFrontTrackingPanel.

private JPanel getFrontTrackingPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(BorderFactory.createTitledBorder(GuiConstants.TAB_PANEL_BORDER, "Front Tracking"));
    int gridy = 0;
    GridBagConstraints gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Front To Volume Nodes Ratio"), gbc);
    textFieldFrontToNodeRatio = new JFormattedTextField(DecimalFormat.getInstance());
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    panel.add(textFieldFrontToNodeRatio, gbc);
    ++gridy;
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Front Redistribution Method"), gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    panel.add(comboBoxRedistMode, gbc);
    ++gridy;
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Full Redistribution Mode"), gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    panel.add(comboBoxRedistVersion, gbc);
    ++gridy;
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Redistribution Frequency"), gbc);
    NumberFormatter integerFormatter = new NumberFormatter(NumberFormat.getInstance());
    integerFormatter.setValueClass(Integer.class);
    integerFormatter.setMinimum(1);
    integerFormatter.setMaximum(Integer.MAX_VALUE);
    textFieldRedistributionFrequency = new JFormattedTextField(integerFormatter);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    textFieldRedistributionFrequency.setToolTipText("integer only");
    panel.add(textFieldRedistributionFrequency, gbc);
    comboBoxRedistMode.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            // TODO Auto-generated method stub
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (c instanceof JLabel) {
                JLabel lbl = (JLabel) c;
                lbl.setText(((RedistributionMode) value).getLabel());
            }
            return c;
        }
    });
    comboBoxRedistVersion.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            // TODO Auto-generated method stub
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (c instanceof JLabel) {
                JLabel lbl = (JLabel) c;
                lbl.setText(((RedistributionVersion) value).getLabel());
            }
            return c;
        }
    });
    comboBoxExtrapolationMethod.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            // TODO Auto-generated method stub
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (c instanceof JLabel) {
                JLabel lbl = (JLabel) c;
                lbl.setText(((ExtrapolationMethod) value).getLabel());
            }
            return c;
        }
    });
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) RedistributionMode(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionMode) GridBagLayout(java.awt.GridBagLayout) RedistributionVersion(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) GridBagConstraints(java.awt.GridBagConstraints) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) ExtrapolationMethod(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.ExtrapolationMethod) Component(java.awt.Component) NumberFormatter(javax.swing.text.NumberFormatter)

Example 17 with DefaultListCellRenderer

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

the class PDEPlotControlPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getJTextField1().addActionListener(ivjEventHandler);
    getJTextField1().addFocusListener(ivjEventHandler);
    getDefaultListModelCivilized1().addListDataListener(ivjEventHandler);
    getViewFunctionButton().addActionListener(ivjEventHandler);
    getPlotVariableJList().setModel(getDefaultListModelCivilized1());
    getJSliderTime().getModel().addChangeListener(ivjEventHandler);
    getPlotVariableJList().addListSelectionListener(ivjEventHandler);
    getPlotVariableJList().setCellRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (dataInfoProvider == null) {
                if (value instanceof DataIdentifier) {
                    DataIdentifier var = (DataIdentifier) value;
                    if (var.getVariableType() == VariableType.POSTPROCESSING) {
                        setToolTipText(getText());
                        setText(var.getName());
                    }
                }
                return this;
            }
            // System.out.println("rendering object "+value+" of type "+value.getClass());
            DataIdentifier var = (DataIdentifier) value;
            c.setText(var.getName());
            c.setToolTipText("dataInfoProvier not found");
            DataSymbolMetadataResolver dataSymbolMetadataResolver = dataInfoProvider.getSimulationModelInfo().getDataSymbolMetadataResolver();
            if (dataSymbolMetadataResolver != null && dataSymbolMetadataResolver.getDataSymbolMetadata(var.getName()) != null) {
                DataSymbolMetadata dsm = dataSymbolMetadataResolver.getDataSymbolMetadata(var.getName());
                String tooltipString = "dataInfoProvider found, but identifier " + var.getName() + " not found";
                if (dsm == null) {
                    tooltipString = "did not find info on variable " + var.getDisplayName();
                } else {
                    c.setText(var.getName() + " [" + dsm.unit + "]");
                    tooltipString = dsm.tooltipString;
                }
                c.setToolTipText(tooltipString);
            }
            return this;
        }
    });
}
Also used : DataIdentifier(cbit.vcell.simdata.DataIdentifier) DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) JLabel(javax.swing.JLabel) Component(java.awt.Component) JList(javax.swing.JList) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata)

Example 18 with DefaultListCellRenderer

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

the class MIRIAMAnnotationEditor method getJComboBoxURI.

/**
 * This method initializes jComboBoxURI
 *
 * @return javax.swing.JComboBox
 */
private JComboBox getJComboBoxURI() {
    if (jComboBoxURI == null) {
        jComboBoxURI = new JComboBox();
        DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel();
        for (DataType dataType : vcMetaData.getMiriamManager().getAllDataTypes().values()) {
            defaultComboBoxModel.addElement(dataType);
        }
        jComboBoxURI.setModel(defaultComboBoxModel);
        jComboBoxURI.setRenderer(new DefaultListCellRenderer() {

            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                return super.getListCellRendererComponent(list, ((DataType) value).getDataTypeName(), index, isSelected, cellHasFocus);
            }
        });
    }
    return jComboBoxURI;
}
Also used : JComboBox(javax.swing.JComboBox) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) DataType(cbit.vcell.biomodel.meta.MiriamManager.DataType) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Component(java.awt.Component) JList(javax.swing.JList)

Example 19 with DefaultListCellRenderer

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

the class ODESolverPlotSpecificationPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
@SuppressWarnings({ "serial", "unchecked" })
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    getFilterPanel().addPropertyChangeListener(ivjEventHandler);
    getYAxisChoice().addListSelectionListener(ivjEventHandler);
    this.addPropertyChangeListener(ivjEventHandler);
    getXAxisComboBox_frm().addItemListener(ivjEventHandler);
    getLogSensCheckbox().addActionListener(ivjEventHandler);
    getSensitivityParameterSlider().addChangeListener(ivjEventHandler);
    connPtoP1SetTarget();
    connPtoP3SetTarget();
    getYAxisChoice().setCellRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            ODEDataInterface mdi = getMyDataInterface();
            if (mdi == null) {
                return this;
            }
            String varName = (String) value;
            ColumnDescription cd = null;
            try {
                cd = mdi.getColumnDescription(varName);
            } catch (ObjectNotFoundException e) {
                e.printStackTrace();
            }
            if (cd instanceof FunctionColumnDescription && ((FunctionColumnDescription) cd).getIsUserDefined()) {
                if (function_icon == null) {
                    function_icon = new ImageIcon(getClass().getResource("/icons/function_icon.png"));
                }
                setIcon(function_icon);
            }
            if (mdi.getDataSymbolMetadataResolver() != null && mdi.getDataSymbolMetadataResolver().getDataSymbolMetadata(varName) != null) {
                DataSymbolMetadata dsm = mdi.getDataSymbolMetadataResolver().getDataSymbolMetadata(varName);
                String tooltipString = dsm.tooltipString;
                if (tooltipString == null) {
                    tooltipString = varName;
                }
                setToolTipText(tooltipString);
            }
            return this;
        }
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) ColumnDescription(cbit.vcell.util.ColumnDescription) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata) ODEDataInterface(cbit.vcell.client.data.ODEDataInterface) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) Component(java.awt.Component) FunctionColumnDescription(cbit.vcell.math.FunctionColumnDescription) JList(javax.swing.JList)

Example 20 with DefaultListCellRenderer

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

the class VCellModelSelectionPanel method initializeComponents.

private void initializeComponents() {
    setLayout(new BorderLayout());
    listModel = new DefaultListModel<>();
    list = new JList<>(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setCellRenderer(new DefaultListCellRenderer());
    list.setFixedCellWidth(200);
    JScrollPane leftScrollPane = new JScrollPane(list);
    ImageIcon imageIcon = new ImageIcon();
    imageLabel = new JLabel(imageIcon);
    imageScrollPane = new JScrollPane(imageLabel);
    imageScrollPane.setMinimumSize(new Dimension(0, 200));
    parameterListPanel = new ModelParameterListPanel();
    parameterListPanel.setPreferredSize(new Dimension(-1, 200));
    JScrollPane parameterScrollPane = new JScrollPane(parameterListPanel);
    parameterScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, imageScrollPane, parameterScrollPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftScrollPane, verticalSplitPane);
    verticalSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, event -> {
        displayImageOfSelectedModel();
    });
    add(splitPane, BorderLayout.CENTER);
    list.addListSelectionListener(e -> {
        if (!e.getValueIsAdjusting()) {
            selectedModel = list.getSelectedValue();
            displayImageOfSelectedModel();
            parameterListPanel.setModel(selectedModel);
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane)

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