COPASI API  4.16.103
Public Member Functions | Private Types | List of all members
CCopasiXMLParser::TextElement Class Reference
Inheritance diagram for CCopasiXMLParser::TextElement:
Inheritance graph
[legend]
Collaboration diagram for CCopasiXMLParser::TextElement:
Collaboration graph
[legend]

Public Member Functions

virtual void end (const XML_Char *pszName)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
 TextElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual ~TextElement ()
 
- Public Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
 CXMLElementHandler (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void end (const XML_Char *C_UNUSED(pszName))
 
virtual void reset ()
 
virtual void start (const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
 
virtual ~CXMLElementHandler ()
 

Private Types

enum  Element { RenderText = 0 }
 

Additional Inherited Members

- Protected Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
void addFix (const std::string &key, CCopasiObject *pObject)
 
void deleteCurrentHandler ()
 
- Protected Attributes inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
SCopasiXMLParserCommonmCommon
 
C_INT32 mCurrentElement
 
C_INT32 mLastKnownElement
 
CCopasiXMLParsermParser
 
CXMLElementHandlermpCurrentHandler
 

Detailed Description

Definition at line 4196 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enumerator
RenderText 

Definition at line 4203 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

CCopasiXMLParser::TextElement::TextElement ( CCopasiXMLParser parser,
SCopasiXMLParserCommon common 
)
CCopasiXMLParser::TextElement::~TextElement ( )
virtual

Destructor

Definition at line 12296 of file CCopasiXMLParser.cpp.

References pdelete.

12297 {
12299 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

void CCopasiXMLParser::TextElement::end ( const XML_Char *  pszName)
virtual

End element handler

Parameters
constXML_Char *pszName

Definition at line 12460 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pText, CLText::setText(), START_ELEMENT, and UNKNOWN_ELEMENT.

12461 {
12462  std::string text;
12463 
12464  switch (mCurrentElement)
12465  {
12466  case RenderText:
12467 
12468  if (strcmp(pszName, "Text"))
12470  pszName, "Text", mParser.getCurrentLineNumber());
12471 
12472  text = mParser.getCharacterData("\x0a\x0d\t ", "");
12473  assert(mCommon.pText != NULL);
12474  mCommon.pText->setText(text);
12475  mCommon.pText = NULL;
12477 
12478  //reset handler
12480  //call parent handler
12481  mParser.onEndElement(pszName);
12482  break;
12483 
12484  case UNKNOWN_ELEMENT:
12486  break;
12487 
12488  default:
12490  pszName, "???", mParser.getCurrentLineNumber());
12491  break;
12492  }
12493 
12494  return;
12495 }
void setText(const std::string &text)
Definition: CLText.cpp:366
#define START_ELEMENT
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
std::string getCharacterData(const std::string &toBeStripped="", const std::string &join=" ")
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::TextElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 12301 of file CCopasiXMLParser.cpp.

References CLGroup::addChildElement(), CLText::ANCHOR_BOTTOM, CLText::ANCHOR_END, CLText::ANCHOR_MIDDLE, CLText::ANCHOR_START, CLText::ANCHOR_TOP, CCopasiMessage::EXCEPTION, CLGroup::getElement(), CLGroup::getNumElements(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, CLGraphicalPrimitive1D::parseDashArray(), CLTransformation2D::parseTransformation(), SCopasiXMLParserCommon::pGroup, SCopasiXMLParserCommon::pText, CLText::setCoordinates(), CLText::setFontFamily(), CLText::setFontSize(), CLText::setFontStyle(), CLText::setFontWeight(), CLGraphicalPrimitive1D::setStroke(), CLGraphicalPrimitive1D::setStrokeWidth(), CLText::setTextAnchor(), CLText::setVTextAnchor(), strToDouble(), CLText::STYLE_ITALIC, CLText::STYLE_NORMAL, UNKNOWN_ELEMENT, CLText::WEIGHT_BOLD, and CLText::WEIGHT_NORMAL.

12303 {
12304  mCurrentElement++; /* We should always be on the next element */
12305 
12306  const char * Transform;
12307  const char * Stroke;
12308  const char * StrokeWidth;
12309  const char * StrokeDashArray;
12310  const char * X;
12311  const char * Y;
12312  const char * Z;
12313  const char * FontFamily;
12314  const char * FontSize;
12315  const char * FontWeight;
12316  const char * FontStyle;
12317  const char * TextAnchor;
12318  const char * VTextAnchor;
12319  CLText* pText = NULL;
12320 
12321  switch (mCurrentElement)
12322  {
12323  case RenderText:
12324 
12325  if (strcmp(pszName, "Text"))
12327  pszName, "Text", mParser.getCurrentLineNumber());
12328 
12329  Transform = mParser.getAttributeValue("transform", papszAttrs, false);
12330  Stroke = mParser.getAttributeValue("stroke", papszAttrs, false);
12331  StrokeWidth = mParser.getAttributeValue("stroke-width", papszAttrs, false);
12332  StrokeDashArray = mParser.getAttributeValue("stroke-dasharray", papszAttrs, false);
12333  X = mParser.getAttributeValue("x", papszAttrs);
12334  Y = mParser.getAttributeValue("y", papszAttrs);
12335  Z = mParser.getAttributeValue("z", papszAttrs, "0.0");
12336  FontFamily = mParser.getAttributeValue("font-family", papszAttrs, false);
12337  FontSize = mParser.getAttributeValue("font-size", papszAttrs, false);
12338  FontWeight = mParser.getAttributeValue("font-weight", papszAttrs, false);
12339  FontStyle = mParser.getAttributeValue("font-style", papszAttrs, false);
12340  TextAnchor = mParser.getAttributeValue("text-anchor", papszAttrs, false);
12341  VTextAnchor = mParser.getAttributeValue("vtext-anchor", papszAttrs, false);
12342  pText = new CLText(NULL);
12343 
12344  if (Transform != NULL)
12345  {
12346  pText->parseTransformation(Transform);
12347  }
12348 
12349  if (Stroke != NULL)
12350  {
12351  pText->setStroke(Stroke);
12352  }
12353 
12354  if (StrokeWidth != NULL)
12355  {
12356  double width = strToDouble(StrokeWidth, NULL);
12357  pText->setStrokeWidth(width);
12358  }
12359 
12360  if (StrokeDashArray != NULL)
12361  {
12362  pText->parseDashArray(StrokeDashArray);
12363  }
12364 
12366 
12367  if (FontFamily != NULL)
12368  {
12369  pText->setFontFamily(FontFamily);
12370  }
12371 
12372  if (FontSize != NULL)
12373  {
12374  pText->setFontSize(CLRelAbsVector(FontSize));
12375  }
12376 
12377  if (FontStyle != NULL)
12378  {
12379  std::string s(FontStyle);
12380 
12381  if (s == "normal")
12382  {
12384  }
12385  else if (s == "italic")
12386  {
12388  }
12389  }
12390 
12391  if (FontWeight != NULL)
12392  {
12393  std::string s(FontWeight);
12394 
12395  if (s == "normal")
12396  {
12398  }
12399  else if (s == "bold")
12400  {
12402  }
12403  }
12404 
12405  if (TextAnchor != NULL)
12406  {
12407  std::string s(TextAnchor);
12408 
12409  if (s == "start")
12410  {
12412  }
12413  else if (s == "middle")
12414  {
12416  }
12417  else if (s == "end")
12418  {
12420  }
12421  }
12422 
12423  if (VTextAnchor != NULL)
12424  {
12425  std::string s(VTextAnchor);
12426 
12427  if (s == "top")
12428  {
12430  }
12431  else if (s == "middle")
12432  {
12434  }
12435  else if (s == "bottom")
12436  {
12438  }
12439  }
12440 
12441  mCommon.pGroup->addChildElement(pText);
12442  // delete the text element again since the add method made a copy
12443  delete pText;
12445  assert(mCommon.pText != NULL);
12447  break;
12448 
12449  default:
12453  mParser.onStartElement(pszName, papszAttrs);
12454  break;
12455  }
12456 
12457  return;
12458 }
Definition: CLText.h:27
UnknownElement mUnknownElement
void enableCharacterDataHandler(bool fEnable=true)
void setVTextAnchor(CLText::TEXT_ANCHOR anchor)
Definition: CLText.cpp:294
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
void setTextAnchor(CLText::TEXT_ANCHOR anchor)
Definition: CLText.cpp:286
void parseDashArray(const std::string &s)
void setFontSize(const CLRelAbsVector &size)
Definition: CLText.cpp:262
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CCopasiObject * getElement(size_t n)
Definition: CLGroup.cpp:409
void setFontWeight(CLText::FONT_WEIGHT weight)
Definition: CLText.cpp:270
void setCoordinates(const CLRelAbsVector &x, const CLRelAbsVector &y, const CLRelAbsVector &z=CLRelAbsVector(0.0, 0.0))
Definition: CLText.cpp:172
void setStroke(const std::string &key)
void setFontFamily(const std::string &family)
Definition: CLText.cpp:254
double strToDouble(const char *str, char const **pTail)
Definition: utility.cpp:325
int getCurrentLineNumber() const
Definition: CExpat.h:470
void setStrokeWidth(double width)
size_t getNumElements() const
Definition: CLGroup.cpp:384
void addChildElement(const CLTransformation2D *pChild)
Definition: CLGroup.cpp:517
void setFontStyle(CLText::FONT_STYLE style)
Definition: CLText.cpp:278
virtual void parseTransformation(const std::string &transformationString)

The documentation for this class was generated from the following files: