Search in sources :

Example 11 with Entity

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

the class BioPaxObjectPropertiesPanel method initialize.

private void initialize() {
    try {
        table = new ScrollTable();
        tableModel = new BioPaxObjectPropertiesTableModel(table);
        table.setModel(tableModel);
        details = new JTextPane();
        details.setContentType("text/html");
        details.setEditable(false);
        JScrollPane scrl = new JScrollPane(details);
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    BioPaxObjectProperty property = tableModel.getValueAt(table.getSelectedRow());
                    if (property != null) {
                        final String htmlStart = "<html><font face = \"Arial\"><font size =\"-2\">";
                        final String htmlEnd = "</font></font></html>";
                        if (!property.getDetails().isEmpty()) {
                            details.setText(htmlStart + property.getDetails() + htmlEnd);
                        } else if ((property.value != null) && !property.value.isEmpty()) {
                            String text = FormatDetails(property);
                            details.setText(htmlStart + text + htmlEnd);
                        } else {
                            details.setText(htmlStart + "row: " + table.getSelectedRow() + ", col: " + table.getSelectedColumn() + htmlEnd);
                        }
                    }
                }
            }
        });
        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getEnclosingScrollPane(), scrl);
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(150);
        // provide minimum sizes for the two components in the split pane
        Dimension minimumSize = new Dimension(100, 50);
        table.getEnclosingScrollPane().setMinimumSize(minimumSize);
        scrl.setMinimumSize(minimumSize);
        setLayout(new BorderLayout());
        // add(table.getEnclosingScrollPane(), BorderLayout.CENTER);
        // add(details, BorderLayout.CENTER);
        add(splitPane, BorderLayout.CENTER);
        setBackground(Color.white);
        table.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    // launch the browser when double click on hyperlinks
                    Point pt = e.getPoint();
                    int crow = table.rowAtPoint(pt);
                    int ccol = table.columnAtPoint(pt);
                    if (table.convertColumnIndexToModel(ccol) == BioPaxObjectPropertiesTableModel.Column_Value) {
                        BioPaxObjectProperty property = tableModel.getValueAt(crow);
                        BioPaxObject bioPaxObject = property.bioPaxObject;
                        if (bioPaxObject == null) {
                            BioModelEntityObject bioModelEntityObject = property.bioModelEntityObject;
                            if (bioModelEntityObject != null) {
                                if (bioModelEntityObject instanceof SpeciesContext) {
                                    selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram), new Object[] { bioModelEntityObject });
                                } else if (bioModelEntityObject instanceof MolecularType) {
                                    selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.species_definitions), new Object[] { bioModelEntityObject });
                                }
                            } else if (((Entity) BioPaxObjectPropertiesPanel.this.bioPaxObject).getFormalNames() == null || ((Entity) BioPaxObjectPropertiesPanel.this.bioPaxObject).getFormalNames().size() == 0) {
                                lookupFormalName(crow);
                            }
                        } else if (bioPaxObject instanceof Xref) {
                            // if xRef, get url
                            String url = ((Xref) bioPaxObject).getURL();
                            DialogUtils.browserLauncher(BioPaxObjectPropertiesPanel.this, url, "Wrong URL.");
                        } else if (bioPaxObject instanceof SBEntity) {
                            // TODO: kineticLaw
                            SBEntity sbE = (SBEntity) bioPaxObject;
                            if (sbE.getID().contains("kineticLaw")) {
                                // String url = "http://sabio.h-its.org/sabioRestWebServices/kineticLaws/" + sbE.getID().substring(sbE.getID().indexOf("kineticLaw") + 10);
                                String url = "http://sabiork.h-its.org/kindatadirectiframe.jsp?kinlawid=" + sbE.getID().substring(sbE.getID().indexOf("kineticLaw") + 10);
                                DialogUtils.browserLauncher(BioPaxObjectPropertiesPanel.this, url, "Wrong URL.");
                            }
                        }
                    }
                }
            }
        });
        // --- end of addMouseListener()
        table.getColumnModel().getColumn(BioPaxObjectPropertiesTableModel.Column_Value).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);
                if (column == BioPaxObjectPropertiesTableModel.Column_Value) {
                    BioPaxObjectProperty property = tableModel.getValueAt(row);
                    BioPaxObject bpObject = property.bioPaxObject;
                    String text = property.value;
                    // colorize BLUE and add surround text with <html></html> tags
                    if (bpObject == null) {
                        BioModelEntityObject bioModelEntityObject = property.bioModelEntityObject;
                        if (bioModelEntityObject != null) {
                            if (!isSelected) {
                                setForeground(Color.blue);
                            }
                            setText("<html><u>" + text + "</u></html>");
                        }
                    } else {
                        if (bpObject instanceof Xref) {
                            String url = ((Xref) bpObject).getURL();
                            if (url != null) {
                                setToolTipText(url);
                                if (!isSelected) {
                                    setForeground(Color.blue);
                                }
                                setText("<html><u>" + text + "</u></html>");
                            }
                        } else if (bpObject instanceof SBEntity) {
                            String url = ((SBEntity) bpObject).getID();
                            if (url.contains("kineticLaw")) {
                                setToolTipText(url);
                                if (!isSelected) {
                                    setForeground(Color.blue);
                                }
                                if (url.contains("http")) {
                                    setText("<html><u>" + text + "</u></html>");
                                }
                            }
                        }
                    }
                }
                BioPaxObjectProperty property = tableModel.getValueAt(row);
                if (!property.tooltip.isEmpty()) {
                    setToolTipText(property.tooltip);
                }
                return this;
            }
        });
    // --- end of setCellRenderer()
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : SBEntity(org.vcell.pathway.sbpax.SBEntity) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Entity(org.vcell.pathway.Entity) ScrollTable(org.vcell.util.gui.ScrollTable) BioPaxObject(org.vcell.pathway.BioPaxObject) ListSelectionEvent(javax.swing.event.ListSelectionEvent) SpeciesContext(cbit.vcell.model.SpeciesContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) SBEntity(org.vcell.pathway.sbpax.SBEntity) JTextPane(javax.swing.JTextPane) Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) Point(java.awt.Point) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) MolecularType(org.vcell.model.rbm.MolecularType) JTable(javax.swing.JTable) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) JSplitPane(javax.swing.JSplitPane)

