Search in sources :

Example 1 with EditorScrollTable

use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.

the class ViewObservablesMapPanel method initialize.

private void initialize() {
    try {
        // --------------------------------------- the split panels
        setName("ViewGeneratedSpeciesPanel");
        setLayout(new BorderLayout());
        JPanel topPanel = new JPanel();
        topPanel.setLayout(new GridBagLayout());
        JPanel bottomPanel = new JPanel();
        bottomPanel.setLayout(new GridBagLayout());
        JSplitPane splitPaneHorizontal = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        splitPaneHorizontal.setDividerSize(10);
        splitPaneHorizontal.setOneTouchExpandable(true);
        splitPaneHorizontal.setDividerLocation(260);
        splitPaneHorizontal.setResizeWeight(0.5);
        splitPaneHorizontal.setTopComponent(topPanel);
        splitPaneHorizontal.setBottomComponent(bottomPanel);
        add(splitPaneHorizontal, BorderLayout.CENTER);
        // ---------------------------------------- species shape panel
        shapePanelSpecies = new LargeShapePanel() {

            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                if (spls != null) {
                    spls.paintSelf(g);
                }
            }

            @Override
            public DisplayMode getDisplayMode() {
                return DisplayMode.other;
            }

            @Override
            public RuleAnalysisChanged hasStateChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasStateChanged(MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasBondChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasBondChanged(MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasNoMatch(String reactionRuleName, MolecularTypePattern mtp) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasNoMatch(MolecularTypePattern molecularTypePattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleParticipantSignature getSignature() {
                return null;
            }

            @Override
            public GroupingCriteria getCriteria() {
                return null;
            }

            @Override
            public boolean isViewSingleRow() {
                return true;
            }
        };
        shapePanelSpecies.setLayout(new GridBagLayout());
        shapePanelSpecies.setBackground(Color.white);
        // not really editable but we don't want the brown contours here
        shapePanelSpecies.setEditable(true);
        shapePanelSpecies.setShowMoleculeColor(true);
        shapePanelSpecies.setShowNonTrivialOnly(true);
        Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
        JScrollPane scrollPaneSpecies = new JScrollPane(shapePanelSpecies);
        scrollPaneSpecies.setBorder(loweredBevelBorder);
        scrollPaneSpecies.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPaneSpecies.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        JPanel optionsPanelSpecies = new JPanel();
        optionsPanelSpecies.setLayout(new GridBagLayout());
        getZoomSmallerButtonSpecies().setEnabled(true);
        getZoomLargerButtonSpecies().setEnabled(true);
        shapePanelSpecies.zoomSmaller();
        shapePanelSpecies.zoomSmaller();
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.insets = new Insets(0, 0, 0, 10);
        gbc.anchor = GridBagConstraints.WEST;
        optionsPanelSpecies.add(getZoomLargerButtonSpecies(), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.insets = new Insets(2, 0, 4, 10);
        gbc.anchor = GridBagConstraints.WEST;
        optionsPanelSpecies.add(getZoomSmallerButtonSpecies(), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.weightx = 1;
        // fake cell used for filling all the vertical empty space
        gbc.weighty = 1;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(4, 4, 4, 10);
        optionsPanelSpecies.add(new JLabel(""), gbc);
        JPanel containerOfScrollPanelSpecies = new JPanel();
        containerOfScrollPanelSpecies.setLayout(new BorderLayout());
        containerOfScrollPanelSpecies.add(optionsPanelSpecies, BorderLayout.WEST);
        containerOfScrollPanelSpecies.add(scrollPaneSpecies, BorderLayout.CENTER);
        Dimension dimS = new Dimension(500, 125);
        // dimension of shape panel
        containerOfScrollPanelSpecies.setPreferredSize(dimS);
        containerOfScrollPanelSpecies.setMinimumSize(dimS);
        containerOfScrollPanelSpecies.setMaximumSize(dimS);
        shapePanelObservable = new LargeShapePanel() {

            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                for (SpeciesPatternLargeShape sps : spsList) {
                    if (sps == null) {
                        continue;
                    }
                    sps.paintSelf(g);
                }
            }

            @Override
            public DisplayMode getDisplayMode() {
                return DisplayMode.other;
            }

            @Override
            public RuleAnalysisChanged hasStateChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasStateChanged(MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasBondChanged(String reactionRuleName, MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasBondChanged(MolecularComponentPattern molecularComponentPattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasNoMatch(String reactionRuleName, MolecularTypePattern mtp) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleAnalysisChanged hasNoMatch(MolecularTypePattern molecularTypePattern) {
                return RuleAnalysisChanged.UNCHANGED;
            }

            @Override
            public RuleParticipantSignature getSignature() {
                return null;
            }

            @Override
            public GroupingCriteria getCriteria() {
                return null;
            }

            @Override
            public boolean isViewSingleRow() {
                return true;
            }
        };
        // 
        DefaultScrollTableCellRenderer rbmSpeciesPatternCellRenderer = new DefaultScrollTableCellRenderer() {

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                if (table.getModel() instanceof GeneratedSpeciesTableModel2) {
                    Object selectedObject = null;
                    if (table.getModel() == speciesTableModel) {
                        selectedObject = speciesTableModel.getValueAt(row);
                    }
                    if (selectedObject != null) {
                        if (selectedObject instanceof GeneratedSpeciesTableRow && value instanceof String) {
                            SpeciesPattern sp = ((GeneratedSpeciesTableRow) selectedObject).getSpecies().getSpeciesPattern();
                            String text = "<html>";
                            text += RbmTableRenderer.toHtml(sp, isSelected);
                            text += "</html>";
                            setText(text);
                        }
                    }
                }
                return this;
            }
        };
        // shapePanelObservable.setLayout(null);
        shapePanelObservable.setLayout(new GridBagLayout());
        shapePanelObservable.setBackground(Color.white);
        shapePanelObservable.setEditable(true);
        shapePanelObservable.setShowMoleculeColor(true);
        shapePanelObservable.setShowNonTrivialOnly(true);
        JScrollPane scrollPaneObservable = new JScrollPane(shapePanelObservable);
        scrollPaneObservable.setBorder(loweredBevelBorder);
        scrollPaneObservable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPaneObservable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        JPanel optionsPanelObservable = new JPanel();
        optionsPanelObservable.setLayout(new GridBagLayout());
        getZoomSmallerButtonObservable().setEnabled(true);
        getZoomLargerButtonObservable().setEnabled(true);
        shapePanelObservable.zoomSmaller();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.insets = new Insets(0, 0, 0, 10);
        gbc.anchor = GridBagConstraints.WEST;
        optionsPanelObservable.add(getZoomLargerButtonObservable(), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.insets = new Insets(2, 0, 4, 10);
        gbc.anchor = GridBagConstraints.WEST;
        optionsPanelObservable.add(getZoomSmallerButtonObservable(), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.weightx = 1;
        // fake cell used for filling all the vertical empty space
        gbc.weighty = 1;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(4, 4, 4, 10);
        optionsPanelObservable.add(new JLabel(""), gbc);
        JPanel containerOfScrollPanelObservable = new JPanel();
        containerOfScrollPanelObservable.setLayout(new BorderLayout());
        containerOfScrollPanelObservable.add(optionsPanelObservable, BorderLayout.WEST);
        containerOfScrollPanelObservable.add(scrollPaneObservable, BorderLayout.CENTER);
        Dimension dimO = new Dimension(500, 100);
        // dimension of shape panel
        containerOfScrollPanelObservable.setPreferredSize(dimO);
        containerOfScrollPanelObservable.setMinimumSize(dimO);
        containerOfScrollPanelObservable.setMaximumSize(dimO);
        // -------------- connection between tables, table models, selection models, renderers, event handlers
        speciesTable = new EditorScrollTable();
        speciesTableModel = new GeneratedSpeciesTableModel2(speciesTable, owner);
        speciesTable.setModel(speciesTableModel);
        speciesTable.getSelectionModel().addListSelectionListener(eventHandlerS);
        speciesTable.getModel().addTableModelListener(eventHandlerS);
        observablesTable = new EditorScrollTable();
        observablesTableModel = new ObservablesGroupTableModel(observablesTable, owner, speciesTableModel);
        observablesTable.setModel(observablesTableModel);
        observablesTable.getSelectionModel().addListSelectionListener(eventHandlerO);
        observablesTable.getModel().addTableModelListener(eventHandlerO);
        speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDefinition).setCellRenderer(rbmSpeciesPatternCellRenderer);
        DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
        rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
        // speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColMultiplier).setCellRenderer(rightRenderer);	// right align
        // left column wide enough for title
        speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColMultiplier).setMaxWidth(70);
        speciesTable.addMouseMotionListener(new // add toolTipText for each table cell
        MouseMotionAdapter() {

            public void mouseMoved(MouseEvent e) {
                Point p = e.getPoint();
                int row = speciesTable.rowAtPoint(p);
                int column = speciesTable.columnAtPoint(p);
                speciesTable.setToolTipText(String.valueOf(speciesTable.getValueAt(row, column)));
            }
        });
        // ---------------------------------------------- top panel
        int gridy = 0;
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        observablesTable.setPreferredScrollableViewportSize(new Dimension(400, 200));
        topPanel.add(observablesTable.getEnclosingScrollPane(), gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.insets = new Insets(4, 4, 4, 4);
        topPanel.add(new JLabel("Search "), gbc);
        textFieldSearchObservables = new JTextField(70);
        textFieldSearchObservables.addActionListener(eventHandlerO);
        textFieldSearchObservables.getDocument().addDocumentListener(eventHandlerO);
        textFieldSearchObservables.putClientProperty("JTextField.variant", "search");
        gbc = new java.awt.GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.gridwidth = 3;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 0, 4, 4);
        topPanel.add(textFieldSearchObservables, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = gridy;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 4, 4, 10);
        topPanel.add(totalObservablesLabel, gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        // gbc.weightx = 1.0;
        gbc.gridwidth = 8;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        topPanel.add(containerOfScrollPanelObservable, gbc);
        // -------------------------------------------- bottom panel
        gridy = 0;
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        speciesTable.setPreferredScrollableViewportSize(new Dimension(400, 200));
        bottomPanel.add(speciesTable.getEnclosingScrollPane(), gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.insets = new Insets(4, 4, 4, 4);
        bottomPanel.add(new JLabel("Search "), gbc);
        textFieldSearchSpecies = new JTextField(70);
        textFieldSearchSpecies.addActionListener(eventHandlerS);
        textFieldSearchSpecies.getDocument().addDocumentListener(eventHandlerS);
        textFieldSearchSpecies.putClientProperty("JTextField.variant", "search");
        gbc = new java.awt.GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.gridwidth = 3;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 0, 4, 4);
        bottomPanel.add(textFieldSearchSpecies, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = gridy;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 4, 4, 10);
        bottomPanel.add(totalSpeciesLabel, gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        // gbc.weightx = 1.0;
        gbc.gridwidth = 8;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        bottomPanel.add(containerOfScrollPanelSpecies, gbc);
        // rendering the small shapes of the flattened species in the Depiction column of this viewer table)
        // TODO: this renderer is almost identical with the one in BioModelEditorModelPanel (which paints the small shapes
        // of a species context in the Depiction column of the species table)
        DefaultScrollTableCellRenderer rbmSpeciesShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {

            SpeciesPatternSmallShape spss = null;

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                if (table.getModel() instanceof VCellSortTableModel<?>) {
                    Object selectedObject = null;
                    if (table.getModel() == speciesTableModel) {
                        selectedObject = speciesTableModel.getValueAt(row);
                    }
                    if (selectedObject != null) {
                        if (selectedObject instanceof GeneratedSpeciesTableRow) {
                            SpeciesContext sc = ((GeneratedSpeciesTableRow) selectedObject).getSpecies();
                            // sp cannot be null
                            SpeciesPattern sp = sc.getSpeciesPattern();
                            Graphics panelContext = table.getGraphics();
                            spss = new SpeciesPatternSmallShape(4, 2, sp, panelContext, sc, isSelected, issueManager);
                        }
                    } else {
                        spss = null;
                    }
                }
                setText("");
                return this;
            }

            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                if (spss != null) {
                    spss.paintSelf(g);
                }
            }
        };
        speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDepiction).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
        speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDepiction).setPreferredWidth(400);
        speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDepiction).setMinWidth(400);
        speciesTable.getColumnModel().getColumn(GeneratedSpeciesTableModel2.iColDefinition).setPreferredWidth(30);
        speciesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
        DefaultScrollTableCellRenderer rbmObservableShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {

            List<SpeciesPatternSmallShape> spssList = new ArrayList<SpeciesPatternSmallShape>();

            SpeciesPatternSmallShape spss = null;

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                if (table.getModel() instanceof VCellSortTableModel<?>) {
                    Object selectedObject = null;
                    if (table.getModel() == observablesTableModel) {
                        selectedObject = observablesTableModel.getValueAt(row);
                    }
                    if (selectedObject != null && selectedObject instanceof ObservablesGroupTableRow) {
                        ObservablesGroupTableRow ogtr = ((ObservablesGroupTableRow) selectedObject);
                        String obsName = ogtr.getObservableGroupObject().getObservableGroupName();
                        RbmObservable observable = ogtr.getObservable(obsName);
                        Graphics panelContext = table.getGraphics();
                        int xPos = 4;
                        spssList.clear();
                        for (int i = 0; i < observable.getSpeciesPatternList().size(); i++) {
                            SpeciesPattern sp = observable.getSpeciesPatternList().get(i);
                            spss = new SpeciesPatternSmallShape(xPos, 2, sp, panelContext, observable, isSelected, issueManager);
                            xPos += spss.getWidth() + 6;
                            spssList.add(spss);
                        }
                    } else {
                        spssList.clear();
                    }
                }
                setText("");
                return this;
            }

            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                for (SpeciesPatternSmallShape spss : spssList) {
                    if (spss == null) {
                        continue;
                    }
                    spss.paintSelf(g);
                }
            }
        };
        observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDepiction).setCellRenderer(rbmObservableShapeDepictionCellRenderer);
        observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDepiction).setPreferredWidth(150);
        observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDepiction).setMinWidth(150);
        observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColDefinition).setPreferredWidth(80);
        observablesTable.getColumnModel().getColumn(ObservablesGroupTableModel.iColExpression).setPreferredWidth(100);
        observablesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : JPanel(javax.swing.JPanel) RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) SpeciesPatternSmallShape(cbit.vcell.graph.SpeciesPatternSmallShape) SpeciesContext(cbit.vcell.model.SpeciesContext) JTextField(javax.swing.JTextField) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) LargeShapePanel(cbit.vcell.graph.gui.LargeShapePanel) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) BorderLayout(java.awt.BorderLayout) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) List(java.util.List) ArrayList(java.util.ArrayList) RuleAnalysisChanged(cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) GroupingCriteria(cbit.vcell.model.GroupingCriteria) RbmObservable(cbit.vcell.model.RbmObservable) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point) GridBagConstraints(java.awt.GridBagConstraints) Point(java.awt.Point) Graphics(java.awt.Graphics) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) JSplitPane(javax.swing.JSplitPane) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Border(javax.swing.border.Border)

