Example #1
0
 /**
  * Converts the given node into its XML representation and appends that to
  * this writer's output string.
  *
  * The generated string contains the attributes defined via
  * SVGNode::getSerializableAttributes() and the styles defined via
  * SVGNode::getSerializableStyles().
  * Container nodes (<g></g>) and self-closing tags (<rect />) are
  * distinguished correctly.
  *
  * @param SVGNode $node The node to write.
  *
  * @return void
  */
 public function writeNode(SVGNode $node)
 {
     $this->outString .= '<' . $node->getName();
     $this->appendAttributes($node->getSerializableAttributes());
     $this->appendStyles($node->getSerializableStyles());
     if (!$node instanceof SVGNodeContainer) {
         $this->outString .= ' />';
         return;
     }
     $this->outString .= '>';
     for ($i = 0, $n = $node->countChildren(); $i < $n; ++$i) {
         $this->writeNode($node->getChild($i));
     }
     $this->outString .= '</' . $node->getName() . '>';
 }
Example #2
0
 public function getSerializableAttributes()
 {
     $attrs = parent::getSerializableAttributes();
     $points = '';
     for ($i = 0, $n = count($this->points); $i < $n; ++$i) {
         $point = $this->points[$i];
         if ($i > 0) {
             $points .= ' ';
         }
         $points .= $point[0] . ',' . $point[1];
     }
     $attrs['points'] = $points;
     return $attrs;
 }