Search in sources :

Example 1 with GraphPane

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

the class ReactionCartoonEditorPanel method getGraphPane.

private GraphPane getGraphPane() {
    if (graphPane == null) {
        try {
            graphPane = new GraphPane();
            graphPane.setName("GraphPane");
            graphPane.setBounds(0, 0, 372, 364);
        } catch (Throwable throwable) {
            handleException(throwable);
        }
    }
    return graphPane;
}
Also used : GraphPane(cbit.gui.graph.gui.GraphPane)

Example 2 with GraphPane

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

the class ReactionCartoonTool method deleteReactionsAndSpecies.

public static void deleteReactionsAndSpecies(Component requester, ReactionStep[] reactionStepArr, SpeciesContext[] speciesContextArr) throws Exception, UserCancelException {
    if ((speciesContextArr == null && reactionStepArr == null) || (reactionStepArr == null && speciesContextArr != null && speciesContextArr.length == 0) || (speciesContextArr == null && reactionStepArr != null && reactionStepArr.length == 0) || (speciesContextArr != null && speciesContextArr.length == 0 && reactionStepArr != null && reactionStepArr.length == 0)) {
        return;
    }
    int rxCount = (reactionStepArr != null ? reactionStepArr.length : 0);
    int speciesCount = (speciesContextArr != null ? speciesContextArr.length : 0);
    boolean bHasBoth = speciesCount > 0 && rxCount > 0;
    ReactionCartoon rxCartoon = null;
    if (requester instanceof GraphPane && ((GraphPane) requester).getGraphModel() instanceof ReactionCartoon) {
        rxCartoon = (ReactionCartoon) (((GraphPane) requester).getGraphModel());
    } else if (requester instanceof ReactionCartoonEditorPanel) {
        rxCartoon = ((ReactionCartoonEditorPanel) requester).getReactionCartoon();
    } else {
        throw new IllegalArgumentException("ReactionCartoonTool.deleteSpeciesContext not implemented for type '" + requester.getClass().getName() + "'");
    }
    DeleteSpeciesInfo deleteSpeciesInfo = null;
    final String DETAILS = "Details...";
    while (true) {
        String response = DialogUtils.showWarningDialog(requester, RXSPECIES_DELETE + " " + (bHasBoth ? "Reactions and Species." : (rxCount > 0 ? "Reactions." : (speciesCount > 0 ? "Species." : ""))), RXSPECIES_DELETE + " " + (bHasBoth ? rxCount + " Reactions and " + speciesCount + " Species." : (rxCount > 0 ? rxCount + " Reactions." : (speciesCount > 0 ? speciesCount + " Species." : ""))), new String[] { RXSPECIES_DELETE, DETAILS, RXSPECIES_CANCEL }, RXSPECIES_DELETE);
        if (response == null || response.equals(RXSPECIES_CANCEL)) {
            throw UserCancelException.CANCEL_GENERIC;
        }
        deleteSpeciesInfo = (deleteSpeciesInfo == null ? detailsDeleteSpecies(requester, speciesContextArr, reactionStepArr, rxCartoon) : deleteSpeciesInfo);
        if (response.equals(DETAILS)) {
            TableListResult tableListResult = showDeleteDetails(requester, deleteSpeciesInfo, reactionStepArr, false);
        // if(!tableListResult.selectedOption.equals(RXSPECIES_BACK)){
        // //if(!tableListResult.selectedOption.equals((bCut?RXSPECIES_CUT:RXSPECIES_DELETE))){
        // throw UserCancelException.CANCEL_GENERIC;
        // }
        } else {
            break;
        }
    }
    if (deleteSpeciesInfo != null) {
        for (Boolean errors : deleteSpeciesInfo.getbUnresolvableHashMap().values()) {
            if (errors) {
                while (true) {
                    String response = DialogUtils.showWarningDialog(requester, "Error warning.", "Warning: 1 or more SpeciesContexts have Model references that could cause Model corruption if " + RXSPECIES_DELETE + ".", new String[] { DETAILS, RXSPECIES_CANCEL }, DETAILS);
                    if (response == null || response.equals(RXSPECIES_CANCEL)) {
                        throw UserCancelException.CANCEL_GENERIC;
                    }
                    showDeleteDetails(requester, deleteSpeciesInfo, reactionStepArr, true);
                }
            }
        }
    }
    if (reactionStepArr != null) {
        for (int i = 0; i < reactionStepArr.length; i += 1) {
            rxCartoon.getModel().removeReactionStep(reactionStepArr[i]);
        }
    }
    if (deleteSpeciesInfo != null) {
        // remove all ReactionParticipants ("lines" between reaction and species in "Reaction Diagram") that have this speciesContext before deleting SpeciesContext
        for (SpeciesContext objSpeciesContext : deleteSpeciesInfo.getRxPartHashMap().keySet()) {
            if (deleteSpeciesInfo.getbUnresolvableHashMap().get(objSpeciesContext)) {
                continue;
            }
            Iterator<ReactionParticipant> iterRxPart = deleteSpeciesInfo.getRxPartHashMap().get(objSpeciesContext).iterator();
            while (iterRxPart.hasNext()) {
                ReactionParticipant objRxPart = iterRxPart.next();
                if (rxCartoon.getObjects().contains(objRxPart)) {
                    // Reaction delete may have already removed
                    objRxPart.getReactionStep().removeReactionParticipant(objRxPart);
                }
            }
        }
        // remove the SpeciesContext
        for (int i = 0; i < speciesContextArr.length; i++) {
            if (deleteSpeciesInfo.getbUnresolvableHashMap().get(speciesContextArr[i])) {
                continue;
            }
            if (rxCartoon.getObjects().contains(speciesContextArr[i])) {
                // Reaction delete may have already removed
                rxCartoon.getModel().removeSpeciesContext(speciesContextArr[i]);
            }
        }
    }
}
Also used : TableListResult(org.vcell.util.gui.DialogUtils.TableListResult) SpeciesContext(cbit.vcell.model.SpeciesContext) GraphPane(cbit.gui.graph.gui.GraphPane) Point(java.awt.Point) ReactionCartoon(cbit.vcell.graph.ReactionCartoon) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 3 with GraphPane

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

