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.20 2006/01/01 21:10:25 jan Exp $
  9.  *
  10.  * Copyright 2002-2006 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.     var $_charset;
  288.  
  289.     function printElement($element 'textpath')
  290.     {
  291.         echo '<' $element;
  292.         $this->printParams('id''x''y''dx''dy''rotate',
  293.                            'textLength''lengthAdjust''style''transform');
  294.         echo '>';
  295.         if (isset($this->_charset)) {
  296.             echo @htmlspecialchars($this->_textENT_COMPAT$this->_charset);
  297.         else {
  298.             echo htmlspecialchars($this->_text);
  299.         }
  300.         parent::printElement();
  301.         echo "</$element>\n";
  302.     }
  303.  
  304.     function setShape($x$y$text)
  305.     {
  306.         $this->_x $x;
  307.         $this->_y $y;
  308.         $this->_text $text;
  309.     }
  310.  
  311. }
  312.  
  313. /**
  314.  * XML_SVG_Text
  315.  *
  316.  * @package XML_SVG
  317.  */
  318. class XML_SVG_Text extends XML_SVG_Textpath {
  319.  
  320.     function printElement()
  321.     {
  322.         parent::printElement('text');
  323.     }
  324.  
  325.     function setShape($x$y$text)
  326.     {
  327.         $this->_x $x;
  328.         $this->_y $y;
  329.         $this->_text $text;
  330.     }
  331.  
  332. }
  333.  
  334. /**
  335.  * XML_SVG_Tspan
  336.  *
  337.  * @package XML_SVG
  338.  */
  339. class XML_SVG_Tspan extends XML_SVG_Element {
  340.  
  341.     var $_text;
  342.     var $_x;
  343.     var $_y;
  344.     var $_dx;
  345.     var $_dy;
  346.     var $_rotate;
  347.     var $_textLength;
  348.     var $_lengthAdjust;
  349.  
  350.     function printElement()
  351.     {
  352.         echo '<tspan';
  353.         $this->printParams('id''x''y''dx''dy''rotate',
  354.                            'textLength''lengthAdjust''style''transform');
  355.         echo '>' $this->_text;
  356.         if (is_array($this->_elements)) {
  357.             parent::printElement();
  358.         }
  359.         echo "</tspan>\n";
  360.     }
  361.  
  362.     function setShape($x$y$text)
  363.     {
  364.         $this->_x $x;
  365.         $this->_y $y;
  366.         $this->_text  $text;
  367.     }
  368.  
  369. }
  370.  
  371. /**
  372.  * XML_SVG_Circle
  373.  *
  374.  * @package XML_SVG
  375.  */
  376. class XML_SVG_Circle extends XML_SVG_Element {
  377.  
  378.     var $_cx;
  379.     var $_cy;
  380.     var $_r;
  381.  
  382.     function printElement()
  383.     {
  384.         echo '<circle';
  385.  
  386.         $this->printParams('id''cx''cy''r''style''transform');
  387.         if (is_array($this->_elements)) {
  388.             // Print children, start and end tag.
  389.             echo ">\n";
  390.             parent::printElement();
  391.             echo "</circle>\n";
  392.         else {
  393.             // Print short tag.
  394.             echo "/>\n";
  395.         }
  396.     }
  397.  
  398.     function setShape($cx$cy$r)
  399.     {
  400.         $this->_cx $cx;
  401.         $this->_cy $cy;
  402.         $this->_r  $r;
  403.     }
  404.  
  405. }
  406.  
  407. /**
  408.  * XML_SVG_Line
  409.  *
  410.  * @package XML_SVG
  411.  */
  412. class XML_SVG_Line extends XML_SVG_Element {
  413.  
  414.     var $_x1;
  415.     var $_y1;
  416.     var $_x2;
  417.     var $_y2;
  418.  
  419.     function printElement()
  420.     {
  421.         echo '<line';
  422.         $this->printParams('id''x1''y1''x2''y2''style');
  423.         if (is_array($this->_elements)) {
  424.             // Print children, start and end tag.
  425.             print(">\n");
  426.             parent::printElement();
  427.             print("</line>\n");
  428.         else {
  429.             // Print short tag.
  430.             print("/>\n");
  431.         }
  432.     }
  433.  
  434.     function setShape($x1$y1$x2$y2)
  435.     {
  436.         $this->_x1 $x1;
  437.         $this->_y1 $y1;
  438.         $this->_x2  $x2;
  439.         $this->_y2  $y2;
  440.     }
  441.  
  442. }
  443.  
  444. /**
  445.  * XML_SVG_Rect
  446.  *
  447.  * @package XML_SVG
  448.  */
  449. class XML_SVG_Rect extends XML_SVG_Element {
  450.  
  451.     var $_x;
  452.     var $_y;
  453.     var $_width;
  454.     var $_height;
  455.     var $_rx;
  456.     var $_ry;
  457.  
  458.     function printElement()
  459.     {
  460.         echo '<rect';
  461.         $this->printParams('id''x''y''width''height',
  462.                            'rx''ry''style');
  463.         if (is_array($this->_elements)) {
  464.             // Print children, start and end tag.
  465.             print(">\n");
  466.             parent::printElement();
  467.             print("</rect>\n");
  468.         else {
  469.             // Print short tag.
  470.             print("/>\n");
  471.         }
  472.     }
  473.  
  474.     function setShape($x$y$width$height)
  475.     {
  476.         $this->_x $x;
  477.         $this->_y $y;
  478.         $this->_width  $width;
  479.         $this->_height  $height;
  480.     }
  481.  
  482. }
  483.  
  484. /**
  485.  * XML_SVG_Ellipse
  486.  *
  487.  * @package XML_SVG
  488.  */
  489. class XML_SVG_Ellipse extends XML_SVG_Element {
  490.  
  491.     var $_cx;
  492.     var $_cy;
  493.     var $_rx;
  494.     var $_ry;
  495.  
  496.     function printElement()
  497.     {
  498.         echo '<ellipse';
  499.         $this->printParams('id''cx''cy''rx''ry''style''transform');
  500.         if (is_array($this->_elements)) {
  501.             // Print children, start and end tag.
  502.             print(">\n");
  503.             parent::printElement();
  504.             print("</ellipse>\n");
  505.         else {
  506.             // Print short tag.
  507.             print(" />\n");
  508.         }
  509.     }
  510.  
  511.     function setShape($cx$cy$rx$ry)
  512.     {
  513.         $this->_cx $cx;
  514.         $this->_cy $cy;
  515.         $this->_rx  $rx;
  516.         $this->_ry  $ry;
  517.     }
  518.  
  519. }
  520.  
  521. /**
  522.  * XML_SVG_Polyline
  523.  *
  524.  * @package XML_SVG
  525.  */
  526. class XML_SVG_Polyline extends XML_SVG_Element {
  527.  
  528.     var $_points;
  529.  
  530.     function printElement()
  531.     {
  532.         echo '<polyline';
  533.         $this->printParams('id''points''style''transform');
  534.  
  535.         if (is_array($this->_elements)) {
  536.             // Print children, start and end tag.
  537.             print(">\n");
  538.             parent::printElement();
  539.             print("</polyline>\n");
  540.         else {
  541.             // Print short tag.
  542.             print("/>\n");
  543.         }
  544.     }
  545.  
  546.     function setShape($points)
  547.     {
  548.         $this->_points $points;
  549.     }
  550.  
  551. }
  552.  
  553. /**
  554.  * XML_SVG_Polygon
  555.  *
  556.  * @package XML_SVG
  557.  */
  558. class XML_SVG_Polygon extends XML_SVG_Element {
  559.  
  560.     var $_points;
  561.  
  562.     function printElement()
  563.     {
  564.         echo '<polygon';
  565.         $this->printParams('id''points''style''transform');
  566.         if (is_array($this->_elements)) {
  567.             // Print children, start and end tag.
  568.             print(">\n");
  569.             parent::printElement();
  570.             print("</polygon>\n");
  571.         else {
  572.             // Print short tag.
  573.             print("/>\n");
  574.         }
  575.     }
  576.  
  577.     function setShape($points)
  578.     {
  579.         $this->_points $points;
  580.     }
  581.  
  582. }
  583.  
  584. /**
  585.  * XML_SVG_Path
  586.  *
  587.  * @package XML_SVG
  588.  */
  589. class XML_SVG_Path extends XML_SVG_Element {
  590.  
  591.     var $_d;
  592.  
  593.     function printElement()
  594.     {
  595.         echo '<path';
  596.         $this->printParams('id''d''style''transform');
  597.         if (is_array($this->_elements)) {
  598.             // Print children, start and end tag.
  599.             print(">\n");
  600.             parent::printElement();
  601.             print("</path>\n");
  602.         else {
  603.             // Print short tag.
  604.             print("/>\n");
  605.         }
  606.     }
  607.  
  608.     function setShape($d)
  609.     {
  610.         $this->_d $d;
  611.     }
  612.  
  613. }
  614.  
  615. /**
  616.  * XML_SVG_Image
  617.  *
  618.  * @package XML_SVG
  619.  */
  620. class XML_SVG_Image extends XML_SVG_Element {
  621.  
  622.     var $_x;
  623.     var $_y;
  624.     var $_width;
  625.     var $_height;
  626.     var $_href;
  627.  
  628.     function printElement()
  629.     {
  630.         echo '<image';
  631.         $this->printParams('id''x''y''width''height''style');
  632.         if (!empty($this->_href)) {
  633.             echo ' xlink:href="' $this->_href '"';
  634.         }
  635.         if (is_array($this->_elements)) {
  636.             // Print children, start and end tag.
  637.             echo ">\n";
  638.             parent::printElement();
  639.             echo "</image>\n";
  640.         else {
  641.             // Print short tag.
  642.             echo " />\n";
  643.         }
  644.     }
  645.  
  646.     function setShape($x$y$width$height)
  647.     {
  648.         $this->_x $x;
  649.         $this->_y $y;
  650.         $this->_width  $width;
  651.         $this->_height  $height;
  652.     }
  653.  
  654. }
  655.  
  656. /**
  657.  * XML_SVG_Animate
  658.  *
  659.  * @package XML_SVG
  660.  */
  661. class XML_SVG_Animate extends XML_SVG_Element {
  662.  
  663.     var $_attributeName;
  664.     var $_attributeType;
  665.     var $_from;
  666.     var $_to;
  667.     var $_begin;
  668.     var $_dur;
  669.     var $_fill;
  670.  
  671.     function printElement()
  672.     {
  673.         echo '<animate';
  674.         $this->printParams('id''attributeName''attributeType''from''to',
  675.                            'begin''dur''fill');
  676.         if (is_array($this->_elements)) {
  677.             // Print children, start and end tag.
  678.             echo ">\n";
  679.             parent::printElement();
  680.             echo "</animate>\n";
  681.         else {
  682.             echo " />\n";
  683.         }
  684.     }
  685.  
  686.     function setShape($attributeName$attributeType ''$from '',
  687.                       $to ''$begin ''$dur ''$fill '')
  688.     {
  689.         $this->_attributeName $attributeName;
  690.         $this->_attributeType $attributeType;
  691.         $this->_from  $from;
  692.         $this->_to $to;
  693.         $this->_begin $begin;
  694.         $this->_dur $dur;
  695.         $this->_fill $fill;
  696.     }
  697.  
  698. }
  699.  
  700. /**
  701.  * XML_SVG_Filter
  702.  *
  703.  * @package XML_SVG
  704.  */
  705. class XML_SVG_Filter extends XML_SVG_Element {
  706.  
  707.     function printElement()
  708.     {
  709.         echo '<filter';
  710.         $this->printParams('id');
  711.         if (is_array($this->_elements)) {
  712.             // Print children, start and end tag.
  713.             echo ">\n";
  714.             parent::printElement();
  715.             echo "</filter>\n";
  716.         else {
  717.             echo " />\n";
  718.         }
  719.     }
  720.  
  721.     function addPrimitive($primitive$params)
  722.     {
  723.         $this->addChild(new XML_SVG_FilterPrimitive($primitive$params));
  724.     }
  725.  
  726. }
  727.  
  728. /**
  729.  * XML_SVG_FilterPrimitive
  730.  *
  731.  * @package XML_SVG
  732.  */
  733.  
  734.     var $_primitives = array('Blend',
  735.                              'ColorMatrix',
  736.                              'ComponentTransfer',
  737.                              'Composite',
  738.                              'ConvolveMatrix',
  739.                              'DiffuseLighting',
  740.                              'DisplacementMap',
  741.                              'Flood',
  742.                              'GaussianBlur',
  743.                              'Image',
  744.                              'Merge',
  745.                              'Morphology',
  746.                              'Offset',
  747.                              'SpecularLighting',
  748.                              'Tile',
  749.                              'Turbulence');
  750.  
  751.     var $_primitive;
  752.  
  753.     var $_in;
  754.     var $_in2;
  755.     var $_result;
  756.     var $_x;
  757.     var $_y;
  758.     var $_dx;
  759.     var $_dy;
  760.     var $_width;
  761.     var $_height;
  762.     var $_mode;
  763.     var $_type;
  764.     var $_values;
  765.     var $_operator;
  766.     var $_k1;
  767.     var $_k2;
  768.     var $_k3;
  769.     var $_k4;
  770.     var $_surfaceScale;
  771.     var $_diffuseConstant;
  772.     var $_kernelUnitLength;
  773.     var $_floor_color;
  774.     var $_flood_opacity;
  775.  
  776.     function XML_SVG_FilterPrimitive($primitive$params = array())
  777.     {
  778.         parent::XML_SVG_Element($params);
  779.         $this->_primitive $primitive;
  780.     }
  781.  
  782.     function printElement()
  783.     {
  784.         $name 'fe' $this->_primitive;
  785.         echo '<' $name;
  786.         $this->printParams('id''x''y''dx''dy''width''height''in''in2',
  787.                            'result''mode''type''values''operator',
  788.                            'k1''k2''k3''k4''surfaceScale''stdDeviation',
  789.                            'diffuseConstant''kernelUnitLength',
  790.                            'flood_color''flood_opacity');
  791.         if (is_array($this->_elements)) {
  792.             // Print children, start and end tag.
  793.             echo ">\n";
  794.             parent::printElement();
  795.             echo '</' $name '>';
  796.         else {
  797.             echo '/>';
  798.         }
  799.     }
  800.  
  801.     /**
  802.      * For feMerge elements.
  803.      */
  804.     function addMergeNode($in)
  805.     {
  806.         $this->addChild(new XML_SVG_FilterMergeNode(array('in' => $in)));
  807.     }
  808.  
  809. }
  810.  
  811. /**
  812.  * XML_SVG_FilterMergeNode
  813.  *
  814.  * @package XML_SVG
  815.  */
  816.  
  817.     var $_in;
  818.  
  819.     function printElement()
  820.     {
  821.         echo '<feMergeNode';
  822.         $this->printParams('in');
  823.         echo '/>';
  824.     }
  825.  
  826. }
  827.  
  828. /**
  829.  * XML_SVG_Use
  830.  *
  831.  * @package XML_SVG
  832.  */
  833. class XML_SVG_Use extends XML_SVG_Element {
  834.  
  835.     var $_symbol;
  836.  
  837.     function XML_SVG_Use($symbol$params = array())
  838.     {
  839.         parent::XML_SVG_Element($params);
  840.         $this->_symbol $symbol;
  841.     }
  842.  
  843.     function printElement()
  844.     {
  845.         echo '<use xlink:href="#' $this->_symbol '"/>';
  846.     }
  847.  
  848. }
  849.  
  850. /**
  851.  * XML_SVG_Defs
  852.  *
  853.  * @package XML_SVG
  854.  */
  855. class XML_SVG_Defs extends XML_SVG_Element {
  856.  
  857.     function printElement()
  858.     {
  859.         echo '<defs';
  860.         $this->printParams('id''style''transform');
  861.         echo ">\n";
  862.         parent::printElement();
  863.         echo "</defs>\n";
  864.     }
  865.  
  866. }
  867.  
  868. /**
  869.  * XML_SVG_Marker
  870.  *
  871.  * @package XML_SVG
  872.  */
  873. class XML_SVG_Marker extends XML_SVG_Element {
  874.  
  875.     var $_refX;
  876.     var $_refY;
  877.     var $_markerUnits;
  878.     var $_markerWidth;
  879.     var $_markerHeight;
  880.     var $_orient;
  881.  
  882.     function printElement()
  883.     {
  884.         echo '<marker';
  885.         $this->printParams('id''refX''refY''markerUnits',
  886.                            'markerWidth''markerHeight''orient');
  887.         if (is_array($this->_elements)) // Print children, start and end tag.
  888.             print(">\n");
  889.             parent::printElement();
  890.             print("</marker>\n");
  891.         else {
  892.             print("/>\n");
  893.         }
  894.     }
  895.  
  896.     function setShape($refX ''$refY ''$markerUnits '',
  897.                       $markerWidth ''$markerHeight ''$orient '')
  898.     {
  899.         $this->_refX $refX;
  900.         $this->_refY  $refY;
  901.         $this->_markerUnits $markerUnits;
  902.         $this->_markerWidth $markerWidth;
  903.         $this->_markerHeight $markerHeight;
  904.         $this->_orient $orient;
  905.     }
  906.  
  907. }
  908.  
  909. /**
  910.  * XML_SVG_Title
  911.  *
  912.  * @package XML_SVG
  913. */
  914. class XML_SVG_Title extends XML_SVG_Element {
  915.  
  916.     var $_title;
  917.  
  918.     function printElement()
  919.     {
  920.         echo '<title';
  921.         $this->printParams('id''style');
  922.         print(">\n");
  923.         print($this->_title);
  924.         parent::printElement();
  925.         print("</title>\n");
  926.     }
  927.  
  928. }
  929.  
  930. /**
  931.  * XML_SVG_Desc
  932.  *
  933.  * @package XML_SVG
  934.  */
  935. class XML_SVG_Desc extends XML_SVG_Element {
  936.  
  937.     var $_desc;
  938.  
  939.     function printElement()
  940.     {
  941.         echo '<desc';
  942.         $this->printParams('id''style');
  943.         echo '>' $this->_desc;
  944.         parent::printElement();
  945.         echo "</desc>\n";
  946.     }
  947.  
  948. }
  949.  
  950. /**
  951.  * XML_SVG_Tref
  952.  *
  953.  * @package XML_SVG
  954.  */
  955. class XML_SVG_Tref extends XML_SVG_Element {
  956.  
  957.     var $_text;
  958.     var $_x;
  959.     var $_y;
  960.     var $_dx;
  961.     var $_dy;
  962.     var $_rotate;
  963.     var $_textLength;
  964.     var $_lengthAdjust;
  965.  
  966.     function printElement()
  967.     {
  968.         echo '<tref';
  969.         $this->printParams('id''x''y''dx''dy''rotate',
  970.                            'textLength''lengthAdjust''style');
  971.         echo '>' $this->_text;
  972.         parent::printElement();
  973.         echo "</tref>\n";
  974.     }
  975.  
  976. }

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