Example 2 with EditorScrollTable

use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.

the class NetworkConstraintsPanel method initialize.

private void initialize() {
    seedSpeciesLabel = new JLabel();
    reactionRulesLabel = new JLabel();
    generatedSpeciesLabel = new JLabel();
    generatedReactionsLabel = new JLabel();
    observablesMapLabel = new JLabel("Observables Map");
    somethingInsufficientLabel = new JLabel();
    networkConstraintsTable = new EditorScrollTable();
    networkConstraintsTableModel = new NetworkConstraintsTableModel(networkConstraintsTable);
    networkConstraintsTable.setModel(networkConstraintsTableModel);
    getViewGeneratedSpeciesButton().addActionListener(eventHandler);
    getViewGeneratedReactionsButton().addActionListener(eventHandler);
    getViewObservablesMapButton().addActionListener(eventHandler);
    getRefreshMathButton().addActionListener(eventHandler);
    getCreateModelButton().addActionListener(eventHandler);
    // ------------------------------------------- The 2 group boxes --------------------------
    JPanel leftPanel = new JPanel();
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
    TitledBorder titleTop = BorderFactory.createTitledBorder(loweredEtchedBorder, " Network Constraints ");
    titleTop.setTitleJustification(TitledBorder.LEFT);
    titleTop.setTitlePosition(TitledBorder.TOP);
    TitledBorder titleBottom = BorderFactory.createTitledBorder(loweredEtchedBorder, " Generated Network ");
    titleBottom.setTitleJustification(TitledBorder.LEFT);
    titleBottom.setTitlePosition(TitledBorder.TOP);
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(5, 3, 2, 1);
    add(leftPanel, gbc);
    // ------------------------------------------- Populating the left group box ---------------
    JPanel top = new JPanel();
    JPanel bottom = new JPanel();
    top.setBorder(titleTop);
    bottom.setBorder(titleBottom);
    leftPanel.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    // top, left, bottom, right
    gbc.insets = new Insets(5, 2, 2, 3);
    leftPanel.add(top, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(5, 2, 2, 3);
    leftPanel.add(bottom, gbc);
    // we may want to use a scroll pane whose viewing area is the JTable to provide similar look with NetGen Console
    JScrollPane p = new JScrollPane(networkConstraintsTable);
    p.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // --- bottom
    top.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(5, 4, 4, 10);
    top.add(p, gbc);
    // ------------------------------------------- Populating the right group box ------------
    // --- top
    bottom.setLayout(new GridBagLayout());
    int gridy = 0;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(6, 4, 4, 10);
    bottom.add(generatedSpeciesLabel, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    // gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(6, 4, 4, 10);
    bottom.add(getViewGeneratedSpeciesButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = gridy;
    // gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(6, 4, 4, 10);
    bottom.add(getRefreshMathButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 10);
    bottom.add(generatedReactionsLabel, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 10);
    bottom.add(getViewGeneratedReactionsButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = gridy;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 10);
    bottom.add(getCreateModelButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 10);
    bottom.add(observablesMapLabel, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 10);
    bottom.add(getViewObservablesMapButton(), 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(4, 4, 4, 10);
    bottom.add(somethingInsufficientLabel, gbc);
    networkConstraintsTable.setDefaultRenderer(String.class, new DefaultScrollTableCellRenderer());
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) NetworkConstraintsTableModel(cbit.vcell.mapping.gui.NetworkConstraintsTableModel) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) TitledBorder(javax.swing.border.TitledBorder) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder)

Example 3 with EditorScrollTable

use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.

the class BioModelEditorRightSidePanel method initialize.

private void initialize() {
    addNewButton = new JButton("New Application");
    deleteButton = new JButton("Delete");
    textFieldSearch = new JTextField(10);
    textFieldSearch.putClientProperty("JTextField.variant", "search");
    table = new EditorScrollTable();
    tableModel = createTableModel();
    table.setModel(tableModel);
    table.setDefaultRenderer(Structure.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof Structure) {
                setText(((Structure) value).getName());
            }
            return this;
        }
    });
    addNewButton.addActionListener(eventHandler);
    deleteButton.addActionListener(eventHandler);
    deleteButton.setEnabled(false);
    textFieldSearch.getDocument().addDocumentListener(eventHandler);
    table.getSelectionModel().addListSelectionListener(eventHandler);
}
Also used : JTable(javax.swing.JTable) JButton(javax.swing.JButton) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) JTextField(javax.swing.JTextField) Component(java.awt.Component) Structure(cbit.vcell.model.Structure)

Example 4 with EditorScrollTable

use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.

the class BioModelParametersPanel method initialize.

private void initialize() {
    addNewButton = new JButton("New Global Parameter");
    addNewButton.addActionListener(eventHandler);
    addNewButton2 = new JButton("New Application Parameter");
    // addNewButton2.setIcon(downArrow);
    addNewButton2.setHorizontalTextPosition(SwingConstants.LEFT);
    addNewButton2.addActionListener(eventHandler);
    deleteButton = new JButton("Delete");
    deleteButton.setEnabled(false);
    deleteButton.addActionListener(eventHandler);
    changeUnitsButton = new JButton("Change Unit System");
    changeUnitsButton.addActionListener(eventHandler);
    textFieldSearch = new JTextField(10);
    textFieldSearch.getDocument().addDocumentListener(eventHandler);
    textFieldSearch.putClientProperty("JTextField.variant", "search");
    parametersFunctionsTable = new EditorScrollTable();
    parametersFunctionsTableModel = new BioModelParametersTableModel(parametersFunctionsTable);
    parametersFunctionsTable.setModel(parametersFunctionsTableModel);
    globalParametersCheckBox = new JCheckBox("Global");
    globalParametersCheckBox.setSelected(true);
    globalParametersCheckBox.addActionListener(eventHandler);
    reactionsCheckBox = new JCheckBox("Reactions and Rules");
    reactionsCheckBox.setSelected(true);
    reactionsCheckBox.addActionListener(eventHandler);
    applicationsCheckBox = new JCheckBox("Applications");
    applicationsCheckBox.setSelected(true);
    applicationsCheckBox.addActionListener(eventHandler);
    applicationComboBox = new JComboBox<ApplicationSelection>();
    applicationComboBox.setSelectedItem("All");
    applicationComboBox.addActionListener(eventHandler);
    applicationComboBox.setModel(applicationComboBoxModel);
    applicationComboBox.setRenderer(new ApplicationComboBoxRenderer());
    constantsCheckBox = new JCheckBox("Parameters");
    constantsCheckBox.setSelected(true);
    constantsCheckBox.addActionListener(eventHandler);
    functionsCheckBox = new JCheckBox("Functions");
    functionsCheckBox.setSelected(true);
    functionsCheckBox.addActionListener(eventHandler);
    predefinedSymbolsTable = new EditorScrollTable();
    predefinedSymbolsTableModel = new PredefinedSymbolsTableModel(predefinedSymbolsTable);
    predefinedSymbolsTable.setModel(predefinedSymbolsTableModel);
    GuiUtils.flexResizeTableColumns(predefinedSymbolsTable);
    modelUnitSystemTable = new EditorScrollTable();
    modelUnitSystemTableModel = new ModelUnitSystemTableModel(modelUnitSystemTable);
    modelUnitSystemTable.setModel(modelUnitSystemTableModel);
    GuiUtils.flexResizeTableColumns(modelUnitSystemTable);
    tabbedPane = new JTabbedPaneEnhanced();
    tabbedPane.addChangeListener(eventHandler);
    ParametersPanelTab[] parametersPanelTabs = new ParametersPanelTab[ParametersPanelTabID.values().length];
    parametersPanelTabs[ParametersPanelTabID.parameters_functions.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.parameters_functions, getParametersFunctionsPanel(), null);
    parametersPanelTabs[ParametersPanelTabID.predefined.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.predefined, getPredefinedSymbolsPanel(), null);
    parametersPanelTabs[ParametersPanelTabID.modelUnitSystem.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.modelUnitSystem, getModelUnitSystemPanel(), null);
    for (ParametersPanelTab tab : parametersPanelTabs) {
        tab.component.setBorder(GuiConstants.TAB_PANEL_BORDER);
        tabbedPane.addTab(tab.id.title, tab.icon, tab.component);
    }
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(addNewButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(addNewButton2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(deleteButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(changeUnitsButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = new Insets(4, 50, 4, 4);
    buttonPanel.add(new JLabel("Search"), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    buttonPanel.add(textFieldSearch, gbc);
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
    parametersFunctionsTable.setDefaultRenderer(NameScope.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof NameScope) {
                NameScope nameScope = (NameScope) value;
                setText(nameScope.getPathDescription());
            }
            return this;
        }
    });
    {
        // make double click on units panel bring up editing box
        JPanel p = getModelUnitSystemPanel();
        VCAssert.assertValid(p);
        EditorScrollTable est = GuiUtils.findFirstChild(p, EditorScrollTable.class);
        VCAssert.assertValid(est);
        MouseListener ml = new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    changeUnitsButtonPressed();
                }
            }
        };
        est.addMouseListener(ml);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component) JComponent(javax.swing.JComponent) MouseEvent(java.awt.event.MouseEvent) NameScope(cbit.vcell.parser.NameScope) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable)

