use of org.vcell.pathway.GroupObject 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);
}
}
}
}
}
}
use of org.vcell.pathway.GroupObject 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();
}
use of org.vcell.pathway.GroupObject in project vcell by virtualcell.
the class PathwayGraphModel method refreshGroupObject.
private void refreshGroupObject(GroupObject groupObject) {
for (BioPaxObject bpObject : groupObject.getGroupedObjects()) {
if (bpObject instanceof Conversion) {
// Conversions inside groupObject
Conversion conversion = (Conversion) bpObject;
refreshInteraction(conversion);
} else if (bpObject instanceof MolecularInteraction) {
// molecularInteraction inside groupObject
MolecularInteraction molecularInteraction = (MolecularInteraction) bpObject;
refreshInteraction(molecularInteraction);
} else if (bpObject instanceof GroupObject) {
// groupObject inside another groupObject
refreshGroupObject((GroupObject) bpObject);
}
}
}
use of org.vcell.pathway.GroupObject 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.GroupObject 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);
}
}
Aggregations