Search in sources :

Example 1 with TaskCallbackProcessor

use of cbit.vcell.mapping.TaskCallbackProcessor in project vcell by virtualcell.

the class ValidateConstraintsPanel method initialize.

private void initialize() {
    try {
        setName("ValidateConstraintsPanel");
        setLayout(new GridBagLayout());
        maxIterationTextField = new JLabel();
        maxMolTextField = new JLabel();
        speciesLimitTextField = new JLabel();
        reactionsLimitTextField = new JLabel();
        somethingInsufficientLabel = new JLabel();
        NetworkConstraints nc = owner.getSimulationContext().getNetworkConstraints();
        maxIterationTextField.setText(nc.getTestMaxIteration() + "");
        maxMolTextField.setText(nc.getTestMaxMoleculesPerSpecies() + "");
        speciesLimitTextField.setText(nc.getTestSpeciesLimit() + "");
        reactionsLimitTextField.setText(nc.getTestReactionsLimit() + "");
        int gridy = 0;
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        // gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        // top, left, bottom, right
        gbc.insets = new Insets(6, 8, 0, 0);
        add(new JLabel("Max. Iterations"), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(6, 0, 0, 10);
        add(maxIterationTextField, gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        // gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(6, 8, 0, 0);
        add(new JLabel("Max. Molecules / Species"), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(6, 0, 0, 0);
        add(maxMolTextField, gbc);
        // ------------------------------------------------------
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        // gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(6, 8, 0, 0);
        add(new JLabel("Species Limit"), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(6, 0, 0, 0);
        add(speciesLimitTextField, gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        // gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(6, 8, 4, 0);
        add(new JLabel("Reactions Limit"), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(6, 0, 4, 0);
        add(reactionsLimitTextField, gbc);
        // ------------------------------------------------------
        if (showStoichiometryTable) {
            stoichiometryTable = new EditorScrollTable();
            stoichiometryTableModel = new StoichiometryTableModel(stoichiometryTable);
            stoichiometryTable.setModel(stoichiometryTableModel);
            stoichiometryTableModel.setSimulationContext(owner.getSimulationContext());
            stoichiometryTableModel.displayTestMaxStoichiometry();
            // we disable editing for the Value column
            stoichiometryTableModel.setValueEditable(false);
            JScrollPane sp = new JScrollPane(stoichiometryTable);
            sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            gridy++;
            gbc = new GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = gridy;
            gbc.weightx = gbc.weighty = 1.0;
            gbc.fill = GridBagConstraints.BOTH;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.gridwidth = 4;
            gbc.insets = new Insets(5, 8, 4, 10);
            add(sp, gbc);
        }
        // -------------------------------------------------------
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.gridwidth = 4;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(2, 8, 4, 10);
        add(somethingInsufficientLabel, gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 2, 8, 2);
        add(getApplyButton(), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(6, 2, 8, 10);
        add(getCancelButton(), gbc);
        String s = "none";
        TaskCallbackProcessor tcbp = owner.getSimulationContext().getTaskCallbackProcessor();
        if (tcbp.getPreviousIterationSpecies() > 0 && tcbp.getCurrentIterationSpecies() > 0 && tcbp.getCurrentIterationSpecies() != tcbp.getPreviousIterationSpecies()) {
            s = "<font color=#8C001A>" + SimulationContext.IssueInsufficientIterations + "</font>";
        } else if (tcbp.getPreviousIterationSpecies() > 0 && tcbp.getCurrentIterationSpecies() > 0 && tcbp.getCurrentIterationSpecies() == tcbp.getPreviousIterationSpecies()) {
            if (tcbp.isNeedAdjustMaxMolecules()) {
                s = "<font color=#8C001A>" + SimulationContext.IssueInsufficientMolecules + "</font>";
            }
        }
        somethingInsufficientLabel.setText("<html>Warning:  " + s + "</html>");
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) StoichiometryTableModel(cbit.vcell.mapping.gui.StoichiometryTableModel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) TaskCallbackProcessor(cbit.vcell.mapping.TaskCallbackProcessor) JLabel(javax.swing.JLabel) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Aggregations

TaskCallbackProcessor (cbit.vcell.mapping.TaskCallbackProcessor)1 StoichiometryTableModel (cbit.vcell.mapping.gui.StoichiometryTableModel)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 JLabel (javax.swing.JLabel)1 JScrollPane (javax.swing.JScrollPane)1 NetworkConstraints (org.vcell.model.rbm.NetworkConstraints)1 EditorScrollTable (org.vcell.util.gui.EditorScrollTable)1