Search in sources :

Example 1 with LargeShapePanel

use of cbit.vcell.graph.gui.LargeShapePanel 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 LargeShapePanel

use of cbit.vcell.graph.gui.LargeShapePanel in project vcell by virtualcell.

the class ObservablePropertiesPanel method initialize.

private void initialize() {
    observableTree = new BioModelNodeEditableTree();
    observableTreeModel = new ObservableTreeModel(observableTree);
    observableTree.setModel(observableTreeModel);
    setLayout(new GridBagLayout());
    // --------------------------------------------------------------------------------------------------------
    splitPaneHorizontal.setOneTouchExpandable(true);
    splitPaneHorizontal.setDividerLocation(120);
    splitPaneHorizontal.setResizeWeight(0.1);
    Border border = BorderFactory.createLineBorder(Color.gray);
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
    TitledBorder annotationBorder = BorderFactory.createTitledBorder(loweredEtchedBorder, " Annotation ");
    annotationBorder.setTitleJustification(TitledBorder.LEFT);
    annotationBorder.setTitlePosition(TitledBorder.TOP);
    annotationBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
    shapePanel = 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;
        }
    };
    shapePanel.setBorder(border);
    shapePanel.setBackground(Color.white);
    shapePanel.setLayout(null);
    shapePanel.setZoomFactor(-1);
    shapePanel.setEditable(true);
    shapePanel.setShowMoleculeColor(true);
    shapePanel.setShowNonTrivialOnly(true);
    shapePanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            if (e.getButton() == 1) {
                // left click selects the object (we highlight it)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
            } else if (e.getButton() == 3) {
                // right click invokes popup menu (only if the object is highlighted)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
                if (locationContext.getDeepestShape() != null && !locationContext.getDeepestShape().isHighlighted()) {
                // TODO: (maybe) add code here to highlight the shape if it's not highlighted already but don't show the menu
                // return;
                }
                showPopupMenu(e, locationContext);
            }
        }

        private void manageMouseActivity(PointLocationInShapeContext locationContext) {
            Graphics g = shapePanel.getGraphics();
            for (SpeciesPatternLargeShape sps : spsList) {
                sps.turnHighlightOffRecursive(g);
            }
            for (SpeciesPatternLargeShape sps : spsList) {
                if (sps.contains(locationContext)) {
                    // check if mouse is inside shape
                    break;
                }
            }
            locationContext.highlightDeepestShape();
            locationContext.paintDeepestShape(g);
        }
    });
    // shapePanel.addMouseListener(eventHandler);		// alternately use this
    shapePanel.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            Point overWhat = e.getPoint();
            PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
            for (SpeciesPatternLargeShape sps : spsList) {
                if (sps.contains(locationContext)) {
                    break;
                }
            }
            HighlightableShapeInterface hsi = locationContext.getDeepestShape();
            if (hsi == null) {
                shapePanel.setToolTipText(null);
            } else {
                shapePanel.setToolTipText("Right click for " + hsi.getDisplayType() + " menus");
            }
            for (SpeciesPatternLargeShape sps : spsList) {
                for (MolecularTypeLargeShape mtls : sps.getMolecularTypeLargeShapes()) {
                    Rectangle r = mtls.getAnchorHotspot();
                    if (r != null && r.contains(overWhat)) {
                        mtls.getMolecularType();
                        shapePanel.setToolTipText(mtls.getAnchorsHTML());
                        break;
                    }
                }
            }
        }
    });
    JPanel optionsPanel = new JPanel();
    // gray options panel
    optionsPanel.setPreferredSize(new Dimension(140, 200));
    optionsPanel.setLayout(new GridBagLayout());
    getZoomSmallerButton().setEnabled(true);
    getZoomLargerButton().setEnabled(true);
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 3;
    // top, left bottom, right
    gbc.insets = new Insets(4, 4, 2, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    optionsPanel.add(getAddSpeciesButton(), gbc);
    ButtonGroup bg = new ButtonGroup();
    bg.add(getSequenceMultimolecularButton());
    bg.add(getSequencePolimerEqualButton());
    bg.add(getSequencePolimerGreaterButton());
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(8, 4, 2, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getSequenceMultimolecularButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 10, 2, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    JLabel label = new JLabel("Polymer of");
    label.setToolTipText("Compact notation available below for single-Molecule polymers");
    optionsPanel.add(label, gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(2, 4, 1, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getSequencePolimerEqualButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(2, 4, 1, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getLengthEqualTextField(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(1, 4, 4, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getSequencePolimerGreaterButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(1, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionsPanel.add(getLengthGreaterTextField(), gbc);
    // --- zoom buttons in their own panel, for alignment ---
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.gridx = 0;
    gbc2.gridy = 0;
    gbc2.insets = new Insets(1, 1, 1, 1);
    gbc2.anchor = GridBagConstraints.WEST;
    buttonPanel.add(getZoomLargerButton(), gbc2);
    gbc2 = new GridBagConstraints();
    gbc2.gridx = 1;
    gbc2.gridy = 0;
    gbc2.insets = new Insets(1, 1, 1, 1);
    gbc2.anchor = GridBagConstraints.WEST;
    buttonPanel.add(getZoomSmallerButton(), gbc2);
    // ---------------------------------------------------
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(1, 4, 4, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    // zoom buttons panel
    optionsPanel.add(buttonPanel, gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 3;
    gbc.weightx = 1;
    // fake cell used for filling all the vertical empty space
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 1, 2, 10);
    optionsPanel.add(new JLabel(""), gbc);
    // -----------------------------------------------------------------------------------------
    // JPanel generalPanel = new JPanel();		// right bottom panel, contains just the annotation
    // generalPanel.setBorder(annotationBorder);
    // generalPanel.setLayout(new GridBagLayout());
    // 
    // gridy = 0;
    // annotationTextArea = new javax.swing.JTextArea("", 1, 30);
    // annotationTextArea.setLineWrap(true);
    // annotationTextArea.setWrapStyleWord(true);
    // annotationTextArea.setFont(new Font("monospaced", Font.PLAIN, 11));
    // annotationTextArea.setEditable(false);
    // javax.swing.JScrollPane jsp = new javax.swing.JScrollPane(annotationTextArea);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.weightx = 1.0;
    // gbc.weighty = 0.1;
    // gbc.gridx = 0;
    // gbc.gridy = gridy;
    // gbc.anchor = GridBagConstraints.LINE_START;
    // gbc.fill = java.awt.GridBagConstraints.BOTH;
    // gbc.insets = new Insets(4, 4, 4, 4);
    // generalPanel.add(jsp, gbc);
    // where we display the shapes
    scrollPane = new JScrollPane(shapePanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JPanel containerOfScrollPanel = new JPanel();
    containerOfScrollPanel.setLayout(new BorderLayout());
    containerOfScrollPanel.add(optionsPanel, BorderLayout.WEST);
    containerOfScrollPanel.add(scrollPane, BorderLayout.CENTER);
    // splitPaneHorizontal.setTopComponent(containerOfScrollPanel);
    // splitPaneHorizontal.setBottomComponent(generalPanel);
    // splitPaneHorizontal.setResizeWeight(0.9d);
    // splitPaneHorizontal.setDividerLocation(0.8d);
    setName("ObservablePropertiesPanel");
    setLayout(new BorderLayout());
    add(containerOfScrollPanel, BorderLayout.CENTER);
    setBackground(Color.white);
// annotationTextArea.addFocusListener(eventHandler);
// annotationTextArea.addMouseListener(eventHandler);
}
Also used : JPanel(javax.swing.JPanel) RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Rectangle(java.awt.Rectangle) TitledBorder(javax.swing.border.TitledBorder) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) LargeShapePanel(cbit.vcell.graph.gui.LargeShapePanel) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) BorderLayout(java.awt.BorderLayout) 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) MouseAdapter(java.awt.event.MouseAdapter) HighlightableShapeInterface(cbit.vcell.graph.HighlightableShapeInterface) JLabel(javax.swing.JLabel) Point(java.awt.Point) Dimension(java.awt.Dimension) PointLocationInShapeContext(cbit.vcell.graph.PointLocationInShapeContext) Point(java.awt.Point) Graphics(java.awt.Graphics) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) ButtonGroup(javax.swing.ButtonGroup) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder)

Example 3 with LargeShapePanel

use of cbit.vcell.graph.gui.LargeShapePanel 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);
        // we work with a "fake" model and cannot show proper molecule color
        shapePanel.setShowMoleculeColor(false);
        shapePanel.setShowNonTrivialOnly(false);
        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, ssm, 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 4 with LargeShapePanel

use of cbit.vcell.graph.gui.LargeShapePanel in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method initialize.

private void initialize() {
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new GridBagLayout());
    // leftPanel.setBackground(Color.white);
    anchorPanel = new JAnchorPanel();
    anchorScrollPanel = new JScrollPane(anchorPanel);
    molecularTypeTree = new BioModelNodeEditableTree();
    molecularTypeTreeModel = new MolecularTypeTreeModel(molecularTypeTree);
    molecularTypeTree.setModel(molecularTypeTreeModel);
    molecularTypeTree.setEditable(true);
    molecularTypeTree.setCellRenderer(new RbmMolecularTypeTreeCellRenderer(molecularTypeTree, issueManager));
    molecularTypeTree.setCellEditor(new RbmMolecularTypeTreeCellEditor(molecularTypeTree));
    int rowHeight = molecularTypeTree.getRowHeight();
    if (rowHeight < 10) {
        rowHeight = 20;
    }
    molecularTypeTree.setRowHeight(rowHeight + 2);
    molecularTypeTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    ToolTipManager.sharedInstance().registerComponent(molecularTypeTree);
    molecularTypeTree.addTreeSelectionListener(eventHandler);
    molecularTypeTree.addTreeWillExpandListener(eventHandler);
    molecularTypeTree.addMouseListener(eventHandler);
    molecularTypeTree.setLargeModel(true);
    molecularTypeTree.setRootVisible(true);
    setLayout(new GridBagLayout());
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(4, 4, 4, 4);
    titleLabel = new JLabel("Construct Solid Geometry");
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
    leftPanel.add(titleLabel, gbc);
    ButtonGroup bg = new ButtonGroup();
    bg.add(getAnchorAllButton());
    bg.add(getAnchorOnlyButton());
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    leftPanel.add(getAnchorAllButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    leftPanel.add(getAnchorOnlyButton(), gbc);
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.BOTH;
    leftPanel.add(anchorScrollPanel, gbc);
    // ------------------------------------------------------------------------------
    splitPaneHorizontal.setOneTouchExpandable(true);
    splitPaneHorizontal.setDividerLocation(120);
    splitPaneHorizontal.setResizeWeight(0.1);
    Border border = BorderFactory.createLineBorder(Color.gray);
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
    TitledBorder annotationBorder = BorderFactory.createTitledBorder(loweredEtchedBorder, " Pathway Links ");
    annotationBorder.setTitleJustification(TitledBorder.LEFT);
    annotationBorder.setTitlePosition(TitledBorder.TOP);
    annotationBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
    shapePanel = new LargeShapePanel() {

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            for (LargeShape stls : molecularTypeShapeList) {
                stls.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 boolean isViewSingleRow() {
            return true;
        }

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

        @Override
        public GroupingCriteria getCriteria() {
            return null;
        }
    };
    shapePanel.setBorder(border);
    shapePanel.setLayout(null);
    shapePanel.setBackground(Color.white);
    shapePanel.setEditable(true);
    shapePanel.setShowMoleculeColor(true);
    shapePanel.setShowNonTrivialOnly(true);
    shapePanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            stopEditing();
            if (e.getButton() == 1) {
                // left click selects the object (we highlight it)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
            } else if (e.getButton() == 3) {
                // right click invokes popup menu (only if the object is highlighted)
                Point whereClicked = e.getPoint();
                PointLocationInShapeContext locationContext = new PointLocationInShapeContext(whereClicked);
                manageMouseActivity(locationContext);
                if (locationContext.getDeepestShape() != null && !locationContext.getDeepestShape().isHighlighted()) {
                // TODO: (maybe) add code here to highlight the shape if it's not highlighted already but don't show the menu
                // return;
                }
                showPopupMenu(e, locationContext);
            }
        }

        private void manageMouseActivity(PointLocationInShapeContext locationContext) {
            Graphics g = shapePanel.getGraphics();
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                mtls.turnHighlightOffRecursive(g);
            }
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                if (mtls.contains(locationContext)) {
                    // check if mouse is inside shape
                    break;
                }
            }
            locationContext.highlightDeepestShape();
            locationContext.paintDeepestShape(g);
        }
    });
    shapePanel.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            Point overWhat = e.getPoint();
            PointLocationInShapeContext locationContext = new PointLocationInShapeContext(overWhat);
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                if (mtls.contains(locationContext)) {
                    break;
                }
            }
            HighlightableShapeInterface hsi = locationContext.getDeepestShape();
            if (hsi == null) {
                shapePanel.setToolTipText(null);
            } else {
                shapePanel.setToolTipText("Right click for " + hsi.getDisplayType() + " menus");
            }
            for (MolecularTypeLargeShape mtls : molecularTypeShapeList) {
                Rectangle r = mtls.getAnchorHotspot();
                if (r != null && r.contains(overWhat)) {
                    mtls.getMolecularType();
                    shapePanel.setToolTipText(mtls.getAnchorsHTML());
                    break;
                }
            }
        }
    });
    // -------------------------------------------------------------------------------------------
    // right bottom panel, contains just the link
    JPanel generalPanel = new JPanel();
    generalPanel.setBorder(annotationBorder);
    generalPanel.setLayout(new GridBagLayout());
    gridy = 0;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.insets = new Insets(4, 4, 4, 4);
    JLabel pathwayLink = new JLabel("Linked Pathway Object(s): ");
    generalPanel.add(pathwayLink, gbc);
    linkedPOScrollPane = new JScrollPane();
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    // gbc.weightx = 1.0;
    gbc.gridwidth = 3;
    gbc.gridheight = 3;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = java.awt.GridBagConstraints.BOTH;
    gbc.insets = new Insets(4, 4, 4, 4);
    generalPanel.add(linkedPOScrollPane, gbc);
    // annotationTextArea = new JTextPane();
    // annotationTextArea.setContentType("text/html");
    // annotationTextArea.setEditable(false);
    // javax.swing.JScrollPane jsp = new javax.swing.JScrollPane(annotationTextArea);
    gridy++;
    gbc = new java.awt.GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = java.awt.GridBagConstraints.BOTH;
    gbc.insets = new Insets(4, 4, 4, 4);
    generalPanel.add(new JLabel(), gbc);
    scrollPane = new JScrollPane(shapePanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    splitPaneHorizontal.setTopComponent(scrollPane);
    splitPaneHorizontal.setBottomComponent(generalPanel);
    splitPaneHorizontal.setResizeWeight(1.0);
    // splitPaneHorizontal.setDividerLocation(1);
    // -----------------------------------------------------------------------------
    splitPane.setOneTouchExpandable(true);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(splitPaneHorizontal);
    splitPane.setResizeWeight(0.0);
    splitPane.getLeftComponent().setMaximumSize(new Dimension(120, 200));
    splitPane.getLeftComponent().setPreferredSize(new Dimension(120, 200));
    // splitPane.setDividerLocation(0.0d);		// completely hides the left component
    // attempt to use the preferred size
    splitPane.setDividerLocation(-1);
    setName("MolecularTypePropertiesPanel");
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    setBackground(Color.white);
// annotationTextArea.addFocusListener(eventHandler);
// annotationTextArea.addMouseListener(eventHandler);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Rectangle(java.awt.Rectangle) TitledBorder(javax.swing.border.TitledBorder) LargeShapePanel(cbit.vcell.graph.gui.LargeShapePanel) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) BorderLayout(java.awt.BorderLayout) 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) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) HighlightableShapeInterface(cbit.vcell.graph.HighlightableShapeInterface) Point(java.awt.Point) Dimension(java.awt.Dimension) PointLocationInShapeContext(cbit.vcell.graph.PointLocationInShapeContext) GridBagConstraints(java.awt.GridBagConstraints) Point(java.awt.Point) Graphics(java.awt.Graphics) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) ButtonGroup(javax.swing.ButtonGroup) MolecularTypeLargeShape(cbit.vcell.graph.MolecularTypeLargeShape) SpeciesPatternLargeShape(cbit.vcell.graph.SpeciesPatternLargeShape) ComponentStateLargeShape(cbit.vcell.graph.MolecularComponentLargeShape.ComponentStateLargeShape) LargeShape(cbit.vcell.graph.LargeShape) MolecularComponentLargeShape(cbit.vcell.graph.MolecularComponentLargeShape) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder)

Example 5 with LargeShapePanel

use of cbit.vcell.graph.gui.LargeShapePanel in project vcell by virtualcell.

the class ViewGeneratedSpeciesPanel 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 GeneratedSpeciesTableModel(table, owner);
        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);
        // 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);
        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);
        // 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() == tableModel) {
                        selectedObject = tableModel.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);
                }
            }
        };
        table.getColumnModel().getColumn(GeneratedSpeciesTableModel.iColDepiction).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
        table.getColumnModel().getColumn(GeneratedSpeciesTableModel.iColDepiction).setPreferredWidth(400);
        table.getColumnModel().getColumn(GeneratedSpeciesTableModel.iColDepiction).setMinWidth(400);
        table.getColumnModel().getColumn(GeneratedReactionTableModel.iColDefinition).setPreferredWidth(30);
        table.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) 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) 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)

Aggregations

RuleAnalysisChanged (cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged)5 LargeShapePanel (cbit.vcell.graph.gui.LargeShapePanel)5 GroupingCriteria (cbit.vcell.model.GroupingCriteria)5 RuleParticipantSignature (cbit.vcell.model.RuleParticipantSignature)5 BorderLayout (java.awt.BorderLayout)5 Dimension (java.awt.Dimension)5 Graphics (java.awt.Graphics)5 GridBagConstraints (java.awt.GridBagConstraints)5 GridBagLayout (java.awt.GridBagLayout)5 Insets (java.awt.Insets)5 Point (java.awt.Point)5 MouseEvent (java.awt.event.MouseEvent)5 JLabel (javax.swing.JLabel)5 JPanel (javax.swing.JPanel)5 JScrollPane (javax.swing.JScrollPane)5 Border (javax.swing.border.Border)5 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)5 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)5 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)4 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)3