use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class PathwayGraphModel method refreshRelationshipInfo.
protected void refreshRelationshipInfo(Shape shape) {
if (shape instanceof BioPaxShape) {
BioPaxShape bpShape = (BioPaxShape) shape;
BioPaxObject bpObject = bpShape.getBioPaxObject();
boolean hasRelationships = false;
if (bioModel != null) {
HashSet<RelationshipObject> relationships = bioModel.getRelationshipModel().getRelationshipObjects(bpObject);
if (relationships.size() > 0) {
hasRelationships = true;
}
}
bpShape.setHasRelationships(hasRelationships);
}
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class PathwayGraphModel method refreshGroupInteraction.
private void refreshGroupInteraction(GroupObject groupObject, InteractionParticipant participant) {
BioPaxGroupShape groupShape = (BioPaxGroupShape) getShapeFromModelObject(groupObject);
PhysicalEntity physicalEntity = participant.getPhysicalEntity();
GroupNeighbor groupNeighbor = new GroupNeighbor(groupObject, physicalEntity, participant.getType());
BioPaxGroupNeighborShape edgeShape = (BioPaxGroupNeighborShape) getShapeFromModelObject(groupNeighbor);
BioPaxObject ancestorObject = pathwayModel.findTopLevelGroupAncestor(physicalEntity);
if (edgeShape == null) {
Shape shape = getShapeFromModelObject(physicalEntity);
if (shape instanceof BioPaxPhysicalEntityShape) {
BioPaxPhysicalEntityShape physicalEntityShape = (BioPaxPhysicalEntityShape) shape;
edgeShape = new BioPaxGroupNeighborShape(groupNeighbor, groupShape, physicalEntityShape, this);
pathwayContainerShape.addChildShape(edgeShape);
addShape(edgeShape);
}
} else {
// edges without end objects will be removed
if (ancestorObject != physicalEntity) {
// for grouped objects
removeEdgeShape(edgeShape);
}
}
unwantedShapes.remove(refreshGroup(pathwayContainerShape, ancestorObject, groupShape, participant));
unwantedShapes.remove(edgeShape);
}
use of org.vcell.pathway.BioPaxObject 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();
}
}
use of org.vcell.pathway.BioPaxObject 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);
}
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method getSelectedBioPaxObject.
private BioPaxObject getSelectedBioPaxObject() {
ArrayList<Object> selectedObjects = selectionManager.getSelectedObjects(BioPaxObject.class);
BioPaxObject selectedBioPaxObject = null;
if (selectedObjects.size() == 1 && selectedObjects.get(0) instanceof BioPaxObject) {
selectedBioPaxObject = (BioPaxObject) selectedObjects.get(0);
}
return selectedBioPaxObject;
}
Aggregations