the class StructureMappingCartoonPanel method getStructureGraphPane.

/**
 * Return the StructureGraphPane property value.
 * @return cbit.vcell.graph.GraphPane
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private GraphPane getStructureGraphPane() {
    if (ivjStructureGraphPane == null) {
        try {
            ivjStructureGraphPane = new GraphPane();
            ivjStructureGraphPane.setName("StructureGraphPane");
            ivjStructureGraphPane.setBounds(0, 0, 290, 237);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjStructureGraphPane;
}
Also used : GraphPane(cbit.gui.graph.gui.GraphPane)

Example 4 with GraphPane

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

the class BioModelEditorPathwayDiagramPanel method initialize.

private void initialize() {
    JToolBar layoutToolBar = createToolBar(SwingConstants.HORIZONTAL);
    sourceTextArea = new JTextArea();
    graphPane = new GraphPane();
    pathwayGraphModel = new PathwayGraphModel();
    pathwayGraphModel.addPropertyChangeListener(eventHandler);
    graphPane.setGraphModel(pathwayGraphModel);
    graphPane.addMouseListener(eventHandler);
    graphCartoonTool = new PathwayGraphTool();
    graphCartoonTool.setGraphPane(graphPane);
    graphTabPanel = new JPanel(new BorderLayout());
    graphScrollPane = new JScrollPane(graphPane);
    graphScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    graphScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    graphTabPanel.add(graphScrollPane, BorderLayout.CENTER);
    viewPortStabilizer = new ViewPortStabilizer(graphScrollPane);
    graphTabPanel.add(layoutToolBar, BorderLayout.NORTH);
    sourceTabPanel = new JPanel(new BorderLayout());
    sourceTabPanel.add(new JScrollPane(sourceTextArea), BorderLayout.CENTER);
    treeTabPanel.add(new JScrollPane(biopaxTree), BorderLayout.CENTER);
    pathwayModelTable = new JSortTable();
    pathwayModelTable.getSelectionModel().addListSelectionListener(eventHandler);
    pathwayModelTableModel = new PathwayModelTableModel(pathwayModelTable);
    pathwayModelTable.setModel(pathwayModelTableModel);
    searchTextField = new JTextField();
    searchTextField.putClientProperty("JTextField.variant", "search");
    searchTextField.getDocument().addDocumentListener(eventHandler);
    groupButton = new JButton("Group", new DownArrowIcon());
    groupButton.setHorizontalTextPosition(SwingConstants.LEFT);
    groupButton.addActionListener(eventHandler);
    deleteButton = new JButton("Delete");
    deleteButton.addActionListener(eventHandler);
    physiologyLinkButton = new JButton("Physiology Links", new DownArrowIcon());
    physiologyLinkButton.setHorizontalTextPosition(SwingConstants.LEFT);
    physiologyLinkButton.addActionListener(eventHandler);
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    bottomPanel.add(groupButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    bottomPanel.add(deleteButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    bottomPanel.add(physiologyLinkButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 20, 4, 4);
    bottomPanel.add(new JLabel("Search "), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    bottomPanel.add(searchTextField, gbc);
    tabbedPane = new JTabbedPaneEnhanced();
    pathwayPanelTabs[PathwayPanelTabID.pathway_diagram.ordinal()] = new PathwayPanelTab(PathwayPanelTabID.pathway_diagram, graphTabPanel, VCellIcons.diagramIcon);
    pathwayPanelTabs[PathwayPanelTabID.pathway_objects.ordinal()] = new PathwayPanelTab(PathwayPanelTabID.pathway_objects, pathwayModelTable.getEnclosingScrollPane(), VCellIcons.tableIcon);
    pathwayPanelTabs[PathwayPanelTabID.biopax_summary.ordinal()] = new PathwayPanelTab(PathwayPanelTabID.biopax_summary, sourceTabPanel, VCellIcons.textNotesIcon);
    pathwayPanelTabs[PathwayPanelTabID.biopax_tree.ordinal()] = new PathwayPanelTab(PathwayPanelTabID.biopax_tree, treeTabPanel, VCellIcons.tableIcon);
    tabbedPane.addChangeListener(eventHandler);
    tabbedPane.addChangeListener(eventHandler);
    for (PathwayPanelTab tab : pathwayPanelTabs) {
        tab.getComponent().setBorder(GuiConstants.TAB_PANEL_BORDER);
        tabbedPane.addTab(tab.getName(), tab.getIcon(), tab.getComponent());
    }
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    add(bottomPanel, BorderLayout.SOUTH);
    pathwayModelTable.getColumnModel().getColumn(PathwayModelTableModel.COLUMN_ENTITY).setCellRenderer(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);
            // }
            return this;
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) GraphPane(cbit.gui.graph.gui.GraphPane) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) BorderLayout(java.awt.BorderLayout) PathwayGraphModel(cbit.vcell.client.desktop.biomodel.pathway.shapes.PathwayGraphModel) Component(java.awt.Component) JComponent(javax.swing.JComponent) JScrollPane(javax.swing.JScrollPane) ViewPortStabilizer(org.vcell.util.gui.ViewPortStabilizer) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JSortTable(org.vcell.util.gui.sorttable.JSortTable) JTable(javax.swing.JTable) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) GroupObject(org.vcell.pathway.GroupObject) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) BioPaxObject(org.vcell.pathway.BioPaxObject) PathwayGraphTool(cbit.vcell.client.desktop.biomodel.pathway.PathwayGraphTool)

Aggregations

GraphPane (cbit.gui.graph.gui.GraphPane)4 PathwayGraphTool (cbit.vcell.client.desktop.biomodel.pathway.PathwayGraphTool)1 PathwayGraphModel (cbit.vcell.client.desktop.biomodel.pathway.shapes.PathwayGraphModel)1 ReactionCartoon (cbit.vcell.graph.ReactionCartoon)1 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 JButton (javax.swing.JButton)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JTextArea (javax.swing.JTextArea)1