use of cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory in project vcell by virtualcell.
the class Xmlproducer method getXML.
public Element getXML(SpatialObject[] spatialObjects) throws XmlParseException {
Element spatialObjectsElement = new Element(XMLTags.SpatialObjectsTag);
for (SpatialObject spatialObject : spatialObjects) {
Element spatialObjectElement = new Element(XMLTags.SpatialObjectTag);
spatialObjectElement.setAttribute(XMLTags.NameAttrTag, mangle(spatialObject.getName()));
if (spatialObject instanceof PointObject) {
spatialObjectElement.setAttribute(XMLTags.SpatialObjectTypeAttrTag, XMLTags.SpatialObjectTypeAttrValue_Point);
} else if (spatialObject instanceof SurfaceRegionObject) {
spatialObjectElement.setAttribute(XMLTags.SpatialObjectTypeAttrTag, XMLTags.SpatialObjectTypeAttrValue_Surface);
spatialObjectElement.setAttribute(XMLTags.SpatialObjectSubVolumeInsideAttrTag, ((SurfaceRegionObject) spatialObject).getInsideSubVolume().getName());
spatialObjectElement.setAttribute(XMLTags.SpatialObjectRegionIdInsideAttrTag, ((SurfaceRegionObject) spatialObject).getInsideRegionID().toString());
spatialObjectElement.setAttribute(XMLTags.SpatialObjectSubVolumeOutsideAttrTag, ((SurfaceRegionObject) spatialObject).getOutsideSubVolume().getName());
spatialObjectElement.setAttribute(XMLTags.SpatialObjectRegionIdOutsideAttrTag, ((SurfaceRegionObject) spatialObject).getOutsideRegionID().toString());
} else if (spatialObject instanceof VolumeRegionObject) {
spatialObjectElement.setAttribute(XMLTags.SpatialObjectTypeAttrTag, XMLTags.SpatialObjectTypeAttrValue_Volume);
spatialObjectElement.setAttribute(XMLTags.SpatialObjectSubVolumeAttrTag, ((VolumeRegionObject) spatialObject).getSubVolume().getName());
spatialObjectElement.setAttribute(XMLTags.SpatialObjectRegionIdAttrTag, ((VolumeRegionObject) spatialObject).getRegionID().toString());
} else {
throw new RuntimeException("spatialObject type " + spatialObject.getClass().getSimpleName() + " not yet supported for persistence.");
}
Element quantityCategoryListElement = new Element(XMLTags.QuantityCategoryListTag);
for (QuantityCategory quantityCategory : spatialObject.getQuantityCategories()) {
Element quantityCategoryElement = new Element(XMLTags.QuantityCategoryTag);
quantityCategoryElement.setAttribute(XMLTags.QuantityCategoryNameAttrTag, quantityCategory.xmlName);
quantityCategoryElement.setAttribute(XMLTags.QuantityCategoryEnabledAttrTag, Boolean.toString(spatialObject.isQuantityCategoryEnabled(quantityCategory)));
quantityCategoryListElement.addContent(quantityCategoryElement);
}
spatialObjectElement.addContent(quantityCategoryListElement);
spatialObjectsElement.addContent(spatialObjectElement);
}
System.out.println(XmlUtil.xmlToString(spatialObjectsElement));
return spatialObjectsElement;
}
use of cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory in project vcell by virtualcell.
the class SpatialObjectTableModel method getQuantitiesString.
private String getQuantitiesString(SpatialObject spatialObject) {
List<QuantityCategory> categories = spatialObject.getQuantityCategories();
ArrayList<String> categoryNames = new ArrayList<String>();
for (QuantityCategory cat : categories) {
if (spatialObject.isQuantityCategoryEnabled(cat)) {
categoryNames.add("<b>" + cat.varSuffix + "</b>");
} else {
categoryNames.add(cat.varSuffix);
}
}
String ret = categoryNames.toString().replace("]", "").replace("[", "");
ret = "<html>" + ret + "</html>";
return ret;
}
use of cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory in project vcell by virtualcell.
the class SpatialObjectPropertyPanel method setSpatialObject.
/**
* Set the SpeciesContextSpec to a new value.
* @param newValue cbit.vcell.mapping.SpeciesContextSpec
*/
void setSpatialObject(SpatialObject newValue) {
SpatialObject oldSpatialObject = this.spatialObject;
this.spatialObject = newValue;
getSpatialQuantityTableModel().setSpatialObject(this.spatialObject);
for (JCheckBox checkbox : this.optionsCheckboxes) {
checkbox.removeActionListener(actionListener);
}
optionsCheckboxes.clear();
optionsPanel.removeAll();
if (spatialObject != null) {
for (QuantityCategory category : spatialObject.getQuantityCategories()) {
JCheckBox checkbox = new JCheckBox();
checkbox.addActionListener(actionListener);
checkbox.setText(category.description);
checkbox.setSelected(spatialObject.isQuantityCategoryEnabled(category));
optionsPanel.add(checkbox);
System.out.println("adding checkbox for " + checkbox.getText());
optionsCheckboxes.add(checkbox);
}
}
optionsPanel.revalidate();
}
use of cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory in project vcell by virtualcell.
the class XmlReader method getSpatialObjects.
public SpatialObject[] getSpatialObjects(SimulationContext simContext, Element spatialObjectsElement) throws XmlParseException {
Iterator<Element> spatialObjectElementIterator = spatialObjectsElement.getChildren(XMLTags.SpatialObjectTag, vcNamespace).iterator();
ArrayList<SpatialObject> spatialObjectList = new ArrayList<SpatialObject>();
while (spatialObjectElementIterator.hasNext()) {
Element spatialObjectElement = (Element) spatialObjectElementIterator.next();
SpatialObject spatialObject = null;
String name = unMangle(spatialObjectElement.getAttributeValue(XMLTags.NameAttrTag));
String type = unMangle(spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectTypeAttrTag));
if (type.equals(XMLTags.SpatialObjectTypeAttrValue_Point)) {
PointObject pointObject = new PointObject(name, simContext);
spatialObject = pointObject;
} else if (type.equals(XMLTags.SpatialObjectTypeAttrValue_Surface)) {
String insideSubvolumeName = unMangle(spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectSubVolumeInsideAttrTag));
String insideRegionIDString = spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectRegionIdInsideAttrTag);
String outsideSubvolumeName = unMangle(spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectSubVolumeOutsideAttrTag));
String outsideRegionIDString = spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectRegionIdOutsideAttrTag);
SubVolume insideSubvolume = null;
if (insideSubvolumeName != null) {
insideSubvolume = simContext.getGeometry().getGeometrySpec().getSubVolume(insideSubvolumeName);
}
Integer insideRegionID = null;
if (insideRegionIDString != null) {
insideRegionID = Integer.parseUnsignedInt(insideRegionIDString);
}
SubVolume outsideSubvolume = null;
if (outsideSubvolumeName != null) {
outsideSubvolume = simContext.getGeometry().getGeometrySpec().getSubVolume(outsideSubvolumeName);
}
Integer outsideRegionID = null;
if (outsideRegionIDString != null) {
outsideRegionID = Integer.parseUnsignedInt(outsideRegionIDString);
}
SurfaceRegionObject surfaceRegionObject = new SurfaceRegionObject(name, insideSubvolume, insideRegionID, outsideSubvolume, outsideRegionID, simContext);
spatialObject = surfaceRegionObject;
} else if (type.equals(XMLTags.SpatialObjectTypeAttrValue_Volume)) {
String subvolumeName = unMangle(spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectSubVolumeAttrTag));
String regionIDString = spatialObjectElement.getAttributeValue(XMLTags.SpatialObjectRegionIdAttrTag);
SubVolume subvolume = null;
if (subvolumeName != null) {
subvolume = simContext.getGeometry().getGeometrySpec().getSubVolume(subvolumeName);
}
Integer regionID = null;
if (regionIDString != null) {
regionID = Integer.parseUnsignedInt(regionIDString);
}
VolumeRegionObject volumeRegionObject = new VolumeRegionObject(name, subvolume, regionID, simContext);
spatialObject = volumeRegionObject;
}
// set Quantity enables
Element quantityCategoryListElement = spatialObjectElement.getChild(XMLTags.QuantityCategoryListTag, vcNamespace);
List<Element> quantityCategoryElements = quantityCategoryListElement.getChildren(XMLTags.QuantityCategoryTag, vcNamespace);
for (Element quantityCategoryElement : quantityCategoryElements) {
String quantityCategoryName = unMangle(quantityCategoryElement.getAttributeValue(XMLTags.QuantityCategoryNameAttrTag));
Boolean enabled = Boolean.parseBoolean(quantityCategoryElement.getAttributeValue(XMLTags.QuantityCategoryEnabledAttrTag));
QuantityCategory category = QuantityCategory.fromXMLName(quantityCategoryName);
spatialObject.setQuantityCategoryEnabled(category, enabled);
}
spatialObjectList.add(spatialObject);
}
return spatialObjectList.toArray(new SpatialObject[0]);
}
Aggregations