Search in sources :

Example 6 with Interaction

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

the class BioModelEditorPathwayDiagramPanel method refreshButtons.

private void refreshButtons() {
    deleteButton.setEnabled(false);
    physiologyLinkButton.setEnabled(false);
    groupButton.setEnabled(false);
    if (showPhysiologyLinksMenuItem != null) {
        showPhysiologyLinksMenuItem.setEnabled(false);
    }
    if (editPhysiologyLinksMenuItem != null) {
        editPhysiologyLinksMenuItem.setEnabled(false);
    }
    if (importIntoModelMenuItem != null) {
        importIntoModelMenuItem.setEnabled(false);
    }
    if (groupMenuItem != null) {
        groupMenuItem.setEnabled(false);
    }
    if (ungroupMenuItem != null) {
        ungroupMenuItem.setEnabled(false);
    }
    if (expandMenuItem != null) {
        expandMenuItem.setEnabled(false);
    }
    if (collapseMenuItem != null) {
        collapseMenuItem.setEnabled(false);
    }
    if (showPhysiologyLinksMenuItem1 != null) {
        showPhysiologyLinksMenuItem1.setEnabled(false);
    }
    if (editPhysiologyLinksMenuItem1 != null) {
        editPhysiologyLinksMenuItem1.setEnabled(false);
    }
    if (importIntoModelMenuItem1 != null) {
        importIntoModelMenuItem1.setEnabled(false);
    }
    if (groupMenuItem1 != null) {
        groupMenuItem1.setEnabled(false);
    }
    if (ungroupMenuItem1 != null) {
        ungroupMenuItem1.setEnabled(false);
    }
    if (expandMenuItem1 != null) {
        expandMenuItem1.setEnabled(false);
    }
    if (collapseMenuItem1 != null) {
        collapseMenuItem1.setEnabled(false);
    }
    if (deleteMenuItem != null) {
        deleteMenuItem.setEnabled(false);
    }
    if (selectAllMenuItem != null) {
        selectAllMenuItem.setEnabled(false);
    }
    if (selectionManager != null && tabbedPane.getSelectedComponent() != sourceTabPanel) {
        ArrayList<Object> selectedObjects = selectionManager.getSelectedObjects(BioPaxObject.class);
        if (bioModel.getPathwayModel().getBiopaxObjects().size() > 0 && selectAllMenuItem != null) {
            selectAllMenuItem.setEnabled(true);
        }
        if (selectedObjects.size() > 0) {
            deleteButton.setEnabled(true);
            if (deleteMenuItem != null) {
                deleteMenuItem.setEnabled(true);
            }
            physiologyLinkButton.setEnabled(true);
            if (importIntoModelMenuItem != null) {
                importIntoModelMenuItem.setEnabled(true);
            }
            if (importIntoModelMenuItem1 != null) {
                importIntoModelMenuItem1.setEnabled(true);
            }
            if (selectedObjects.size() == 1) {
                if (bioModel.getRelationshipModel().getRelationshipObjects((BioPaxObject) selectedObjects.get(0)).size() > 0) {
                    if (showPhysiologyLinksMenuItem != null) {
                        showPhysiologyLinksMenuItem.setEnabled(true);
                    }
                    if (showPhysiologyLinksMenuItem1 != null) {
                        showPhysiologyLinksMenuItem1.setEnabled(true);
                    }
                }
                if (editPhysiologyLinksMenuItem != null) {
                    editPhysiologyLinksMenuItem.setEnabled(true);
                }
                if (editPhysiologyLinksMenuItem1 != null) {
                    editPhysiologyLinksMenuItem1.setEnabled(true);
                }
                if ((selectedObjects.get(0) instanceof GroupObject)) {
                    GroupObject selectedGroup = (GroupObject) selectedObjects.get(0);
                    if (// (selectedGroup.getType().equals(GroupObject.Type.GROUPEDCOMPLEX)) || // expand function for complex
                    (selectedGroup.getType().equals(GroupObject.Type.GROUPEDINTERACTION))) {
                        groupButton.setEnabled(true);
                        if (expandMenuItem != null) {
                            // expand function only available when one grouped complex or interaction is selected
                            expandMenuItem.setEnabled(true);
                        }
                        if (expandMenuItem1 != null) {
                            // expand function only available when one grouped complex or interaction is selected
                            expandMenuItem1.setEnabled(true);
                        }
                    }
                }
                if (// (selectedObjects.get(0) instanceof Protein) ||  // collapse function for Protein
                (selectedObjects.get(0) instanceof Interaction)) {
                    groupButton.setEnabled(true);
                    if (collapseMenuItem != null) {
                        collapseMenuItem.setEnabled(true);
                    }
                    if (collapseMenuItem1 != null) {
                        collapseMenuItem1.setEnabled(true);
                    }
                }
            }
            if (selectedObjects.size() > 1) {
                // only provide the "group" function when users select more than one object
                groupButton.setEnabled(true);
                if (groupMenuItem != null) {
                    groupMenuItem.setEnabled(true);
                }
                if (groupMenuItem1 != null) {
                    groupMenuItem1.setEnabled(true);
                }
            }
            boolean includingGroup = false;
            for (Object object : selectedObjects) {
                if (object instanceof GroupObject) {
                    includingGroup = true;
                    break;
                }
            }
            if (includingGroup) {
                // only provide the "ungroup" function when selected objects contain at least one GroupObject
                groupButton.setEnabled(true);
                if (ungroupMenuItem != null) {
                    ungroupMenuItem.setEnabled(true);
                }
                if (ungroupMenuItem1 != null) {
                    ungroupMenuItem1.setEnabled(true);
                }
            }
        }
    }
}
Also used : Interaction(org.vcell.pathway.Interaction) GroupObject(org.vcell.pathway.GroupObject) GroupObject(org.vcell.pathway.GroupObject) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 7 with Interaction

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