Example 12 with Entity

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

the class BioModelEditorConversionTableModel method createTableRowForTransportParticipant.

private ConversionTableRow createTableRowForTransportParticipant(BioPaxObject bpObject, String interactionId, String interactionLabel, String participantType, double stoich, HashSet<RelationshipObject> relationshipObjects) {
    String location = "";
    ConversionTableRow conversionTableRow = new ConversionTableRow(bpObject);
    conversionTableRow.setInteractionId(interactionId);
    conversionTableRow.setInteractionLabel(interactionLabel);
    conversionTableRow.setParticipantType(participantType);
    // stoichiometry and location
    Model model = bioModel.getModel();
    StructureTopology structTopology = model.getStructureTopology();
    if (participantType.equals("Reactant")) {
        // stoichiometry
        if (stoich != 0)
            conversionTableRow.setStoich(stoich);
        else
            conversionTableRow.setStoich(1.0);
        // else{
        if (model.getMembranes().size() > 0)
            location = structTopology.getOutsideFeature(model.getMembranes().get(0)).getName();
        else
            location = model.getStructures()[0].getName();
        // }
        conversionTableRow.setLocation(location);
    } else if (participantType.equals("Product")) {
        // stoichiometry
        if (stoich != 0)
            conversionTableRow.setStoich(stoich);
        else
            conversionTableRow.setStoich(1.0);
        // else{
        if (model.getMembranes().size() > 0)
            location = structTopology.getInsideFeature(model.getMembranes().get(0)).getName();
        else
            location = model.getStructures()[0].getName();
        // }
        conversionTableRow.setLocation(location);
    } else {
        conversionTableRow.setStoich(1.0);
        // else
        if (bpObject instanceof Transport) {
            if (model.getMembranes().size() > 0)
                location = model.getMembranes().get(0).getName();
            else
                location = model.getStructures()[0].getName();
        } else
            location = model.getStructures()[0].getName();
        conversionTableRow.setLocation(location);
    }
    // id
    if (relationshipObjects == null) {
        if (bpObject instanceof Entity) {
            String id = (BioPAXUtil.getName((Entity) bpObject) + "_" + location).trim();
            if (isValid(id))
                conversionTableRow.setId(id);
            else
                conversionTableRow.setId(changeID(id));
        }
    } else {
        String id = null;
        for (RelationshipObject relationshipObject : relationshipObjects) {
            if (relationshipObject.getBioModelEntityObject().getStructure().getName().equalsIgnoreCase(location)) {
                id = relationshipObject.getBioModelEntityObject().getName();
            }
        }
        if (id != null) {
            // the linked bmObject with the same location will be used
            conversionTableRow.setId(id);
        } else {
            // a new bmObject will be created if no linked bmObject in the same location
            if (bpObject instanceof Entity) {
                id = (BioPAXUtil.getName((Entity) bpObject) + "_" + location).trim();
                if (isValid(id))
                    conversionTableRow.setId(id);
                else
                    conversionTableRow.setId(changeID(id));
            }
        }
    }
    return conversionTableRow;
}
Also used : Entity(org.vcell.pathway.Entity) PhysicalEntity(org.vcell.pathway.PhysicalEntity) StructureTopology(cbit.vcell.model.Model.StructureTopology) ConversionTableRow(org.vcell.relationship.ConversionTableRow) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) BioModel(cbit.vcell.biomodel.BioModel) AutoCompleteTableModel(org.vcell.util.gui.AutoCompleteTableModel) Model(cbit.vcell.model.Model) Transport(org.vcell.pathway.Transport) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 13 with Entity

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

