use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.
the class StructureMappingPanel method setgeometryContext1.
/**
* Set the GeometryContext to a new value.
* @param newValue cbit.vcell.mapping.GeometryContext
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setgeometryContext1(GeometryContext newValue) {
if (ivjgeometryContext1 != newValue) {
try {
GeometryContext oldValue = getgeometryContext1();
/* Stop listening for events from the current object */
if (ivjgeometryContext1 != null) {
ivjgeometryContext1.removePropertyChangeListener(ivjEventHandler);
}
ivjgeometryContext1 = newValue;
/* Listen for events from the new object */
if (ivjgeometryContext1 != null) {
ivjgeometryContext1.addPropertyChangeListener(ivjEventHandler);
}
connPtoP3SetSource();
getVolumeSurfaceCalculatorPanel().setVisible(ivjgeometryContext1.getGeometry().getDimension() == 0);
getStructureMappingTableModel1().setGeometryContext(ivjgeometryContext1);
firePropertyChange(PROPERTY_GEOMETRY_CONTEXT, oldValue, newValue);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
;
// user code begin {3}
// user code end
}
use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.
the class MembraneStructureAnalyzer method refreshResolvedFluxes.
/**
* This method was created in VisualAge.
*/
void refreshResolvedFluxes() throws Exception {
// System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes()");
GeometryContext geoContext = mathMapping_4_8.getSimulationContext().getGeometryContext();
StructureTopology structTopology = mathMapping_4_8.getSimulationContext().getModel().getStructureTopology();
Vector<ResolvedFlux> resolvedFluxList = new Vector<ResolvedFlux>();
//
// for each reaction, get all fluxReactions associated with this membrane
//
Vector<ReactionStep> fluxList = new Vector<ReactionStep>();
ReactionSpec[] reactionSpecs = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpecs();
for (int j = 0; j < reactionSpecs.length; j++) {
if (reactionSpecs[j].isExcluded()) {
continue;
}
ReactionStep rs = reactionSpecs[j].getReactionStep();
if (rs.getStructure() == getMembrane()) {
if (rs instanceof FluxReaction) {
fluxList.addElement(rs);
}
}
}
//
for (int i = 0; i < fluxList.size(); i++) {
FluxReaction fr = (FluxReaction) fluxList.elementAt(i);
Species fluxCarrier = null;
for (ReactionParticipant rp : fr.getReactionParticipants()) {
if (rp instanceof Reactant || rp instanceof Product) {
if (fluxCarrier == null) {
fluxCarrier = rp.getSpecies();
} else {
if (fluxCarrier != rp.getSpecies()) {
throw new Exception("Flux reaction '" + fr.getName() + "' with multiple species not allowed in VCell 4.8.");
}
}
}
}
if (fluxCarrier == null) {
continue;
}
ResolvedFlux rf = null;
for (int j = 0; j < resolvedFluxList.size(); j++) {
ResolvedFlux rf_tmp = (ResolvedFlux) resolvedFluxList.elementAt(j);
if (rf_tmp.getSpecies() == fluxCarrier) {
rf = rf_tmp;
}
}
//
// if "inside" speciesContext is not "fixed", add flux to ResolvedFlux
//
SpeciesContext insideSpeciesContext = mathMapping_4_8.getSimulationContext().getModel().getSpeciesContext(fluxCarrier, structTopology.getInsideFeature(getMembrane()));
SpeciesContextSpec insideSpeciesContextSpec = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(insideSpeciesContext);
// if (!insideSpeciesContextSpec.isConstant()){
if (bNoFluxIfFixed || !insideSpeciesContextSpec.isConstant()) {
if (bNoFluxIfFixed && insideSpeciesContextSpec.isConstant()) {
bNoFluxIfFixedExercised = true;
}
if (rf == null) {
rf = new ResolvedFlux(fluxCarrier, fr.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_ReactionRate).getUnitDefinition());
resolvedFluxList.addElement(rf);
}
FeatureMapping insideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping((structTopology.getInsideFeature((Membrane) fr.getStructure())));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(insideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression insideFluxCorrection = Expression.invert(residualVolumeFraction);
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
insideFluxCorrection = new Expression(1.0);
}
//
if (fr.getKinetics() instanceof DistributedKinetics) {
Expression reactionRateParameter = new Expression(((DistributedKinetics) fr.getKinetics()).getReactionRateParameter(), mathMapping_4_8.getNameScope());
if (rf.inFluxExpression.isZero()) {
rf.inFluxExpression = Expression.mult(reactionRateParameter, insideFluxCorrection).flatten();
} else {
rf.inFluxExpression = Expression.add(rf.inFluxExpression, Expression.mult(reactionRateParameter, insideFluxCorrection).flatten());
}
} else if (fr.getKinetics() instanceof LumpedKinetics) {
throw new RuntimeException("Lumped Kinetics for fluxes not yet supported");
} else {
throw new RuntimeException("unexpected Kinetic type in MembraneStructureAnalyzer.refreshResolvedFluxes()");
}
// rf.inFlux.bindExpression(mathMapping);
}
SpeciesContext outsideSpeciesContext = mathMapping_4_8.getSimulationContext().getModel().getSpeciesContext(fluxCarrier, structTopology.getOutsideFeature(getMembrane()));
SpeciesContextSpec outsideSpeciesContextSpec = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(outsideSpeciesContext);
// if (!outsideSpeciesContextSpec.isConstant()){
if (bNoFluxIfFixed || !outsideSpeciesContextSpec.isConstant()) {
if (bNoFluxIfFixed && outsideSpeciesContextSpec.isConstant()) {
bNoFluxIfFixedExercised = true;
}
if (rf == null) {
rf = new ResolvedFlux(fluxCarrier, fr.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_ReactionRate).getUnitDefinition());
resolvedFluxList.addElement(rf);
}
FeatureMapping outsideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping(structTopology.getOutsideFeature((Membrane) fr.getStructure()));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(outsideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression outsideFluxCorrection = Expression.invert(residualVolumeFraction);
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
outsideFluxCorrection = new Expression(1.0);
}
//
if (fr.getKinetics() instanceof DistributedKinetics) {
Expression reactionRateParameter = new Expression(((DistributedKinetics) fr.getKinetics()).getReactionRateParameter(), mathMapping_4_8.getNameScope());
if (rf.outFluxExpression.isZero()) {
rf.outFluxExpression = Expression.mult(Expression.negate(reactionRateParameter), outsideFluxCorrection).flatten();
} else {
rf.outFluxExpression = Expression.add(rf.outFluxExpression, Expression.mult(Expression.negate(reactionRateParameter), outsideFluxCorrection).flatten());
}
} else if (fr.getKinetics() instanceof LumpedKinetics) {
throw new RuntimeException("Lumped Kinetics not yet supported for Flux Reaction: " + fr.getName());
} else {
throw new RuntimeException("unexpected Kinetics type for Flux Reaction " + fr.getName());
}
// rf.outFlux.bindExpression(mathMapping);
}
}
//
// for each reaction, incorporate all reactionSteps involving binding with volumetric species
//
double kMoleValue = 1 / 602.0;
for (int i = 0; i < reactionSpecs.length; i++) {
if (reactionSpecs[i].isExcluded()) {
continue;
}
ReactionStep rs = reactionSpecs[i].getReactionStep();
if (rs.getStructure() == getMembrane()) {
if (rs instanceof SimpleReaction) {
SimpleReaction sr = (SimpleReaction) rs;
ReactionParticipant[] rp_Array = sr.getReactionParticipants();
for (int k = 0; k < rp_Array.length; k++) {
if (rp_Array[k] instanceof Reactant || rp_Array[k] instanceof Product) {
SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(rp_Array[k].getSpeciesContext());
// if (rp_Array[k].getStructure() instanceof Feature && !scs.isConstant()){
if (rp_Array[k].getStructure() instanceof Feature && (bNoFluxIfFixed || !scs.isConstant())) {
if (bNoFluxIfFixed && scs.isConstant()) {
bNoFluxIfFixedExercised = true;
}
//
// for each Reactant or Product binding to this membrane...
//
//
// get ResolvedFlux for this species
//
ResolvedFlux rf = null;
for (int j = 0; j < resolvedFluxList.size(); j++) {
ResolvedFlux rf_tmp = (ResolvedFlux) resolvedFluxList.elementAt(j);
if (rf_tmp.getSpecies() == rp_Array[k].getSpecies()) {
rf = rf_tmp;
}
}
if (rf == null) {
rf = new ResolvedFlux(rp_Array[k].getSpecies(), sr.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_ReactionRate).getUnitDefinition());
resolvedFluxList.addElement(rf);
}
Expression reactionRateExpression = getReactionRateExpression(sr, rp_Array[k]).renameBoundSymbols(mathMapping_4_8.getNameScope());
if (rp_Array[k].getStructure() == structTopology.getInsideFeature(getMembrane())) {
//
// for binding on inside, add to ResolvedFlux.inFlux
//
FeatureMapping insideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping(structTopology.getInsideFeature(getMembrane()));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(insideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression insideFluxCorrection = Expression.div(new Expression(kMoleValue), residualVolumeFraction).flatten();
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
insideFluxCorrection = new Expression(kMoleValue);
}
if (rf.inFluxExpression.isZero()) {
rf.inFluxExpression = Expression.mult(insideFluxCorrection, reactionRateExpression);
} else {
rf.inFluxExpression = Expression.add(rf.inFluxExpression, Expression.mult(insideFluxCorrection, reactionRateExpression));
}
// rf.inFlux.bindExpression(mathMapping);
} else if (rp_Array[k].getStructure() == structTopology.getOutsideFeature(getMembrane())) {
//
// for binding on outside, add to ResolvedFlux.outFlux
//
FeatureMapping outsideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping(structTopology.getOutsideFeature(getMembrane()));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(outsideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression outsideFluxCorrection = Expression.div(new Expression(kMoleValue), residualVolumeFraction).flatten();
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
outsideFluxCorrection = new Expression(kMoleValue);
}
if (rf.outFluxExpression.isZero()) {
rf.outFluxExpression = Expression.mult(outsideFluxCorrection, reactionRateExpression);
} else {
rf.outFluxExpression = Expression.add(rf.outFluxExpression, Expression.mult(outsideFluxCorrection, reactionRateExpression));
}
// rf.outFlux.bindExpression(mathMapping);
} else {
throw new Exception("SpeciesContext " + rp_Array[k].getSpeciesContext().getName() + " doesn't border membrane " + getMembrane().getName() + " but reacts there");
}
}
}
}
}
}
}
//
if (resolvedFluxList.size() > 0) {
resolvedFluxes = new ResolvedFlux[resolvedFluxList.size()];
resolvedFluxList.copyInto(resolvedFluxes);
} else {
resolvedFluxes = null;
}
}
use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.
the class IssuePanel method invokeHyperlink.
private void invokeHyperlink(Issue issue) {
if (selectionManager != null) {
// followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
IssueContext issueContext = issue.getIssueContext();
IssueSource object = issue.getSource();
if (object instanceof DecoratedIssueSource) {
DecoratedIssueSource dis = (DecoratedIssueSource) object;
dis.activateView(selectionManager);
} else if (object instanceof Parameter) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
} else if (object instanceof StructureMapping) {
StructureMapping structureMapping = (StructureMapping) object;
StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof SpatialObject) {
SpatialObject spatialObject = (SpatialObject) object;
SimulationContext simulationContext = spatialObject.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
} else if (object instanceof SpatialProcess) {
SpatialProcess spatialProcess = (SpatialProcess) object;
SimulationContext simulationContext = spatialProcess.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
} else if (object instanceof GeometryContext.UnmappedGeometryClass) {
UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof MicroscopeMeasurement) {
SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
} else if (object instanceof BioEvent) {
BioEvent be = (BioEvent) object;
SimulationContext simulationContext = be.getSimulationContext();
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
} else if (object instanceof OutputFunctionIssueSource) {
SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
if (simulationOwner instanceof SimulationContext) {
SimulationContext simulationContext = (SimulationContext) simulationOwner;
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
} else if (simulationOwner instanceof MathModel) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
}
} else if (object instanceof Simulation) {
Simulation simulation = (Simulation) object;
SimulationOwner simulationOwner = simulation.getSimulationOwner();
if (simulationOwner instanceof SimulationContext) {
SimulationContext simulationContext = (SimulationContext) simulationOwner;
followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
} else if (simulationOwner instanceof MathModel) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
}
} else if (object instanceof GeometryContext) {
setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
} else if (object instanceof Structure) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
} else if (object instanceof MolecularType) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
} else if (object instanceof ReactionStep) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
} else if (object instanceof ReactionRule) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
followHyperlink(av, new Object[] { object });
} else if (object instanceof ReactionCombo) {
ReactionCombo rc = (ReactionCombo) object;
followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
} else if (object instanceof SpeciesContext) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
} else if (object instanceof RbmObservable) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
} else if (object instanceof MathDescription) {
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
} else if (object instanceof SpeciesPattern) {
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
// } else {
System.err.println("SpeciesPattern object missing a proper issue context.");
// }
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmNetworkConstraintsBad:
NetworkConstraints nc = sc.getNetworkConstraints();
if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, NetworkConstraintsTableModel.sValueType, nc.getMaxMoleculesPerSpecies() + "");
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
} else {
NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, NetworkConstraintsTableModel.sValueType, nc.getMaxIteration() + "");
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
}
break;
default:
followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
break;
}
} else if (object instanceof Geometry) {
if (issueContext.hasContextType(ContextType.SimContext)) {
SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
} else if (issueContext.hasContextType(ContextType.MathModel)) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
} else if (issueContext.hasContextType(ContextType.MathDescription)) {
followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
}
} else {
System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
}
}
}
use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.
the class ITextWriter method writeGeom.
// Section used can be a chapter or a section of one, based on the document type.
protected void writeGeom(Section container, Geometry geom, GeometryContext geomCont) throws Exception {
try {
Section geomSection = container.addSection("Geometry: " + geom.getName(), container.numberDepth() + 1);
if (geom.getDimension() == 0) {
Paragraph p = new Paragraph(new Phrase("Non spatial geometry."));
p.setAlignment(Paragraph.ALIGN_CENTER);
geomSection.add(p);
return;
}
ByteArrayOutputStream bos = generateGeometryImage(geom);
com.lowagie.text.Image geomImage = com.lowagie.text.Image.getInstance(java.awt.Toolkit.getDefaultToolkit().createImage(bos.toByteArray()), null);
geomImage.setAlignment(Table.ALIGN_LEFT);
geomSection.add(geomImage);
// addImage(geomSection, bos);
Table geomTable = getTable(2, 50, 1, 2, 2);
geomTable.setAlignment(Table.ALIGN_LEFT);
Extent extent = geom.getExtent();
String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
Origin origin = geom.getOrigin();
String originStr = "(" + origin.getX() + ", " + origin.getY() + ", " + origin.getZ() + ")";
geomTable.addCell(createCell("Size", getFont()));
geomTable.addCell(createCell(extentStr, getFont()));
geomTable.addCell(createCell("Origin", getFont()));
geomTable.addCell(createCell(originStr, getFont()));
geomSection.add(geomTable);
} catch (Exception e) {
System.err.println("Unable to add geometry image to report.");
e.printStackTrace();
}
}
use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.
the class ITextWriter method writeStructureMapping.
// boundary types ignored.
protected void writeStructureMapping(Section simContextSection, SimulationContext sc) throws DocumentException {
GeometryContext gc = sc.getGeometryContext();
if (gc == null) {
return;
}
Section structMappSection = null;
/*try {
ByteArrayOutputStream bos = generateStructureMappingImage(sc);
com.lowagie.text.Image structMapImage = com.lowagie.text.Image.getInstance(Toolkit.getDefaultToolkit().createImage(bos.toByteArray()), null);
structMappSection = simContextSection.addSection("Structure Mapping For " + sc.getName(), simContextSection.numberDepth() + 1);
structMappSection.add(structMapImage);
} catch (Exception e) {
System.err.println("Unable to add structure mapping image to report.");
e.printStackTrace();
}*/
StructureMapping[] structMap = gc.getStructureMappings();
Table structMapTable = null;
ModelUnitSystem modelUnitSystem = sc.getModel().getUnitSystem();
for (int i = 0; i < structMap.length; i++) {
if (!(structMap[i] instanceof FeatureMapping)) {
continue;
}
if (i == 0) {
structMapTable = getTable(5, 100, 1, 3, 3);
structMapTable.addCell(createCell("Structure Mapping", getBold(DEF_HEADER_FONT_SIZE), 5, 1, Element.ALIGN_CENTER, true));
structMapTable.addCell(createHeaderCell("Structure", getBold(), 1));
structMapTable.addCell(createHeaderCell("Subdomain", getBold(), 1));
structMapTable.addCell(createHeaderCell("Resolved (T/F)", getBold(), 1));
structMapTable.addCell(createHeaderCell("Surf/Vol", getBold(), 1));
structMapTable.addCell(createHeaderCell("VolFract", getBold(), 1));
structMapTable.endHeaders();
}
String structName = structMap[i].getStructure().getName();
SubVolume subVol = (SubVolume) ((FeatureMapping) structMap[i]).getGeometryClass();
String subDomain = "";
if (subVol != null) {
subDomain = subVol.getName();
}
// ((FeatureMapping)structMap[i]).getResolved();
boolean isResolved = false;
String surfVolStr = "", volFractStr = "";
MembraneMapping mm = (MembraneMapping) gc.getStructureMapping(sc.getModel().getStructureTopology().getParentStructure(structMap[i].getStructure()));
if (mm != null) {
StructureMapping.StructureMappingParameter smp = mm.getSurfaceToVolumeParameter();
if (smp != null) {
Expression tempExp = smp.getExpression();
VCUnitDefinition tempUnit = smp.getUnitDefinition();
if (tempExp != null) {
surfVolStr = tempExp.infix();
if (tempUnit != null && !modelUnitSystem.getInstance_DIMENSIONLESS().compareEqual(tempUnit)) {
// no need to add '1' for dimensionless unit
surfVolStr += " " + tempUnit.getSymbolUnicode();
}
}
}
smp = mm.getVolumeFractionParameter();
if (smp != null) {
Expression tempExp = smp.getExpression();
VCUnitDefinition tempUnit = smp.getUnitDefinition();
if (tempExp != null) {
volFractStr = tempExp.infix();
if (tempUnit != null && !modelUnitSystem.getInstance_DIMENSIONLESS().compareEqual(tempUnit)) {
volFractStr += " " + tempUnit.getSymbolUnicode();
}
}
}
}
structMapTable.addCell(createCell(structName, getFont()));
structMapTable.addCell(createCell(subDomain, getFont()));
structMapTable.addCell(createCell((isResolved ? " T " : " F "), getFont()));
structMapTable.addCell(createCell(surfVolStr, getFont()));
structMapTable.addCell(createCell(volFractStr, getFont()));
}
if (structMapTable != null) {
if (structMappSection == null) {
structMappSection = simContextSection.addSection("Structure Mapping For " + sc.getName(), simContextSection.numberDepth() + 1);
}
structMappSection.add(structMapTable);
}
}
Aggregations