Search in sources :

Example 1 with GeneratedSpeciesTableRow

use of org.vcell.model.rbm.gui.GeneratedSpeciesTableRow in project vcell by virtualcell.

the class OutputSpeciesResultsPanel method updateShape.

public void updateShape(int selectedRow) {
    GeneratedSpeciesTableRow speciesTableRow = tableModel.getValueAt(selectedRow);
    SpeciesContext sc = speciesTableRow.species;
    if (sc == null || sc.getSpeciesPattern() == null) {
        // error (red circle)
        spls = new SpeciesPatternLargeShape(20, 20, -1, shapePanel, true, issueManager);
    } else {
        spls = new SpeciesPatternLargeShape(20, 20, -1, sc.getSpeciesPattern(), shapePanel, sc, issueManager);
    }
    int xOffset = spls.getRightEnd() + 45;
    Dimension preferredSize = new Dimension(xOffset + 90, 50);
    shapePanel.setPreferredSize(preferredSize);
    shapePanel.repaint();
}
Also used : GeneratedSpeciesTableRow(org.vcell.model.rbm.gui.GeneratedSpeciesTableRow) SpeciesContext(cbit.vcell.model.SpeciesContext) Dimension(java.awt.Dimension) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) Point(java.awt.Point)

Example 2 with GeneratedSpeciesTableRow

use of org.vcell.model.rbm.gui.GeneratedSpeciesTableRow in project vcell by virtualcell.

the class OutputSpeciesResultsPanel method initialize.

private void initialize() {
    try {
        setName("ViewGeneratedSpeciesPanel");
        setLayout(new GridBagLayout());
        shapePanel = 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;
            }
        };
        Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
        shapePanel.setLayout(new GridBagLayout());
        shapePanel.setBackground(Color.white);
        // not really editable but we don't want the brown contours here
        shapePanel.setEditable(true);
        shapePanel.setShowMoleculeColor(true);
        shapePanel.setShowNonTrivialOnly(true);
        JScrollPane scrollPane = new JScrollPane(shapePanel);
        scrollPane.setBorder(loweredBevelBorder);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        JPanel optionsPanel = new JPanel();
        optionsPanel.setLayout(new GridBagLayout());
        getZoomSmallerButton().setEnabled(true);
        getZoomLargerButton().setEnabled(false);
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.insets = new Insets(0, 0, 0, 10);
        gbc.anchor = GridBagConstraints.WEST;
        optionsPanel.add(getZoomLargerButton(), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.insets = new Insets(2, 0, 4, 10);
        gbc.anchor = GridBagConstraints.WEST;
        optionsPanel.add(getZoomSmallerButton(), 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);
        optionsPanel.add(new JLabel(""), gbc);
        JPanel containerOfScrollPanel = new JPanel();
        containerOfScrollPanel.setLayout(new BorderLayout());
        containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
        containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
        Dimension dim = new Dimension(500, 135);
        // dimension of shape panel
        containerOfScrollPanel.setPreferredSize(dim);
        containerOfScrollPanel.setMinimumSize(dim);
        containerOfScrollPanel.setMaximumSize(dim);
        // ------------------------------------------------------------------------
        table = new EditorScrollTable();
        tableModel = new OutputSpeciesResultsTableModel();
        table.setModel(tableModel);
        table.getSelectionModel().addListSelectionListener(eventHandler);
        table.getModel().addTableModelListener(eventHandler);
        DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
        rightRenderer.setHorizontalAlignment(JLabel.RIGHT);
        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);
        table.setPreferredScrollableViewportSize(new Dimension(400, 200));
        add(table.getEnclosingScrollPane(), gbc);
        // 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);
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = gridy;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 4, 4, 10);
        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);
        add(containerOfScrollPanel, gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.gridwidth = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 4, 4, 4);
        add(getSpeciesFileLocationPanel(), gbc);
        // // button to copy to clipboard the content of the JTextField.
        // // TODO: do not delete! this is how it's done
        // JButton buttonCopy = new JButton("Copy");
        // buttonCopy.setToolTipText("Copy to clipboard the species file path");
        // buttonCopy.addActionListener(new ActionListener() {
        // public void actionPerformed(ActionEvent le) {
        // if(speciesFileLocationTextField.getSelectionStart() == speciesFileLocationTextField.getSelectionEnd()) {
        // speciesFileLocationTextField.setSelectionStart(0);
        // speciesFileLocationTextField.setSelectionEnd(speciesFileLocationTextField.getText().length());
        // }
        // speciesFileLocationTextField.copy();
        // speciesFileLocationTextField.setSelectionStart(0);
        // speciesFileLocationTextField.setSelectionEnd(0);
        // }
        // });
        // gbc = new GridBagConstraints();
        // gbc.gridx = 4;
        // gbc.gridy = gridy;
        // gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        // gbc.insets = new Insets(4,4,4,4);
        // add(buttonCopy, gbc);
        // rendering the small shapes of the flattened species in the Depiction column of this viewer 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() == tableModel) {
                        selectedObject = tableModel.getValueAt(row);
                    }
                    if (selectedObject != null) {
                        if (selectedObject instanceof GeneratedSpeciesTableRow) {
                            SpeciesContext sc = ((GeneratedSpeciesTableRow) selectedObject).species;
                            if (sc == null || sc.getSpeciesPattern() == null) {
                                spss = null;
                            } else {
                                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);
                }
            }
        };
        table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
        table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setPreferredWidth(400);
        table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDepiction).setMinWidth(400);
        table.getColumnModel().getColumn(OutputSpeciesResultsTableModel.iColDefinition).setPreferredWidth(30);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : GeneratedSpeciesTableRow(org.vcell.model.rbm.gui.GeneratedSpeciesTableRow) 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) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ASTSpeciesPattern(org.vcell.model.bngl.ASTSpeciesPattern) LargeShapePanel(cbit.vcell.graph.gui.LargeShapePanel) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) BorderLayout(java.awt.BorderLayout) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) 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) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point) GridBagConstraints(java.awt.GridBagConstraints) Point(java.awt.Point) Graphics(java.awt.Graphics) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Border(javax.swing.border.Border)

Example 3 with GeneratedSpeciesTableRow

use of org.vcell.model.rbm.gui.GeneratedSpeciesTableRow in project vcell by virtualcell.

the class OutputSpeciesResultsPanel method createTableRow.

private GeneratedSpeciesTableRow createTableRow(String expression, Integer count) {
    GeneratedSpeciesTableRow row = new GeneratedSpeciesTableRow(count);
    row.deriveSpecies(expression);
    return row;
}
Also used : GeneratedSpeciesTableRow(org.vcell.model.rbm.gui.GeneratedSpeciesTableRow)

Aggregations

GeneratedSpeciesTableRow (org.vcell.model.rbm.gui.GeneratedSpeciesTableRow)3 SpeciesContext (cbit.vcell.model.SpeciesContext)2 Dimension (java.awt.Dimension)2 Point (java.awt.Point)2 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)1 RuleAnalysisChanged (cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged)1 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)1 SpeciesPatternSmallShape (cbit.vcell.graph.SpeciesPatternSmallShape)1 LargeShapePanel (cbit.vcell.graph.gui.LargeShapePanel)1 GroupingCriteria (cbit.vcell.model.GroupingCriteria)1 RuleParticipantSignature (cbit.vcell.model.RuleParticipantSignature)1 BorderLayout (java.awt.BorderLayout)1 Graphics (java.awt.Graphics)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 MouseEvent (java.awt.event.MouseEvent)1 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1