use of cbit.vcell.model.SimpleReaction in project vcell by virtualcell.
the class ReactionCartoonTool method lineActon.
private void lineActon(Structure startStructure, ReactionStep reactionEnd) throws Exception {
Structure endStructure = reactionEnd.getStructure();
if (StructureUtil.reactionHereCanHaveParticipantThere(endStructure, startStructure)) {
// if reactionStart is a SimpleRxn OR FluxRxn without a product, add speciesContext as reactant
if ((reactionEnd instanceof SimpleReaction) || ((reactionEnd instanceof FluxReaction) && !reactionEnd.hasReactant())) {
SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(startStructure);
reactionEnd.addReactant(speciesContext, 1);
positionShapeForObject(startStructure, speciesContext, edgeShape.getStart());
}
if (((startStructure instanceof Feature && endStructure instanceof Feature) || (startStructure instanceof Membrane && endStructure instanceof Membrane)) && startStructure != endStructure) {
// ============ change kinetics to lumped or warn user ?????????
// simpleReaction.setKinetics(new GeneralLumpedKinetics(simpleReaction));
}
getReactionCartoon().notifyChangeEvent();
}
}
use of cbit.vcell.model.SimpleReaction in project vcell by virtualcell.
the class ReactionCartoonTool method getLineTypeFromDirection.
private LineType getLineTypeFromDirection(Shape startingShape, Point worldPoint) throws Exception {
Shape mouseOverShape = getReactionCartoon().pickWorld(worldPoint);
if (mouseOverShape instanceof ReactionStepShape) {
if (startingShape instanceof SpeciesContextShape) {
SpeciesContext speciesContext = (SpeciesContext) startingShape.getModelObject();
// check if the ReactionStep already has a Product for this SpeciesContext
ReactionStep reactionStep = (ReactionStep) mouseOverShape.getModelObject();
ReactionParticipant[] rps = reactionStep.getReactionParticipants();
if ((mouseOverShape instanceof SimpleReactionShape) || (mouseOverShape instanceof FluxReactionShape)) {
for (int i = 0; i < rps.length; i++) {
if (rps[i] instanceof Reactant && rps[i].getSpeciesContext() == speciesContext) {
return LineType.NULL;
}
}
return LineType.REACTANT;
}
// else if (mouseOverShape instanceof FluxReactionShape){
// for (int i = 0; i < rps.length; i++){
// if ((rps[i] instanceof Reactant || rps[i] instanceof Product) && rps[i].getSpeciesContext() == speciesContext) {
// return LineType.NULL;
// }
// }
// return LineType.FLUX;
// }
}
} else if (mouseOverShape instanceof SpeciesContextShape) {
SpeciesContext speciesContext = (SpeciesContext) mouseOverShape.getModelObject();
if (startingShape instanceof SpeciesContextShape) {
// straight from one species to another ... will create a reaction upon release
return LineType.PRODUCT;
} else if (startingShape instanceof ReactionStepShape) {
ReactionStep reactionStep = (ReactionStep) startingShape.getModelObject();
ReactionParticipant[] rps = reactionStep.getReactionParticipants();
// } else
if (reactionStep instanceof SimpleReaction || reactionStep instanceof FluxReaction) {
for (int i = 0; i < rps.length; i++) {
if (rps[i] instanceof Reactant && rps[i].getSpeciesContext() == speciesContext) {
return LineType.NULL;
}
}
return LineType.REACTANT;
}
}
}
return LineType.NULL;
}
use of cbit.vcell.model.SimpleReaction in project vcell by virtualcell.
the class ReactionCartoonTool method lineAction.
private void lineAction(SpeciesContext speciesContextStart, ReactionStep reactionEnd) throws Exception {
Structure endStructure = reactionEnd.getStructure();
Structure startStructure = speciesContextStart.getStructure();
if (StructureUtil.reactionHereCanHaveParticipantThere(endStructure, startStructure)) {
int stoichiometry = 1;
Reactant reactant = null;
for (ReactionParticipant participant : reactionEnd.getReactionParticipants()) {
if (participant instanceof Reactant && participant.getSpeciesContext().equals(speciesContextStart)) {
reactant = (Reactant) participant;
}
}
if (reactant != null) {
// only increase stoichiometry if reaction is SimpleReaction
if (reactionEnd instanceof SimpleReaction) {
reactant.setStoichiometry(reactant.getStoichiometry() + 1);
}
Shape shape = getReactionCartoon().getShapeFromModelObject(reactant);
if (shape != null) {
shape.refreshLabel();
}
} else {
// add speciesContextEnd as pdt to reactionStart only if reactionStart is a SimpleRxn or if it is a FluxRxn and doesn't have a pdt.
if (reactionEnd instanceof SimpleReaction || ((reactionEnd instanceof FluxReaction) && !(reactionEnd.hasReactant()))) {
reactionEnd.addReactant(speciesContextStart, stoichiometry);
}
}
if (((startStructure instanceof Feature && endStructure instanceof Feature) || (startStructure instanceof Membrane && endStructure instanceof Membrane)) && startStructure != endStructure) {
// ============ change kinetics to lumped or warn user ?????????
// simpleReactionEnd.setKinetics(new GeneralLumpedKinetics(simpleReactionEnd));
}
getReactionCartoon().notifyChangeEvent();
}
}
use of cbit.vcell.model.SimpleReaction in project vcell by virtualcell.
the class ReactionCartoonTool method lineAction.
private void lineAction(Structure startStructure, Structure endStructure, Shape endShape) throws Exception, PropertyVetoException, ExpressionException {
Point startPos = edgeShape.getStart();
Point endPos = edgeShape.getEnd();
if (endStructure.equals(startStructure)) {
SpeciesContext speciesContext1 = getReactionCartoon().getModel().createSpeciesContext(endStructure);
SpeciesContext speciesContext2 = getReactionCartoon().getModel().createSpeciesContext(endStructure);
SimpleReaction reaction = getReactionCartoon().getModel().createSimpleReaction(endStructure);
reaction.addReactant(speciesContext1, 1);
reaction.addProduct(speciesContext2, 1);
getReactionCartoon().notifyChangeEvent();
positionShapeForObject(endStructure, speciesContext1, startPos);
positionShapeForObject(endStructure, speciesContext2, endPos);
positionShapeForObject(endStructure, reaction, new Point((startPos.x + endPos.x) / 2, (startPos.y + endPos.y) / 2));
getGraphModel().clearSelection();
getGraphModel().select(reaction);
} else {
if (endStructure instanceof Membrane && startStructure instanceof Feature) {
Membrane endMembrane = (Membrane) endStructure;
Feature startFeature = (Feature) startStructure;
// if(structTopology.getOutsideFeature(endMembrane).equals(startFeature) || structTopology.getInsideFeature(endMembrane).equals(startFeature))
// {
SpeciesContext speciesContext1 = getReactionCartoon().getModel().createSpeciesContext(startFeature);
SpeciesContext speciesContext2 = getReactionCartoon().getModel().createSpeciesContext(endMembrane);
SimpleReaction reaction = getReactionCartoon().getModel().createSimpleReaction(endMembrane);
reaction.addReactant(speciesContext1, 1);
reaction.addProduct(speciesContext2, 1);
getReactionCartoon().notifyChangeEvent();
positionShapeForObject(startFeature, speciesContext1, startPos);
positionShapeForObject(endMembrane, speciesContext2, endPos);
// finding correct insertion point for reaction, statements below should be put into a utility if used often
int memAbsXmin = endShape.getSpaceManager().getAbsLoc().x;
int memAbsXmax = memAbsXmin + endShape.getSpaceManager().getSize().width;
int reactionWidth = new SimpleReactionShape(reaction, getReactionCartoon()).getSpaceManager().getSize().width;
int reactionAbsX = (startPos.x + endPos.x) / 2;
if ((memAbsXmax - memAbsXmin) <= reactionWidth) {
reactionAbsX = memAbsXmin;
} else {
reactionAbsX = Math.max(reactionAbsX, memAbsXmin);
reactionAbsX = Math.min(reactionAbsX, (memAbsXmax - reactionWidth));
}
positionShapeForObject(endMembrane, reaction, new Point(reactionAbsX, (startPos.y + endPos.y) / 2));
getGraphModel().clearSelection();
getGraphModel().select(reaction);
// }
} else if (endStructure instanceof Feature && startStructure instanceof Membrane) {
Membrane startMembrane = (Membrane) startStructure;
Feature endFeature = (Feature) endStructure;
// if(structTopology.getOutsideFeature(startMembrane).equals(endFeature) || structTopology.getInsideFeature(startMembrane).equals(endFeature))
// {
SpeciesContext speciesContext1 = getReactionCartoon().getModel().createSpeciesContext(startMembrane);
SpeciesContext speciesContext2 = getReactionCartoon().getModel().createSpeciesContext(endFeature);
SimpleReaction reaction = getReactionCartoon().getModel().createSimpleReaction(startMembrane);
reaction.addReactant(speciesContext1, 1);
reaction.addProduct(speciesContext2, 1);
getReactionCartoon().notifyChangeEvent();
positionShapeForObject(startMembrane, speciesContext1, startPos);
positionShapeForObject(endFeature, speciesContext2, endPos);
// finding correct insertion point for reaction, statements below should be put into a utility if used often
int memAbsXmin = startShape.getSpaceManager().getAbsLoc().x;
int memAbsXmax = memAbsXmin + startShape.getSpaceManager().getSize().width;
int reactionWidth = new SimpleReactionShape(reaction, getReactionCartoon()).getSpaceManager().getSize().width;
int reactionAbsX = (startPos.x + endPos.x) / 2;
if ((memAbsXmax - memAbsXmin) <= reactionWidth) {
reactionAbsX = memAbsXmin;
} else {
reactionAbsX = Math.max(reactionAbsX, memAbsXmin);
reactionAbsX = Math.min(reactionAbsX, (memAbsXmax - reactionWidth));
}
positionShapeForObject(startMembrane, reaction, new Point(reactionAbsX, (startPos.y + endPos.y) / 2));
getGraphModel().clearSelection();
getGraphModel().select(reaction);
// }
} else if (endStructure instanceof Feature && startStructure instanceof Feature) {
Feature startFeature = (Feature) startStructure;
Feature endFeature = (Feature) endStructure;
SpeciesContext speciesContext1 = getReactionCartoon().getModel().createSpeciesContext(startStructure);
SpeciesContext speciesContext2 = getReactionCartoon().getModel().createSpeciesContext(endStructure);
SimpleReaction reaction = getReactionCartoon().getModel().createSimpleReaction(startStructure);
reaction.addReactant(speciesContext1, 1);
reaction.addProduct(speciesContext2, 1);
reaction.setKinetics(new GeneralLumpedKinetics(reaction));
getReactionCartoon().notifyChangeEvent();
positionShapeForObject(startStructure, speciesContext1, startPos);
positionShapeForObject(endStructure, speciesContext2, endPos);
positionShapeForObject(startStructure, reaction, new Point((startPos.x + endPos.x) / 2, (startPos.y + endPos.y) / 2));
getGraphModel().clearSelection();
getGraphModel().select(reaction);
} else if (endStructure instanceof Membrane && startStructure instanceof Membrane) {
SpeciesContext speciesContext1 = getReactionCartoon().getModel().createSpeciesContext(startStructure);
SpeciesContext speciesContext2 = getReactionCartoon().getModel().createSpeciesContext(endStructure);
SimpleReaction reaction = getReactionCartoon().getModel().createSimpleReaction(startStructure);
reaction.addReactant(speciesContext1, 1);
reaction.addProduct(speciesContext2, 1);
reaction.setKinetics(new GeneralLumpedKinetics(reaction));
getReactionCartoon().notifyChangeEvent();
positionShapeForObject(startStructure, speciesContext1, startPos);
positionShapeForObject(endStructure, speciesContext2, endPos);
positionShapeForObject(startStructure, reaction, new Point((startPos.x + endPos.x) / 2, (startPos.y + endPos.y) / 2));
getGraphModel().clearSelection();
getGraphModel().select(reaction);
}
}
}
use of cbit.vcell.model.SimpleReaction in project vcell by virtualcell.
the class SimpleReactionPanel method setSimpleReaction.
/**
* Sets the simpleReaction property (cbit.vcell.model.SimpleReaction) value.
* @param simpleReaction The new value for the property.
* @see #getSimpleReaction
*/
public void setSimpleReaction(SimpleReaction simpleReaction) {
SimpleReaction oldValue = fieldSimpleReaction;
fieldSimpleReaction = simpleReaction;
firePropertyChange("simpleReaction", oldValue, simpleReaction);
}
Aggregations