END_TEST START_TEST (test_GradientBase_GradientStops) { fail_unless(B->getNumGradientStops() == 0); GradientStop* pStop=B->createGradientStop(); fail_unless(pStop != NULL); fail_unless(B->getNumGradientStops() == 1); pStop = new GradientStop(renderns); fail_unless( B->addGradientStop(pStop) == LIBSBML_INVALID_OBJECT); fail_unless(B->getNumGradientStops() == 1); pStop->setOffset(RelAbsVector(0.0,50.0)); fail_unless( B->addGradientStop(pStop) == LIBSBML_INVALID_OBJECT); fail_unless(B->getNumGradientStops() == 1); pStop->setStopColor("#FF0000"); fail_unless( B->addGradientStop(pStop) == LIBSBML_OPERATION_SUCCESS); fail_unless(B->getNumGradientStops() == 2); delete pStop; pStop = new GradientStop(2,1); pStop->setOffset(RelAbsVector(0.0,50.0)); pStop->setStopColor("#FF0000"); fail_unless(B->addGradientStop(pStop) == LIBSBML_LEVEL_MISMATCH); delete pStop; fail_unless(B->getNumGradientStops() == 2); }
LIBSBML_CPP_NAMESPACE_BEGIN /** @cond doxygenLibsbmlInternal */ /* * Creates a new RenderPoint object with the given SBML level * and SBML version. * * @param level SBML level of the new object * @param level SBML version of the new object */ RenderPoint::RenderPoint (unsigned int level, unsigned int version, unsigned int pkgVersion) : SBase(level,version) ,mXOffset(RelAbsVector(0.0,0.0)) ,mYOffset(RelAbsVector(0.0,0.0)) ,mZOffset(RelAbsVector(0.0,0.0)) ,mElementName("element") { if (!hasValidLevelVersionNamespaceCombination()) throw SBMLConstructorException(); RenderPkgNamespaces* renderns = new RenderPkgNamespaces(level, version, pkgVersion); setSBMLNamespacesAndOwn(renderns); connectToChild(); loadPlugins(renderns); }
/* * Creates a new Text object with the given SBML level * and SBML version. * * @param level SBML level of the new object * @param level SBML version of the new object */ Text::Text (unsigned int level, unsigned int version, unsigned int pkgVersion) : GraphicalPrimitive1D(level,version, pkgVersion), mX(RelAbsVector(0.0,0.0)), mY(RelAbsVector(0.0,0.0)), mZ(RelAbsVector(0.0,0.0)), mFontFamily(""), mFontSize(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN())), mFontWeight(Text::WEIGHT_UNSET), mFontStyle(Text::STYLE_UNSET), mTextAnchor(Text::ANCHOR_UNSET), mVTextAnchor(Text::ANCHOR_UNSET), mText("") { if (!hasValidLevelVersionNamespaceCombination()) throw SBMLConstructorException(); }
/* * Instantiates a new Text object with the given @p id and position offset. * The position offset coordinates can be omitted and will be set to 0 in * that case. * * All attributes are set as described for the default constructor * of GraphicalPrimitive1D. * All the font rendering attributes as well * as the text to be rendered are unset. * * @param id id string for the Text object * @param x x coordinate of the position offset * @param y y coordinate of the position offset * @param z z coordinate of the position offset * * This constructor is deprecated. The new libsbml API only has * constructors which take the SBML level and version or one that takes * an SBMLNamespaces object. */ Text::Text(RenderPkgNamespaces* renderns, const std::string& id,const RelAbsVector& x,const RelAbsVector& y,const RelAbsVector& z): GraphicalPrimitive1D(renderns, id), mX(x), mY(y), mZ(z), mFontFamily(""), mFontSize(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN())), mFontWeight(Text::WEIGHT_UNSET), mFontStyle(Text::STYLE_UNSET), mTextAnchor(Text::ANCHOR_UNSET), mVTextAnchor(Text::ANCHOR_UNSET), mText("") { #ifdef DEPRECATION_WARNINGS std::cerr << "Warning. Text::Text(const std::string& id,const RelAbsVector& x,const RelAbsVector& y,const RelAbsVector& z) is deprecated." << std::endl; #endif // DEPRECATION_WARNINGS // set the element namespace of this object setElementNamespace(renderns->getURI()); // connect child elements to this element. connectToChild(); // load package extensions bound with this object (if any) loadPlugins(renderns); }
/* * Creates a new RenderPoint object with the given SBMLNamespaces. * * @param sbmlns The SBML namespace for the object. */ RenderPoint::RenderPoint (RenderPkgNamespaces* renderns): SBase(renderns) ,mXOffset(RelAbsVector(0.0,0.0)) ,mYOffset(RelAbsVector(0.0,0.0)) ,mZOffset(RelAbsVector(0.0,0.0)) ,mElementName("element") { if (!hasValidLevelVersionNamespaceCombination()) throw SBMLConstructorException(); // set the element namespace of this object setElementNamespace(renderns->getURI()); // connect child elements to this element. connectToChild(); // load package extensions bound with this object (if any) loadPlugins(renderns); }
/* * Subclasses should override this method to write their XML attributes * to the XMLOutputStream. Be sure to call your parents implementation * of this method as well. For example: * * SBase::writeAttributes(stream); * stream.writeAttribute( "id" , mId ); * stream.writeAttribute( "name", mName ); * ... */ void RenderCubicBezier::writeAttributes (XMLOutputStream& stream) const { SBase::writeAttributes(stream); XMLTriple triple("type","","xsi"); stream.writeAttribute(triple,std::string("RenderCubicBezier")); std::ostringstream os; os << this->mXOffset; stream.writeAttribute("x", getPrefix(), os.str()); os.str(""); os << this->mYOffset; stream.writeAttribute("y", getPrefix(), os.str()); if(this->mZOffset!=RelAbsVector(0.0,0.0)) { os.str(""); os << this->mZOffset; stream.writeAttribute("z", getPrefix(), os.str()); } os.str(""); os << this->mBasePoint1_X; stream.writeAttribute("basePoint1_x", getPrefix(), os.str()); os.str(""); os << this->mBasePoint1_Y; stream.writeAttribute("basePoint1_y", getPrefix(), os.str()); if(this->mBasePoint1_Z!=RelAbsVector(0.0,0.0)) { os.str(""); os << this->mBasePoint1_Z; stream.writeAttribute("basePoint1_z", getPrefix(), os.str()); } os.str(""); os << this->mBasePoint2_X; stream.writeAttribute("basePoint2_x", getPrefix(), os.str()); os.str(""); os << this->mBasePoint2_Y; stream.writeAttribute("basePoint2_y", getPrefix(), os.str()); if(this->mBasePoint2_Z!=RelAbsVector(0.0,0.0)) { os.str(""); os << this->mBasePoint2_Z; stream.writeAttribute("basePoint2_z", getPrefix(), os.str()); } }
/** @cond doxygenLibsbmlInternal */ void RenderPoint::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { SBase::readAttributes(attributes, expectedAttributes); std::string s; if(attributes.readInto("x",s, getErrorLog(), false, getLine(), getColumn())) { this->mXOffset=RelAbsVector(s); } else { this->mXOffset=RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()); } if(attributes.readInto("y",s, getErrorLog(), false, getLine(), getColumn())) { this->mYOffset=RelAbsVector(s); } else { this->mYOffset=RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()); } if(attributes.readInto("z",s, getErrorLog(), false, getLine(), getColumn())) { this->mZOffset=RelAbsVector(s); } else { this->mZOffset=RelAbsVector(0.0,0.0); } }
/* * Creates a new Text object with the given SBMLNamespaces. * * @param sbmlns The SBML namespace for the object. */ Text::Text (RenderPkgNamespaces* renderns) : GraphicalPrimitive1D(renderns) , mX(RelAbsVector(0.0,0.0)) , mY(RelAbsVector(0.0,0.0)) , mZ(RelAbsVector(0.0,0.0)) , mFontFamily("") , mFontSize(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN())) , mFontWeight(Text::WEIGHT_UNSET) , mFontStyle(Text::STYLE_UNSET) , mTextAnchor(Text::ANCHOR_UNSET) , mVTextAnchor(Text::ANCHOR_UNSET) , mText("") { if (!hasValidLevelVersionNamespaceCombination()) throw SBMLConstructorException(); // set the element namespace of this object setElementNamespace(renderns->getURI()); // connect child elements to this element. connectToChild(); // load package extensions bound with this object (if any) loadPlugins(renderns); }
END_TEST START_TEST (test_RenderCubicBezier_setBasePoint2 ) { fail_unless(P->basePoint2_X().getAbsoluteValue() < 1e-9); fail_unless(P->basePoint2_X().getRelativeValue() < 1e-9); fail_unless(P->basePoint2_Y().getAbsoluteValue() < 1e-9); fail_unless(P->basePoint2_Y().getRelativeValue() < 1e-9); fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9); fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 20.0) / 20.0) < 1e-9); fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 30.0) / 30.0) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 40.0) / 40.0) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 50.0) / 50.0) < 1e-9); fail_unless(fabs((P->basePoint2_Z().getAbsoluteValue() - 60.0) / 60.0) < 1e-9); fail_unless(fabs((P->basePoint2_Z().getRelativeValue() - 70.0) / 70.0) < 1e-9); P->setBasePoint2(RelAbsVector(2.0,3.0),RelAbsVector(4.0,5.0)); fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 2.0) / 2.0) < 1e-9); fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 3.0) / 3.0) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 4.0) / 4.0) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 5.0) / 5.0) < 1e-9); fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9); fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9); P->setBasePoint2_X(RelAbsVector(3.2,2.3)); fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 3.2) / 3.2) < 1e-9); fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 2.3) / 2.3) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 4.0) / 4.0) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 5.0) / 5.0) < 1e-9); fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9); fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9); P->setBasePoint2_Y(RelAbsVector(1.1,2.2)); fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 3.2) / 3.2) < 1e-9); fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 2.3) / 2.3) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 1.1) / 1.1) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 2.2) / 2.2) < 1e-9); fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9); fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9); P->setBasePoint2_Z(RelAbsVector(5.5,6.6)); fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 3.2) / 3.2) < 1e-9); fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 2.3) / 2.3) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 1.1) / 1.1) < 1e-9); fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 2.2) / 2.2) < 1e-9); fail_unless(fabs((P->basePoint2_Z().getAbsoluteValue() - 5.5) / 5.5) < 1e-9); fail_unless(fabs((P->basePoint2_Z().getRelativeValue() - 6.6) / 6.6) < 1e-9); }
/** @cond doxygenLibsbmlInternal */ void RenderPoint::writeAttributes (XMLOutputStream& stream) const { SBase::writeAttributes(stream); XMLTriple triple("type","","xsi"); stream.writeAttribute(triple,std::string("RenderPoint")); std::ostringstream os; os << mXOffset; stream.writeAttribute("x", getPrefix(), os.str()); os.str(""); os << mYOffset; stream.writeAttribute("y", getPrefix(), os.str()); if(this->mZOffset!=RelAbsVector(0.0,0.0)) { os.str(""); os << mZOffset; stream.writeAttribute("z", getPrefix(), os.str()); } }
END_TEST START_TEST ( test_Text_FontSize ) { fail_unless(!T->isSetFontSize()); T->setFontSize(RelAbsVector(18.0,0.0)); fail_unless(T->isSetFontSize()); fail_unless(T->getFontSize() == RelAbsVector(18.0,0.0)); T->setFontSize(RelAbsVector(0.0,50.0)); fail_unless(T->isSetFontSize()); fail_unless(T->getFontSize() == RelAbsVector(0.0,50.0)); T->setFontSize(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN())); fail_unless(!T->isSetFontSize()); T->setFontSize(RelAbsVector(23.0,std::numeric_limits<double>::quiet_NaN())); fail_unless(!T->isSetFontSize()); T->setFontSize(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),75.0)); fail_unless(!T->isSetFontSize()); }
/** @cond doxygenLibsbmlInternal */ void RenderCubicBezier::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { RenderPoint::readAttributes(attributes, expectedAttributes); std::string s; if(attributes.readInto("basePoint1_x",s, getErrorLog(), false, getLine(), getColumn())) { this->mBasePoint1_X=RelAbsVector(s); } else { this->mBasePoint1_X=RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()); } if(attributes.readInto("basePoint1_y",s, getErrorLog(), false, getLine(), getColumn())) { this->mBasePoint1_Y=RelAbsVector(s); } else { this->mBasePoint1_Y=RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()); } if(attributes.readInto("basePoint1_z",s, getErrorLog(), false, getLine(), getColumn())) { this->mBasePoint1_Z=RelAbsVector(s); } else { this->mBasePoint1_Z=RelAbsVector(0.0,0.0); } if(attributes.readInto("basePoint2_x",s, getErrorLog(), false, getLine(), getColumn())) { this->mBasePoint2_X=RelAbsVector(s); } else { this->mBasePoint2_X=RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()); } if(attributes.readInto("basePoint2_y",s, getErrorLog(), false, getLine(), getColumn())) { this->mBasePoint2_Y=RelAbsVector(s); } else { this->mBasePoint2_Y=RelAbsVector(std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()); } if(attributes.readInto("basePoint2_z",s, getErrorLog(), false, getLine(), getColumn())) { this->mBasePoint2_Z=RelAbsVector(s); } else { this->mBasePoint2_Z=RelAbsVector(0.0,0.0); } }
/** @cond doxygenLibsbmlInternal */ void Text::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { GraphicalPrimitive1D::readAttributes(attributes,expectedAttributes); std::string s; double NaN=std::numeric_limits<double>::quiet_NaN(); attributes.readInto("font-family", this->mFontFamily, getErrorLog(), false, getLine(), getColumn()); Text::FONT_WEIGHT fw=Text::WEIGHT_UNSET; Text::FONT_STYLE fs=Text::STYLE_UNSET; Text::TEXT_ANCHOR ta=Text::ANCHOR_UNSET; Text::TEXT_ANCHOR vta=Text::ANCHOR_UNSET; attributes.readInto("x",s, getErrorLog(), false, getLine(), getColumn()); this->mX=RelAbsVector(s); attributes.readInto("y",s, getErrorLog(), false, getLine(), getColumn()); this->mY=RelAbsVector(s); if(attributes.readInto("z",s, getErrorLog(), false, getLine(), getColumn())) { this->mZ=RelAbsVector(s); } else { this->mZ=RelAbsVector(0.0,0.0); } if(attributes.readInto("font-size", s, getErrorLog(), false, getLine(), getColumn())) { this->mFontSize=RelAbsVector(s); } else { this->mFontSize=RelAbsVector(NaN,NaN); } if(attributes.readInto("font-weight", s, getErrorLog(), false, getLine(), getColumn())) { if(s=="bold") { fw=Text::WEIGHT_BOLD; } else if (s == "normal") { fw = Text::WEIGHT_NORMAL; } } if(attributes.readInto("font-style", s, getErrorLog(), false, getLine(), getColumn())) { if(s=="italic") { fs=Text::STYLE_ITALIC; } else if (s == "normal") { fs = Text::STYLE_NORMAL; } } if(attributes.readInto("text-anchor", s, getErrorLog(), false, getLine(), getColumn())) { if(s=="end") { ta=Text::ANCHOR_END; } else if(s=="middle") { ta=Text::ANCHOR_MIDDLE; } else if(s=="start") { ta=Text::ANCHOR_START; } } if(attributes.readInto("vtext-anchor", s, getErrorLog(), false, getLine(), getColumn())) { if(s=="bottom") { vta=Text::ANCHOR_BOTTOM; } else if(s=="middle") { vta=Text::ANCHOR_MIDDLE; } else if(s=="top") { vta=Text::ANCHOR_TOP; } /* else if(s=="baseline") { vta=Text::ANCHOR_BASELINE; } */ } this->setTextAnchor(ta); this->setVTextAnchor(vta); this->setFontWeight(fw); this->setFontStyle(fs); }
END_TEST START_TEST ( test_RenderCubicBezier_hasRequiredAttributes ) { fail_unless( P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless( P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),50.0),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,std::numeric_limits<double>::quiet_NaN())); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless( P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless( P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),50.0),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,std::numeric_limits<double>::quiet_NaN())); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless(! P->hasRequiredAttributes() ); P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0)); fail_unless( P->hasRequiredAttributes() ); }