the class ReactionPropertiesPanel method listLinkedPathwayObjects.

private String listLinkedPathwayObjects() {
    // Kinetics kinetics = reactionStep.getKinetics();
    if (reactionStep == null) {
        return "no selected reaction";
    }
    if (bioModel == null || bioModel.getModel() == null) {
        return "no biomodel";
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    String linkedPOlist = "";
    for (RelationshipObject relObject : bioModel.getRelationshipModel().getRelationshipObjects(reactionStep)) {
        if (relObject == null) {
            continue;
        }
        final BioPaxObject bpObject = relObject.getBioPaxObject();
        if (bpObject == null) {
            continue;
        }
        if (bpObject instanceof Entity) {
            String name = new String();
            if (((Entity) bpObject).getName().isEmpty()) {
                name = ((Entity) bpObject).getID();
            } else {
                name = ((Entity) bpObject).getName().get(0);
            }
            if (name.contains("#")) {
                name = name.substring(name.indexOf("#") + 1);
            }
            JLabel label = new JLabel("<html><u>" + name + "</u></html>");
            label.setForeground(Color.blue);
            label.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), new Object[] { bpObject });
                    }
                }
            });
            panel.add(label);
        }
    }
    Dimension dim = new Dimension(200, 20);
    panel.setMinimumSize(dim);
    panel.setPreferredSize(dim);
    linkedPOScrollPane.setViewportView(panel);
    return linkedPOlist;
}
Also used : JPanel(javax.swing.JPanel) Entity(org.vcell.pathway.Entity) MouseEvent(java.awt.event.MouseEvent) BioPaxObject(org.vcell.pathway.BioPaxObject) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) Dimension(java.awt.Dimension) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 14 with Entity

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

