[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/ezc/Graph/src/options/ -> flash_driver.php (source)

   1  <?php
   2  /**
   3   * File containing the ezcGraphFlashDriverOption class
   4   *
   5   * @package Graph
   6   * @version 1.5
   7   * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
   8   * @license http://ez.no/licenses/new_bsd New BSD License
   9   */
  10  /**
  11   * Class containing the extended configuration options for the flash driver.
  12   *
  13   * The flash driver can be configured to use a different circle resolution, as
  14   * circles are only emulated in the flash driver, and to use a diffrent
  15   * compression for the generated SWF files.
  16   *
  17   * <code>
  18   *   $graph = new ezcGraphPieChart();
  19   *   $graph->title = 'Access statistics';
  20   *   $graph->legend = false;
  21   *   
  22   *   $graph->driver = new ezcGraphFlashDriver();
  23   *   $graph->driver->options->compresion = 0;
  24   *
  25   *   $graph->options->font = 'tutorial_font.fdb';
  26   *   
  27   *   $graph->driver->options->compression = 7;
  28   *   
  29   *   $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
  30   *       'Mozilla' => 19113,
  31   *       'Explorer' => 10917,
  32   *       'Opera' => 1464,
  33   *       'Safari' => 652,
  34   *       'Konqueror' => 474,
  35   *   ) );
  36   *   
  37   *   $graph->render( 400, 200, 'tutorial_driver_flash.swf' );
  38   * </code>
  39   *
  40   * @property int $compression
  41   *           Compression level used for generated flash file
  42   *           @see http://php.net/manual/en/function.swfmovie.save.php
  43   * @property float $circleResolution
  44   *           Resolution for circles, until I understand how to draw ellipses
  45   *           with SWFShape::curveTo()
  46   * 
  47   * @version 1.5
  48   * @package Graph
  49   */
  50  class ezcGraphFlashDriverOptions extends ezcGraphDriverOptions
  51  {
  52      /**
  53       * Constructor
  54       * 
  55       * @param array $options Default option array
  56       * @return void
  57       * @ignore
  58       */
  59      public function __construct( array $options = array() )
  60      {
  61          $this->properties['compression'] = 9;
  62          $this->properties['circleResolution'] = 2.;
  63  
  64          parent::__construct( $options );
  65      }
  66  
  67      /**
  68       * Set an option value
  69       * 
  70       * @param string $propertyName 
  71       * @param mixed $propertyValue 
  72       * @throws ezcBasePropertyNotFoundException
  73       *          If a property is not defined in this class
  74       * @return void
  75       * @ignore
  76       */
  77      public function __set( $propertyName, $propertyValue )
  78      {
  79          switch ( $propertyName )
  80          {
  81              case 'compression':
  82                  if ( !is_numeric( $propertyValue ) ||
  83                       ( $propertyValue < 0 ) ||
  84                       ( $propertyValue > 9 ) )
  85                  {
  86                      throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 9' );
  87                  }
  88  
  89                  $this->properties['compression'] = max( 0, min( 9, (int) $propertyValue ) );
  90                  break;
  91              case 'circleResolution':
  92                  if ( !is_numeric( $propertyValue ) ||
  93                       ( $propertyValue <= 0 ) )
  94                  {
  95                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
  96                  }
  97  
  98                  $this->properties['circleResolution'] = (float) $propertyValue;
  99                  break;
 100              default:
 101                  parent::__set( $propertyName, $propertyValue );
 102                  break;
 103          }
 104      }
 105  }
 106  
 107  ?>


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7