Search in sources :

Example 6 with SmallMolecule

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

the class PathwayGraphModel method refreshAll.

@Override
public void refreshAll() {
    if (pathwayModel == null) {
        clearAllShapes();
        fireGraphChanged();
        return;
    }
    unwantedShapes = new HashSet<Shape>();
    unwantedShapes.addAll(getShapes());
    pathwayContainerShape = (PathwayContainerShape) getShapeFromModelObject(pathwayModel);
    if (pathwayContainerShape == null) {
        pathwayContainerShape = new PathwayContainerShape(this, pathwayModel);
        pathwayContainerShape.getSpaceManager().setSize(400, 300);
        addShape(pathwayContainerShape);
    }
    unwantedShapes.remove(pathwayContainerShape);
    Set<BioPaxObject> bioPaxObjects = new HashSet<BioPaxObject>(pathwayModel.getDisplayableBioPaxObjectList());
    for (BioPaxObject bpObject : bioPaxObjects) {
        BioPaxShape bpObjectShape = (BioPaxShape) getShapeFromModelObject(bpObject);
        if (bpObjectShape == null) {
            if (bpObject instanceof Conversion) {
                bpObjectShape = new BioPaxConversionShape((Conversion) bpObject, this);
            } else if (bpObject instanceof MolecularInteraction) {
                bpObjectShape = new BioPaxMolecularInteractionShape((MolecularInteraction) bpObject, this);
            } else if (bpObject instanceof Protein) {
                bpObjectShape = new BioPaxProteinShape((Protein) bpObject, this);
            } else if (bpObject instanceof Complex) {
                bpObjectShape = new BioPaxComplexShape((Complex) bpObject, this);
            } else if (bpObject instanceof SmallMolecule) {
                bpObjectShape = new BioPaxSmallMoleculeShape((SmallMolecule) bpObject, this);
            } else if (bpObject instanceof Dna) {
                bpObjectShape = new BioPaxDnaShape((Dna) bpObject, this);
            } else if (bpObject instanceof Rna) {
                bpObjectShape = new BioPaxRnaShape((Rna) bpObject, this);
            } else if (bpObject instanceof PhysicalEntity) {
                bpObjectShape = new BioPaxPhysicalEntityShape((PhysicalEntity) bpObject, this);
            } else if (bpObject instanceof GroupObject) {
                bpObjectShape = new BioPaxGroupShape((GroupObject) bpObject, this);
            } else {
                bpObjectShape = new BioPaxObjectShape(bpObject, this);
            }
            if (!(bpObject instanceof Control)) {
                // the Control objects will not be displayed on the diagram
                pathwayContainerShape.addChildShape(bpObjectShape);
                addShape(bpObjectShape);
            }
            Dimension shapeSize = bpObjectShape.getSpaceManager().getSize();
            Rectangle boundary = getContainerLayout().getBoundaryForAutomaticLayout(pathwayContainerShape);
            int xPos = boundary.x + random.nextInt(boundary.width - shapeSize.width);
            int yPos = boundary.y + random.nextInt(boundary.height - shapeSize.height);
            bpObjectShape.setAbsPos(xPos, yPos);
        }
        unwantedShapes.remove(bpObjectShape);
    }
    for (BioPaxObject bpObject : bioPaxObjects) {
        if (bpObject instanceof Conversion) {
            refreshInteraction((Conversion) bpObject);
        } else if (bpObject instanceof MolecularInteraction) {
            refreshInteraction((MolecularInteraction) bpObject);
        } else if (bpObject instanceof Control) {
            refreshControl((Control) bpObject);
        } else if (bpObject instanceof GroupObject) {
            refreshGroupObject((GroupObject) bpObject);
        }
    }
    for (Shape unwantedShape : unwantedShapes) {
        removeShape(unwantedShape);
    }
    refreshRelationshipInfo();
    fireGraphChanged();
}
Also used : EdgeShape(cbit.gui.graph.EdgeShape) Shape(cbit.gui.graph.Shape) Rna(org.vcell.pathway.Rna) BioPaxObject(org.vcell.pathway.BioPaxObject) Rectangle(java.awt.Rectangle) Complex(org.vcell.pathway.Complex) Control(org.vcell.pathway.Control) MolecularInteraction(org.vcell.pathway.MolecularInteraction) HashSet(java.util.HashSet) GroupObject(org.vcell.pathway.GroupObject) Dimension(java.awt.Dimension) Conversion(org.vcell.pathway.Conversion) Protein(org.vcell.pathway.Protein) PhysicalEntity(org.vcell.pathway.PhysicalEntity) SmallMolecule(org.vcell.pathway.SmallMolecule) Dna(org.vcell.pathway.Dna)