the class BioPaxObjectPropertiesPanel method refreshInterface.

protected void refreshInterface() {
    if (bioPaxObject == null) {
        // sanity check
        return;
    }
    ArrayList<BioPaxObjectProperty> propertyList = new ArrayList<BioPaxObjectProperty>();
    if (!(bioPaxObject instanceof SBEntity)) {
        tableModel.setData(propertyList);
        return;
    }
    SBEntity sbEntity = (SBEntity) bioPaxObject;
    if (!(sbEntity instanceof Entity)) {
        tableModel.setData(propertyList);
        return;
    }
    Entity entity = (Entity) sbEntity;
    // entity::type
    propertyList.add(new BioPaxObjectProperty("Type", bioPaxObject.getTypeLabel()));
    if (lookupContains(entity)) {
        propertyList.add(new BioPaxObjectProperty("Name", entity.getName().get(0) + " (looking...)"));
    } else if (entity.getFormalNames() != null && entity.getFormalNames().size() != 0) {
        propertyList.add(new BioPaxObjectProperty("Name", entity.getName().get(0) + " (" + entity.getFormalNames().get(0) + ")"));
    } else if (entity.getName() != null && entity.getName().size() > 0) {
        String displayName = entity.getName().get(0);
        if (entity.getxRef() != null && entity.getxRef().size() > 0) {
            displayName = displayName + " (double-click lookup)";
        }
        // entity::name
        propertyList.add(new BioPaxObjectProperty("Name", displayName));
    }
    // entity::Link
    for (RelationshipObject rObject : bioModel.getRelationshipModel().getRelationshipObjects(bioPaxObject)) {
        BioModelEntityObject beObject = rObject.getBioModelEntityObject();
        propertyList.add(new BioPaxObjectProperty("Linked physiology object", beObject.getName(), beObject));
    }
    if (entity instanceof PhysicalEntity) {
        // ------------------------ PHYSICAL ENTITY -----------------------
        PhysicalEntity physicalEntity = (PhysicalEntity) entity;
        // physicalEntity::feature (***ignored***)
        // physicalEntity::memberPhysicalEntity (***ignored***)
        // physicalEntity::notFeature (***ignored***)
        // TODO:  extract the kinetic law, then the SBEntities, then the measurables, units, aso
        boolean isReactionParticipant = BioPAXUtil.isReactionParticipant(physicalEntity, bioModel.getPathwayModel());
        String role = "";
        if (BioPAXUtil.isController(physicalEntity, bioModel.getPathwayModel())) {
            role += "Controller";
            if (isReactionParticipant) {
                role += ", Participant";
            }
        } else if (isReactionParticipant) {
            role += "Participant";
        }
        if (!role.isEmpty()) {
            propertyList.add(new BioPaxObjectProperty("Role(s)", role));
        }
        if (!(physicalEntity instanceof SmallMolecule)) {
            // physicalEntity::cellular location
            CellularLocationVocabulary cellularLocation = physicalEntity.getCellularLocation();
            if (cellularLocation != null && cellularLocation.getTerm() != null && cellularLocation.getTerm().size() > 0) {
                propertyList.add(new BioPaxObjectProperty("Cellular Location", cellularLocation.getTerm().get(0), cellularLocation));
            } else if (entity.getName() != null && entity.getName().size() > 1) {
                String location = entity.getName().get(1);
                if (location.contains("[") && location.contains("]")) {
                    location = location.substring(location.indexOf("[") + 1, location.indexOf("]"));
                    propertyList.add(new BioPaxObjectProperty("Cellular Location", location));
                }
            }
        }
        if (physicalEntity instanceof Complex) {
            Complex complex = (Complex) physicalEntity;
            // complex::components
            for (PhysicalEntity pe : complex.getComponents()) {
                propertyList.add(new BioPaxObjectProperty("Component", getEntityName(pe), pe));
            }
        } else if (physicalEntity instanceof Protein) {
        // Protein protein = (Protein)entity;
        // protein::entity reference (***ignored***)
        } else if (physicalEntity instanceof SmallMolecule) {
            SmallMolecule sm = (SmallMolecule) physicalEntity;
            EntityReference er = sm.getEntityReference();
            if (er != null && !er.getName().isEmpty() && er.getName().get(0) != null && !er.getName().get(0).isEmpty()) {
                propertyList.add(new BioPaxObjectProperty("Entity Reference", er.getName().get(0)));
                ArrayList<Xref> xrefList = er.getxRef();
                for (Xref xref : xrefList) {
                    propertyList.add(new BioPaxObjectProperty("   Xref", xref.getDb() + ":" + xref.getId(), xref));
                }
            }
        } else if (physicalEntity instanceof Dna) {
        // dna::entityReference (***ignored***)
        } else if (physicalEntity instanceof DnaRegion) {
        // dnaRegion::entityReference (***ignored***)
        } else if (physicalEntity instanceof Rna) {
        // rna::entityReference (***ignored***)
        } else if (physicalEntity instanceof RnaRegion) {
        // rnaRegion::entityReference (***ignored***)
        }
    } else if (entity instanceof Interaction) {
        // --------------------------- INTERACTION -------------------
        Interaction interaction = (Interaction) entity;
        // interaction::interactionType
        for (InteractionVocabulary interactionVocabulary : interaction.getInteractionTypes()) {
            if (interactionVocabulary.getTerm().size() > 0) {
                propertyList.add(new BioPaxObjectProperty("Interaction Type", interactionVocabulary.getTerm().get(0), interactionVocabulary));
            }
        }
        // interaction::participants
        for (InteractionParticipant interactionParticipant : interaction.getParticipants()) {
            PhysicalEntity physicalEntity = interactionParticipant.getPhysicalEntity();
            String physicalEntityName = physicalEntity.getName().size() > 0 ? physicalEntity.getName().get(0) : physicalEntity.getIDShort();
            String cellularLocation = "";
            if (physicalEntity.getCellularLocation() != null) {
                cellularLocation = physicalEntity.getCellularLocation().getTerm().size() > 0 ? " [" + physicalEntity.getCellularLocation().getTerm().get(0) + "]" : "";
            }
            propertyList.add(new BioPaxObjectProperty(interactionParticipant.getLevel3PropertyName(), physicalEntityName + cellularLocation, physicalEntity));
        }
        // get the controllers for interactions
        // we always need this because there's no guarantee we'll have kinetic laws
        // for instance pathway commons doesn't have quantitative information
        Set<String> controllersNames = getControllersNames(interaction);
        if (controllersNames.size() > 0) {
            for (String str : controllersNames) {
                // String tooltip = "<html>how many of these 12 M <br>average size  1.12345*E12 nm <br>temperature 37 degrees Celsius</html>";
                String tooltip = "";
                propertyList.add(new BioPaxObjectProperty("Controlled by", str, interaction, tooltip));
            }
        }
        // get the kinetic laws (if any)
        Set<Control> controls = BioPAXUtil.getControlsOfInteraction(interaction, bioModel.getPathwayModel());
        for (Control control : controls) {
            ArrayList<SBEntity> sbEntities = control.getSBSubEntity();
            for (SBEntity sbE : sbEntities) {
                // the only SBSubEntities allowed in a control are kinetic laws
                if (sbE.getID().contains("kineticLaw")) {
                    String str = new String();
                    if (control.getPhysicalControllers() != null) {
                        str += " for Controller(s): ";
                        for (PhysicalEntity ep : control.getPhysicalControllers()) {
                            if (ep.getName().size() > 0) {
                                str += ep.getName().get(0);
                            } else {
                                str += ep.getIDShort();
                            }
                            str += " ";
                        }
                    }
                    String sDetails = "";
                    ArrayList<SBVocabulary> sbTerms = sbE.getSBTerm();
                    for (SBVocabulary sbv : sbTerms) {
                        // type of kinetic law
                        String str1 = sbv.getID();
                        str1 = str1.substring(str1.lastIndexOf('#') + 1);
                        System.out.println(str1);
                        SBOTerm sboT = SBOListEx.sboMap.get(str1);
                        sDetails += "<font color=\"#660000\"><b>" + sboT.getName() + "</b></font>" + "  " + "<font color=\"#006600\">" + sboT.getDescription() + "</font>";
                        sDetails += "<br>";
                    }
                    ArrayList<SBEntity> klProperties = sbE.getSBSubEntity();
                    for (SBEntity klProperty : klProperties) {
                        if (klProperty instanceof SBMeasurable) {
                            SBMeasurable m = (SBMeasurable) klProperty;
                            String str1 = "";
                            String str2 = "";
                            String str3 = "";
                            if (m.hasTerm()) {
                                str1 += m.extractSBOTermAsString();
                            }
                            if (m.hasNumber()) {
                                str2 += m.getNumber().get(0);
                            }
                            if (m.hasUnit()) {
                                str3 += m.extractSBOUnitAsString();
                            }
                            // str1 is an SBO id, for example "SBO:0000064"
                            SBOTerm sboT = SBOListEx.sboMap.get(str1);
                            sDetails += sboT.getSymbol() + "   (" + sboT.getName() + ")" + "<font color=\"#660000\"><b>" + str2 + str3 + "</b></font>" + "  " + "<font color=\"#006600\">" + sboT.getDescription() + "</font>";
                        } else {
                            sDetails = klProperty.getIDShort() + "  " + klProperty.getTypeLabel();
                        }
                        sDetails += "<br>";
                    }
                    // String tooltip = "<html>how many of these 12 M <br>average size  1.12345*E12 nm <br>temperature 37 degrees Celsius</html>";
                    String tooltip = "";
                    BioPaxObjectProperty bpop = new BioPaxObjectProperty("Kinetic Law" + str, sbE.getID(), sbE, tooltip);
                    bpop.setDetails(sDetails);
                    propertyList.add(bpop);
                }
            }
        }
        if (interaction instanceof Control) {
            // TODO: is this ever being called?
            Control c = (Control) interaction;
            // catalysis::controlled
            Interaction controlledInteraction = c.getControlledInteraction();
            if (controlledInteraction != null) {
                String controlledName = controlledInteraction.getIDShort();
                if (controlledInteraction.getName().size() > 0) {
                    controlledName = controlledInteraction.getName().get(0);
                }
                propertyList.add(new BioPaxObjectProperty("Controlled Interaction", controlledName, controlledInteraction));
            }
        }
    } else if (entity instanceof GroupObject) {
        // ---------------------- GROUP OBJECT ------------------
        GroupObject groupObject = (GroupObject) entity;
        for (BioPaxObject bpo : groupObject.getGroupedObjects()) {
            propertyList.add(new BioPaxObjectProperty("Element::" + bpo.getTypeLabel(), getEntityName((Entity) bpo), bpo));
        }
    }
    // entity::comments
    for (String comment : entity.getComments()) {
        propertyList.add(new BioPaxObjectProperty("Comment", comment));
    }
    // entity::xRef
    ArrayList<Xref> xrefList = ((Entity) bioPaxObject).getxRef();
    for (Xref xref : xrefList) {
        if (xref instanceof UnificationXref) {
            propertyList.add(new BioPaxObjectProperty("Xref", xref.getDb() + ":" + xref.getId(), xref));
        }
    }
    for (Xref xref : xrefList) {
        if (xref instanceof RelationshipXref) {
            propertyList.add(new BioPaxObjectProperty("Xref (related)", xref.getDb() + ":" + xref.getId(), xref));
        }
    }
    for (Xref xref : xrefList) {
        if (xref instanceof PublicationXref) {
            propertyList.add(new BioPaxObjectProperty("Publication", xref.getDb() + ":" + xref.getId(), xref));
        }
    }
    // for(SBVocabulary sbVocab : sbEntity.getSBTerm()) {
    // propertyList.add(new BioPaxObjectProperty("SBO Term", SBPAXLabelUtil.makeLabel(sbVocab)));
    // }
    // if(sbEntity instanceof Interaction) {
    // // TODO: this goes away
    // Interaction interaction = (Interaction) sbEntity;
    // Set<SBEntity> subEntities = new HashSet<SBEntity>();
    // subEntities.add(interaction);
    // Set<Control> controls = BioPAXUtil.findAllControls(interaction, bioModel.getPathwayModel());
    // subEntities.addAll(controls);
    // subEntities = SBPAX3Util.extractAllEntities(subEntities);
    // for(SBEntity subEntity : subEntities) {
    // if(subEntity instanceof SBMeasurable) {
    // propertyList.add(new BioPaxObjectProperty("Measured quantity", SBPAXLabelUtil.makeLabel(subEntity)));
    // }
    // }
    // }
    tableModel.setData(propertyList);
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) SBEntity(org.vcell.pathway.sbpax.SBEntity) PhysicalEntity(org.vcell.pathway.PhysicalEntity) Entity(org.vcell.pathway.Entity) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Rna(org.vcell.pathway.Rna) PublicationXref(org.vcell.pathway.PublicationXref) InteractionVocabulary(org.vcell.pathway.InteractionVocabulary) BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) CellularLocationVocabulary(org.vcell.pathway.CellularLocationVocabulary) SBEntity(org.vcell.pathway.sbpax.SBEntity) RelationshipObject(org.vcell.relationship.RelationshipObject) Complex(org.vcell.pathway.Complex) RnaRegion(org.vcell.pathway.RnaRegion) SBMeasurable(org.vcell.pathway.sbpax.SBMeasurable) Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) Control(org.vcell.pathway.Control) DnaRegion(org.vcell.pathway.DnaRegion) EntityReference(org.vcell.pathway.EntityReference) Interaction(org.vcell.pathway.Interaction) UnificationXref(org.vcell.pathway.UnificationXref) GroupObject(org.vcell.pathway.GroupObject) SBOTerm(org.vcell.pathway.sbo.SBOTerm) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) Protein(org.vcell.pathway.Protein) RelationshipXref(org.vcell.pathway.RelationshipXref) PhysicalEntity(org.vcell.pathway.PhysicalEntity) SmallMolecule(org.vcell.pathway.SmallMolecule) Dna(org.vcell.pathway.Dna) InteractionParticipant(org.vcell.pathway.InteractionParticipant)

Example 8 with Interaction

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

the class BioPaxInteractionParticipantShape method getCurve.

// very similar with the code in ReactionParticipantShape
@Override
protected final CubicCurve2D.Double getCurve() {
    refreshLayoutSelf();
    // default behavior of control points is for direction at ends to follow secant between end-points.
    if (lastCurve_Start == null || !lastCurve_Start.equals(start) || lastCurve_End == null || !lastCurve_End.equals(end)) {
        lastp1ctrl = new Point2D.Double((1.0 - FRACT_WEIGHT) * start.getX() + FRACT_WEIGHT * end.getX(), (1.0 - FRACT_WEIGHT) * start.getY() + FRACT_WEIGHT * end.getY());
    }
    Point2D.Double p2ctrl = new Point2D.Double(FRACT_WEIGHT * start.getX() + (1.0 - FRACT_WEIGHT) * end.getX(), FRACT_WEIGHT * start.getY() + (1.0 - FRACT_WEIGHT) * end.getY());
    // check for siblings in the reaction (like a+a-> or a->a) and calculate a correction factor
    // so that the edges won't overlap
    correctionFactor = 0;
    if (endShape instanceof BioPaxInteractionShape) {
        // index in the array of siblings
        int myPosition = 0;
        // in total
        int numSiblings = 0;
        BioPaxInteractionShape reactionStepShape = (BioPaxInteractionShape) endShape;
        Interaction rs = reactionStepShape.getInteraction();
        for (InteractionParticipant rp : rs.getParticipants()) {
            if (rp == participant) {
                // myself
                if (rp.getType() == InteractionParticipant.Type.LEFT || rp.getType() == InteractionParticipant.Type.RIGHT) {
                    myPosition = numSiblings;
                    numSiblings++;
                }
            } else if (rp.getPhysicalEntity().getName().equals(participant.getPhysicalEntity().getName())) {
                if (rp.getType() == InteractionParticipant.Type.LEFT || rp.getType() == InteractionParticipant.Type.RIGHT) {
                    numSiblings++;
                }
            }
        }
        if (numSiblings > 1) {
            double offset = numSiblings / 2 - 0.5;
            correctionFactor = (myPosition - offset) * 0.08;
        }
    }
    // calculate tangent direction at interaction
    double tangentX = 0.0;
    double tangentY = 0.0;
    if (endShape instanceof BioPaxInteractionShape) {
        BioPaxInteractionShape reactionStepShape = (BioPaxInteractionShape) endShape;
        for (Shape shape : graphModel.getShapes()) {
            if (shape instanceof BioPaxInteractionParticipantShape && ((BioPaxInteractionParticipantShape) shape).endShape == reactionStepShape) {
                BioPaxInteractionParticipantShape rpShape = (BioPaxInteractionParticipantShape) shape;
                double dx = rpShape.start.getX() - rpShape.end.getX();
                double dy = rpShape.start.getY() - rpShape.end.getY();
                double len = dx * dx + dy * dy;
                if (rpShape.participant.getType() == InteractionParticipant.Type.LEFT) {
                    tangentX += (rpShape.start.getX() - rpShape.end.getX()) / len;
                    tangentY += (rpShape.start.getY() - rpShape.end.getY()) / len;
                } else if (rpShape.participant.getType() == InteractionParticipant.Type.RIGHT) {
                    tangentX -= (rpShape.start.getX() - rpShape.end.getX()) / len;
                    tangentY -= (rpShape.start.getY() - rpShape.end.getY()) / len;
                }
            }
        }
    }
    double tangentLength = Math.sqrt(tangentX * tangentX + tangentY * tangentY);
    if (tangentLength != 0) {
        tangentX = tangentX * CONTROL_WEIGHT / tangentLength;
        tangentY = tangentY * CONTROL_WEIGHT / tangentLength;
    }
    if (participant.getType() == InteractionParticipant.Type.CONTROLLER) {
        // choose side based on inner product with displacement vector between catalyst and reactionStep
        if (((start.getX() - end.getX()) * tangentY - (start.getY() - end.getY()) * tangentX) > 0) {
            p2ctrl.setLocation(end.getX() + tangentY, end.getY() - tangentX);
        } else {
            p2ctrl.setLocation(end.getX() - tangentY, end.getY() + tangentX);
        }
    } else if (participant.getType() == InteractionParticipant.Type.RIGHT) {
        p2ctrl.setLocation(end.getX() + tangentX, end.getY() + tangentY);
    } else if (participant.getType() == InteractionParticipant.Type.LEFT) {
        p2ctrl.setLocation(end.getX() - tangentX, end.getY() - tangentY);
    }
    if (lastCurve != null && lastCurve_Start != null && lastCurve_Start.equals(start) && lastCurve_End != null && lastCurve_End.equals(end) && lastp2ctrl != null && lastp2ctrl.equals(p2ctrl)) {
    // Do Nothing
    } else {
        lastCurve = new CubicCurve2D.Double(start.getX(), start.getY(), lastp1ctrl.getX() * (1 + correctionFactor), lastp1ctrl.getY() * (1 + correctionFactor), p2ctrl.getX(), p2ctrl.getY(), end.getX(), end.getY());
        lastCurve_Start = new Point(start);
        lastCurve_End = new Point(end);
        lastp2ctrl = p2ctrl;
    }
    return lastCurve;
}
Also used : EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) Interaction(org.vcell.pathway.Interaction) Point(java.awt.Point) Point(java.awt.Point) Point2D(java.awt.geom.Point2D) InteractionParticipant(org.vcell.pathway.InteractionParticipant) CubicCurve2D(java.awt.geom.CubicCurve2D)

Example 9 with Interaction

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

the class PathwayGraphModel method refreshControl.

private void refreshControl(Control control) {
    Interaction controlledInteraction = control.getControlledInteraction();
    if (controlledInteraction instanceof Conversion) {
        List<InteractionParticipant> physicalControllers = control.getParticipants();
        if (physicalControllers != null) {
            Conversion conversion = (Conversion) controlledInteraction;
            BioPaxObject ancestorObject = pathwayModel.findTopLevelGroupAncestor(conversion);
            if (ancestorObject == conversion) {
                // conversion was not grouped
                BioPaxConversionShape conversionShape = (BioPaxConversionShape) getShapeFromModelObject(conversion);
                if (conversionShape != null) {
                    for (InteractionParticipant participant : physicalControllers) {
                        refreshParticipant(conversionShape, participant);
                    }
                }
            } else {
                if (ancestorObject instanceof GroupObject) {
                    // conversion has been grouped
                    GroupObject groupObject = (GroupObject) ancestorObject;
                    for (InteractionParticipant participant : physicalControllers) {
                        refreshGroupInteraction(groupObject, participant);
                    }
                }
            }
        }
    }
}
Also used : Interaction(org.vcell.pathway.Interaction) MolecularInteraction(org.vcell.pathway.MolecularInteraction) BioPaxObject(org.vcell.pathway.BioPaxObject) InteractionParticipant(org.vcell.pathway.InteractionParticipant) GroupObject(org.vcell.pathway.GroupObject) Conversion(org.vcell.pathway.Conversion)

