Source for file SvgTransform.php

Documentation is available at SvgTransform.php

  1. <?php
  2. /**
  3.  * $Source: /cvsroot/svggrapher/svggrapher/mains/SvgTransform.php,v $
  4.  *
  5.  * 
  6.  *
  7.  * @version $Id: SvgTransform.php,v 1.3 2007/10/20 22:22:53 geelweb Exp $
  8.  * @author Guillaume L. <guillaume@geelweb.org>
  9.  * @copyright Copyright © 2006, Guillaume Luchet.
  10.  * @license http://opensource.org/licenses/bsd-license.php BSD License
  11.  * @package SvgGrapher
  12.  * @subpackage Elements
  13.  */
  14.  
  15. // doc {{{
  16.  
  17. /**
  18.  * Transform.
  19.  *
  20.  * @author Guillaume L. <guillaume@geelweb.org>
  21.  * @link http://www.geelweb.org
  22.  * @license http://opensource.org/licenses/bsd-license.php BSD License
  23.  * @copyright Copyright © 2006, Guillaume Luchet.
  24.  * @version CVS: $Id: SvgTransform.php,v 1.3 2007/10/20 22:22:53 geelweb Exp $
  25.  * @package SvgGrapher
  26.  * @subpackage Elements
  27.  */ // }}}
  28. class SvgTransform 
  29. {
  30.     // properties {{{
  31.     
  32.     /**
  33.      * _transforms
  34.      * 
  35.      * @var mixed 
  36.      * @access private
  37.      */
  38.     private $_transforms;
  39.     
  40.     // }}}
  41.     // Transform::__construct() {{{
  42.  
  43.     /**
  44.      * __construct
  45.      * 
  46.      * @param mixed $transform 
  47.      * @access public
  48.      * @return void 
  49.      */
  50.     public function __construct($transform=NULL
  51.     {
  52.           if(!is_null($transform)) {
  53.               $this->fromString($transform);
  54.           }
  55.     }
  56.  
  57.     // }}}
  58.     // Transform::set() {{{
  59.  
  60.     /**
  61.      * Set the value of a transformation.
  62.      * 
  63.      * @param string $transformName Transformation name.
  64.      * @param string $transformValue Transformation value.
  65.      * @return void 
  66.      * @access public
  67.      */
  68.     public function set($transformName$transformValue=NULL
  69.     {
  70.         if(isset($transformValue&& is_null($transformValue)) {
  71.             unset($this->_transforms[$transformName]);
  72.             return;
  73.         }
  74.         $this->_transforms[$transformName$transformValue;
  75.     }
  76.  
  77.     // }}}
  78.     // Transform::get() {{{
  79.  
  80.     /**
  81.      * Get the value of a transformation.
  82.      * 
  83.      * @param string $transformName Transformation name.
  84.      * @return string 
  85.      * @access public
  86.      */
  87.     public function get($transformName
  88.     {
  89.         return isset($this->_transforms[$transformName]
  90.             $this->_transforms[$transformNamefalse;
  91.     }
  92.  
  93.     // }}}
  94.     // Transform::fromString() {{{
  95.  
  96.     /**
  97.      * Initialize the object from a string.
  98.      * 
  99.      * @param string $str Transformation string.
  100.      * @return void 
  101.      */
  102.     public function fromString($str
  103.     {
  104.         $transformPairs explode(')'$str);
  105.         foreach($transformPairs as $pair{
  106.             if(empty($pair)) 
  107.                 continue
  108.             }
  109.             list($transformName$transformValueexplode('('$pair);
  110.             $this->_transforms[trim($transformName)trim($transformValue);
  111.         }
  112.     }
  113.  
  114.     // }}}
  115.     // Transfrom::toString() {{{
  116.  
  117.     /**
  118.      * Get the sting representation of the object.
  119.      * 
  120.      * @return string 
  121.      */
  122.     public function toString(
  123.     {
  124.         $retStr '';
  125.         $paddind '';
  126.         foreach($this->_transforms as $transformName => $transformValue{
  127.             $retStr .= $padding $transformName '(' $transformValue ')';
  128.         }
  129.         return $retStr;
  130.     }
  131.  
  132.     // }}}
  133.  
  134.     /**
  135.      * Allow direct acces to set transformation value.
  136.      * 
  137.      * @param mixed $transformName transformation name
  138.      * @param mixed $transformValue transformation value
  139.      * @access public
  140.      * @return void 
  141.      */
  142.     public function __set($transformName$transformValue=NULL
  143.     {
  144.         $this->set($transformName$transformValue);
  145.     }
  146.  
  147.     /**
  148.      * Allow direct acces to get a transformation.
  149.      * 
  150.      * @param mixed $transformName transformation name
  151.      * @access public
  152.      * @return void 
  153.      */
  154.     public function __get($transformName)
  155.     {
  156.         $this->get($transformName);
  157.     }
  158. }
  159.  
  160.  
  161. ?>

Documentation generated on Tue, 23 Oct 2007 11:32:19 +0200 by phpDocumentor 1.4.0