XML_SVG
[ class tree: XML_SVG ] [ index: XML_SVG ] [ all elements ]

Source for file SVG.php

Documentation is available at SVG.php

  1. <?php
  2. /**
  3.  * XML_SVG
  4.  *
  5.  * Wrapper class that provides some examples and a few convenience
  6.  * methods.
  7.  *
  8.  * $Horde: framework/XML_SVG/SVG.php,v 1.18 2005/01/03 13:09:24 jan Exp $
  9.  *
  10.  * Copyright 2002-2005 Chuck Hagenbuch <chuck@horde.org>
  11.  *
  12.  * See the enclosed file COPYING for license information (LGPL). If you
  13.  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  14.  *
  15.  * @package XML_SVG
  16.  */
  17. class XML_SVG {
  18.  
  19.     function example()
  20.     {
  21.         // Create an instance of XML_SVG_Document. All other objects
  22.         // will be added to this instance for printing. Set the height
  23.         // and width of the viewport.
  24.         $svg &new XML_SVG_Document(array('width' => 400,
  25.                                            'height' => 200));
  26.  
  27.         // Create an instance of XML_SVG_Group. Set the style,
  28.         // transforms for child objects.
  29.         $g &new XML_SVG_Group(array('style' => 'stroke:black',
  30.                                       'transform' => 'translate(200 100)'));
  31.  
  32.         // Add a parent to the g instance.
  33.         $g->addParent($svg);
  34.  
  35.         // The same results can be accomplished by making g a child of the svg.
  36.         // $svg->addChild($g);
  37.  
  38.         // Create and animate a circle.
  39.         $circle &new XML_SVG_Circle(array('cx' => 0,
  40.                                            'cy' => 0,
  41.                                            'r' => 100,
  42.                                            'style' => 'stroke-width:3'));
  43.         $circle->addChild(new XML_SVG_Animate(array('attributeName' => 'r',
  44.                                                     'attributeType' => 'XML',
  45.                                                     'from' => 0,
  46.                                                     'to' => 75,
  47.                                                     'dur' => '3s',
  48.                                                     'fill' => 'freeze')));
  49.         $circle->addChild(new XML_SVG_Animate(array('attributeName' => 'fill',
  50.                                                     'attributeType' => 'CSS',
  51.                                                     'from' => 'green',
  52.                                                     'to' => 'red',
  53.                                                     'dur' => '3s',
  54.                                                     'fill' => 'freeze')));
  55.  
  56.         // Make the circle a child of g.
  57.         $g->addChild($circle);
  58.  
  59.         // Create and animate some text.
  60.         $text &new XML_SVG_Text(array('text' => 'SVG chart!',
  61.                                        'x' => 0,
  62.                                        'y' => 0,
  63.                                        'style' => 'font-size:20;text-anchor:middle;'));
  64.         $text->addChild(new XML_SVG_Animate(array('attributeName' => 'font-size',
  65.                                                   'attributeType' => 'auto',
  66.                                                   'from' => 0,
  67.                                                   'to' => 20,
  68.                                                   'dur' => '3s',
  69.                                                   'fill' => 'freeze')));
  70.  
  71.         // Make the text a child of g.
  72.         $g->addChild($text);
  73.  
  74.         // Send a message to the svg instance to start printing.
  75.         $svg->printElement();
  76.     }
  77.  
  78. }
  79.  
  80. /**
  81.  * XML_SVG_Element
  82.  *
  83.  * This is the base class for the different SVG Element
  84.  * Objects. Extend this class to create a new SVG Element.
  85.  *
  86.  * @package XML_SVG
  87.  */
  88. class XML_SVG_Element {
  89.  
  90.     var $_elements = null;
  91.     var $_style = null;
  92.     var $_transform = null;
  93.     var $_id = null;
  94.  
  95.     function XML_SVG_Element($params = array())
  96.     {
  97.         foreach ($params as $p => $v{
  98.             $param '_' $p;
  99.             $this->$param $v;
  100.         }
  101.     }
  102.  
  103.     /**
  104.      * Most SVG elements can contain child elements. This method calls
  105.      * the printElement method of any child element added to this
  106.      * object by use of the addChild method.
  107.      */
  108.     function printElement()
  109.     {
  110.         // Loop and call.
  111.         if (is_array($this->_elements)) {
  112.             foreach ($this->_elements as $child{
  113.                 $child->printElement();
  114.             }
  115.         }
  116.     }
  117.  
  118.     /**
  119.      * This method adds an object reference (or value, if $copy is
  120.      * true) to the _elements array.
  121.      */
  122.     function addChild(&$element$copy = false)
  123.     {
  124.         if ($copy{
  125.             $this->_elements[&$element->copy();
  126.         else {
  127.             $this->_elements[&$element;
  128.         }
  129.     }
  130.  
  131.     /**
  132.      * This method sends a message to the passed element requesting to
  133.      * be added as a child.
  134.      */
  135.     function addParent(&$parent)
  136.     {
  137.         if (is_subclass_of($parent'XML_SVG_Element')) {
  138.             $parent->addChild($this);
  139.         }
  140.     }
  141.  
  142.     function copy()
  143.     {
  144.         if (version_compare(zend_version()'2''>')) {
  145.             return clone($this);
  146.         else {
  147.             $xml_svg $this;
  148.             return $xml_svg;
  149.         }
  150.     }
  151.  
  152.     /**
  153.      * Print each of the passed parameters, if they are set.
  154.      */
  155.     function printParams()
  156.     {
  157.         foreach (func_get_args(as $param{
  158.             $_param '_' $param;
  159.             if (isset($this->$_param)) {
  160.                 switch ($param{
  161.                 case 'filter':
  162.                     echo ' filter="url(#' $this->$_param ')"';
  163.                     break;
  164.  
  165.                 default:
  166.                     echo ' ' str_replace('_''-'$param'="' $this->$_param '"';
  167.                     break;
  168.                 }
  169.             }
  170.         }
  171.     }
  172.  
  173.     // Set any named attribute of an element to a value.
  174.     function setParam($param$value)
  175.     {
  176.         $attr '_' $param;
  177.         $this->$attr $value;
  178.     }
  179.  
  180.     // Get any named attribute of an element.
  181.     function getParam($param)
  182.     {
  183.         $attr '_' $param;
  184.         if (isset($this->$attr)) {
  185.             return $this->$attr;
  186.         else {
  187.             return null;
  188.         }
  189.     }
  190.  
  191.     // Print out the object for debugging.
  192.     function debug()
  193.     {
  194.         echo '<pre>'var_dump($this); echo '</pre>';
  195.     }
  196.  
  197. }
  198.  
  199. /**
  200.  * XML_SVG_Fragment
  201.  *
  202.  * @package XML_SVG
  203.  */
  204. class XML_SVG_Fragment extends XML_SVG_Element {
  205.  
  206.     var $_width;
  207.     var $_height;
  208.     var $_viewBox;
  209.     var $_x;
  210.     var $_y;
  211.  
  212.     function printElement()
  213.     {
  214.         echo '<svg';
  215.         $this->printParams('id''width''height''x''y''viewBox''style');
  216.         echo ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' "\n";
  217.         parent::printElement();
  218.         echo "</svg>\n";
  219.     }
  220.  
  221.     function bufferObject()
  222.     {
  223.         ob_start();
  224.         $this->printElement();
  225.         $output ob_get_contents();
  226.         ob_end_clean();
  227.  
  228.         return $output;
  229.     }
  230. }
  231.  
  232. /**
  233.  * XML_SVG_Document
  234.  *
  235.  * This extends the XML_SVG_Fragment class. It wraps the XML_SVG_Frament output
  236.  * with a content header, xml definition and doctype.
  237.  *
  238.  * @package XML_SVG
  239.  */
  240.  
  241.     function printElement()
  242.     {
  243.         header('Content-Type: image/svg+xml');
  244.  
  245.         print('<?xml version="1.0" encoding="iso-8859-1"?>'."\n");
  246.         print('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  247.             "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' "\n");
  248.  
  249.         parent::printElement();
  250.     }
  251.  
  252. }
  253.  
  254. /**
  255.  * XML_SVG_Group
  256.  *
  257.  * @package XML_SVG
  258.  */
  259. class XML_SVG_Group extends XML_SVG_Element {
  260.  
  261.     function printElement()
  262.     {
  263.         echo '<g';
  264.         $this->printParams('id''style''transform''filter');
  265.         print(">\n");
  266.         parent::printElement();
  267.         print("</g>\n");
  268.     }
  269.  
  270. }
  271.  
  272. /**
  273.  * XML_SVG_Textpath
  274.  *
  275.  * @package XML_SVG
  276.  */
  277. class XML_SVG_Textpath extends XML_SVG_Element {
  278.  
  279.     var $_text;
  280.     var $_x;
  281.     var $_y;
  282.     var $_dx;
  283.     var $_dy;
  284.     var $_rotate;
  285.     var $_textLength;
  286.     var $_lengthAdjust;
  287.  
  288.     function printElement($element 'textpath')
  289.     {
  290.         echo '<' $element;
  291.         $this->printParams('id''x''y''dx''dy''rotate',
  292.                            'textLength''lengthAdjust''style''transform');
  293.         echo '>' htmlentities($this->_text);
  294.         parent::printElement();
  295.         echo "</$element>\n";
  296.     }
  297.  
  298.     function setShape($x$y$text)
  299.     {
  300.         $this->_x $x;
  301.         $this->_y $y;
  302.         $this->_text $text;
  303.     }
  304.  
  305. }
  306.  
  307. /**
  308.  * XML_SVG_Text
  309.  *
  310.  * @package XML_SVG
  311.  */
  312. class XML_SVG_Text extends XML_SVG_Textpath {
  313.  
  314.     function printElement()
  315.     {
  316.         parent::printElement('text');
  317.     }
  318.  
  319.     function setShape($x$y$text)
  320.     {
  321.         $this->_x $x;
  322.         $this->_y $y;
  323.         $this->_text $text;
  324.     }
  325.  
  326. }
  327.  
  328. /**
  329.  * XML_SVG_Tspan
  330.  *
  331.  * @package XML_SVG
  332.  */
  333. class XML_SVG_Tspan extends XML_SVG_Element {
  334.  
  335.     var $_text;
  336.     var $_x;
  337.     var $_y;
  338.     var $_dx;
  339.     var $_dy;
  340.     var $_rotate;
  341.     var $_textLength;
  342.     var $_lengthAdjust;
  343.  
  344.     function printElement()
  345.     {
  346.         echo '<tspan';
  347.         $this->printParams('id''x''y''dx''dy''rotate',
  348.                            'textLength''lengthAdjust''style''transform');
  349.         echo '>' $this->_text;
  350.         if (is_array($this->_elements)) {
  351.             parent::printElement();
  352.         }
  353.         echo "</tspan>\n";
  354.     }
  355.  
  356.     function setShape($x$y$text)
  357.     {
  358.         $this->_x $x;
  359.         $this->_y $y;
  360.         $this->_text  $text;
  361.     }
  362.  
  363. }
  364.  
  365. /**
  366.  * XML_SVG_Circle
  367.  *
  368.  * @package XML_SVG
  369.  */
  370. class XML_SVG_Circle extends XML_SVG_Element {
  371.  
  372.     var $_cx;
  373.     var $_cy;
  374.     var $_r;
  375.  
  376.     function printElement()
  377.     {
  378.         echo '<circle';
  379.  
  380.         $this->printParams('id''cx''cy''r''style''transform');
  381.         if (is_array($this->_elements)) {
  382.             // Print children, start and end tag.
  383.             echo ">\n";
  384.             parent::printElement();
  385.             echo "</circle>\n";
  386.         else {
  387.             // Print short tag.
  388.             echo "/>\n";
  389.         }
  390.     }
  391.  
  392.     function setShape($cx$cy$r)
  393.     {
  394.         $this->_cx $cx;
  395.         $this->_cy $cy;
  396.         $this->_r  $r;
  397.     }
  398.  
  399. }
  400.  
  401. /**
  402.  * XML_SVG_Line
  403.  *
  404.  * @package XML_SVG
  405.  */
  406. class XML_SVG_Line extends XML_SVG_Element {
  407.  
  408.     var $_x1;
  409.     var $_y1;
  410.     var $_x2;
  411.     var $_y2;
  412.  
  413.     function printElement()
  414.     {
  415.         echo '<line';
  416.         $this->printParams('id''x1''y1''x2''y2''style');
  417.         if (is_array($this->_elements)) {
  418.             // Print children, start and end tag.
  419.             print(">\n");
  420.             parent::printElement();
  421.             print("</line>\n");
  422.         else {
  423.             // Print short tag.
  424.             print("/>\n");
  425.         }
  426.     }
  427.  
  428.     function setShape($x1$y1$x2$y2)
  429.     {
  430.         $this->_x1 $x1;
  431.         $this->_y1 $y1;
  432.         $this->_x2  $x2;
  433.         $this->_y2  $y2;
  434.     }
  435.  
  436. }
  437.  
  438. /**
  439.  * XML_SVG_Rect
  440.  *
  441.  * @package XML_SVG
  442.  */
  443. class XML_SVG_Rect extends XML_SVG_Element {
  444.  
  445.     var $_x;
  446.     var $_y;
  447.     var $_width;
  448.     var $_height;
  449.     var $_rx;
  450.     var $_ry;
  451.  
  452.     function printElement()
  453.     {
  454.         echo '<rect';
  455.         $this->printParams('id''x''y''width''height',
  456.                            'rx''ry''style');
  457.         if (is_array($this->_elements)) {
  458.             // Print children, start and end tag.
  459.             print(">\n");
  460.             parent::printElement();
  461.             print("</rect>\n");
  462.         else {
  463.             // Print short tag.
  464.             print("/>\n");
  465.         }
  466.     }
  467.  
  468.     function setShape($x$y$width$height)
  469.     {
  470.         $this->_x $x;
  471.         $this->_y $y;
  472.         $this->_width  $width;
  473.         $this->_height  $height;
  474.     }
  475.  
  476. }
  477.  
  478. /**
  479.  * XML_SVG_Ellipse
  480.  *
  481.  * @package XML_SVG
  482.  */
  483. class XML_SVG_Ellipse extends XML_SVG_Element {
  484.  
  485.     var $_cx;
  486.     var $_cy;
  487.     var $_rx;
  488.     var $_ry;
  489.  
  490.     function printElement()
  491.     {
  492.         echo '<ellipse';
  493.         $this->printParams('id''cx''cy''rx''ry''style''transform');
  494.         if (is_array($this->_elements)) {
  495.             // Print children, start and end tag.
  496.             print(">\n");
  497.             parent::printElement();
  498.             print("</ellipse>\n");
  499.         else {
  500.             // Print short tag.
  501.             print(" />\n");
  502.         }
  503.     }
  504.  
  505.     function setShape($cx$cy$rx$ry)
  506.     {
  507.         $this->_cx $cx;
  508.         $this->_cy $cy;
  509.         $this->_rx  $rx;
  510.         $this->_ry  $ry;
  511.     }
  512.  
  513. }
  514.  
  515. /**
  516.  * XML_SVG_Polyline
  517.  *
  518.  * @package XML_SVG
  519.  */
  520. class XML_SVG_Polyline extends XML_SVG_Element {
  521.  
  522.     var $_points;
  523.  
  524.     function printElement()
  525.     {
  526.         echo '<polyline';
  527.         $this->printParams('id''points''style''transform');
  528.  
  529.         if (is_array($this->_elements)) {
  530.             // Print children, start and end tag.
  531.             print(">\n");
  532.             parent::printElement();
  533.             print("</polyline>\n");
  534.         else {
  535.             // Print short tag.
  536.             print("/>\n");
  537.         }
  538.     }
  539.  
  540.     function setShape($points)
  541.     {
  542.         $this->_points $points;
  543.     }
  544.  
  545. }
  546.  
  547. /**
  548.  * XML_SVG_Polygon
  549.  *
  550.  * @package XML_SVG
  551.  */
  552. class XML_SVG_Polygon extends XML_SVG_Element {
  553.  
  554.     var $_points;
  555.  
  556.     function printElement()
  557.     {
  558.         echo '<polygon';
  559.         $this->printParams('id''points''style''transform');
  560.         if (is_array($this->_elements)) {
  561.             // Print children, start and end tag.
  562.             print(">\n");
  563.             parent::printElement();
  564.             print("</polygon>\n");
  565.         else {
  566.             // Print short tag.
  567.             print("/>\n");
  568.         }
  569.     }
  570.  
  571.     function setShape($points)
  572.     {
  573.         $this->_points $points;
  574.     }
  575.  
  576. }
  577.  
  578. /**
  579.  * XML_SVG_Path
  580.  *
  581.  * @package XML_SVG
  582.  */
  583. class XML_SVG_Path extends XML_SVG_Element {
  584.  
  585.     var $_d;
  586.  
  587.     function printElement()
  588.     {
  589.         echo '<path';
  590.         $this->printParams('id''d''style''transform');
  591.         if (is_array($this->_elements)) {
  592.             // Print children, start and end tag.
  593.             print(">\n");
  594.             parent::printElement();
  595.             print("</path>\n");
  596.         else {
  597.             // Print short tag.
  598.             print("/>\n");
  599.         }
  600.     }
  601.  
  602.     function setShape($d)
  603.     {
  604.         $this->_d $d;
  605.     }
  606.  
  607. }
  608.  
  609. /**
  610.  * XML_SVG_Image
  611.  *
  612.  * @package XML_SVG
  613.  */
  614. class XML_SVG_Image extends XML_SVG_Element {
  615.  
  616.     var $_x;
  617.     var $_y;
  618.     var $_width;
  619.     var $_height;
  620.     var $_href;
  621.  
  622.     function printElement()
  623.     {
  624.         echo '<image';
  625.         $this->printParams('id''x''y''width''height''style');
  626.         if (!empty($this->_href)) {
  627.             echo ' xlink:href="' $this->_href '"';
  628.         }
  629.         if (is_array($this->_elements)) {
  630.             // Print children, start and end tag.
  631.             echo ">\n";
  632.             parent::printElement();
  633.             echo "</image>\n";
  634.         else {
  635.             // Print short tag.
  636.             echo " />\n";
  637.         }
  638.     }
  639.  
  640.     function setShape($x$y$width$height)
  641.     {
  642.         $this->_x $x;
  643.         $this->_y $y;
  644.         $this->_width  $width;
  645.         $this->_height  $height;
  646.     }
  647.  
  648. }
  649.  
  650. /**
  651.  * XML_SVG_Animate
  652.  *
  653.  * @package XML_SVG
  654.  */
  655. class XML_SVG_Animate extends XML_SVG_Element {
  656.  
  657.     var $_attributeName;
  658.     var $_attributeType;
  659.     var $_from;
  660.     var $_to;
  661.     var $_begin;
  662.     var $_dur;
  663.     var $_fill;
  664.  
  665.     function printElement()
  666.     {
  667.         echo '<animate';
  668.         $this->printParams('id''attributeName''attributeType''from''to',
  669.                            'begin''dur''fill');
  670.         if (is_array($this->_elements)) {
  671.             // Print children, start and end tag.
  672.             echo ">\n";
  673.             parent::printElement();
  674.             echo "</animate>\n";
  675.         else {
  676.             echo " />\n";
  677.         }
  678.     }
  679.  
  680.     function setShape($attributeName$attributeType ''$from '',
  681.                       $to ''$begin ''$dur ''$fill '')
  682.     {
  683.         $this->_attributeName $attributeName;
  684.         $this->_attributeType $attributeType;
  685.         $this->_from  $from;
  686.         $this->_to $to;
  687.         $this->_begin $begin;
  688.         $this->_dur $dur;
  689.         $this->_fill $fill;
  690.     }
  691.  
  692. }
  693.  
  694. /**
  695.  * XML_SVG_Filter
  696.  *
  697.  * @package XML_SVG
  698.  */
  699. class XML_SVG_Filter extends XML_SVG_Element {
  700.  
  701.     function printElement()
  702.     {
  703.         echo '<filter';
  704.         $this->printParams('id');
  705.         if (is_array($this->_elements)) {
  706.             // Print children, start and end tag.
  707.             echo ">\n";
  708.             parent::printElement();
  709.             echo "</filter>\n";
  710.         else {
  711.             echo " />\n";
  712.         }
  713.     }
  714.  
  715.     function addPrimitive($primitive$params)
  716.     {
  717.         $this->addChild(new XML_SVG_FilterPrimitive($primitive$params));
  718.     }
  719.  
  720. }
  721.  
  722. /**
  723.  * XML_SVG_FilterPrimitive
  724.  *
  725.  * @package XML_SVG
  726.  */
  727.  
  728.     var $_primitives = array('Blend',
  729.                              'ColorMatrix',
  730.                              'ComponentTransfer',
  731.                              'Composite',
  732.                              'ConvolveMatrix',
  733.                              'DiffuseLighting',
  734.                              'DisplacementMap',
  735.                              'Flood',
  736.                              'GaussianBlur',
  737.                              'Image',
  738.                              'Merge',
  739.                              'Morphology',
  740.                              'Offset',
  741.                              'SpecularLighting',
  742.                              'Tile',
  743.                              'Turbulence');
  744.  
  745.     var $_primitive;
  746.  
  747.     var $_in;
  748.     var $_in2;
  749.     var $_result;
  750.     var $_x;
  751.     var $_y;
  752.     var $_dx;
  753.     var $_dy;
  754.     var $_width;
  755.     var $_height;
  756.     var $_mode;
  757.     var $_type;
  758.     var $_values;
  759.     var $_operator;
  760.     var $_k1;
  761.     var $_k2;
  762.     var $_k3;
  763.     var $_k4;
  764.     var $_surfaceScale;
  765.     var $_diffuseConstant;
  766.     var $_kernelUnitLength;
  767.     var $_floor_color;
  768.     var $_flood_opacity;
  769.  
  770.     function XML_SVG_FilterPrimitive($primitive$params = array())
  771.     {
  772.         parent::XML_SVG_Element($params);
  773.         $this->_primitive $primitive;
  774.     }
  775.  
  776.     function printElement()
  777.     {
  778.         $name 'fe' $this->_primitive;
  779.         echo '<' $name;
  780.         $this->printParams('id''x''y''dx''dy''width''height''in''in2',
  781.                            'result''mode''type''values''operator',
  782.                            'k1''k2''k3''k4''surfaceScale''stdDeviation',
  783.                            'diffuseConstant''kernelUnitLength',
  784.                            'flood_color''flood_opacity');
  785.         if (is_array($this->_elements)) {
  786.             // Print children, start and end tag.
  787.             echo ">\n";
  788.             parent::printElement();
  789.             echo '</' $name '>';
  790.         else {
  791.             echo '/>';
  792.         }
  793.     }
  794.  
  795.     /**
  796.      * For feMerge elements.
  797.      */
  798.     function addMergeNode($in)
  799.     {
  800.         $this->addChild(new XML_SVG_FilterMergeNode(array('in' => $in)));
  801.     }
  802.  
  803. }
  804.  
  805. /**
  806.  * XML_SVG_FilterMergeNode
  807.  *
  808.  * @package XML_SVG
  809.  */
  810.  
  811.     var $_in;
  812.  
  813.     function printElement()
  814.     {
  815.         echo '<feMergeNode';
  816.         $this->printParams('in');
  817.         echo '/>';
  818.     }
  819.  
  820. }
  821.  
  822. /**
  823.  * XML_SVG_Use
  824.  *
  825.  * @package XML_SVG
  826.  */
  827. class XML_SVG_Use extends XML_SVG_Element {
  828.  
  829.     var $_symbol;
  830.  
  831.     function XML_SVG_Use($symbol$params = array())
  832.     {
  833.         parent::XML_SVG_Element($params);
  834.         $this->_symbol $symbol;
  835.     }
  836.  
  837.     function printElement()
  838.     {
  839.         echo '<use xlink:href="#' $this->_symbol '"/>';
  840.     }
  841.  
  842. }
  843.  
  844. /**
  845.  * XML_SVG_Defs
  846.  *
  847.  * @package XML_SVG
  848.  */
  849. class XML_SVG_Defs extends XML_SVG_Element {
  850.  
  851.     function printElement()
  852.     {
  853.         echo '<defs';
  854.         $this->printParams('id''style''transform');
  855.         echo ">\n";
  856.         parent::printElement();
  857.         echo "</defs>\n";
  858.     }
  859.  
  860. }
  861.  
  862. /**
  863.  * XML_SVG_Marker
  864.  *
  865.  * @package XML_SVG
  866.  */
  867. class XML_SVG_Marker extends XML_SVG_Element {
  868.  
  869.     var $_refX;
  870.     var $_refY;
  871.     var $_markerUnits;
  872.     var $_markerWidth;
  873.     var $_markerHeight;
  874.     var $_orient;
  875.  
  876.     function printElement()
  877.     {
  878.         echo '<marker';
  879.         $this->printParams('id''refX''refY''markerUnits',
  880.                            'markerWidth''markerHeight''orient');
  881.         if (is_array($this->_elements)) // Print children, start and end tag.
  882.             print(">\n");
  883.             parent::printElement();
  884.             print("</marker>\n");
  885.         else {
  886.             print("/>\n");
  887.         }
  888.     }
  889.  
  890.     function setShape($refX ''$refY ''$markerUnits '',
  891.                       $markerWidth ''$markerHeight ''$orient '')
  892.     {
  893.         $this->_refX $refX;
  894.         $this->_refY  $refY;
  895.         $this->_markerUnits $markerUnits;
  896.         $this->_markerWidth $markerWidth;
  897.         $this->_markerHeight $markerHeight;
  898.         $this->_orient $orient;
  899.     }
  900.  
  901. }
  902.  
  903. /**
  904.  * XML_SVG_Title
  905.  *
  906.  * @package XML_SVG
  907. */
  908. class XML_SVG_Title extends XML_SVG_Element {
  909.  
  910.     var $_title;
  911.  
  912.     function printElement()
  913.     {
  914.         echo '<title';
  915.         $this->printParams('id''style');
  916.         print(">\n");
  917.         print($this->_title);
  918.         parent::printElement();
  919.         print("</title>\n");
  920.     }
  921.  
  922. }
  923.  
  924. /**
  925.  * XML_SVG_Desc
  926.  *
  927.  * @package XML_SVG
  928.  */
  929. class XML_SVG_Desc extends XML_SVG_Element {
  930.  
  931.     var $_desc;
  932.  
  933.     function printElement()
  934.     {
  935.         echo '<desc';
  936.         $this->printParams('id''style');
  937.         echo '>' $this->_desc;
  938.         parent::printElement();
  939.         echo "</desc>\n";
  940.     }
  941.  
  942. }
  943.  
  944. /**
  945.  * XML_SVG_Tref
  946.  *
  947.  * @package XML_SVG
  948.  */
  949. class XML_SVG_Tref extends XML_SVG_Element {
  950.  
  951.     var $_text;
  952.     var $_x;
  953.     var $_y;
  954.     var $_dx;
  955.     var $_dy;
  956.     var $_rotate;
  957.     var $_textLength;
  958.     var $_lengthAdjust;
  959.  
  960.     function printElement()
  961.     {
  962.         echo '<tref';
  963.         $this->printParams('id''x''y''dx''dy''rotate',
  964.                            'textLength''lengthAdjust''style');
  965.         echo '>' $this->_text;
  966.         parent::printElement();
  967.         echo "</tref>\n";
  968.     }
  969.  
  970. }

Documentation generated on Mon, 11 Mar 2019 14:21:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.