Example 10 with Interaction

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

the class BioModelEditorPathwayDiagramPanel method collapseBioPaxObject.

private void collapseBioPaxObject() {
    HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>(getSelectedBioPaxObjects());
    if (selected.size() == 0)
        return;
    if (bioModel == null || bioModel.getPathwayModel() == null)
        return;
    PathwayGrouping pathwayGrouping = new PathwayGrouping();
    GroupObject groupObject = null;
    HashSet<BioPaxObject> hiddenobjects = new HashSet<BioPaxObject>();
    for (BioPaxObject bpObject : selected) {
        hiddenobjects.clear();
        if (bpObject instanceof Complex || bpObject instanceof Protein || bpObject instanceof SmallMolecule) {
            // collapse complex with physicalEntities
            groupObject = collapse2Complex(bpObject);
        } else if (bpObject instanceof Interaction) {
            for (InteractionParticipant itp : ((Interaction) bpObject).getParticipants()) {
                hiddenobjects.add(itp.getPhysicalEntity());
            }
            hiddenobjects.add(bpObject);
            String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
            groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), ((Entity) bpObject).getName(), id, hiddenobjects, GroupObject.Type.GROUPEDINTERACTION);
        }
    }
    if (groupObject != null) {
        bioModel.getPathwayModel().add(groupObject);
        bioModel.getPathwayModel().refreshGroupMap();
        // set the grouped object to be selected
        graphCartoonTool.getGraphModel().setSelectedObjects(new GroupObject[] { groupObject });
        pathwayGraphModel.refreshAll();
    }
}
Also used : PathwayGrouping(org.vcell.pathway.group.PathwayGrouping) SmallMolecule(org.vcell.pathway.SmallMolecule) BioPaxObject(org.vcell.pathway.BioPaxObject) Interaction(org.vcell.pathway.Interaction) InteractionParticipant(org.vcell.pathway.InteractionParticipant) GroupObject(org.vcell.pathway.GroupObject) Protein(org.vcell.pathway.Protein) HashSet(java.util.HashSet) Complex(org.vcell.pathway.Complex)

Aggregations

Interaction (org.vcell.pathway.Interaction)14 BioPaxObject (org.vcell.pathway.BioPaxObject)9 MolecularInteraction (org.vcell.pathway.MolecularInteraction)8 Element (org.jdom.Element)7 GeneticInteraction (org.vcell.pathway.GeneticInteraction)7 GroupObject (org.vcell.pathway.GroupObject)7 InteractionParticipant (org.vcell.pathway.InteractionParticipant)5 Pathway (org.vcell.pathway.Pathway)4 Complex (org.vcell.pathway.Complex)3 Protein (org.vcell.pathway.Protein)3 SmallMolecule (org.vcell.pathway.SmallMolecule)3 InteractionProxy (org.vcell.pathway.persistence.BiopaxProxy.InteractionProxy)3 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 BiochemicalPathwayStep (org.vcell.pathway.BiochemicalPathwayStep)2 Control (org.vcell.pathway.Control)2 Dna (org.vcell.pathway.Dna)2 DnaRegion (org.vcell.pathway.DnaRegion)2 InteractionImpl (org.vcell.pathway.InteractionImpl)2