use of cbit.vcell.model.RbmObservable in project vcell by virtualcell.
the class SpeciesPatternLargeShape method paintSelf.
public void paintSelf(Graphics g, boolean bPaintContour) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (shapePanel.getDisplayMode() == DisplayMode.participantSignatures) {
if (bMatchesSignature == true) {
paintMatchesSignatureContour(g);
}
} else if (bPaintContour && (owner instanceof RbmObservable || owner instanceof ReactionRule)) {
paintContour(g);
}
// TODO: bring this back once we add compartments to species patterns
paintCompartment(g);
if (speciesShapes.isEmpty()) {
// paint empty dummy
MolecularTypeLargeShape.paintDummy(g, xPos, yPos, shapePanel);
}
for (MolecularTypeLargeShape stls : speciesShapes) {
stls.paintSelf(g);
}
if (owner instanceof RbmObservable) {
// endText = "Right click here to add a molecule.";
endText = "";
}
// // matches between molecular types - only within reaction rules
// if(owner instanceof ReactionRule) {
// Color colorOld = g2.getColor();
// Font fontOld = g.getFont();
//
// Font font = MolecularComponentLargeShape.deriveComponentFontBold(graphicsContext);
// Color fontColor = Color.gray;
// Color lineColor = Color.lightGray;
// g2.setFont(font);
// g2.setColor(fontColor);
// for(MolecularTypeLargeShape mtls : speciesShapes) {
// MolecularTypePattern mtp = mtls.getMolecularTypePattern();
// if(!mtp.hasExplicitParticipantMatch()) {
// continue; // nothing to do if no explicit match
// }
// int x = mtls.getX()+10;
// int y = mtls.getY()-7;
// if(((ReactionRule)owner).isReactant(sp)) {
// g2.drawLine(x, y, x, y+6); // vertical line
// g2.drawLine(x+1, y, x+1, y+6);
//
// g2.drawLine(x, y, x+10, y); // line to right
// g2.drawLine(x, y+1, x+10, y+1);
//
// g2.drawString(mtp.getParticipantMatchLabel(), x+12, y+4);
// } else {
// g2.drawLine(x, y, x, y+6);
// g2.drawLine(x+1, y, x+1, y+6);
//
// g2.drawLine(x, y, x-10, y); // line to left
// g2.drawLine(x, y+1, x-10, y+1);
//
// g2.drawString(mtp.getParticipantMatchLabel(), x+3, y+4); // the match label
// }
// }
// g2.setFont(fontOld);
// g2.setColor(colorOld);
// }
// --- ------- Bonds between components ------------------------------------------------------------------------
// initial height of vertical bar of matched bond
int yDouble = 18;
if (shapePanel != null) {
// arbitrary factor, to be determined
int Ratio = 1;
// negative if going smaller
int zoomFactor = shapePanel.getZoomFactor() * Ratio;
yDouble += zoomFactor;
}
// distance between 2 vertical line segments of "exists" bond
int yExists = 5;
// separation between 2 vertical line segments of "exists" bond
int ysExists = 3;
if (shapePanel != null) {
// negative if going smaller
double zoomFactor = (double) (shapePanel.getZoomFactor()) / 3.0;
yExists += (int) zoomFactor;
ysExists += (int) zoomFactor;
}
// bond related attributes
// offset of the bond id - we assume there will never be more than 99
final int xOneLetterOffset = 7;
final int xTwoLetterOffset = 13;
// default y distance between 2 adjacent bars
int separ = 5;
for (int i = 0; i < bondSingles.size(); i++) {
BondSingle bs = bondSingles.get(i);
Color colorOld = g2.getColor();
Font fontOld = g.getFont();
Color fontColor = Color.red;
Color lineColor = Color.red;
if (AbstractComponentShape.isHidden(owner, bs.mcp)) {
fontColor = getDefaultColor(Color.gray);
lineColor = getDefaultColor(Color.lightGray);
} else {
fontColor = getDefaultColor(Color.black);
lineColor = getDefaultColor(Color.gray);
}
if (bs.mcp.getBondType().equals(BondType.Possible)) {
// ? (Possible)
Graphics gc = shapePanel.getGraphics();
if (shapePanel.getZoomFactor() >= LargeShapeCanvas.SmallestZoomFactorWithText) {
Font font = MolecularComponentLargeShape.deriveComponentFontBold(gc, shapePanel);
g2.setFont(font);
g2.setColor(fontColor);
g2.drawString(bs.mcp.getBondType().symbol, bs.from.x - xOneLetterOffset, bs.from.y + yLetterOffset);
}
g2.setColor(lineColor);
g2.drawLine(bs.from.x, bs.from.y, bs.from.x, bs.from.y + ysExists);
g2.setColor(getDefaultColor(Color.gray));
g2.drawLine(bs.from.x + 1, bs.from.y, bs.from.x + 1, bs.from.y + ysExists);
g2.setColor(lineColor);
g2.drawLine(bs.from.x, bs.from.y + yExists, bs.from.x, bs.from.y + yExists + ysExists);
g2.setColor(getDefaultColor(Color.gray));
g2.drawLine(bs.from.x + 1, bs.from.y + yExists, bs.from.x + 1, bs.from.y + yExists + ysExists);
g2.setColor(lineColor);
g2.drawLine(bs.from.x, bs.from.y + yExists * 2, bs.from.x, bs.from.y + yExists * 2 + ysExists);
g2.setColor(getDefaultColor(Color.gray));
g2.drawLine(bs.from.x + 1, bs.from.y + yExists * 2, bs.from.x + 1, bs.from.y + yExists * 2 + ysExists);
} else if (bs.mcp.getBondType().equals(BondType.Exists)) {
// g2.setColor(plusSignGreen); // draw a green '+' sign
// g2.drawLine(bs.from.x-8, bs.from.y+6, bs.from.x-3, bs.from.y+6); // horizontal
// g2.drawLine(bs.from.x-8, bs.from.y+7, bs.from.x-3, bs.from.y+7);
// g2.drawLine(bs.from.x-6, bs.from.y+4, bs.from.x-6, bs.from.y+9); // vertical
// g2.drawLine(bs.from.x-5, bs.from.y+4, bs.from.x-5, bs.from.y+9);
g2.setColor(lineColor);
g2.drawLine(bs.from.x, bs.from.y, bs.from.x, bs.from.y + yExists * 2 + ysExists);
g2.setColor(getDefaultColor(Color.gray));
g2.drawLine(bs.from.x + 1, bs.from.y, bs.from.x + 1, bs.from.y + yExists * 2 + ysExists);
} else {
// g2.setColor(Color.red.darker()); // draw a dark red '-' sign
// g2.drawLine(bs.from.x-10, bs.from.y+5, bs.from.x-4, bs.from.y+5); // horizontal
// g2.drawLine(bs.from.x-10, bs.from.y+6, bs.from.x-4, bs.from.y+6);
// g2.drawLine(bs.from.x-6, bs.from.y+4, bs.from.x-6, bs.from.y+9); // vertical
// g2.drawLine(bs.from.x-5, bs.from.y+4, bs.from.x-5, bs.from.y+9);
// for BondType.None we show nothing at all
// below small black vertical line ended in a red "x" (comment out if not wanted)
// g2.setColor(lineColor);
// g2.drawLine(bs.from.x, bs.from.y, bs.from.x, bs.from.y+7);
// g2.setColor(Color.gray);
// g2.drawLine(bs.from.x+1, bs.from.y, bs.from.x+1, bs.from.y+7);
//
// int vo = 8;
// g2.setColor(Color.red);
// g2.drawLine(bs.from.x-3, bs.from.y+2+vo, bs.from.x+4, bs.from.y-2+vo);
// g2.setColor(Color.gray);
// g2.drawLine(bs.from.x-3, bs.from.y+3+vo, bs.from.x+4, bs.from.y-1+vo);
//
// g2.setColor(Color.red);
// g2.drawLine(bs.from.x-3, bs.from.y-2+vo, bs.from.x+4, bs.from.y+2+vo);
// g2.setColor(Color.gray);
// g2.drawLine(bs.from.x-3, bs.from.y-1+vo, bs.from.x+4, bs.from.y+3+vo);
// below small black vertical line (comment out if not wanted)
// int vo = 10;
// g2.setColor(lineColor);
// g2.drawLine(bs.from.x, bs.from.y, bs.from.x, bs.from.y+vo);
// g2.setColor(Color.gray);
// g2.drawLine(bs.from.x+1, bs.from.y, bs.from.x+1, bs.from.y+vo);
//
// small horizontal red line at the end of the vertical one
// g2.setColor(Color.gray);
// g2.drawLine(bs.from.x-1, bs.from.y+vo-1, bs.from.x+2, bs.from.y+vo-1);
// g2.setColor(Color.gray);
// g2.drawLine(bs.from.x-1, bs.from.y+vo, bs.from.x+2, bs.from.y+vo);
}
g.setFont(fontOld);
g2.setColor(colorOld);
}
switch(// variable distance on y between bonds, we draw them closer when there are many of them
bondPairs.size()) {
case 1:
case 2:
separ = 5;
break;
case 3:
case 4:
separ = 4;
break;
case 5:
case 6:
separ = 3;
break;
case 7:
case 8:
case 9:
separ = 2;
break;
default:
separ = 1;
}
for (int i = 0; i < bondPairs.size(); i++) {
BondPair bp = bondPairs.get(i);
Color colorOld = g2.getColor();
Font fontOld = g.getFont();
if (shapePanel.isShowDifferencesOnly()) {
g2.setColor(getDefaultColor(Color.gray));
} else {
g2.setColor(getDefaultColor(GraphConstants.bondHtmlColors[bp.id % GraphConstants.bondHtmlColors.length]));
}
g2.drawLine(bp.from.x, bp.from.y, bp.from.x, bp.from.y + yDouble + i * separ);
g2.drawLine(bp.to.x, bp.to.y, bp.to.x, bp.to.y + yDouble + i * separ);
g2.drawLine(bp.from.x, bp.from.y + yDouble + i * separ, bp.to.x, bp.to.y + yDouble + i * separ);
Graphics gc = shapePanel.getGraphics();
if (shapePanel.getZoomFactor() >= LargeShapeCanvas.SmallestZoomFactorWithText) {
Font font = MolecularComponentLargeShape.deriveComponentFontBold(gc, shapePanel);
g.setFont(font);
String nr = bp.id + "";
if (nr.length() < 2) {
g2.drawString(nr, bp.from.x - xOneLetterOffset, bp.from.y + yLetterOffset);
g2.drawString(nr, bp.to.x - xOneLetterOffset, bp.to.y + yLetterOffset);
} else {
g2.drawString(nr, bp.from.x - xTwoLetterOffset, bp.from.y + yLetterOffset);
g2.drawString(nr, bp.to.x - xTwoLetterOffset, bp.to.y + yLetterOffset);
}
}
g2.setColor(getDefaultColor(Color.lightGray));
g2.drawLine(bp.from.x + 1, bp.from.y + 1, bp.from.x + 1, bp.from.y + yDouble + i * separ);
g2.drawLine(bp.to.x + 1, bp.to.y + 1, bp.to.x + 1, bp.to.y + yDouble + i * separ);
g2.drawLine(bp.from.x, bp.from.y + yDouble + i * separ + 1, bp.to.x + 1, bp.to.y + yDouble + i * separ + 1);
g.setFont(fontOld);
g2.setColor(colorOld);
}
if (!endText.isEmpty()) {
Color colorOld = g2.getColor();
g2.setColor(getDefaultColor(Color.black));
g.drawString(endText, getRightEnd() + 20, yPos + 20);
g2.setColor(colorOld);
}
}
use of cbit.vcell.model.RbmObservable in project vcell by virtualcell.
the class SpeciesPatternLargeShape method getStructure.
public Structure getStructure() {
Structure structure = null;
if (owner instanceof ReactionRule) {
ReactionRule rr = (ReactionRule) owner;
ReactantPattern rp = rr.getReactantPattern(sp);
ProductPattern pp = rr.getProductPattern(sp);
if (rp != null) {
structure = rp.getStructure();
} else if (pp != null) {
structure = pp.getStructure();
} else {
structure = ((ReactionRule) owner).getStructure();
}
} else if (owner instanceof SpeciesContext && ((SpeciesContext) owner).hasSpeciesPattern()) {
structure = ((SpeciesContext) owner).getStructure();
} else if (owner instanceof RbmObservable) {
structure = ((RbmObservable) owner).getStructure();
}
return structure;
}
use of cbit.vcell.model.RbmObservable in project vcell by virtualcell.
the class SpeciesPatternRoundShape method paintSelf.
public void paintSelf(Graphics g, boolean bPaintContour) {
Graphics2D g2 = (Graphics2D) g;
Font fontOld = g2.getFont();
Color colorOld = g2.getColor();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// if(bPaintContour && (owner instanceof RbmObservable || owner instanceof ReactionRule)) {
// paintContour(g);
// }
// paintCompartment(g); // TODO: bring this back once we add compartments to species patterns
//
// if(speciesShapes.isEmpty()) { // paint empty dummy
// MolecularTypeLargeShape.paintDummy(g, xPos, yPos, shapePanel);
// }
// g2.setPaint(Color.green.darker().darker());
// Ellipse2D circle = new Ellipse2D.Double(xPos, yPos, 2*radius, 2*radius);
// g2.fill(circle);
// paint the bonds first as circles
// as we keep painting other shapes over the bonds, all the unwanted parts of the bonds will get hidden
//
// for(Pair<Integer, Integer> p : bondsSet) {
//
// MolecularTypeRoundShape mtrsFrom = speciesShapes.get(p.one);
// MolecularTypeRoundShape mtrsTo = speciesShapes.get(p.two);
//
// // Point p1 = new Point(mtrsFrom.xPos + MolecularTypeRoundShape.radius, mtrsFrom.yPos + MolecularTypeRoundShape.radius);
// // Point p2 = new Point(mtrsTo.xPos + MolecularTypeRoundShape.radius, mtrsTo.yPos + MolecularTypeRoundShape.radius);
// Point p1 = new Point(mtrsFrom.xPos, mtrsFrom.yPos);
// Point p2 = new Point(mtrsTo.xPos, mtrsTo.yPos);
//
// int dx = Math.abs(p1.x - p2.x);
// int dy = Math.abs(p1.y - p2.y);
// double len = Math.sqrt(Math.pow((double)dx, 2) + Math.pow((double)dy, 2));
//
// Point m = new Point((p1.x+p2.x)/2, (p1.y+p2.y)/2);
// // Point c = new Point(m.x+dy-MolecularTypeRoundShape.radius, m.y+dx-MolecularTypeRoundShape.radius);
// Point c = new Point(m.x+dy, m.y+dx);
//
//
// // Ellipse2D circle2 = new Ellipse2D.Double(c.x, c.y, len, len);
// Ellipse2D circle2 = new Ellipse2D.Double(c.x-8, c.y-8, len+9, len+9);
// g2.setPaint(Color.gray);
// g2.draw(circle2);
//
//
// }
Ellipse2D circle2 = new Ellipse2D.Double(xPos, yPos, 2 * radius, 2 * radius);
g2.setPaint(Color.lightGray);
g2.draw(circle2);
g.setFont(fontOld);
g.setColor(colorOld);
for (MolecularTypeRoundShape mtls : speciesShapes) {
mtls.paintSelf(g);
}
if (owner instanceof RbmObservable) {
// endText = "Right click here to add a molecule.";
endText = "";
}
if (!endText.isEmpty()) {
g.drawString(endText, getRightEnd() + 20, yPos + 20);
}
}
use of cbit.vcell.model.RbmObservable in project vcell by virtualcell.
the class AbstractMathMapping method getMathSymbol0.
/**
* Substitutes appropriate variables for speciesContext bindings
*
* @return cbit.vcell.parser.Expression
* @param origExp cbit.vcell.parser.Expression
* @param structureMapping cbit.vcell.mapping.StructureMapping
*/
protected final String getMathSymbol0(SymbolTableEntry ste, GeometryClass geometryClass) throws MappingException {
String steName = ste.getName();
if (ste instanceof Kinetics.KineticsParameter) {
Integer count = localNameCountHash.get(steName);
if (count == null) {
throw new MappingException("KineticsParameter " + steName + " not found in local name count");
}
if (count > 1 || steName.equals("J")) {
return steName + "_" + ste.getNameScope().getName();
// return getNameScope().getSymbolName(ste);
} else {
return steName;
}
}
if (ste instanceof LocalParameter && ((LocalParameter) ste).getNameScope() instanceof ReactionRule.ReactionRuleNameScope) {
Integer count = localNameCountHash.get(steName);
if (count == null) {
throw new MappingException("Reaction Rule Parameter " + steName + " not found in local name count");
}
if (count > 1 || steName.equals("J")) {
return steName + "_" + ste.getNameScope().getName();
// return getNameScope().getSymbolName(ste);
} else {
return steName;
}
}
if (ste instanceof ProbabilityParameter) {
// be careful here, to see if we need mangle the reaction name
ProbabilityParameter probParm = (ProbabilityParameter) ste;
return probParm.getName() + PARAMETER_PROBABLIITY_RATE_SUFFIX;
}
if (ste instanceof SpeciesConcentrationParameter) {
SpeciesConcentrationParameter concParm = (SpeciesConcentrationParameter) ste;
return concParm.getSpeciesContext().getName() + MATH_FUNC_SUFFIX_SPECIES_CONCENTRATION;
}
if (ste instanceof SpeciesCountParameter) {
SpeciesCountParameter countParm = (SpeciesCountParameter) ste;
return countParm.getSpeciesContext().getName() + MATH_VAR_SUFFIX_SPECIES_COUNT;
}
if (ste instanceof ObservableConcentrationParameter) {
ObservableConcentrationParameter concParm = (ObservableConcentrationParameter) ste;
return concParm.getObservable().getName() + MATH_FUNC_SUFFIX_SPECIES_CONCENTRATION;
}
if (ste instanceof ObservableCountParameter) {
ObservableCountParameter countParm = (ObservableCountParameter) ste;
return countParm.getObservable().getName() + MATH_VAR_SUFFIX_SPECIES_COUNT;
}
if (ste instanceof RbmObservable) {
RbmObservable observable = (RbmObservable) ste;
return observable.getName() + MATH_FUNC_SUFFIX_SPECIES_CONCENTRATION;
}
if (ste instanceof EventAssignmentOrRateRuleInitParameter) {
EventAssignmentOrRateRuleInitParameter eventInitParm = (EventAssignmentOrRateRuleInitParameter) ste;
// + MATH_FUNC_SUFFIX_EVENTASSIGN_OR_RATE_INIT;
return eventInitParm.getName();
}
if (ste instanceof RateRuleRateParameter) {
RateRuleRateParameter rateRuleRateParm = (RateRuleRateParameter) ste;
// + MATH_FUNC_SUFFIX_RATERULE_RATE;
return rateRuleRateParm.getName();
}
if (ste instanceof Model.ReservedSymbol) {
return steName;
}
if (ste instanceof Membrane.MembraneVoltage) {
return steName;
}
if (ste instanceof Structure.StructureSize) {
Structure structure = ((Structure.StructureSize) ste).getStructure();
StructureMapping.StructureMappingParameter sizeParameter = simContext.getGeometryContext().getStructureMapping(structure).getSizeParameter();
return getMathSymbol(sizeParameter, geometryClass);
}
if (ste instanceof ProxyParameter) {
ProxyParameter pp = (ProxyParameter) ste;
return getMathSymbol0(pp.getTarget(), geometryClass);
}
//
if (ste instanceof ModelParameter) {
ModelParameter mp = (ModelParameter) ste;
return mp.getName();
}
if (ste instanceof SpeciesContextSpec.SpeciesContextSpecParameter) {
SpeciesContextSpec.SpeciesContextSpecParameter scsParm = (SpeciesContextSpec.SpeciesContextSpecParameter) ste;
SpeciesContext speciesContext = ((SpeciesContextSpec) (scsParm.getNameScope().getScopedSymbolTable())).getSpeciesContext();
SpeciesContextMapping scm = getSpeciesContextMapping(speciesContext);
String speciesContextVarName = null;
if (scm.getVariable() != null) {
speciesContextVarName = scm.getVariable().getName();
} else {
speciesContextVarName = speciesContext.getName();
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_InitialConcentration) {
return speciesContextVarName + MATH_FUNC_SUFFIX_SPECIES_INIT_CONC_UNIT_PREFIX + TokenMangler.fixTokenStrict(scsParm.getUnitDefinition().getSymbol());
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_InitialCount) {
return speciesContextVarName + MATH_FUNC_SUFFIX_SPECIES_INIT_COUNT;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_DiffusionRate) {
return speciesContextVarName + PARAMETER_DIFFUSION_RATE_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_BoundaryValueXm) {
return speciesContextVarName + PARAMETER_BOUNDARY_XM_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_BoundaryValueXp) {
return speciesContextVarName + PARAMETER_BOUNDARY_XP_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_BoundaryValueYm) {
return speciesContextVarName + PARAMETER_BOUNDARY_YM_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_BoundaryValueYp) {
return speciesContextVarName + PARAMETER_BOUNDARY_YP_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_BoundaryValueZm) {
return speciesContextVarName + PARAMETER_BOUNDARY_ZM_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_BoundaryValueZp) {
return speciesContextVarName + PARAMETER_BOUNDARY_ZP_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_VelocityX) {
return speciesContextVarName + PARAMETER_VELOCITY_X_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_VelocityY) {
return speciesContextVarName + PARAMETER_VELOCITY_Y_SUFFIX;
}
if (scsParm.getRole() == SpeciesContextSpec.ROLE_VelocityZ) {
return speciesContextVarName + PARAMETER_VELOCITY_Z_SUFFIX;
}
}
if (ste instanceof ElectricalDevice.ElectricalDeviceParameter) {
ElectricalDevice.ElectricalDeviceParameter edParm = (ElectricalDevice.ElectricalDeviceParameter) ste;
ElectricalDevice electricalDevice = (ElectricalDevice) edParm.getNameScope().getScopedSymbolTable();
if (electricalDevice instanceof MembraneElectricalDevice) {
String nameWithScope = ((MembraneElectricalDevice) electricalDevice).getMembraneMapping().getMembrane().getNameScope().getName();
if (edParm.getRole() == ElectricalDevice.ROLE_TotalCurrent) {
return PARAMETER_TOTAL_CURRENT_PREFIX + nameWithScope;
}
if (edParm.getRole() == ElectricalDevice.ROLE_TransmembraneCurrent) {
return PARAMETER_TRANSMEMBRANE_CURRENT_PREFIX + nameWithScope;
}
// }else if (electricalDevice instanceof CurrentClampElectricalDevice) {
// if (edParm.getRole()==ElectricalDevice.ROLE_TotalCurrentDensity){
// return "I_"+((CurrentClampElectricalDevice)electricalDevice).getCurrentClampStimulus().getNameScope().getName();
// }
// if (edParm.getRole()==ElectricalDevice.ROLE_TransmembraneCurrentDensity){
// return "F_"+((CurrentClampElectricalDevice)electricalDevice).getCurrentClampStimulus().getNameScope().getName();
// }
// }else if (electricalDevice instanceof VoltageClampElectricalDevice) {
// if (edParm.getRole()==ElectricalDevice.ROLE_TotalCurrentDensity){
// return "I_"+((VoltageClampElectricalDevice)electricalDevice).getVoltageClampStimulus().getNameScope().getName();
// }
// if (edParm.getRole()==ElectricalDevice.ROLE_TransmembraneCurrentDensity){
// return "F_"+((VoltageClampElectricalDevice)electricalDevice).getVoltageClampStimulus().getNameScope().getName();
// }
}
}
if (ste instanceof LocalParameter && ((LocalParameter) ste).getNameScope() instanceof ElectricalStimulus.ElectricalStimulusNameScope) {
LocalParameter esParm = (LocalParameter) ste;
String nameWithScope = esParm.getNameScope().getName();
if (esParm.getRole() == ElectricalStimulus.ElectricalStimulusParameterType.TotalCurrent) {
return PARAMETER_TOTAL_CURRENT_PREFIX + nameWithScope;
} else if (esParm.getRole() == ElectricalStimulus.ElectricalStimulusParameterType.Voltage) {
return PARAMETER_VOLTAGE_PREFIX + nameWithScope;
}
}
if (ste instanceof StructureMapping.StructureMappingParameter) {
StructureMapping.StructureMappingParameter smParm = (StructureMapping.StructureMappingParameter) ste;
Structure structure = ((StructureMapping) (smParm.getNameScope().getScopedSymbolTable())).getStructure();
String nameWithScope = structure.getNameScope().getName();
int role = smParm.getRole();
if (role == StructureMapping.ROLE_InitialVoltage) {
return smParm.getName();
} else if (role == StructureMapping.ROLE_SpecificCapacitance) {
return PARAMETER_SPECIFIC_CAPACITANCE_PREFIX + nameWithScope;
} else if (role == StructureMapping.ROLE_Size) {
if (simContext.getGeometry().getDimension() == 0) {
// if geometry is compartmental, make sure compartment sizes are set if referenced in model.
if (smParm.getExpression() == null || smParm.getExpression().isZero()) {
throw new MappingException("\nIn non-spatial application '" + getSimulationContext().getName() + "', " + "size of structure '" + structure.getName() + "' must be assigned a " + "positive value if referenced in the model.\n\nPlease go to 'Structure Mapping' tab to check the size.");
}
}
return PARAMETER_SIZE_FUNCTION_PREFIX + nameWithScope;
} else if (role == StructureMapping.ROLE_AreaPerUnitArea) {
return "AreaPerUnitArea_" + nameWithScope;
} else if (role == StructureMapping.ROLE_AreaPerUnitVolume) {
return "AreaPerUnitVolume_" + nameWithScope;
} else if (role == StructureMapping.ROLE_VolumePerUnitArea) {
return "VolumePerUnitArea_" + nameWithScope;
} else if (role == StructureMapping.ROLE_VolumePerUnitVolume) {
return "VolumePerUnitVolume_" + nameWithScope;
}
}
//
if (ste instanceof SpeciesContext) {
SpeciesContext sc = (SpeciesContext) ste;
SpeciesContextMapping scm = getSpeciesContextMapping(sc);
if (scm == null) {
throw new RuntimeException("Species '" + sc.getName() + "' is referenced in model but may have been deleted. " + "Find its references in '" + GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_BIOMODEL_PARAMETERS + "'.");
}
//
if (geometryClass instanceof SubVolume) {
//
if (scm.getVariable() != null && !scm.getVariable().getName().equals(steName)) {
return scm.getVariable().getName();
}
//
// for reactions within a surface, may need "_INSIDE" or "_OUTSIDE" for jump condition
//
} else if (geometryClass instanceof SurfaceClass) {
//
// if the speciesContext is also within the surface, replace SpeciesContext name with Variable name
//
StructureMapping sm = simContext.getGeometryContext().getStructureMapping(sc.getStructure());
if (sm.getGeometryClass() == geometryClass) {
if (scm.getVariable() != null && !(scm.getVariable().getName().equals(ste.getName()))) {
return scm.getVariable().getName();
}
//
// if the speciesContext is "inside" or "outside" the membrane
//
} else if (sm.getGeometryClass() instanceof SubVolume && ((SurfaceClass) geometryClass).isAdjacentTo((SubVolume) sm.getGeometryClass())) {
SpeciesContextSpec scs = simContext.getReactionContext().getSpeciesContextSpec(sc);
if (!scs.isConstant()) {
if (!scs.isDiffusing() && !scs.isWellMixed()) {
throw new MappingException("Enable diffusion in Application '" + simContext.getName() + "'. This must be done for any species (e.g '" + sc.getName() + "') in flux reactions.\n\n" + "To save or run simulations, set the diffusion rate to a non-zero " + "value in Initial Conditions or disable those reactions in Specifications->Reactions.");
}
}
if (scm.getVariable() != null) {
return scm.getVariable().getName();
}
} else {
throw new MappingException("species '" + sc.getName() + "' interacts with surface '" + geometryClass.getName() + "', but is not mapped spatially adjacent");
}
}
}
return getNameScope().getSymbolName(ste);
}
use of cbit.vcell.model.RbmObservable in project vcell by virtualcell.
the class MolecularComponentLargeShape method setComponentColor.
private Color setComponentColor() {
boolean highlight = isHighlighted();
if (owner == null) {
return highlight == true ? componentBad.brighter() : componentBad;
}
Color componentColor = highlight == true ? componentBad.brighter() : componentBad;
if (owner instanceof MolecularType) {
componentColor = highlight == true ? componentPaleYellow.brighter() : componentPaleYellow;
} else if (owner instanceof SpeciesContext) {
if (shapePanel != null && !shapePanel.isShowNonTrivialOnly()) {
componentColor = componentHidden;
} else {
componentColor = highlight == true ? componentPaleYellow.brighter() : componentPaleYellow;
}
} else if (mcp != null && owner instanceof RbmObservable) {
if (shapePanel != null && !shapePanel.isEditable()) {
componentColor = componentHidden;
} else {
componentColor = highlight == true ? componentHidden.brighter() : componentHidden;
}
if (mcp.getBondType() != BondType.Possible) {
componentColor = highlight == true ? componentPaleYellow.brighter() : componentPaleYellow;
}
} else if (owner instanceof ReactionRule) {
ReactionRule reactionRule = (ReactionRule) owner;
if (shapePanel.getDisplayMode() == DisplayMode.participantSignatures) {
componentColor = componentHidden;
if (shapePanel.isShowNonTrivialOnly() == true) {
if (mcp.getBondType() != BondType.Possible) {
componentColor = componentPaleYellow;
} else {
componentColor = componentHidden;
}
}
if (shapePanel.isShowDifferencesOnly()) {
switch(shapePanel.hasBondChanged(reactionRule.getName(), mcp)) {
case CHANGED:
componentColor = Color.orange;
break;
case ANALYSISFAILED:
ArrayList<Issue> issueList = new ArrayList<Issue>();
reactionRule.gatherIssues(new IssueContext(), issueList);
boolean bRuleHasErrorIssues = false;
for (Issue issue : issueList) {
if (issue.getSeverity() == Severity.ERROR) {
bRuleHasErrorIssues = true;
break;
}
}
if (bRuleHasErrorIssues) {
componentColor = componentHidden;
} else {
System.err.println("ReactionRule Analysis failed, but there are not Error Issues with ReactionRule " + reactionRule.getName());
componentColor = Color.red.darker();
}
break;
default:
break;
}
}
} else if (shapePanel.getDisplayMode() == DisplayMode.rules) {
componentColor = componentHidden;
if (shapePanel.isShowNonTrivialOnly() == true) {
if (mcp.getBondType() != BondType.Possible) {
componentColor = componentPaleYellow;
} else {
componentColor = componentHidden;
}
}
if (shapePanel.isShowDifferencesOnly()) {
switch(shapePanel.hasBondChanged(mcp)) {
case CHANGED:
componentColor = Color.orange;
break;
case ANALYSISFAILED:
ArrayList<Issue> issueList = new ArrayList<Issue>();
reactionRule.gatherIssues(new IssueContext(), issueList);
boolean bRuleHasErrorIssues = false;
for (Issue issue : issueList) {
if (issue.getSeverity() == Severity.ERROR) {
bRuleHasErrorIssues = true;
break;
}
}
if (bRuleHasErrorIssues) {
componentColor = componentHidden;
} else {
System.err.println("ReactionRule Analysis failed, but there are not Error Issues with ReactionRule " + reactionRule.getName());
componentColor = Color.red.darker();
}
break;
default:
break;
}
}
} else {
componentColor = highlight == true ? componentHidden.brighter() : componentHidden;
if (mcp.getBondType() != BondType.Possible) {
componentColor = highlight == true ? componentPaleYellow.brighter() : componentPaleYellow;
}
}
}
if (hasErrorIssues(owner, mcp, mc)) {
componentColor = highlight == true ? componentBad.brighter() : componentBad;
}
return componentColor;
}
Aggregations