Search in sources :

Example 1 with QuantityCategory

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;
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointObject(cbit.vcell.mapping.spatial.PointObject) Element(org.jdom.Element) QuantityCategory(cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 2 with QuantityCategory

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;
}
Also used : QuantityCategory(cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory) ArrayList(java.util.ArrayList)

Example 3 with QuantityCategory

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();
}
Also used : JCheckBox(javax.swing.JCheckBox) QuantityCategory(cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject)

Example 4 with QuantityCategory

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]);
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) Element(org.jdom.Element) QuantityCategory(cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory) ArrayList(java.util.ArrayList) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SubVolume(cbit.vcell.geometry.SubVolume) CompartmentSubVolume(cbit.vcell.geometry.CompartmentSubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Aggregations

QuantityCategory (cbit.vcell.mapping.spatial.SpatialObject.QuantityCategory)4 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)3 PointObject (cbit.vcell.mapping.spatial.PointObject)2 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)2 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)2 ArrayList (java.util.ArrayList)2 Element (org.jdom.Element)2 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)1 CompartmentSubVolume (cbit.vcell.geometry.CompartmentSubVolume)1 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)1 SubVolume (cbit.vcell.geometry.SubVolume)1 JCheckBox (javax.swing.JCheckBox)1