Search in sources :

Example 6 with Conversion

use of org.vcell.pathway.Conversion in project vcell by virtualcell.

the class PathwayGraphModel method refreshGroupObject.

private void refreshGroupObject(GroupObject groupObject) {
    for (BioPaxObject bpObject : groupObject.getGroupedObjects()) {
        if (bpObject instanceof Conversion) {
            // Conversions inside groupObject
            Conversion conversion = (Conversion) bpObject;
            refreshInteraction(conversion);
        } else if (bpObject instanceof MolecularInteraction) {
            // molecularInteraction inside  groupObject
            MolecularInteraction molecularInteraction = (MolecularInteraction) bpObject;
            refreshInteraction(molecularInteraction);
        } else if (bpObject instanceof GroupObject) {
            // groupObject inside another groupObject
            refreshGroupObject((GroupObject) bpObject);
        }
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) MolecularInteraction(org.vcell.pathway.MolecularInteraction) GroupObject(org.vcell.pathway.GroupObject) Conversion(org.vcell.pathway.Conversion)

Example 7 with Conversion

use of org.vcell.pathway.Conversion in project vcell by virtualcell.

the class BioModelEditorPathwayDiagramPanel method deleteSelectedBioPaxObjects.

public static void deleteSelectedBioPaxObjects(Component guiRequester, BioModel bioModel, GraphModel graphModel) {
    StringBuilder warning = new StringBuilder("You can NOT delete the following pathway objects:\n\n");
    StringBuilder text = new StringBuilder("You are going to DELETE the following pathway objects:\n\n");
    // all objects required by user
    List<BioPaxObject> selected = getSelectedBioPaxObjects(graphModel);
    // the user required objects that can be deleted
    List<BioPaxObject> selectedBioPaxObjects = new ArrayList<BioPaxObject>();
    // all objects that will be deleted from the pathway model
    List<BioPaxObject> completeSelectedBioPaxObjects = new ArrayList<BioPaxObject>();
    // used for recover group objects
    HashSet<GroupObject> undeletedGroupObjects = new HashSet<GroupObject>();
    // all objects required by user + grouped elements contained in selected group objects
    List<BioPaxObject> allSelectedBioPaxObjects = new ArrayList<BioPaxObject>();
    // build a list of selected objects with selected grouped elements
    for (BioPaxObject bpObject : selected) {
        if (bpObject instanceof GroupObject) {
            // all elements of the groupObject will be deleted
            allSelectedBioPaxObjects.add(bpObject);
            // check all elements
            allSelectedBioPaxObjects.addAll(getAllGroupedObjects((GroupObject) bpObject));
        } else {
            allSelectedBioPaxObjects.add(bpObject);
        }
    }
    // if so, whether participants and catalysts of a selected reaction can be deleted
    for (BioPaxObject bpObject : allSelectedBioPaxObjects) {
        if (canDelete(bioModel, allSelectedBioPaxObjects, bpObject)) {
            selectedBioPaxObjects.add(bpObject);
            text.append("    " + bpObject.getTypeLabel() + ": \'" + PhysiologyRelationshipTableModel.getLabel(bpObject) + "\'\n");
            completeSelectedBioPaxObjects.add(bpObject);
            if (bpObject instanceof Conversion) {
                // check each participant
                for (InteractionParticipant ip : ((Conversion) bpObject).getParticipants()) {
                    if (canDelete(bioModel, allSelectedBioPaxObjects, ip.getPhysicalEntity())) {
                        completeSelectedBioPaxObjects.add(ip.getPhysicalEntity());
                        // the complex of the pysicalEntity will be removed
                        for (Complex complex : getComplex(bioModel, ip.getPhysicalEntity())) {
                            if (canDelete(bioModel, allSelectedBioPaxObjects, complex))
                                completeSelectedBioPaxObjects.add(complex);
                        }
                    }
                }
                // check catalysts
                for (BioPaxObject bp : bioModel.getPathwayModel().getBiopaxObjects()) {
                    if (bp instanceof Control) {
                        Control control = (Control) bp;
                        if (control.getControlledInteraction() == bpObject) {
                            completeSelectedBioPaxObjects.add(bp);
                            for (PhysicalEntity pe : control.getPhysicalControllers()) {
                                if (canDelete(bioModel, allSelectedBioPaxObjects, pe))
                                    completeSelectedBioPaxObjects.add(pe);
                            }
                        }
                    }
                }
            } else if (bpObject instanceof GroupObject) {
                // all elements of the groupObject will be deleted
                completeSelectedBioPaxObjects.add(bpObject);
                // check all elements
                completeSelectedBioPaxObjects.addAll(getAllGroupedObjects((GroupObject) bpObject));
            }
        } else {
            warning.append("    " + bpObject.getTypeLabel() + ": \'" + PhysiologyRelationshipTableModel.getLabel(bpObject) + "\'\n");
            if (bpObject instanceof GroupObject) {
                undeletedGroupObjects.add((GroupObject) bpObject);
            }
        }
    }
    warning.append("\nThey are either required by other reactions or linked with other physiological objects.\n\n");
    // for(GroupObject gObject : undeletedGroupObjects){
    // for (BioPaxObject bpo : gObject.getGroupedObjects()){
    // completeSelectedBioPaxObjects.remove(bpo);
    // }
    // }
    StringBuilder finalWarningMessage = new StringBuilder();
    if (allSelectedBioPaxObjects.size() > selectedBioPaxObjects.size()) {
        finalWarningMessage.append(warning.toString() + "\n\n");
    }
    if (selectedBioPaxObjects.size() > 0) {
        text.append("\nContinue?");
        finalWarningMessage.append(text.toString());
    }
    if (finalWarningMessage.length() == 0) {
        return;
    }
    String confirm = DialogUtils.showOKCancelWarningDialog(guiRequester, "Deleting pathway objects", finalWarningMessage.toString());
    if (confirm.equals(UserMessage.OPTION_CANCEL)) {
        return;
    }
    if (completeSelectedBioPaxObjects.size() > 0) {
        bioModel.getPathwayModel().remove(completeSelectedBioPaxObjects);
        bioModel.getPathwayModel().cleanGroupObjects();
        bioModel.getRelationshipModel().removeRelationshipObjects(completeSelectedBioPaxObjects);
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) Conversion(org.vcell.pathway.Conversion) Complex(org.vcell.pathway.Complex) Control(org.vcell.pathway.Control) PhysicalEntity(org.vcell.pathway.PhysicalEntity) InteractionParticipant(org.vcell.pathway.InteractionParticipant) HashSet(java.util.HashSet)

Example 8 with Conversion

use of org.vcell.pathway.Conversion in project vcell by virtualcell.

the class BioModelEditorConversionTableModel method refreshData.

private void refreshData() {
    if (bioModel == null || bioModel.getPathwayModel() == null || bioPaxObjects == null) {
        setData(null);
        return;
    }
    // function I :: get selected objects only
    // create ConversionTableRow objects
    allPathwayObjectList = new ArrayList<ConversionTableRow>();
    convertedBPObjects = new HashSet<BioPaxObject>();
    printObjects(bioPaxObjects);
    BioModel.printBpModelObjects(bioModel.getPathwayModel().getBiopaxObjects());
    // BioModel.printBpRelationshipObjects(bioModel.getRelationshipModel().getBioPaxObjects());	// derived; the bpObjects that are part of a relationship
    BioModel.printRelationships(bioModel.getRelationshipModel().getRelationshipObjects());
    System.out.println("----------------------------------------------------------------------");
    for (BioPaxObject bpo : bioPaxObjects) {
        if (bpo instanceof Conversion) {
            if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                Conversion conversion = (Conversion) bpo;
                ArrayList<String> nameList = conversion.getName();
                String interactionId = conversion.getID();
                String interactionLabel = nameList.isEmpty() ? conversion.getIDShort() : nameList.get(0);
                ConversionTableRow newConversionTableRow = createTableRow(conversion, interactionId, interactionLabel, "Conversion", 1.0, null);
                allPathwayObjectList.add(newConversionTableRow);
                convertedBPObjects.add(bpo);
                ArrayList<Stoichiometry> stoichiometryList = conversion.getParticipantStoichiometry();
                // stoichiometryMap problem:
                // how to deal with the case that the same object occurs on both left and right sides
                HashMap<PhysicalEntity, Double> stoichiometryMap = createStoichiometryMap(stoichiometryList);
                // reactant
                for (BioPaxObject bpObject1 : conversion.getLeft()) {
                    Double stoich = 1.0;
                    if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
                        stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
                    }
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
                    } else {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(bpObject1);
                }
                // product
                for (BioPaxObject bpObject1 : conversion.getRight()) {
                    Double stoich = 1.0;
                    if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
                        stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
                    }
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
                    } else {
                        if (conversion instanceof Transport)
                            conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                        else
                            conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(bpObject1);
                }
                // control
                for (BioPaxObject bpObject : bioModel.getPathwayModel().getBiopaxObjects()) {
                    if (bpObject instanceof Control) {
                        Control control = (Control) bpObject;
                        if (control instanceof Catalysis) {
                            // catalysis
                            if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
                                for (PhysicalEntity pe : ((Catalysis) control).getPhysicalControllers()) {
                                    ConversionTableRow conversionTableRow;
                                    if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, null);
                                    } else {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
                                    }
                                    allPathwayObjectList.add(conversionTableRow);
                                    convertedBPObjects.add(pe);
                                }
                            }
                        } else {
                            // other control types
                            if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
                                for (PhysicalEntity pe : control.getPhysicalControllers()) {
                                    ConversionTableRow conversionTableRow;
                                    if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, null);
                                    } else {
                                        conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
                                    }
                                    allPathwayObjectList.add(conversionTableRow);
                                    convertedBPObjects.add(pe);
                                }
                            }
                        }
                    }
                }
            }
        } else if (bpo instanceof Catalysis) {
            for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
                if (!convertedBPObjects.contains(pe)) {
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
                        conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, null);
                    } else {
                        conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(pe);
                }
            }
            for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
            // TODO
            }
        } else if (bpo instanceof Control) {
            for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
                if (!convertedBPObjects.contains(pe)) {
                    ConversionTableRow conversionTableRow;
                    if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
                        conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, null);
                    } else {
                        conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
                    }
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(pe);
                }
            }
            for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
            // TODO
            }
        }
    }
    // 2nd pass - entities selected as themselves
    for (BioPaxObject bpo : bioPaxObjects) {
        if (bpo instanceof PhysicalEntity) {
            if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
                PhysicalEntity physicalEntityObject = (PhysicalEntity) bpo;
                // we add standalone selected entities, only if they were not already added as part of any reaction
                if (!convertedBPObjects.contains(physicalEntityObject)) {
                    ConversionTableRow conversionTableRow = createTableRow(physicalEntityObject, "", "", "", 1.0, null);
                    allPathwayObjectList.add(conversionTableRow);
                    convertedBPObjects.add(physicalEntityObject);
                }
            }
        }
    }
    // apply text search function for particular columns
    ArrayList<ConversionTableRow> pathwayObjectList = new ArrayList<ConversionTableRow>();
    if (searchText == null || searchText.length() == 0) {
        pathwayObjectList.addAll(allPathwayObjectList);
    } else {
        String lowerCaseSearchText = searchText.toLowerCase();
        for (ConversionTableRow rs : allPathwayObjectList) {
            BioPaxObject bpObject = rs.getBioPaxObject();
            if (rs.interactionLabel().toLowerCase().contains(lowerCaseSearchText) || rs.participantType().toLowerCase().contains(lowerCaseSearchText) || getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
                pathwayObjectList.add(rs);
            }
        }
    }
    setData(pathwayObjectList);
    GuiUtils.flexResizeTableColumns(ownerTable);
}
Also used : Stoichiometry(org.vcell.pathway.Stoichiometry) BioPaxObject(org.vcell.pathway.BioPaxObject) Pathway(org.vcell.pathway.Pathway) ArrayList(java.util.ArrayList) Conversion(org.vcell.pathway.Conversion) Control(org.vcell.pathway.Control) PhysicalEntity(org.vcell.pathway.PhysicalEntity) ConversionTableRow(org.vcell.relationship.ConversionTableRow) Catalysis(org.vcell.pathway.Catalysis) Transport(org.vcell.pathway.Transport)