the class MolecularTypePropertiesPanel method listLinkedPathwayObjects.

private String listLinkedPathwayObjects() {
    if (molecularType == null) {
        return "no selected molecule";
    }
    if (bioModel == null || bioModel.getModel() == null) {
        return "no biomodel";
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    String linkedPOlist = "";
    for (RelationshipObject relObject : bioModel.getRelationshipModel().getRelationshipObjects(molecularType)) {
        final BioPaxObject bpObject = relObject.getBioPaxObject();
        if (bpObject instanceof Entity) {
            JLabel label = new JLabel("<html><u>" + ((Entity) bpObject).getName().get(0) + "</u></html>");
            label.setForeground(Color.blue);
            label.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), new Object[] { bpObject });
                    }
                }
            });
            panel.add(label);
        }
    }
    Dimension dim = new Dimension(200, 20);
    panel.setMinimumSize(dim);
    panel.setPreferredSize(dim);
    linkedPOScrollPane.setViewportView(panel);
    return linkedPOlist;
}
Also used : JPanel(javax.swing.JPanel) Entity(org.vcell.pathway.Entity) MouseEvent(java.awt.event.MouseEvent) BioPaxObject(org.vcell.pathway.BioPaxObject) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) Dimension(java.awt.Dimension) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 15 with Entity

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

the class MolecularTypeTableModel method computeData.

@Override
protected List<MolecularType> computeData() {
    if (getModel() == null) {
        return new ArrayList<MolecularType>();
    }
    List<MolecularType> mtList;
    if (searchText == null || searchText.length() == 0) {
        mtList = new ArrayList<MolecularType>(getModel().getRbmModelContainer().getMolecularTypeList());
    } else {
        mtList = new ArrayList<MolecularType>();
        String lowerCaseSearchText = searchText.toLowerCase();
        for (MolecularType mt : getModel().getRbmModelContainer().getMolecularTypeList()) {
            boolean bMatchRelationshipObj = false;
            HashSet<RelationshipObject> relObjsHash = bioModel.getRelationshipModel().getRelationshipObjects(mt);
            for (RelationshipObject relObj : relObjsHash) {
                if (relObj.getBioPaxObject() instanceof Entity) {
                    if (((Entity) relObj.getBioPaxObject()).getName().get(0).toLowerCase().contains(lowerCaseSearchText)) {
                        bMatchRelationshipObj = true;
                        break;
                    }
                }
            }
            String expression = pattern(mt);
            if (expression != null && expression.toLowerCase().contains(lowerCaseSearchText)) {
                mtList.add(mt);
            }
        }
    }
    return mtList;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Entity(org.vcell.pathway.Entity) ArrayList(java.util.ArrayList) RelationshipObject(org.vcell.relationship.RelationshipObject)

Aggregations

Entity (org.vcell.pathway.Entity)15 RelationshipObject (org.vcell.relationship.RelationshipObject)12 BioPaxObject (org.vcell.pathway.BioPaxObject)8 PhysicalEntity (org.vcell.pathway.PhysicalEntity)7 ArrayList (java.util.ArrayList)6 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)5 MouseAdapter (java.awt.event.MouseAdapter)5 MouseEvent (java.awt.event.MouseEvent)5 Dimension (java.awt.Dimension)4 BoxLayout (javax.swing.BoxLayout)4 JLabel (javax.swing.JLabel)4 JPanel (javax.swing.JPanel)4 GroupObject (org.vcell.pathway.GroupObject)4 PublicationXref (org.vcell.pathway.PublicationXref)4 RelationshipXref (org.vcell.pathway.RelationshipXref)4 Xref (org.vcell.pathway.Xref)4 SBEntity (org.vcell.pathway.sbpax.SBEntity)4 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)3 MolecularType (org.vcell.model.rbm.MolecularType)3 UnificationXref (org.vcell.pathway.UnificationXref)3