diff options
author | Tobias Schlitt <toby@php.net> | 2006-05-17 16:14:50 +0000 |
---|---|---|
committer | Tobias Schlitt <toby@php.net> | 2006-05-17 16:14:50 +0000 |
commit | 559f33a133a5b7d3f19afcd618fbc2e8e9ec3ade (patch) | |
tree | 4cede6a3e70216e6552a9e2d6b4465a8fd2d5815 /src/options/chart.php | |
parent | 3ed40a4c2cf646edd4adb964b8a2f3224ae37263 (diff) | |
download | zetacomponents-graph-559f33a133a5b7d3f19afcd618fbc2e8e9ec3ade.zip zetacomponents-graph-559f33a133a5b7d3f19afcd618fbc2e8e9ec3ade.tar.gz |
- Fixed new option handling.
Diffstat (limited to 'src/options/chart.php')
-rw-r--r-- | src/options/chart.php | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/options/chart.php b/src/options/chart.php new file mode 100644 index 0000000..a81193c --- /dev/null +++ b/src/options/chart.php @@ -0,0 +1,117 @@ +<?php +/** + * File containing the ezcGraphChartOption class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Class containing the basic options for charts + * + * @package Graph + */ +class ezcGraphChartOptions extends ezcBaseOptions +{ + /** + * Width of the chart + * + * @var int + */ + protected $width; + + /** + * Height of the chart + * + * @var int + * @access protected + */ + protected $height; + + /** + * Background images filename + * + * @var string + */ + protected $backgroundImage; + + /** + * Background color of the chart + * + * @var ezcGraphColor + */ + protected $background; + + /** + * Border color of the chart + * + * @var ezcGraphColor + */ + protected $border; + + /** + * Border width + * + * @var int + */ + protected $borderWidth; + + /** + * Set an option value + * + * @param string $propertyName + * @param mixed $propertyValue + * @throws ezcBasePropertyNotFoundException + * If a property is not defined in this class + * @return void + */ + public function __set( $propertyName, $propertyValue ) + { + switch ( $propertyName ) + { + case 'width': + $this->width = max( 1, (int) $propertyValue ); + break; + case 'height': + $this->height = max( 1, (int) $propertyValue ); + break; + case 'backgroundImage': + // Check for existance of file + if ( !is_file( $propertyValue ) || !is_readable( $propertyValue ) ) + { + throw new ezcBaseFileNotFoundException( $propertyValue ); + } + + // Check for beeing an image file + $data = getImageSize( $propertyValue ); + if ( $data === false ) + { + throw new ezcGraphInvalidImageFileException( $propertyValue ); + } + + // SWF files are useless.. + if ( $data[2] === 4 ) + { + throw new ezcGraphInvalidImageFileException( 'We cant use SWF files like <' . $propertyValue . '>.' ); + } + + $this->backgroundImage = $propertyValue; + break; + case 'background': + $this->background = ezcGraphColor::create( $propertyValue ); + break; + case 'border': + $this->border = ezcGraphColor::create( $propertyValue ); + break; + case 'borderWidth': + $this->borderWidth = max( 1, (int) $propertyValue ); + break; + default: + throw new ezcBasePropertyNotFoundException( $propertyName ); + break; + } + } +} + +?> |