use of cbit.vcell.model.Membrane in project vcell by virtualcell.
the class ReactionCartoonTool method lineAction.
private void lineAction(Structure startStructure, SpeciesContext speciesContextEnd) throws PropertyVetoException, Exception {
Structure endStructure = speciesContextEnd.getStructure();
Model model = getModel();
ReactionStep reaction = null;
Point startPos = edgeShape.getStart();
Point endPos = edgeShape.getEnd();
Structure reactionStructure = null;
if (startStructure != endStructure) {
if (startStructure instanceof Feature && endStructure instanceof Feature) {
// Feature ==> Feature-speciesContext
Feature startFeature = (Feature) startStructure;
Feature endFeature = (Feature) endStructure;
// Feature ==> feature-speciesContext with no membrane between : create a 0th-order simpleReaction in startFeature with GeneralLumpedKinetics
reactionStructure = startStructure;
reaction = model.createSimpleReaction(reactionStructure);
reaction.setKinetics(new GeneralLumpedKinetics(reaction));
} else if (startStructure instanceof Feature && endStructure instanceof Membrane) {
// Feature ==> membrane-species : Create volume species ; create membrane reaction ; add volume species as reactant and membrane species(End) as product.
reactionStructure = endStructure;
reaction = model.createSimpleReaction(reactionStructure);
SpeciesContext startingSpeciesContext = model.createSpeciesContext(startStructure);
reaction.addReactant(startingSpeciesContext, 1);
positionShapeForObject(startStructure, startingSpeciesContext, startPos);
} else if (startStructure instanceof Membrane && endStructure instanceof Feature) {
// Membrane ==> Feature-species : 0th-order reaction in membrane
reactionStructure = startStructure;
reaction = model.createSimpleReaction(reactionStructure);
} else if (startStructure instanceof Membrane && endStructure instanceof Membrane) {
// Membrane ==> membrane-species : the 2 membranes are different : create a 0th-order lumped simpleReaction in startMembrane
reactionStructure = startStructure;
reaction = model.createSimpleReaction(reactionStructure);
reaction.setKinetics(new GeneralLumpedKinetics(reaction));
}
} else {
// startStructure == endStructure : 0th-order simplereaction in structure
reactionStructure = startStructure;
reaction = model.createSimpleReaction(reactionStructure);
}
// speciesContextEnd should be added as a product to reaction (if not flux).
if (!(reaction instanceof FluxReaction)) {
reaction.addProduct(speciesContextEnd, 1);
}
positionShapeForObject(reactionStructure, reaction, new Point((2 * startPos.x + 8 * endPos.x) / 10, (2 * startPos.y + 8 * endPos.y) / 10));
getReactionCartoon().notifyChangeEvent();
getGraphModel().clearSelection();
getGraphModel().select(reaction);
}
use of cbit.vcell.model.Membrane in project vcell by virtualcell.
the class ReactStepDbDriver method populateStructureAndElectricalTopology.
public static void populateStructureAndElectricalTopology(Model model, HashMap<KeyValue, StructureKeys> structureKeysMap) throws DataAccessException {
//
for (Structure structure : model.getStructures()) {
// get parent struct
KeyValue parentKey = structureKeysMap.get(structure.getKey()).parentKey;
Structure parentStructure = null;
if (parentKey != null) {
for (Structure struct1 : model.getStructures()) {
if (struct1.getKey().equals(parentKey)) {
parentStructure = struct1;
break;
}
}
}
if (parentStructure != null) {
StructureTopology structureTopology = model.getStructureTopology();
if (structure instanceof Feature) {
Feature feature = (Feature) structure;
if (parentStructure instanceof Feature) {
// feature.setParentFeature((Feature)parent);
throw new DataAccessException("Feature is not permitted to be the parent of another feature");
} else if (parentStructure instanceof Membrane) {
structureTopology.setInsideFeature((Membrane) parentStructure, feature);
}
} else if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
if (parentStructure instanceof Feature) {
structureTopology.setOutsideFeature(membrane, (Feature) parentStructure);
} else {
throw new DataAccessException("Membrane '" + membrane.getName() + "' is not permitted to be the parent of another membrane '" + parentStructure.getName());
}
}
}
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
KeyValue negKey = structureKeysMap.get(structure.getKey()).negKey;
if (negKey != null) {
for (Structure struct : model.getStructures()) {
if (struct instanceof Feature && struct.getKey().equals(negKey)) {
Feature feature = (Feature) struct;
model.getElectricalTopology().setNegativeFeature(membrane, feature);
break;
}
}
}
KeyValue posKey = structureKeysMap.get(structure.getKey()).posKey;
if (posKey != null) {
for (Structure struct : model.getStructures()) {
if (struct instanceof Feature && struct.getKey().equals(posKey)) {
Feature feature = (Feature) struct;
model.getElectricalTopology().setPositiveFeature(membrane, feature);
break;
}
}
}
}
}
}
use of cbit.vcell.model.Membrane 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.Membrane in project vcell by virtualcell.
the class ReactionCartoonTool method lineAction.
private void lineAction(SpeciesContext speciesContextStart, SpeciesContext speciesContextEnd) throws Exception {
Structure endStructure = speciesContextEnd.getStructure();
Structure startStructure = speciesContextStart.getStructure();
Model model = getModel();
ReactionStep reaction = null;
Point startPos = edgeShape.getStart();
Point endPos = edgeShape.getEnd();
Structure reactionStructure = null;
boolean bLumpedKinetics = false;
if (startStructure != endStructure) {
if (startStructure instanceof Feature && endStructure instanceof Feature) {
// Feature-speciesContext ==> Feature-speciesContext
Membrane membraneBetween = model.getStructureTopology().getMembrane((Feature) startStructure, (Feature) endStructure);
// Feature-speciesContext ==> Feature-speciesContext with membrane in between : add reaction in Membrane (scStart : reactant; scEnd : pdt)
if (membraneBetween != null) {
reactionStructure = membraneBetween;
} else {
// Feature-speciesContext ==> Feature-speciesContext with no membrane between : create a lumped reaction in startFeature
reactionStructure = startStructure;
bLumpedKinetics = true;
}
} else if (startStructure instanceof Feature && endStructure instanceof Membrane) {
// Feature-speciesContext ==> Membrane-speciesContext : create membrane reaction ; add scStart : reactant and scEnd : pdt.
reactionStructure = endStructure;
} else if (startStructure instanceof Membrane && endStructure instanceof Feature) {
// Membrane-speciesContext ==> Feature-speciesContext : create reaction in membrane; scStart : reactant, scEnd : pdt.
reactionStructure = startStructure;
} else if (startStructure instanceof Membrane && endStructure instanceof Membrane) {
// Membrane-speciesContext ==> Membrane-speciesContext : the 2 membranes are different : create lumped reaction in endMembrane
reactionStructure = endStructure;
bLumpedKinetics = true;
}
} else {
// startStructure == endStructure : create reaction in structure
reactionStructure = startStructure;
}
reaction = model.createSimpleReaction(reactionStructure);
if (bLumpedKinetics) {
reaction.setKinetics(new GeneralLumpedKinetics(reaction));
}
reaction.addReactant(speciesContextStart, 1);
reaction.addProduct(speciesContextEnd, 1);
positionShapeForObject(reactionStructure, reaction, new Point((startPos.x + endPos.x) / 2, (startPos.y + endPos.y) / 2));
getReactionCartoon().notifyChangeEvent();
getGraphModel().clearSelection();
getGraphModel().select(reaction);
}
use of cbit.vcell.model.Membrane in project vcell by virtualcell.
the class ReactionCartoonTool method mouseClicked.
@Override
public void mouseClicked(MouseEvent event) {
Point screenPoint = new Point(event.getX(), event.getY());
Point worldPoint = screenToWorld(screenPoint);
try {
if (event.getButton() != MouseEvent.BUTTON1) {
return;
}
switch(mode) {
case SELECT:
{
if (event.getClickCount() == 2) {
final Shape selectedShape = getReactionCartoon().getSelectedShape();
if (selectedShape instanceof ReactionContainerShape || selectedShape instanceof SpeciesContextShape || selectedShape instanceof SimpleReactionShape || selectedShape instanceof FluxReactionShape || selectedShape instanceof ReactionRuleDiagramShape || selectedShape instanceof RuleParticipantSignatureDiagramShape) {
editInPlace(selectedShape, worldPoint);
}
if (selectedShape != null) {
menuAction(selectedShape, CartoonToolMiscActions.Properties.MENU_ACTION);
}
}
break;
}
case STEP:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
if (getReactionCartoon().getStructureSuite().areReactionsShownFor(structure)) {
ReactionStep reactionStep = getReactionCartoon().getModel().createSimpleReaction(structure);
positionShapeForObject(structure, reactionStep, worldPoint);
saveDiagram();
}
}
break;
}
case FLUX:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
Structure structure = ((ReactionContainerShape) pickedShape).getStructure();
if (structure instanceof Membrane) {
Membrane membrane = (Membrane) structure;
FluxReaction fluxReaction = getReactionCartoon().getModel().createFluxReaction(membrane);
ReactionStepShape frShape = (ReactionStepShape) getReactionCartoon().getShapeFromModelObject(fluxReaction);
Point parentLocation = frShape.getParent().getSpaceManager().getAbsLoc();
frShape.getSpaceManager().setRelPos(worldPoint.x - parentLocation.x, worldPoint.y - parentLocation.y);
saveDiagram();
// setMode(SELECT_MODE);
} else {
// setMode(SELECT_MODE);
// throw new Exception("fluxes only applicable to membranes");
}
}
break;
}
case SPECIES:
{
Shape pickedShape = getReactionCartoon().pickWorld(worldPoint);
if (pickedShape instanceof ReactionContainerShape) {
SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(((ReactionContainerShape) pickedShape).getStructure());
reactionCartoon.clearSelection();
getGraphModel().select(speciesContext);
positionShapeForObject(speciesContext.getStructure(), speciesContext, worldPoint);
// showCreateSpeciesContextDialog(getGraphPane(), getReactionCartoon().getModel(), ((ReactionContainerShape) pickedShape).getStructure(), scShapeLocation);
saveDiagram();
}
}
default:
break;
}
} catch (Exception e) {
System.out.println("CartoonTool.mouseClicked: uncaught exception");
e.printStackTrace(System.out);
Point canvasLoc = getGraphPane().getLocationOnScreen();
canvasLoc.x += screenPoint.x;
canvasLoc.y += screenPoint.y;
DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
}
}
Aggregations