Example 7 with SmallMolecule

use of org.vcell.pathway.SmallMolecule 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)

Example 8 with SmallMolecule

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

the class PathwayReaderBiopax3 method addObjectSmallMolecule.

private SmallMolecule addObjectSmallMolecule(Element element) {
    SmallMolecule smallMolecule = new SmallMolecule();
    addAttributes(smallMolecule, element);
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (!addContentSmallMolecule(smallMolecule, element, childElement)) {
                showUnexpected(childElement);
            }
        }
    }
    pathwayModel.add(smallMolecule);
    return smallMolecule;
}
Also used : SmallMolecule(org.vcell.pathway.SmallMolecule) Element(org.jdom.Element) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 9 with SmallMolecule

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

the class AnnotationMapping method createPhysicalEntity.

private PhysicalEntity createPhysicalEntity(ArrayList<Xref> xRef, ArrayList<String> refName, String name) {
    PhysicalEntity physicalEntity = null;
    if (isSmallMolecule(xRef)) {
        physicalEntity = new SmallMolecule();
    } else {
        physicalEntity = new PhysicalEntity();
    }
    physicalEntity.setName(refName);
    physicalEntity.setID("BIOMODEL_" + name);
    // physicalEntity.setxRef(xRef);
    for (Xref ref : xRef) {
        physicalEntity.getxRef().add(ref);
    }
    return physicalEntity;
}
Also used : Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) PhysicalEntity(org.vcell.pathway.PhysicalEntity) SmallMolecule(org.vcell.pathway.SmallMolecule)

Example 10 with SmallMolecule

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

the class PathwayReader method addObjectSmallMolecule.

private SmallMolecule addObjectSmallMolecule(Element element) {
    SmallMolecule smallMolecule = new SmallMolecule();
    addAttributes(smallMolecule, element);
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (!addContentSmallMolecule(smallMolecule, element, childElement)) {
                showUnexpected(childElement, smallMolecule);
            }
        }
    }
    pathwayModel.add(smallMolecule);
    return smallMolecule;
}
Also used : SmallMolecule(org.vcell.pathway.SmallMolecule) Element(org.jdom.Element) BioPaxObject(org.vcell.pathway.BioPaxObject)

Aggregations

SmallMolecule (org.vcell.pathway.SmallMolecule)10 BioPaxObject (org.vcell.pathway.BioPaxObject)8 GroupObject (org.vcell.pathway.GroupObject)7 Complex (org.vcell.pathway.Complex)6 Protein (org.vcell.pathway.Protein)6 Element (org.jdom.Element)5 PhysicalEntity (org.vcell.pathway.PhysicalEntity)5 HashSet (java.util.HashSet)4 Dna (org.vcell.pathway.Dna)4 Rna (org.vcell.pathway.Rna)4 DnaRegion (org.vcell.pathway.DnaRegion)3 Interaction (org.vcell.pathway.Interaction)3 RnaRegion (org.vcell.pathway.RnaRegion)3 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 Control (org.vcell.pathway.Control)2 Entity (org.vcell.pathway.Entity)2 InteractionParticipant (org.vcell.pathway.InteractionParticipant)2 MolecularInteraction (org.vcell.pathway.MolecularInteraction)2 PublicationXref (org.vcell.pathway.PublicationXref)2