}
}
else if (graphicalObject instanceof ReferenceGlyph)
{
ReferenceGlyph refGlyph = (ReferenceGlyph) contextObject;
if (elementName.equals(curve)) {
Curve curve = new Curve();
refGlyph.setCurve(curve);
return curve;
}
}
}
else if (contextObject instanceof BoundingBox)
{
BoundingBox bbox = (BoundingBox) contextObject;
if (elementName.equals(position)) {
Position position = new Position();
bbox.setPosition(position);
return position;
}
else if (elementName.equals(dimensions)) {
Dimensions dimension = new Dimensions();
bbox.setDimensions(dimension);
return dimension;
}
}
else if (contextObject instanceof Curve) {
Curve curve = (Curve) contextObject;
SBase newElement = null;
if (elementName.equals(listOfCurveSegments)) {
newElement = curve.getListOfCurveSegments();
}
if (newElement != null) {
return newElement;
}
}
else if (contextObject instanceof CurveSegment) {
CubicBezier curveSegment = (CubicBezier) contextObject;
if (elementName.equals(start)) {
Start point = new Start();
curveSegment.setStart(point);
return point;
}
else if (elementName.equals(end)) {
End point = new End();
curveSegment.setEnd(point);
return point;
}
else if (elementName.equals(basePoint1)) {
BasePoint1 point = new BasePoint1();
curveSegment.setBasePoint1(point);
return point;
}
else if (elementName.equals(basePoint2)) {
BasePoint2 point = new BasePoint2();
curveSegment.setBasePoint2(point);
return point;
}
}
else if (contextObject instanceof ListOf<?>) {
ListOf<SBase> listOf = (ListOf<SBase>) contextObject;
SBase newElement = null;
if (elementName.equals(layout)) {
newElement = new Layout();
}
else if (elementName.equals(compartmentGlyph)) {
newElement = new CompartmentGlyph();
}
else if (elementName.equals(speciesGlyph)) {
newElement = new SpeciesGlyph();
}
else if (elementName.equals(reactionGlyph)) {
newElement = new ReactionGlyph();
}
else if (elementName.equals(textGlyph)) {
newElement = new TextGlyph();
}
else if (elementName.equals(curveSegment) || elementName.equals("cubicBezier")
|| elementName.equals("lineSegment")) // to allow reading of not properly written XML, we add "cubicBezier" and "lineSegment" here.
{
newElement = new CubicBezier(); //Always creating a CubicBezier instance until we know the exact 'type' of the curveElement !!
}
else if (elementName.equals(speciesReferenceGlyph)) {
newElement = new SpeciesReferenceGlyph();
}
else if (elementName.equals(referenceGlyph)) {
newElement = new ReferenceGlyph();
}
else if (elementName.equals(generalGlyph)) {
newElement = new GeneralGlyph();
}