use of cbit.vcell.model.Model.RbmModelContainer in project vcell by virtualcell.
the class XmlReader method getRbmObservableList.
// private void getRbmSeedSpeciesList(Element param, Model newModel) {
// RbmModelContainer mc = newModel.getRbmModelContainer();
// List<SeedSpecies> ssl = mc.getSeedSpeciesList();
// List<Element> children = param.getChildren(XMLTags.RbmSeedSpeciesTag, vcNamespace);
// for (Element element : children) {
// SeedSpecies s = getRbmSeedSpecies(element, newModel);
// if(s != null) { ssl.add(s); }
// }
// }
private void getRbmObservableList(Element param, Model newModel) throws ModelException, PropertyVetoException {
RbmModelContainer mc = newModel.getRbmModelContainer();
List<Element> children = new ArrayList<Element>();
children = param.getChildren(XMLTags.RbmObservableTag, vcNamespace);
for (Element element : children) {
RbmObservable o = getRbmObservables(element, newModel);
if (o != null) {
mc.addObservable(o);
}
}
}
use of cbit.vcell.model.Model.RbmModelContainer in project vcell by virtualcell.
the class XmlReader method getRbmMolecularTypeList.
private void getRbmMolecularTypeList(Element param, Model newModel) {
RbmModelContainer mc = newModel.getRbmModelContainer();
List<MolecularType> mtl = mc.getMolecularTypeList();
List<Element> children = param.getChildren(XMLTags.RbmMolecularTypeTag, vcNamespace);
for (Element element : children) {
MolecularType t = getRbmMolecularType(element, newModel);
if (t != null) {
mtl.add(t);
}
}
}
use of cbit.vcell.model.Model.RbmModelContainer in project vcell by virtualcell.
the class RuleParticipantSignatureDiagramShape method paintSelf.
// TODO: Override ElipseShape::isInside()
// our shape here is rounded rectangle while IsInside thinks it's an ellipse, which means
// that clicking near the corners of a long shape (with many molecules) fails to select the shape
// TODO: the RoundRectangle2D contour below needs to be recalculated with updated width, using the
// species pattern in the RuleParticipantSignature
@Override
public void paintSelf(Graphics2D g, int absPosX, int absPosY) {
if (!bVisible) {
return;
}
// we reserve space for at least 1 molecule
int numMolecules = Math.max(1, ruleParticipantSignature.getSpeciesPattern().getMolecularTypePatterns().size());
width = leftmargin + circleDiameter + displacement * (numMolecules - 1) + 1;
getSpaceManager().setSize(width, height);
int shapeHeight = getSpaceManager().getSize().height;
int shapeWidth = getSpaceManager().getSize().width;
Graphics2D g2D = g;
Paint oldPaint = g2D.getPaint();
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color exterior;
// draw the contour around the whole rule participant
// no need to really draw it if the shapes of the molecules fill it perfectly, because it won't be visible anyway
// however, the "isInside" function will need exactly this RoundRectangle2D to compute whether the point is inside the shape
RoundRectangle2D contour = new RoundRectangle2D.Double(absPosX, absPosY, shapeWidth, shapeHeight, shapeHeight, shapeHeight);
g2D.setPaint(isSelected() ? AbstractComponentShape.componentMediumPalePink : AbstractComponentShape.componentPaleGreen);
g2D.fill(contour);
exterior = isSelected() ? Color.red.darker().darker() : Color.darkGray;
g.setColor(exterior);
g2D.draw(contour);
Model model = ((ReactionCartoon) graphModel).getModel();
RbmModelContainer rbmmc = model.getRbmModelContainer();
List<MolecularType> mtList = rbmmc.getMolecularTypeList();
List<MolecularType> ruleSignatureMolecularTypes = ruleParticipantSignature.getMolecularTypes();
// draw the molecules (they are properly drawn because we use the sp as it is in the associated RuleParticipantSignature object)
for (int i = 0; i < ruleSignatureMolecularTypes.size(); i++) {
double offsetx = leftmargin + i * displacement - 1.4;
int offsety = getSpaceManager().getSize().height - circleDiameter - 2;
Ellipse2D icon = new Ellipse2D.Double(absPosX + offsetx, absPosY + offsety, circleDiameter, circleDiameter);
// int offsetx = leftmargin + i*displacement;
// int offsety = 0;
// Rectangle2D icon = new Rectangle2D.Double(absPosX + offsetx, absPosY + offsety, displacement, shapeHeight-1);
MolecularType mt = ruleSignatureMolecularTypes.get(i);
int index = mtList.indexOf(mt);
index = index % 7;
defaultBG = Color.lightGray;
Color interior = Color.white;
if (graphModel instanceof ReactionCartoonFull) {
// take color from molecular type color selection
defaultBG = MolecularTypeLargeShape.colorTable[index];
}
backgroundColor = defaultBG;
// darkerBackground = backgroundColor.darker().darker();
exterior = !isSelected() ? backgroundColor.darker().darker() : backgroundColor.darker();
Color[] colors = { interior, exterior };
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Point2D center = new Point2D.Double(absPosX + offsetx + circleDiameter / 2, absPosY + offsety + circleDiameter / 2);
float radius = circleDiameter * 0.5f;
Point2D focus = new Point2D.Double(absPosX + offsetx + circleDiameter / 2 - 2, absPosY + offsety + circleDiameter / 2 - 2);
float[] dist = { 0.1f, 1.0f };
RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
// Paint p = defaultBG.darker().darker();
g2D.setPaint(p);
g2D.fill(icon);
g.setColor(forgroundColor);
g2D.draw(icon);
}
// TODO: see if RefreshLabel below works properly, if it does make a similar call to refresh the width!!!
if (getLabel() != null && getLabel().length() > 0) {
if (isSelected()) {
// clear background and outline to make selected label stand out
Rectangle outlineRectangle = getLabelOutline(absPosX, absPosY);
drawRaisedOutline(outlineRectangle.x, outlineRectangle.y, outlineRectangle.width, outlineRectangle.height, g, Color.white, forgroundColor, Color.gray);
}
if (bDisplayLabel || isSelected()) {
g.setColor(forgroundColor);
g.drawString((isSelected() || smallLabel == null ? getLabel() : smallLabel), (isSelected() || smallLabel == null ? getLabelPos().x : smallLabelPos.x) + absPosX, getLabelPos().y - 2 + absPosY);
}
}
if (linkText != null && linkText != "") {
ShapePaintUtil.paintLinkMark(g2D, this, Color.BLACK);
}
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2D.setPaint(oldPaint);
}
use of cbit.vcell.model.Model.RbmModelContainer in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectPathDescription.
private String getSourceObjectPathDescription(VCDocument vcDocument, Issue issue) {
VCAssert.assertValid(issue);
Object source = issue.getSource();
{
IssueOrigin io = BeanUtils.downcast(IssueOrigin.class, source);
if (io != null) {
return io.getDescription();
}
}
if (vcDocument instanceof BioModel) {
BioModel bioModel = (BioModel) vcDocument;
String description = "";
if (source instanceof SymbolTableEntry) {
if (source instanceof SpeciesContext) {
description = "Model / Species";
} else if (source instanceof RbmObservable) {
description = "Model / Observables";
} else {
description = ((SymbolTableEntry) source).getNameScope().getPathDescription();
}
} else if (source instanceof MolecularType) {
description = "Model / Molecules";
} else if (source instanceof ReactionStep) {
ReactionStep reactionStep = (ReactionStep) source;
description = ((ReactionNameScope) reactionStep.getNameScope()).getPathDescription();
} else if (source instanceof ReactionRule) {
ReactionRule reactionRule = (ReactionRule) source;
description = ((ReactionRuleNameScope) reactionRule.getNameScope()).getPathDescription();
} else if (source instanceof SpeciesPattern) {
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// description = "Model / Species";
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = ((ReactionRuleNameScope)thing.getNameScope()).getPathDescription();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// description = "Model / Observables";
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) source).toString());
description = ((SpeciesPattern) source).toString();
// }
} else if (source instanceof Structure) {
Structure structure = (Structure) source;
description = "Model / " + structure.getTypeName() + "(" + structure.getName() + ")";
} else if (source instanceof StructureMapping) {
StructureMapping structureMapping = (StructureMapping) source;
description = ((StructureMappingNameScope) structureMapping.getNameScope()).getPathDescription();
} else if (source instanceof OutputFunctionIssueSource) {
SimulationContext simulationContext = (SimulationContext) ((OutputFunctionIssueSource) source).getOutputFunctionContext().getSimulationOwner();
description = "App(" + simulationContext.getName() + ") / " + "Simulations" + " / " + "Output Functions";
} else if (source instanceof Simulation) {
Simulation simulation = (Simulation) source;
try {
SimulationContext simulationContext = bioModel.getSimulationContext(simulation);
description = "App(" + simulationContext.getName() + ") / Simulations";
} catch (ObjectNotFoundException e) {
e.printStackTrace();
description = "App(" + "unknown" + ") / Simulations";
}
} else if (source instanceof UnmappedGeometryClass) {
UnmappedGeometryClass unmappedGC = (UnmappedGeometryClass) source;
description = "App(" + unmappedGC.getSimulationContext().getName() + ") / Subdomain(" + unmappedGC.getGeometryClass().getName() + ")";
} else if (source instanceof GeometryContext) {
description = "App(" + ((GeometryContext) source).getSimulationContext().getName() + ")";
} else if (source instanceof ModelOptimizationSpec) {
description = "App(" + ((ModelOptimizationSpec) source).getSimulationContext().getName() + ") / Parameter Estimation";
} else if (source instanceof MicroscopeMeasurement) {
description = "App(" + ((MicroscopeMeasurement) source).getSimulationContext().getName() + ") / Microscope Measurements";
} else if (source instanceof SpatialObject) {
description = "App(" + ((SpatialObject) source).getSimulationContext().getName() + ") / Spatial Objects";
} else if (source instanceof SpatialProcess) {
description = "App(" + ((SpatialProcess) source).getSimulationContext().getName() + ") / Spatial Processes";
} else if (source instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) source;
description = "App(" + scs.getSimulationContext().getName() + ") / Specifications / Species";
} else if (source instanceof ReactionCombo) {
ReactionCombo rc = (ReactionCombo) source;
description = "App(" + rc.getReactionContext().getSimulationContext().getName() + ") / Specifications / Reactions";
} else if (source instanceof RbmModelContainer) {
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmMolecularTypesTableBad:
description = "Model / " + MolecularType.typeName + "s";
break;
case RbmReactionRulesTableBad:
description = "Model / Reactions";
break;
case RbmObservablesTableBad:
description = "Model / Observables";
break;
case RbmNetworkConstraintsBad:
description = "Network Constrains";
break;
default:
description = "Model";
break;
}
} else if (source instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) source;
IssueCategory ic = issue.getCategory();
switch(ic) {
case RbmNetworkConstraintsBad:
description = "Specifications / Network";
break;
default:
description = "Application";
break;
}
} else if (source instanceof Model) {
description = "Model";
} else if (source instanceof BioEvent) {
return "Protocols / Events";
} else if (source instanceof MathDescription) {
return "Math Description";
} else {
System.err.println("unknown source type in IssueTableModel.getSourceObjectPathDescription(): " + source.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
if (source instanceof Geometry) {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_GEOMETRY;
} else if (source instanceof OutputFunctionIssueSource) {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_OUTPUTFUNCTIONS;
} else if (source instanceof Simulation) {
return "Simulation(" + ((Simulation) source).getName() + ")";
} else {
return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_VCML;
}
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectPathDescription()");
return "";
}
}
use of cbit.vcell.model.Model.RbmModelContainer in project vcell by virtualcell.
the class IssueTableModel method getSourceObjectDescription.
private String getSourceObjectDescription(VCDocument vcDocument, Issue issue) {
if (vcDocument instanceof BioModel) {
Object object = issue.getSource();
{
DecoratedIssueSource dis = BeanUtils.downcast(DecoratedIssueSource.class, object);
if (dis != null) {
return dis.getSourcePath();
}
}
String description = "";
if (object instanceof SymbolTableEntry) {
description = ((SymbolTableEntry) object).getName();
} else if (object instanceof ReactionStep) {
description = ((ReactionStep) object).getName();
} else if (object instanceof ReactionRule) {
description = ((ReactionRule) object).getName();
} else if (object instanceof SpeciesPattern) {
// Object parent = issue.getIssueContext().getContextObject();
// if (parent instanceof SpeciesContext){
// description = ((SpeciesContext)parent).getName();
// }
// if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
// SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
// ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
// description = thing.getName();
// }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
// RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
// description = thing.getName();
// } else {
System.err.println("Bad issue context for " + ((SpeciesPattern) object).toString());
description = ((SpeciesPattern) object).toString();
// }
} else if (object instanceof MolecularType) {
description = ((MolecularType) object).getName();
} else if (object instanceof MolecularComponent) {
description = ((MolecularComponent) object).getName();
} else if (object instanceof ComponentStateDefinition) {
description = ((ComponentStateDefinition) object).getName();
} else if (object instanceof Structure) {
description = ((Structure) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = ((Geometry) object).getName();
} else if (object instanceof StructureMapping) {
description = ((StructureMapping) object).getStructure().getName();
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof UnmappedGeometryClass) {
description = ((UnmappedGeometryClass) object).getGeometryClass().getName();
} else if (object instanceof MicroscopeMeasurement) {
description = ((MicroscopeMeasurement) object).getName();
} else if (object instanceof SpatialObject) {
description = ((SpatialObject) object).getName();
} else if (object instanceof SpatialProcess) {
description = ((SpatialProcess) object).getName();
} else if (object instanceof GeometryContext) {
description = "Geometry";
} else if (object instanceof ModelOptimizationSpec) {
description = ((ModelOptimizationSpec) object).getParameterEstimationTask().getName();
} else if (object instanceof Simulation) {
description = ((Simulation) object).getName();
} else if (object instanceof SpeciesContextSpec) {
SpeciesContextSpec scs = (SpeciesContextSpec) object;
description = scs.getSpeciesContext().getName();
} else if (object instanceof ReactionCombo) {
ReactionSpec rs = ((ReactionCombo) object).getReactionSpec();
description = rs.getReactionStep().getName();
} else if (object instanceof RbmModelContainer) {
// RbmModelContainer mc = (RbmModelContainer)object;
description = "Rules validator";
} else if (object instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) object;
description = sc.getName();
} else if (object instanceof Model) {
Model m = (Model) object;
description = m.getName();
} else if (object instanceof BioEvent) {
return ((BioEvent) object).getName() + "";
} else if (object instanceof MathDescription) {
return ((MathDescription) object).getName() + "";
} else {
System.err.println("unknown object type in IssueTableModel.getSourceObjectDescription(): " + object.getClass());
}
return description;
} else if (vcDocument instanceof MathModel) {
Object object = issue.getSource();
String description = "";
if (object instanceof Variable) {
description = ((Variable) object).getName();
} else if (object instanceof SubDomain) {
description = ((SubDomain) object).getName();
} else if (object instanceof Geometry) {
description = "Geometry";
} else if (object instanceof OutputFunctionIssueSource) {
description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
} else if (object instanceof MathDescription) {
return "math";
} else if (object instanceof Simulation) {
return "Simulation " + ((Simulation) object).getName() + "";
}
return description;
} else {
System.err.println("unknown document type in IssueTableModel.getSourceObjectDescription()");
return "";
}
}
Aggregations