} else {
spatialModel = new SpatialModelPlugin(model);
model.addExtension(SpatialConstants.namespaceURI, spatialModel);
}
if (elementName.equals(SpatialConstants.geometry)) {
Geometry geometry = new Geometry();
spatialModel.setGeometry(geometry);
return geometry;
}
} else if (contextObject instanceof Compartment) {
Compartment compartment = (Compartment) contextObject;
SpatialCompartmentPlugin spatialCompartment = null;
if (compartment.getExtension(SpatialConstants.namespaceURI) != null) {
spatialCompartment = (SpatialCompartmentPlugin) compartment.getExtension(SpatialConstants.namespaceURI);
} else {
spatialCompartment = new SpatialCompartmentPlugin(compartment);
compartment.addExtension(SpatialConstants.namespaceURI, spatialCompartment);
}
if (elementName.equals(SpatialConstants.compartmentMapping)) {
CompartmentMapping compartmentMapping = new CompartmentMapping();
spatialCompartment.setCompartmentMapping(compartmentMapping);
return compartmentMapping;
}
} else if (contextObject instanceof Parameter) {
Parameter param = (Parameter) contextObject;
SpatialParameterPlugin spatialParam = null;
if (param.getExtension(SpatialConstants.namespaceURI) != null) {
spatialParam = (SpatialParameterPlugin) param.getExtension(SpatialConstants.namespaceURI);
} else {
spatialParam = new SpatialParameterPlugin(param);
param.addExtension(SpatialConstants.namespaceURI, spatialParam);
}
if (elementName.equals(SpatialConstants.spatialSymbolReference)) {
SpatialSymbolReference ssr = new SpatialSymbolReference();
spatialParam.setParamType(ssr);
return ssr;
} else if (elementName.equals(SpatialConstants.diffusionCoefficient)){
DiffusionCoefficient dc = new DiffusionCoefficient();
spatialParam.setParamType(dc);
return dc;
} else if (elementName.equals(SpatialConstants.advectionCoefficient)){
AdvectionCoefficient ac = new AdvectionCoefficient();
spatialParam.setParamType(ac);
return ac;
} else if (elementName.equals(SpatialConstants.boundaryCondition)){
BoundaryCondition bc = new BoundaryCondition();
spatialParam.setParamType(bc);
return bc;
}
} else if (contextObject instanceof Geometry) {
Geometry geometry = (Geometry) contextObject;
if (elementName.equals(SpatialConstants.listOfCoordinateComponents)) {
ListOf<CoordinateComponent> listOfCoordinateComponents = geometry.getListOfCoordinateComponents();
return listOfCoordinateComponents;
} else if (elementName.equals(SpatialConstants.listOfDomainTypes)) {
ListOf<DomainType> listOfDomainTypes = geometry.getListOfDomainTypes();
return listOfDomainTypes;
} else if (elementName.equals(SpatialConstants.listOfDomains)) {
ListOf<Domain> listOfDomains = geometry.getListOfDomains();
return listOfDomains;
} else if (elementName.equals(SpatialConstants.listOfAdjacentDomains)) {
ListOf<AdjacentDomains> listOfAdjacentDomains = geometry.getListOfAdjacentDomains();
return listOfAdjacentDomains;
} else if (elementName.equals(SpatialConstants.listOfGeometryDefinitions)) {
ListOf<GeometryDefinition> listOfGeometryDefinitions = geometry.getListOfGeometryDefinitions();
return listOfGeometryDefinitions;
}
} else if (contextObject instanceof CoordinateComponent) {
CoordinateComponent cc = (CoordinateComponent) contextObject;
if (elementName.equals(SpatialConstants.boundaryMinimum)) {
Boundary boundary = new Boundary();
cc.setMinimum(boundary);
return boundary;
} else if (elementName.equals(SpatialConstants.boundaryMaximum)) {
Boundary boundary = new Boundary();
cc.setMaximum(boundary);
return boundary;
}
} else if (contextObject instanceof Domain) {
Domain domain = (Domain) contextObject;
if (elementName.equals(SpatialConstants.listOfInteriorPoints)){
ListOf<InteriorPoint> listOfInteriorPoints = domain.getListOfInteriorPoints();
return listOfInteriorPoints;
}
} else if (contextObject instanceof AnalyticGeometry) {
AnalyticGeometry analyticGeometry = (AnalyticGeometry) contextObject;
if (elementName.equals(SpatialConstants.listOfAnalyticVolumes)){
ListOf<AnalyticVolume> listOfAnalyticVolumes = analyticGeometry.getListOfAnalyticVolumes();
return listOfAnalyticVolumes;
}
} else if (contextObject instanceof SampledFieldGeometry) {
SampledFieldGeometry sfg = (SampledFieldGeometry) contextObject;
if (elementName.equals(SpatialConstants.listOfSampledVolumes)){
ListOf<SampledVolume> listOfSampledVolumes = sfg.getListOfSampledVolumes();
return listOfSampledVolumes;
} else if (elementName.equals(SpatialConstants.sampledField)){
SampledField sf = new SampledField();
sfg.setSampledField(sf);
return sf;
}
} else if (contextObject instanceof SampledField) {
SampledField sf = (SampledField) contextObject;
if (elementName.equals(SpatialConstants.imageData)){
ImageData im = new ImageData();
sf.setImageData(im);
return im;
}
} else if (contextObject instanceof CSGeometry) {
CSGeometry csg = (CSGeometry) contextObject;
if (elementName.equals(SpatialConstants.listOfCSGObjects)){
ListOf<CSGObject> listOfCSGObjects = csg.getListOfCSGObjects();
return listOfCSGObjects;
}
} else if (contextObject instanceof CSGObject) {
CSGObject cso = (CSGObject) contextObject;
if (elementName.equals(SpatialConstants.csgPrimitive)){
CSGPrimitive csgNode = new CSGPrimitive();
cso.setCSGNode(csgNode);
return csgNode;
} else if (elementName.equals(SpatialConstants.csgPseudoPrimitive)){
CSGPseudoPrimitive csgNode = new CSGPseudoPrimitive();
cso.setCSGNode(csgNode);
return csgNode;
} else if (elementName.equals(SpatialConstants.csgSetOperator)){
CSGSetOperator csgNode = new CSGSetOperator();
cso.setCSGNode(csgNode);
return csgNode;
} else if (elementName.equals(SpatialConstants.csgTranslation)){
CSGTranslation csgNode = new CSGTranslation();
cso.setCSGNode(csgNode);
return csgNode;
} else if (elementName.equals(SpatialConstants.csgRotation)){
CSGRotation csgNode = new CSGRotation();
cso.setCSGNode(csgNode);
return csgNode;
} else if (elementName.equals(SpatialConstants.csgScale)){
CSGScale csgNode = new CSGScale();
cso.setCSGNode(csgNode);
return csgNode;
} else if (elementName.equals(SpatialConstants.csgHomogeneousTransformation)){
CSGHomogeneousTransformation csgNode = new CSGHomogeneousTransformation();
cso.setCSGNode(csgNode);
return csgNode;
}
} else if (contextObject instanceof CSGSetOperator) {
CSGSetOperator csgso = (CSGSetOperator) contextObject;
if (elementName.equals(SpatialConstants.listOfCSGNodes)) {
ListOf<CSGNode> listOfCSGNodes = csgso.getListOfCSGNodes();
return listOfCSGNodes;
}
} else if (contextObject instanceof CSGHomogeneousTransformation) {
CSGHomogeneousTransformation csght = (CSGHomogeneousTransformation) contextObject;
if (elementName.equals(SpatialConstants.forwardTransformation)) {
TransformationComponent tc = new TransformationComponent();
csght.setForwardTransformation(tc);
return tc;
} else if (elementName.equals(SpatialConstants.reverseTransformation)) {
TransformationComponent tc = new TransformationComponent();
csght.setReverseTransformation(tc);
return tc;
}
} else if (contextObject instanceof ParametricGeometry) {
ParametricGeometry pg = (ParametricGeometry) contextObject;
if (elementName.equals(SpatialConstants.listOfSpatialPoints)){
ListOf<SpatialPoint> listOfSpatialPoints = pg.getListOfSpatialPoints();
return listOfSpatialPoints;
} else if (elementName.equals(SpatialConstants.listOfParametricObjects)){
ListOf<ParametricObject> listOfParametricObjects = pg.getListOfParametricObjects();
return listOfParametricObjects;
}
} else if (contextObject instanceof ParametricObject) {
ParametricObject po = (ParametricObject) contextObject;
if (elementName.equals(SpatialConstants.imageData)){
PolygonObject polygonObject = new PolygonObject();
po.setPolygonObject(polygonObject);
return polygonObject;
}
}
else if (contextObject instanceof ListOf<?>) {
ListOf<SBase> listOf = (ListOf<SBase>) contextObject;
if (elementName.equals(SpatialConstants.coordinateComponent)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
CoordinateComponent elem = new CoordinateComponent();
geo.addCoordinateComponent(elem);
return elem;
} else if (elementName.equals(SpatialConstants.domainType)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
DomainType elem = new DomainType();
geo.addDomainType(elem);
return elem;
} else if (elementName.equals(SpatialConstants.domain)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
Domain elem = new Domain();
geo.addDomain(elem);
return elem;
} else if (elementName.equals(SpatialConstants.adjacentDomains)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
AdjacentDomains elem = new AdjacentDomains();
geo.addAdjacentDomain(elem);
return elem;
} else if (elementName.equals(SpatialConstants.sampledFieldGeometry)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
SampledFieldGeometry elem = new SampledFieldGeometry();
geo.addGeometryDefinition(elem);
return elem;
} else if (elementName.equals(SpatialConstants.analyticGeometry)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
AnalyticGeometry elem = new AnalyticGeometry();
geo.addGeometryDefinition(elem);
return elem;
} else if (elementName.equals(SpatialConstants.analyticGeometry)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
AnalyticGeometry elem = new AnalyticGeometry();
geo.addGeometryDefinition(elem);
return elem;
} else if (elementName.equals(SpatialConstants.csGeometry)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
CSGeometry elem = new CSGeometry();
geo.addGeometryDefinition(elem);
return elem;
} else if (elementName.equals(SpatialConstants.parametricGeometry)) {
Geometry geo = (Geometry) listOf.getParentSBMLObject();
ParametricGeometry elem = new ParametricGeometry();
geo.addGeometryDefinition(elem);
return elem;
} else if (elementName.equals(SpatialConstants.interiorPoint)) {
Domain domain = (Domain) listOf.getParentSBMLObject();
InteriorPoint elem = new InteriorPoint();
domain.addInteriorPoint(elem);