Search in sources :

Example 21 with RelationshipObject

use of org.vcell.relationship.RelationshipObject 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)

Example 22 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class PhysiologyRelationshipTableModel method setValueAt.

public void setValueAt(Object valueNew, int iRow, int iCol) {
    try {
        if (valueNew instanceof Boolean && iCol == iColSelected) {
            PhysiologyRelationshipTableRow entitySelectionTableRow = getValueAt(iRow);
            if ((Boolean) valueNew) {
                // if the row is checked, then add the link to relationshipModel
                RelationshipObject reObject = new RelationshipObject(bioModelEntityObject, entitySelectionTableRow.getBioPaxObject());
                bioModel.getRelationshipModel().addRelationshipObject(reObject);
            } else {
                // if the row is unchecked and the link is in the relationshipModel,
                // then remove the link from the relationshipModel
                ArrayList<RelationshipObject> relationshipObjectsToRemove = new ArrayList<RelationshipObject>();
                for (RelationshipObject re : bioModel.getRelationshipModel().getRelationshipObjects()) {
                    if (re.getBioModelEntityObject() == bioModelEntityObject && re.getBioPaxObject() == (entitySelectionTableRow.getBioPaxObject())) {
                        relationshipObjectsToRemove.add(re);
                    }
                }
                for (RelationshipObject re : relationshipObjectsToRemove) {
                    bioModel.getRelationshipModel().removeRelationshipObject(re);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 23 with RelationshipObject

use of org.vcell.relationship.RelationshipObject 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)

Example 24 with RelationshipObject

use of org.vcell.relationship.RelationshipObject in project vcell by virtualcell.

the class RelationshipProducer method getXML.

public void getXML(RelationshipModel relationshipModel, Element rootElement, IdentifiableProvider provider) {
    relationshipElement = rootElement;
    relationshipObjects = (HashSet<RelationshipObject>) (relationshipModel.getRelationshipObjects());
    for (RelationshipObject relationshipObject : relationshipObjects) {
        if (relationshipObject == null) {
            System.out.println("null object!");
            break;
        }
        String className = relationshipObject.getClass().getName().substring(1 + relationshipObject.getClass().getName().lastIndexOf('.'));
        if (className.equals(XMLTags.relationshipObjectTag)) {
            relationshipElement.addContent(addObjectRelationshipObject(relationshipObject, className, provider));
        } else {
            showUnexpected(relationshipObject);
        }
    }
    return;
}
Also used : RelationshipObject(org.vcell.relationship.RelationshipObject)

Aggregations

RelationshipObject (org.vcell.relationship.RelationshipObject)24 ArrayList (java.util.ArrayList)11 BioPaxObject (org.vcell.pathway.BioPaxObject)11 Entity (org.vcell.pathway.Entity)10 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)7 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)6 PhysicalEntity (org.vcell.pathway.PhysicalEntity)6 JLabel (javax.swing.JLabel)5 JPanel (javax.swing.JPanel)5 MolecularType (org.vcell.model.rbm.MolecularType)5 SpeciesContext (cbit.vcell.model.SpeciesContext)4 Dimension (java.awt.Dimension)4 MouseAdapter (java.awt.event.MouseAdapter)4 MouseEvent (java.awt.event.MouseEvent)4 BoxLayout (javax.swing.BoxLayout)4 Conversion (org.vcell.pathway.Conversion)4 ReactionStep (cbit.vcell.model.ReactionStep)3 ModelProcessEquation (cbit.gui.ModelProcessEquation)2 Shape (cbit.gui.graph.Shape)2 ModelProcess (cbit.vcell.model.ModelProcess)2