use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class PathwayGraphModel method relationshipChanged.
public void relationshipChanged(RelationshipEvent event) {
Shape shape = getShapeFromModelObject(event.getRelationshipObject());
refreshRelationshipInfo(shape);
refreshAll();
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class ShapeGroupUtil method shapesCanBeMadeGroup.
/*
* Shapes can be made a group if they each are eligible and if for any two
* shapes the next non-eligible ancestor (e.g. compartment) is the same.
* This excludes nodes in different compartments
*/
public static boolean shapesCanBeMadeGroup(Set<Shape> shapes) {
boolean bCanBeMadeGroup = true;
Set<Shape> eligibleAncestors = new HashSet<Shape>();
Set<Shape> ineligibleAncestors = new HashSet<Shape>();
for (Shape shape : shapes) {
if (!willBeSkippedWhenGrouping(shape)) {
if (!isEligibleAsGroupMember(shape)) {
bCanBeMadeGroup = false;
break;
}
Shape parent = shape.getParent();
if (parent != null) {
if (isEligibleAsGroupMember(parent)) {
eligibleAncestors.add(parent);
} else {
ineligibleAncestors.add(parent);
if (ineligibleAncestors.size() > 1) {
bCanBeMadeGroup = false;
break;
}
}
}
}
}
while (bCanBeMadeGroup && !eligibleAncestors.isEmpty()) {
Set<Shape> eligibleAncestorsNew = new HashSet<Shape>();
for (Shape ancestor : eligibleAncestors) {
Shape parent = ancestor.getParent();
if (isEligibleAsGroupMember(parent)) {
eligibleAncestorsNew.add(parent);
} else {
ineligibleAncestors.add(parent);
if (ineligibleAncestors.size() > 1) {
bCanBeMadeGroup = false;
break;
}
}
}
eligibleAncestors = eligibleAncestorsNew;
}
return bCanBeMadeGroup;
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class VCGroupManager method collapseExistingGroups.
public void collapseExistingGroups() {
GraphModel graphModel = graphView.getGraphModel();
List<Shape> selectedShapes = graphModel.getSelectedShapes();
for (Shape selectedShape : selectedShapes) {
Shape parentShape = selectedShape.getParent();
if (parentShape != null) {
ShapeGroupUtil.collapseGroup(parentShape);
}
}
graphView.repaint();
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class ModelCartoon method refreshRelationshipInfo.
public final void refreshRelationshipInfo(RelationshipModel relationshipModel) {
for (RelationshipObject relationship : relationshipModel.getRelationshipObjects()) {
BioModelEntityObject bioModelEntity = relationship.getBioModelEntityObject();
Shape shape = getShapeFromModelObject(bioModelEntity);
if (shape instanceof SpeciesContextShape) {
SpeciesContextShape scShape = (SpeciesContextShape) shape;
scShape.setLinkText("L");
} else if (shape instanceof SimpleReactionShape) {
SimpleReactionShape srShape = (SimpleReactionShape) shape;
srShape.setLinkText("L");
} else if (shape instanceof ReactionRuleDiagramShape) {
ReactionRuleDiagramShape srShape = (ReactionRuleDiagramShape) shape;
srShape.setLinkText("L");
}
}
}
use of cbit.gui.graph.Shape in project vcell by virtualcell.
the class ModelCartoon method relationshipChanged.
public void relationshipChanged(RelationshipEvent event) {
RelationshipObject relationshipObject = event.getRelationshipObject();
if (event.getOperationType() == event.ADDED) {
Shape shape = getShapeFromModelObject(relationshipObject.getBioModelEntityObject());
if (shape instanceof SpeciesContextShape) {
SpeciesContextShape scShape = (SpeciesContextShape) shape;
scShape.setLinkText("L");
} else if (shape instanceof SimpleReactionShape) {
SimpleReactionShape srShape = (SimpleReactionShape) shape;
srShape.setLinkText("L");
} else if (shape instanceof ReactionRuleDiagramShape) {
ReactionRuleDiagramShape srShape = (ReactionRuleDiagramShape) shape;
srShape.setLinkText("L");
}
} else if (event.getOperationType() == event.REMOVED) {
Shape shape = getShapeFromModelObject(relationshipObject.getBioModelEntityObject());
if (shape instanceof SpeciesContextShape) {
SpeciesContextShape scShape = (SpeciesContextShape) shape;
scShape.setLinkText("");
// if the BioModelEntity Object is still linked with other BioPax objects, we add the "L" shape back
if (((RelationshipModel) event.getSource()).getRelationshipObjects(relationshipObject.getBioModelEntityObject()).size() > 0) {
scShape.setLinkText("L");
}
} else if (shape instanceof SimpleReactionShape) {
SimpleReactionShape srShape = (SimpleReactionShape) shape;
srShape.setLinkText("");
if (((RelationshipModel) event.getSource()).getRelationshipObjects(relationshipObject.getBioModelEntityObject()).size() > 0) {
srShape.setLinkText("L");
}
} else if (shape instanceof ReactionRuleDiagramShape) {
ReactionRuleDiagramShape srShape = (ReactionRuleDiagramShape) shape;
srShape.setLinkText("");
if (((RelationshipModel) event.getSource()).getRelationshipObjects(relationshipObject.getBioModelEntityObject()).size() > 0) {
srShape.setLinkText("L");
}
}
}
}
Aggregations