Example 5 with EditorScrollTable

use of org.vcell.util.gui.EditorScrollTable in project vcell by virtualcell.

the class ConversionPanel method initialize.

private void initialize() {
    try {
        setName("KineticsTypeTemplatePanel");
        setLayout(new GridBagLayout());
        table = new EditorScrollTable();
        tableModel = new BioModelEditorConversionTableModel(table);
        table.setModel(tableModel);
        tableModel.setIssueManager(issueManager);
        int gridy = 0;
        GridBagConstraints gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        table.setPreferredScrollableViewportSize(new Dimension(400, 200));
        add(table.getEnclosingScrollPane(), gbc);
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 9;
        gbc.gridy = gridy;
        // add toolTipText for each table cell
        table.addMouseMotionListener(new MouseMotionAdapter() {

            public void mouseMoved(MouseEvent e) {
                Point p = e.getPoint();
                int row = table.rowAtPoint(p);
                int column = table.columnAtPoint(p);
                table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
            }
        });
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.insets = new Insets(4, 4, 4, 4);
        add(new JLabel("Search "), gbc);
        textFieldSearch = new JTextField(70);
        textFieldSearch.addActionListener(eventHandler);
        textFieldSearch.getDocument().addDocumentListener(eventHandler);
        textFieldSearch.putClientProperty("JTextField.variant", "search");
        gbc = new java.awt.GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.gridwidth = 3;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 0, 4, 4);
        add(textFieldSearch, gbc);
        addSubunits = new JCheckBox("Add Subunits");
        addSubunits.setHorizontalTextPosition(SwingConstants.LEFT);
        addSubunits.setSelected(false);
        addSubunits.setBackground(Color.white);
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 7;
        gbc.gridy = gridy;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.insets = new Insets(4, 4, 4, 4);
        add(addSubunits, gbc);
        setBackground(Color.white);
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point) GridBagConstraints(java.awt.GridBagConstraints) JTextField(javax.swing.JTextField) Point(java.awt.Point) JCheckBox(javax.swing.JCheckBox) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) EditorScrollTable(org.vcell.util.gui.EditorScrollTable)

Aggregations

EditorScrollTable (org.vcell.util.gui.EditorScrollTable)12 JTextField (javax.swing.JTextField)11 GridBagConstraints (java.awt.GridBagConstraints)10 GridBagLayout (java.awt.GridBagLayout)10 Insets (java.awt.Insets)10 JLabel (javax.swing.JLabel)10 DefaultScrollTableCellRenderer (org.vcell.util.gui.DefaultScrollTableCellRenderer)10 JPanel (javax.swing.JPanel)9 JTable (javax.swing.JTable)9 BorderLayout (java.awt.BorderLayout)7 Dimension (java.awt.Dimension)7 MouseEvent (java.awt.event.MouseEvent)7 Point (java.awt.Point)6 Border (javax.swing.border.Border)6 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)5 SpeciesPatternSmallShape (cbit.vcell.graph.SpeciesPatternSmallShape)5 Graphics (java.awt.Graphics)5 JScrollPane (javax.swing.JScrollPane)5 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)5 SpeciesContext (cbit.vcell.model.SpeciesContext)4