Example 9 with Conversion

use of org.vcell.pathway.Conversion in project vcell by virtualcell.

the class BioModelEditorModelPanel method initialize.

private void initialize() {
    newButton = new JButton("New");
    newButton2 = new JButton("New Rule");
    newMemButton = new JButton("New Membrane");
    deleteButton = new JButton("Delete");
    duplicateButton = new JButton("Duplicate");
    pathwayButton = new JButton("Pathway Links", new DownArrowIcon());
    pathwayButton.setHorizontalTextPosition(SwingConstants.LEFT);
    textFieldSearch = new JTextField();
    textFieldSearch.putClientProperty("JTextField.variant", "search");
    structuresTable = new EditorScrollTable();
    reactionsTable = new EditorScrollTable();
    speciesTable = new EditorScrollTable();
    molecularTypeTable = new EditorScrollTable();
    observablesTable = new EditorScrollTable();
    structureTableModel = new BioModelEditorStructureTableModel(structuresTable);
    reactionTableModel = new BioModelEditorReactionTableModel(reactionsTable);
    speciesTableModel = new BioModelEditorSpeciesTableModel(speciesTable);
    molecularTypeTableModel = new MolecularTypeTableModel(molecularTypeTable);
    observableTableModel = new ObservableTableModel(observablesTable);
    structuresTable.setModel(structureTableModel);
    reactionsTable.setModel(reactionTableModel);
    speciesTable.setModel(speciesTableModel);
    molecularTypeTable.setModel(molecularTypeTableModel);
    observablesTable.setModel(observableTableModel);
    reactionCartoonEditorPanel = new ReactionCartoonEditorPanel();
    reactionCartoonEditorPanel.addPropertyChangeListener(eventHandler);
    reactionCartoonEditorPanel.getReactionCartoonFull().addPropertyChangeListener(eventHandler);
    reactionCartoonEditorPanel.getReactionCartoonMolecule().addPropertyChangeListener(eventHandler);
    reactionCartoonEditorPanel.getReactionCartoonRule().addPropertyChangeListener(eventHandler);
    // cartoonEditorPanel  = new CartoonEditorPanelFixed();
    // cartoonEditorPanel.getStructureCartoon().addPropertyChangeListener(eventHandler);
    /* button panel */
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(newButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(newButton2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(newMemButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(duplicateButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(deleteButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 5;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(pathwayButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 6;
    gbc.gridy = 0;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    buttonPanel.add(Box.createRigidArea(new Dimension(5, 5)), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 7;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = new Insets(4, 4, 4, 4);
    buttonPanel.add(new JLabel("Search "), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 8;
    gbc.gridy = 0;
    gbc.weightx = 1.5;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    buttonPanel.add(textFieldSearch, gbc);
    /* button panel */
    tabbedPane = new JTabbedPaneEnhanced();
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    modelPanelTabs[ModelPanelTabID.reaction_diagram.ordinal()] = new ModelPanelTab(ModelPanelTabID.reaction_diagram, reactionCartoonEditorPanel, VCellIcons.diagramIcon);
    // modelPanelTabs[ModelPanelTabID.structure_diagram.ordinal()] = new ModelPanelTab(ModelPanelTabID.structure_diagram, cartoonEditorPanel, VCellIcons.structureIcon);
    modelPanelTabs[ModelPanelTabID.reaction_table.ordinal()] = new ModelPanelTab(ModelPanelTabID.reaction_table, reactionsTable.getEnclosingScrollPane(), VCellIcons.tableIcon);
    modelPanelTabs[ModelPanelTabID.structure_table.ordinal()] = new ModelPanelTab(ModelPanelTabID.structure_table, structuresTable.getEnclosingScrollPane(), VCellIcons.tableIcon);
    modelPanelTabs[ModelPanelTabID.species_table.ordinal()] = new ModelPanelTab(ModelPanelTabID.species_table, speciesTable.getEnclosingScrollPane(), VCellIcons.tableIcon);
    modelPanelTabs[ModelPanelTabID.species_definitions_table.ordinal()] = new ModelPanelTab(ModelPanelTabID.species_definitions_table, molecularTypeTable.getEnclosingScrollPane(), VCellIcons.tableIcon);
    modelPanelTabs[ModelPanelTabID.observables_table.ordinal()] = new ModelPanelTab(ModelPanelTabID.observables_table, observablesTable.getEnclosingScrollPane(), VCellIcons.tableIcon);
    tabbedPane.addChangeListener(eventHandler);
    tabbedPane.addMouseListener(eventHandler);
    for (ModelPanelTab tab : modelPanelTabs) {
        tab.getComponent().setBorder(GuiConstants.TAB_PANEL_BORDER);
        tabbedPane.addTab(tab.getName(), tab.getIcon(), tab.getComponent());
    }
    // tabbedPane.addChangeListener(changeListener);
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    newButton.addActionListener(eventHandler);
    newButton2.addActionListener(eventHandler);
    newMemButton.addActionListener(eventHandler);
    duplicateButton.addActionListener(eventHandler);
    duplicateButton.setEnabled(false);
    deleteButton.addActionListener(eventHandler);
    deleteButton.setEnabled(false);
    pathwayButton.addActionListener(eventHandler);
    pathwayButton.setEnabled(false);
    textFieldSearch.addActionListener(eventHandler);
    textFieldSearch.getDocument().addDocumentListener(eventHandler);
    structuresTable.getSelectionModel().addListSelectionListener(eventHandler);
    reactionsTable.getSelectionModel().addListSelectionListener(eventHandler);
    speciesTable.getSelectionModel().addListSelectionListener(eventHandler);
    molecularTypeTable.getSelectionModel().addListSelectionListener(eventHandler);
    observablesTable.getSelectionModel().addListSelectionListener(eventHandler);
    DefaultScrollTableCellRenderer tableRenderer = new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof Structure) {
                setText(((Structure) value).getName());
            } else if (value instanceof Kinetics) {
                setText(((Kinetics) value).getKineticsDescription().getDescription());
            } else if (value instanceof RbmKineticLaw) {
                setText(((RbmKineticLaw) value).getRateLawType().name());
            }
            return this;
        }
    };
    RbmTableRenderer rbmTableRenderer = new RbmTableRenderer();
    structuresTable.setDefaultRenderer(Structure.class, tableRenderer);
    speciesTable.setDefaultRenderer(Structure.class, tableRenderer);
    reactionsTable.setDefaultRenderer(Structure.class, tableRenderer);
    reactionsTable.setDefaultRenderer(Kinetics.class, tableRenderer);
    reactionsTable.setDefaultRenderer(RbmKineticLaw.class, tableRenderer);
    reactionsTable.setDefaultRenderer(ModelProcessDynamics.class, tableRenderer);
    DefaultScrollTableCellRenderer tableCellRenderer = 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);
            BioModelEntityObject bioModelEntityObject = null;
            if (table.getModel() instanceof VCellSortTableModel<?>) {
                if (table.getModel() == reactionTableModel && reactionTableModel.getValueAt(row) instanceof BioModelEntityObject) {
                    bioModelEntityObject = (BioModelEntityObject) reactionTableModel.getValueAt(row);
                } else if (table.getModel() == speciesTableModel) {
                    bioModelEntityObject = speciesTableModel.getValueAt(row);
                } else if (table.getModel() == molecularTypeTableModel) {
                    bioModelEntityObject = molecularTypeTableModel.getValueAt(row);
                }
                if (bioModelEntityObject != null) {
                    Set<RelationshipObject> relationshipSet = bioModel.getRelationshipModel().getRelationshipObjects(bioModelEntityObject);
                    if (relationshipSet.size() > 0) {
                        StringBuilder tooltip = new StringBuilder("<html>Links to Pathway objects:<br>");
                        for (RelationshipObject ro : relationshipSet) {
                            tooltip.append("<li>" + ro.getBioPaxObject() + "</li>");
                        }
                        if (!isSelected) {
                            setForeground(Color.blue);
                        }
                        String finalName = null;
                        BioPaxObject bioPaxObject = relationshipSet.iterator().next().getBioPaxObject();
                        if (bioPaxObject instanceof EntityImpl && ((EntityImpl) bioPaxObject).getName() != null && ((EntityImpl) bioPaxObject).getName().size() > 0) {
                            finalName = ((EntityImpl) bioPaxObject).getName().get(0);
                        } else if (bioPaxObject instanceof Conversion) {
                            Conversion mp = (Conversion) bioPaxObject;
                            finalName = "[" + bioPaxObject.getIDShort() + "]";
                        } else {
                            finalName = bioModelEntityObject.getName();
                        }
                        final int LIMIT = 40;
                        final String DOTS = "...";
                        if (finalName != null && finalName.length() > LIMIT) {
                            finalName = finalName.substring(0, LIMIT - DOTS.length() - 1) + DOTS;
                        }
                        setText("<html><u>" + finalName + "</u></html>");
                        setToolTipText(tooltip.toString());
                    }
                }
            }
            return this;
        }
    };
    DefaultScrollTableCellRenderer rbmReactionExpressionCellRenderer = 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 VCellSortTableModel<?>) {
                Object selectedObject = null;
                if (table.getModel() == reactionTableModel) {
                    selectedObject = reactionTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof ReactionRule && value instanceof ModelProcessEquation) {
                        String text = "<html>";
                        text += "Reaction Rule";
                        text += "</html>";
                        setText(text);
                    } else {
                        // plain reaction, check if reactants have species pattern
                        ReactionStep rs = (ReactionStep) selectedObject;
                        String text = "<html>";
                        for (int i = 0; i < rs.getNumReactants(); i++) {
                            Reactant p = rs.getReactant(i);
                            if (p.getSpeciesContext().hasSpeciesPattern()) {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                // text += "<b>" + p.getName() + "</b>";
                                text += p.getName();
                            } else {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                text += p.getName();
                            }
                            if (i < rs.getNumReactants() - 1) {
                                text += " + ";
                            }
                        }
                        text += " -&gt; ";
                        for (int i = 0; i < rs.getNumProducts(); i++) {
                            Product p = rs.getProduct(i);
                            if (p.getSpeciesContext().hasSpeciesPattern()) {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                // text += "<b>" + p.getName() + "</b>";
                                text += p.getName();
                            } else {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                text += p.getName();
                            }
                            if (i < rs.getNumProducts() - 1) {
                                text += " + ";
                            }
                        }
                        text += "</html>";
                        setText(text);
                    }
                }
            }
            return this;
        }
    };
    DefaultScrollTableCellRenderer rbmReactionDefinitionCellRenderer = 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 VCellSortTableModel<?>) {
                Object selectedObject = null;
                if (table.getModel() == reactionTableModel) {
                    selectedObject = reactionTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof ReactionRule && value instanceof ModelProcessEquation) {
                        ReactionRule rr = (ReactionRule) selectedObject;
                        String text = "<html>";
                        for (int i = 0; i < rr.getReactantPatterns().size(); i++) {
                            ReactantPattern rp = rr.getReactantPattern(i);
                            if (rp.getStructure() != null && !rp.getSpeciesPattern().getMolecularTypePatterns().isEmpty()) {
                                text += "@" + rp.getStructure().getName() + ":";
                            }
                            text += RbmUtils.toBnglString(rp.getSpeciesPattern(), null, CompartmentMode.hide, 0);
                            // text += RbmTableRenderer.toHtml(rp.getSpeciesPattern(), isSelected);
                            if (i < rr.getReactantPatterns().size() - 1) {
                                text += "+";
                            }
                        }
                        if (rr.isReversible()) {
                            // &lt;-&gt;  <->
                            text += " &lt;-&gt; ";
                        } else {
                            text += " -&gt; ";
                        }
                        for (int i = 0; i < rr.getProductPatterns().size(); i++) {
                            ProductPattern pp = rr.getProductPattern(i);
                            if (pp.getStructure() != null && !pp.getSpeciesPattern().getMolecularTypePatterns().isEmpty()) {
                                text += "@" + pp.getStructure().getName() + ":";
                            }
                            text += RbmUtils.toBnglString(pp.getSpeciesPattern(), null, CompartmentMode.hide, 0);
                            if (i < rr.getProductPatterns().size() - 1) {
                                text += "+";
                            }
                        }
                        text += "</html>";
                        setText(text);
                    } else {
                        // plain reaction, check if reactants have species pattern
                        ReactionStep rs = (ReactionStep) selectedObject;
                        String text = "<html>";
                        for (int i = 0; i < rs.getNumReactants(); i++) {
                            Reactant p = rs.getReactant(i);
                            if (p.getSpeciesContext().hasSpeciesPattern()) {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                text += p.getName();
                            } else {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                text += p.getName();
                            }
                            if (i < rs.getNumReactants() - 1) {
                                text += " + ";
                            }
                        }
                        if (rs.isReversible()) {
                            // &lt;-&gt;  <->
                            text += " &lt;-&gt; ";
                        } else {
                            text += " -&gt; ";
                        }
                        for (int i = 0; i < rs.getNumProducts(); i++) {
                            Product p = rs.getProduct(i);
                            if (p.getSpeciesContext().hasSpeciesPattern()) {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                text += p.getName();
                            } else {
                                text += p.getStoichiometry() > 1 ? (p.getStoichiometry() + "") : "";
                                text += p.getName();
                            }
                            if (i < rs.getNumProducts() - 1) {
                                text += " + ";
                            }
                        }
                        text += "</html>";
                        setText(text);
                    }
                }
            }
            return this;
        }
    };
    DefaultScrollTableCellRenderer rbmObservablePatternCellRenderer = 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 VCellSortTableModel<?>) {
                Object selectedObject = null;
                if (table.getModel() == observableTableModel) {
                    selectedObject = observableTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof RbmObservable && value instanceof String) {
                        RbmObservable o = (RbmObservable) selectedObject;
                        String text = "<html>";
                        for (int i = 0; i < o.getSpeciesPatternList().size(); i++) {
                            SpeciesPattern sp = o.getSpeciesPattern(i);
                            text += RbmTableRenderer.toHtml(sp, isSelected);
                            if (i < o.getSpeciesPatternList().size() - 1) {
                                text += " ";
                            }
                        }
                        text = RbmUtils.appendSequence(text, o);
                        text += "</html>";
                        setText(text);
                    }
                }
            }
            return this;
        }
    };
    DefaultScrollTableCellRenderer rbmSpeciesNameCellRenderer = 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 VCellSortTableModel<?>) {
                Object selectedObject = null;
                if (table.getModel() == speciesTableModel) {
                    selectedObject = speciesTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof SpeciesContext) {
                        SpeciesContext sc = (SpeciesContext) selectedObject;
                        String text = "<html>";
                        if (sc.hasSpeciesPattern()) {
                            text += "<b>" + sc.getName() + "</b>";
                        } else {
                            text += sc.getName();
                        }
                        text += "</html>";
                        setText(text);
                    }
                }
            }
            return this;
        }
    };
    // 
    // this renderer only paints the molecular type small shape in the MolecularType Table
    // 
    DefaultScrollTableCellRenderer rbmMolecularTypeShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {

        MolecularTypeSmallShape stls = 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() == molecularTypeTableModel) {
                    selectedObject = molecularTypeTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof MolecularType) {
                        MolecularType mt = (MolecularType) selectedObject;
                        Graphics cellContext = table.getGraphics();
                        if (mt != null) {
                            stls = new MolecularTypeSmallShape(4, 3, mt, null, cellContext, mt, null, issueManager);
                        }
                    }
                } else {
                    stls = null;
                }
            }
            return this;
        }

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (stls != null) {
                stls.paintSelf(g);
            }
        }
    };
    // painting of species patterns small shapes inside the species context 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 SpeciesContext) {
                        SpeciesContext sc = (SpeciesContext) selectedObject;
                        // sp may be null for "plain" species contexts
                        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);
            }
        }
    };
    // ---------------------------------------------------------------------------------------------------------------------------------
    DefaultScrollTableCellRenderer rbmReactionShapeDepictionCellRenderer = 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() == reactionTableModel) {
                    selectedObject = reactionTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof ReactionRule) {
                        ReactionRule rr = (ReactionRule) selectedObject;
                        Graphics panelContext = table.getGraphics();
                        spssList.clear();
                        List<ReactantPattern> rpList = rr.getReactantPatterns();
                        int xPos = 4;
                        for (int i = 0; i < rpList.size(); i++) {
                            SpeciesPattern sp = rr.getReactantPattern(i).getSpeciesPattern();
                            spss = new SpeciesPatternSmallShape(xPos, 2, sp, null, panelContext, rr, isSelected, issueManager);
                            if (i < rpList.size() - 1) {
                                spss.addEndText("+");
                            } else {
                                if (rr.isReversible()) {
                                    spss.addEndText("<->");
                                    xPos += 7;
                                } else {
                                    spss.addEndText("->");
                                }
                            }
                            xPos += spss.getWidth() + 15;
                            spssList.add(spss);
                        }
                        List<ProductPattern> ppList = rr.getProductPatterns();
                        xPos += 7;
                        for (int i = 0; i < ppList.size(); i++) {
                            SpeciesPattern sp = rr.getProductPattern(i).getSpeciesPattern();
                            spss = new SpeciesPatternSmallShape(xPos, 2, sp, null, panelContext, rr, isSelected, issueManager);
                            if (i < ppList.size() - 1) {
                                spss.addEndText("+");
                            }
                            xPos += spss.getWidth() + 15;
                            spssList.add(spss);
                        }
                    } else {
                        ReactionStep rs = (ReactionStep) selectedObject;
                        Graphics panelContext = table.getGraphics();
                        spssList.clear();
                        int xPos = 4;
                        int extraSpace = 0;
                        for (int i = 0; i < rs.getNumReactants(); i++) {
                            SpeciesPattern sp = rs.getReactant(i).getSpeciesContext().getSpeciesPattern();
                            spss = new SpeciesPatternSmallShape(xPos, 2, sp, panelContext, rs, isSelected, issueManager);
                            if (i < rs.getNumReactants() - 1) {
                                spss.addEndText("+");
                            } else {
                                if (rs.isReversible()) {
                                    spss.addEndText("<->");
                                    extraSpace += 7;
                                } else {
                                    spss.addEndText("->");
                                }
                            }
                            int offset = sp == null ? 17 : 15;
                            offset += extraSpace;
                            int w = spss.getWidth();
                            xPos += w + offset;
                            spssList.add(spss);
                        }
                        xPos += 8;
                        for (int i = 0; i < rs.getNumProducts(); i++) {
                            SpeciesPattern sp = rs.getProduct(i).getSpeciesContext().getSpeciesPattern();
                            if (i == 0 && rs.getNumReactants() == 0) {
                                xPos += 14;
                            }
                            spss = new SpeciesPatternSmallShape(xPos, 2, sp, panelContext, rs, isSelected, issueManager);
                            if (i == 0 && rs.getNumReactants() == 0) {
                                spss.addStartText("->");
                            }
                            if (i < rs.getNumProducts() - 1) {
                                spss.addEndText("+");
                            }
                            int offset = sp == null ? 17 : 15;
                            int w = spss.getWidth();
                            xPos += w + offset;
                            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);
            }
        }
    };
    // -------------------------------------------------------------------------------------------------------------------------------
    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() == observableTableModel) {
                    selectedObject = observableTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof RbmObservable) {
                        RbmObservable observable = (RbmObservable) selectedObject;
                        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);
            }
        }
    };
    // TODO: here are the renderers associated with the columns
    reactionsTable.getColumnModel().getColumn(BioModelEditorReactionTableModel.COLUMN_LINK).setCellRenderer(tableCellRenderer);
    reactionsTable.getColumnModel().getColumn(BioModelEditorReactionTableModel.COLUMN_EQUATION).setCellRenderer(rbmReactionExpressionCellRenderer);
    reactionsTable.getColumnModel().getColumn(BioModelEditorReactionTableModel.COLUMN_DEFINITION).setCellRenderer(rbmReactionDefinitionCellRenderer);
    speciesTable.getColumnModel().getColumn(BioModelEditorSpeciesTableModel.COLUMN_NAME).setCellRenderer(rbmSpeciesNameCellRenderer);
    speciesTable.getColumnModel().getColumn(BioModelEditorSpeciesTableModel.COLUMN_LINK).setCellRenderer(tableCellRenderer);
    molecularTypeTable.getColumnModel().getColumn(MolecularTypeTableModel.Column.link.ordinal()).setCellRenderer(tableCellRenderer);
    observablesTable.getColumnModel().getColumn(ObservableTableModel.Column.species_pattern.ordinal()).setCellRenderer(rbmObservablePatternCellRenderer);
    observablesTable.getColumnModel().getColumn(ObservableTableModel.Column.structure.ordinal()).setCellRenderer(tableRenderer);
    // all "depictions" have their own renderer
    molecularTypeTable.getColumnModel().getColumn(MolecularTypeTableModel.Column.depiction.ordinal()).setCellRenderer(rbmMolecularTypeShapeDepictionCellRenderer);
    molecularTypeTable.getColumnModel().getColumn(MolecularTypeTableModel.Column.depiction.ordinal()).setMaxWidth(180);
    speciesTable.getColumnModel().getColumn(BioModelEditorSpeciesTableModel.COLUMN_DEPICTION).setCellRenderer(rbmSpeciesShapeDepictionCellRenderer);
    speciesTable.getColumnModel().getColumn(BioModelEditorSpeciesTableModel.COLUMN_DEFINITION).setCellRenderer(rbmTableRenderer);
    observablesTable.getColumnModel().getColumn(ObservableTableModel.Column.depiction.ordinal()).setCellRenderer(rbmObservableShapeDepictionCellRenderer);
    reactionsTable.getColumnModel().getColumn(BioModelEditorReactionTableModel.COLUMN_DEPICTION).setCellRenderer(rbmReactionShapeDepictionCellRenderer);
    reactionsTable.getColumnModel().getColumn(BioModelEditorReactionTableModel.COLUMN_DEPICTION).setPreferredWidth(180);
    observablesTable.getColumnModel().getColumn(ObservableTableModel.Column.type.ordinal()).setCellEditor(observableTableModel.getObservableTypeComboBoxEditor());
    observableTableModel.updateObservableTypeComboBox();
    reactionsTable.addMouseListener(eventHandler);
    reactionsTable.addKeyListener(eventHandler);
    speciesTable.addMouseListener(eventHandler);
    speciesTable.addKeyListener(eventHandler);
    molecularTypeTable.addMouseListener(eventHandler);
    molecularTypeTable.addKeyListener(eventHandler);
    observablesTable.addMouseListener(eventHandler);
    observablesTable.addKeyListener(eventHandler);
    structuresTable.addKeyListener(eventHandler);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Product(cbit.vcell.model.Product) SpeciesContext(cbit.vcell.model.SpeciesContext) RelationshipObject(org.vcell.relationship.RelationshipObject) Reactant(cbit.vcell.model.Reactant) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) BorderLayout(java.awt.BorderLayout) ArrayList(java.util.ArrayList) List(java.util.List) JList(javax.swing.JList) EntityImpl(org.vcell.pathway.EntityImpl) RbmObservable(cbit.vcell.model.RbmObservable) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) Conversion(org.vcell.pathway.Conversion) ReactionCartoonEditorPanel(cbit.vcell.graph.gui.ReactionCartoonEditorPanel) MolecularType(org.vcell.model.rbm.MolecularType) JTable(javax.swing.JTable) ReactionStep(cbit.vcell.model.ReactionStep) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) BioPaxObject(org.vcell.pathway.BioPaxObject) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) Kinetics(cbit.vcell.model.Kinetics) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) SpeciesPatternSmallShape(cbit.vcell.graph.SpeciesPatternSmallShape) BioPaxObject(org.vcell.pathway.BioPaxObject) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) Structure(cbit.vcell.model.Structure) ReactantPattern(cbit.vcell.model.ReactantPattern) ReactionRule(cbit.vcell.model.ReactionRule) ProductPattern(cbit.vcell.model.ProductPattern) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) RbmKineticLaw(cbit.vcell.model.RbmKineticLaw) Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) ModelProcessEquation(cbit.gui.ModelProcessEquation) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer)

Example 10 with Conversion

use of org.vcell.pathway.Conversion in project vcell by virtualcell.

the class PhysiologyRelationshipTableModel method refreshData.

private void refreshData() {
    ArrayList<PhysiologyRelationshipTableRow> pathwayObjectList = new ArrayList<PhysiologyRelationshipTableRow>();
    if (bioModel != null) {
        HashSet<RelationshipObject> relationshipObjects = null;
        if (bioModelEntityObject != null) {
            relationshipObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModelEntityObject);
        }
        List<PhysiologyRelationshipTableRow> allPathwayObjectList = new ArrayList<PhysiologyRelationshipTableRow>();
        for (BioPaxObject bpObject1 : bioModel.getPathwayModel().getBiopaxObjects()) {
            if ((bpObject1 instanceof PhysicalEntity && (bioModelEntityObject == null || bioModelEntityObject instanceof SpeciesContext)) || (bpObject1 instanceof Conversion && (bioModelEntityObject == null || bioModelEntityObject instanceof ModelProcess)) || (bpObject1 instanceof PhysicalEntity && (bioModelEntityObject == null || bioModelEntityObject instanceof MolecularType))) {
                PhysiologyRelationshipTableRow entityRow = new PhysiologyRelationshipTableRow(bpObject1);
                if (relationshipObjects != null) {
                    for (RelationshipObject ro : relationshipObjects) {
                        if (ro.getBioPaxObject() == entityRow.getBioPaxObject()) {
                            entityRow.setSelected(true);
                            break;
                        }
                    }
                }
                if (!bShowLinkOnly || entityRow.selected) {
                    allPathwayObjectList.add(entityRow);
                }
            }
        }
        if (searchText == null || searchText.length() == 0) {
            pathwayObjectList.addAll(allPathwayObjectList);
        } else {
            for (PhysiologyRelationshipTableRow rs : allPathwayObjectList) {
                BioPaxObject bpObject = rs.getBioPaxObject();
                String lowerCaseSearchText = searchText.toLowerCase();
                if (getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
                    pathwayObjectList.add(rs);
                }
            }
        }
    }
    setData(pathwayObjectList);
    GuiUtils.flexResizeTableColumns(ownerTable);
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) ModelProcess(cbit.vcell.model.ModelProcess) SpeciesContext(cbit.vcell.model.SpeciesContext) RelationshipObject(org.vcell.relationship.RelationshipObject) Conversion(org.vcell.pathway.Conversion) MolecularType(org.vcell.model.rbm.MolecularType) PhysicalEntity(org.vcell.pathway.PhysicalEntity)

Aggregations

Conversion (org.vcell.pathway.Conversion)13 BioPaxObject (org.vcell.pathway.BioPaxObject)10 PhysicalEntity (org.vcell.pathway.PhysicalEntity)9 ArrayList (java.util.ArrayList)7 GroupObject (org.vcell.pathway.GroupObject)6 SpeciesContext (cbit.vcell.model.SpeciesContext)4 RelationshipObject (org.vcell.relationship.RelationshipObject)4 HashSet (java.util.HashSet)3 Control (org.vcell.pathway.Control)3 InteractionParticipant (org.vcell.pathway.InteractionParticipant)3 MolecularInteraction (org.vcell.pathway.MolecularInteraction)3 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)2 Catalyst (cbit.vcell.model.Catalyst)2 Product (cbit.vcell.model.Product)2 Reactant (cbit.vcell.model.Reactant)2 ReactionParticipant (cbit.vcell.model.ReactionParticipant)2 ReactionRule (cbit.vcell.model.ReactionRule)2 ReactionStep (cbit.vcell.model.ReactionStep)2 Dimension (java.awt.Dimension)2 Element (org.jdom.Element)2