added ezcomponents dependencies
This commit is contained in:
		
							parent
							
								
									627c95ed81
								
							
						
					
					
						commit
						b79abfd331
					
				
							
								
								
									
										17
									
								
								build.xml
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								build.xml
									
									
									
									
									
								
							| @ -27,12 +27,19 @@ | |||||||
| 	<target name="manifest" depends="init, product" description="Builds the manifest file for the autoload mechanism (to ./inc/manifest.php)"> | 	<target name="manifest" depends="init, product" description="Builds the manifest file for the autoload mechanism (to ./inc/manifest.php)"> | ||||||
| 		<exec executable="php"> | 		<exec executable="php"> | ||||||
| 			<arg line="${dir.tools}/manifester.php"/> | 			<arg line="${dir.tools}/manifester.php"/> | ||||||
| 			<arg line="-d ${dir.src}/${ant.project.name}"/> | 			<arg line="-d"/> | ||||||
| 			<arg line="-v ${product.version}"/> | 			<arg line="${dir.src}/${ant.project.name}"/> | ||||||
| 			<arg line="-p ${ant.project.name}"/> | 			<arg line="-v"/> | ||||||
| 			<arg line="-o ${dir.src}/${ant.project.name}/manifest.php"/> | 			<arg line="${product.version}"/> | ||||||
|  | 			<arg line="-p"/> | ||||||
|  | 			<arg line="${ant.project.name}"/> | ||||||
|  | 			<arg line="-o"/> | ||||||
|  | 			<arg line="${dir.src}/${ant.project.name}/manifest.php"/> | ||||||
| 			<arg line="-r"/> | 			<arg line="-r"/> | ||||||
| 			<arg line="-b ${dir.src}"/> | 			<arg line="-b"/> | ||||||
|  | 			<arg line="${dir.src}"/> | ||||||
|  | 			<arg line="-i"/> | ||||||
|  | 			<arg line="${file.separator}external${file.separator}"/> | ||||||
| 		</exec> | 		</exec> | ||||||
| 	</target> | 	</target> | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -2,4 +2,4 @@ name=TUnit | |||||||
| version=0.5.0 | version=0.5.0 | ||||||
| author="Tommy Montgomery" | author="Tommy Montgomery" | ||||||
| website=http://tommymontgomery.com/ | website=http://tommymontgomery.com/ | ||||||
| ezc=1.0 | ezc=1.7 | ||||||
							
								
								
									
										656
									
								
								src/TUnit/external/ezc/Base/base.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										656
									
								
								src/TUnit/external/ezc/Base/base.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,656 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBase class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Base class implements the methods needed to use the eZ components. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcBase | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Used for dependency checking, to check for a PHP extension. | ||||||
|  |      */ | ||||||
|  |     const DEP_PHP_EXTENSION = "extension"; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Used for dependency checking, to check for a PHP version. | ||||||
|  |      */ | ||||||
|  |     const DEP_PHP_VERSION = "version"; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Denotes the production mode | ||||||
|  |      */ | ||||||
|  |     const MODE_PRODUCTION = 0; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Denotes the development mode | ||||||
|  |      */ | ||||||
|  |     const MODE_DEVELOPMENT = 1; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Indirectly it determines the path where the autoloads are stored. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     private static $libraryMode = "tarball"; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains the current working directory, which is used when the | ||||||
|  |      * $libraryMode is set to "custom". | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     private static $currentWorkingDirectory = null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The full path to the autoload directory. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected static $packageDir = null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains which development mode is used. It's "development" by default, | ||||||
|  |      * because of backwards compatibility reasons. | ||||||
|  |      */ | ||||||
|  |     private static $runMode = self::MODE_DEVELOPMENT; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Stores info with additional paths where autoload files and classes for | ||||||
|  |      * autoloading could be found. Each item of $repositoryDirs looks like | ||||||
|  |      * array( autoloadFileDir, baseDir ). The array key is the prefix belonging | ||||||
|  |      * to classes within that repository - if provided when calling | ||||||
|  |      * addClassRepository(), or an autoincrement integer otherwise. | ||||||
|  |      * | ||||||
|  |      * @var array(string=>array) | ||||||
|  |      */ | ||||||
|  |     protected static $repositoryDirs = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * This variable stores all the elements from the autoload arrays. When a | ||||||
|  |      * new autoload file is loaded, their files are added to this array. | ||||||
|  |      * | ||||||
|  |      * @var array(string=>string) | ||||||
|  |      */ | ||||||
|  |     protected static $autoloadArray = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * This variable stores all the elements from the autoload arrays for | ||||||
|  |      * external repositories. When a new autoload file is loaded, their files | ||||||
|  |      * are added to this array. | ||||||
|  |      * | ||||||
|  |      * @var array(string=>string) | ||||||
|  |      */ | ||||||
|  |     protected static $externalAutoloadArray = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Options for the ezcBase class. | ||||||
|  |      * | ||||||
|  |      * @var ezcBaseOptions | ||||||
|  |      */ | ||||||
|  |     static private $options; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Associates an option object with this static class. | ||||||
|  |      * | ||||||
|  |      * @param ezcBaseAutoloadOptions $options | ||||||
|  |      */ | ||||||
|  |     static public function setOptions( ezcBaseAutoloadOptions $options ) | ||||||
|  |     { | ||||||
|  |         self::$options = $options; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Tries to autoload the given className. If the className could be found | ||||||
|  |      * this method returns true, otherwise false. | ||||||
|  |      * | ||||||
|  |      * This class caches the requested class names (including the ones who | ||||||
|  |      * failed to load). | ||||||
|  |      * | ||||||
|  |      * @param string $className  The name of the class that should be loaded. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function autoload( $className ) | ||||||
|  |     { | ||||||
|  |         ezcBase::setPackageDir(); | ||||||
|  | 
 | ||||||
|  |         // Check whether the classname is already in the cached autoloadArray.
 | ||||||
|  |         if ( array_key_exists( $className, ezcBase::$autoloadArray ) ) | ||||||
|  |         { | ||||||
|  |             // Is it registered as 'unloadable'?
 | ||||||
|  |             if ( ezcBase::$autoloadArray[$className] == false ) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             ezcBase::loadFile( ezcBase::$autoloadArray[$className] ); | ||||||
|  | 
 | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Check whether the classname is already in the cached autoloadArray
 | ||||||
|  |         // for external repositories.
 | ||||||
|  |         if ( array_key_exists( $className, ezcBase::$externalAutoloadArray ) ) | ||||||
|  |         { | ||||||
|  |             // Is it registered as 'unloadable'?
 | ||||||
|  |             if ( ezcBase::$externalAutoloadArray[$className] == false ) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] ); | ||||||
|  | 
 | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Not cached, so load the autoload from the package.
 | ||||||
|  |         // Matches the first and optionally the second 'word' from the classname.
 | ||||||
|  |         $fileNames = array(); | ||||||
|  |         if ( preg_match( "/^([a-z0-9]*)([A-Z][a-z0-9]*)([A-Z][a-z0-9]*)?/", $className, $matches ) !== false ) | ||||||
|  |         { | ||||||
|  |             $autoloadFile = ""; | ||||||
|  |             // Try to match with both names, if available.
 | ||||||
|  |             switch ( sizeof( $matches ) ) | ||||||
|  |             { | ||||||
|  |                 case 4: | ||||||
|  |                     // check for x_y_autoload.php
 | ||||||
|  |                     $autoloadFile = strtolower( "{$matches[2]}_{$matches[3]}_autoload.php" ); | ||||||
|  |                     $fileNames[] = $autoloadFile; | ||||||
|  |                     if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) | ||||||
|  |                     { | ||||||
|  |                         return true; | ||||||
|  |                     } | ||||||
|  |                     // break intentionally missing.
 | ||||||
|  | 
 | ||||||
|  |                 case 3: | ||||||
|  |                     // check for x_autoload.php
 | ||||||
|  |                     $autoloadFile = strtolower( "{$matches[2]}_autoload.php" ); | ||||||
|  |                     $fileNames[] = $autoloadFile; | ||||||
|  |                     if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) | ||||||
|  |                     { | ||||||
|  |                         return true; | ||||||
|  |                     } | ||||||
|  | 
 | ||||||
|  |                     // check for autoload.php
 | ||||||
|  |                     $autoloadFile = 'autoload.php'; | ||||||
|  |                     $fileNames[] = $autoloadFile; | ||||||
|  |                     if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) | ||||||
|  |                     { | ||||||
|  |                         return true; | ||||||
|  |                     } | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Maybe there is another autoload available.
 | ||||||
|  |             // Register this classname as false.
 | ||||||
|  |             ezcBase::$autoloadArray[$className] = false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $path = ezcBase::$packageDir . 'autoload/'; | ||||||
|  |         $realPath = realpath( $path ); | ||||||
|  | 
 | ||||||
|  |         if ( $realPath == '' ) | ||||||
|  |         { | ||||||
|  |             // Can not be tested, because if this happens, then the autoload
 | ||||||
|  |             // environment has not been set-up correctly.
 | ||||||
|  |             trigger_error( "Couldn't find autoload directory '$path'", E_USER_ERROR ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $dirs = self::getRepositoryDirectories(); | ||||||
|  |         if ( ezcBase::$options && ezcBase::$options->debug ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseAutoloadException( $className, $fileNames, $dirs ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets the current working directory to $directory. | ||||||
|  |      * | ||||||
|  |      * @param string $directory | ||||||
|  |      */ | ||||||
|  |     public static function setWorkingDirectory( $directory ) | ||||||
|  |     { | ||||||
|  |         self::$libraryMode = 'custom'; | ||||||
|  |         self::$currentWorkingDirectory = $directory; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Figures out the base path of the eZ Components installation. | ||||||
|  |      * | ||||||
|  |      * It stores the path that it finds in a static member variable. The path | ||||||
|  |      * depends on the installation method of the eZ Components. The SVN version | ||||||
|  |      * has a different path than the PEAR installed version. | ||||||
|  |      */ | ||||||
|  |     protected static function setPackageDir() | ||||||
|  |     { | ||||||
|  |         if ( ezcBase::$packageDir !== null ) | ||||||
|  |         { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Get the path to the components.
 | ||||||
|  |         $baseDir = dirname( __FILE__ ); | ||||||
|  | 
 | ||||||
|  |         switch ( ezcBase::$libraryMode ) | ||||||
|  |         { | ||||||
|  |             case "custom": | ||||||
|  |                 ezcBase::$packageDir = self::$currentWorkingDirectory . '/'; | ||||||
|  |                 break; | ||||||
|  |             case "devel": | ||||||
|  |             case "tarball": | ||||||
|  |                 ezcBase::$packageDir = $baseDir. "/../../"; | ||||||
|  |                 break; | ||||||
|  |             case "pear"; | ||||||
|  |                 ezcBase::$packageDir = $baseDir. "/../"; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Tries to load the autoload array and, if loaded correctly, includes the class. | ||||||
|  |      * | ||||||
|  |      * @param string $fileName    Name of the autoload file. | ||||||
|  |      * @param string $className   Name of the class that should be autoloaded. | ||||||
|  |      * @param string $prefix      The prefix of the class repository. | ||||||
|  |      * | ||||||
|  |      * @return bool  True is returned when the file is correctly loaded. | ||||||
|  |      *                   Otherwise false is returned. | ||||||
|  |      */ | ||||||
|  |     protected static function requireFile( $fileName, $className, $prefix ) | ||||||
|  |     { | ||||||
|  |         $autoloadDir = ezcBase::$packageDir . "autoload/"; | ||||||
|  | 
 | ||||||
|  |         // We need the full path to the fileName. The method file_exists() doesn't
 | ||||||
|  |         // automatically check the (php.ini) library paths. Therefore:
 | ||||||
|  |         // file_exists( "ezc/autoload/$fileName" ) doesn't work.
 | ||||||
|  |         if ( $prefix === 'ezc' && file_exists( "$autoloadDir$fileName" ) ) | ||||||
|  |         { | ||||||
|  |             $array = require( "$autoloadDir$fileName" ); | ||||||
|  | 
 | ||||||
|  |             if ( is_array( $array) && array_key_exists( $className, $array ) ) | ||||||
|  |             { | ||||||
|  |                 // Add the array to the cache, and include the requested file.
 | ||||||
|  |                 ezcBase::$autoloadArray = array_merge( ezcBase::$autoloadArray, $array ); | ||||||
|  |                 if ( ezcBase::$options !== null && ezcBase::$options->preload && !preg_match( '/Exception$/', $className ) ) | ||||||
|  |                 { | ||||||
|  |                     foreach ( $array as $loadClassName => $file ) | ||||||
|  |                     { | ||||||
|  |                         if ( $loadClassName !== 'ezcBase' && !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false ) && !preg_match( '/Exception$/', $loadClassName ) /*&& !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false )*/ ) | ||||||
|  |                         { | ||||||
|  |                             ezcBase::loadFile( ezcBase::$autoloadArray[$loadClassName] ); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     ezcBase::loadFile( ezcBase::$autoloadArray[$className] ); | ||||||
|  |                 } | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // It is not in components autoload/ dir.
 | ||||||
|  |         // try to search in additional dirs.
 | ||||||
|  |         foreach ( ezcBase::$repositoryDirs as $repositoryPrefix => $extraDir ) | ||||||
|  |         { | ||||||
|  |             if ( gettype( $repositoryPrefix ) === 'string' && $repositoryPrefix !== $prefix ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( file_exists( $extraDir['autoloadDirPath'] . '/' . $fileName ) ) | ||||||
|  |             { | ||||||
|  |                 $array = array(); | ||||||
|  |                 $originalArray = require( $extraDir['autoloadDirPath'] . '/' . $fileName ); | ||||||
|  | 
 | ||||||
|  |                 // Building paths.
 | ||||||
|  |                 // Resulting path to class definition file consists of:
 | ||||||
|  |                 // path to extra directory with autoload file +
 | ||||||
|  |                 // basePath provided for current extra directory +
 | ||||||
|  |                 // path to class definition file stored in autoload file.
 | ||||||
|  |                 foreach ( $originalArray as $class => $classPath ) | ||||||
|  |                 { | ||||||
|  |                     $array[$class] = $extraDir['basePath'] . '/' . $classPath; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if ( is_array( $array ) && array_key_exists( $className, $array ) ) | ||||||
|  |                 { | ||||||
|  |                     // Add the array to the cache, and include the requested file.
 | ||||||
|  |                     ezcBase::$externalAutoloadArray = array_merge( ezcBase::$externalAutoloadArray, $array ); | ||||||
|  |                     ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] ); | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Nothing found :-(.
 | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Loads, require(), the given file name. If we are in development mode, | ||||||
|  |      * "/src/" is inserted into the path. | ||||||
|  |      * | ||||||
|  |      * @param string $file  The name of the file that should be loaded. | ||||||
|  |      */ | ||||||
|  |     protected static function loadFile( $file ) | ||||||
|  |     { | ||||||
|  |         switch ( ezcBase::$libraryMode ) | ||||||
|  |         { | ||||||
|  |             case "devel": | ||||||
|  |             case "tarball": | ||||||
|  |                 list( $first, $second ) = explode( '/', $file, 2 ); | ||||||
|  |                 $file = $first . "/src/" . $second; | ||||||
|  |                 break; | ||||||
|  | 
 | ||||||
|  |             case "custom": | ||||||
|  |                 list( $first, $second ) = explode( '/', $file, 2 ); | ||||||
|  |                 // Add the "src/" after the package name.
 | ||||||
|  |                 if ( $first == 'Base' || $first == 'UnitTest' ) | ||||||
|  |                 { | ||||||
|  |                     list( $first, $second ) = explode( '/', $file, 2 ); | ||||||
|  |                     $file = $first . "/src/" . $second; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     list( $first, $second, $third ) = explode( '/', $file, 3 ); | ||||||
|  |                     $file = $first . '/' . $second . "/src/" . $third; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  | 
 | ||||||
|  |             case "pear": | ||||||
|  |                 /* do nothing, it's already correct */ | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( file_exists( ezcBase::$packageDir . $file ) ) | ||||||
|  |         { | ||||||
|  |             require( ezcBase::$packageDir . $file ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             // Can not be tested, because if this happens, then one of the
 | ||||||
|  |             // components has a broken autoload file.
 | ||||||
|  |             throw new ezcBaseFileNotFoundException( ezcBase::$packageDir.$file ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Loads, require(), the given file name from an external package. | ||||||
|  |      * | ||||||
|  |      * @param string $file  The name of the file that should be loaded. | ||||||
|  |      */ | ||||||
|  |     protected static function loadExternalFile( $file ) | ||||||
|  |     { | ||||||
|  |         if ( file_exists( $file ) ) | ||||||
|  |         { | ||||||
|  |             require( $file ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $file ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Checks for dependencies on PHP versions or extensions | ||||||
|  |      * | ||||||
|  |      * The function as called by the $component component checks for the $type | ||||||
|  |      * dependency. The dependency $type is compared against the $value. The | ||||||
|  |      * function aborts the script if the dependency is not matched. | ||||||
|  |      * | ||||||
|  |      * @param string $component | ||||||
|  |      * @param int $type | ||||||
|  |      * @param mixed $value | ||||||
|  |      */ | ||||||
|  |     public static function checkDependency( $component, $type, $value ) | ||||||
|  |     { | ||||||
|  |         switch ( $type ) | ||||||
|  |         { | ||||||
|  |             case self::DEP_PHP_EXTENSION: | ||||||
|  |                 if ( extension_loaded( $value ) ) | ||||||
|  |                 { | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     // Can not be tested as it would abort the PHP script.
 | ||||||
|  |                     die( "\nThe {$component} component depends on the default PHP extension '{$value}', which is not loaded.\n" ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  | 
 | ||||||
|  |             case self::DEP_PHP_VERSION: | ||||||
|  |                 $phpVersion = phpversion(); | ||||||
|  |                 if ( version_compare( $phpVersion, $value, '>=' ) ) | ||||||
|  |                 { | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     // Can not be tested as it would abort the PHP script.
 | ||||||
|  |                     die( "\nThe {$component} component depends on the PHP version '{$value}', but the current version is '{$phpVersion}'.\n" ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return the list of directories that contain class repositories. | ||||||
|  |      * | ||||||
|  |      * The path to the eZ components directory is always included in the result | ||||||
|  |      * array. Each element in the returned array has the format of: | ||||||
|  |      * packageDirectory => ezcBaseRepositoryDirectory | ||||||
|  |      * | ||||||
|  |      * @return array(string=>ezcBaseRepositoryDirectory) | ||||||
|  |      */ | ||||||
|  |     public static function getRepositoryDirectories() | ||||||
|  |     { | ||||||
|  |         $autoloadDirs = array(); | ||||||
|  |         ezcBase::setPackageDir(); | ||||||
|  |         $repositoryDir = self::$currentWorkingDirectory ? self::$currentWorkingDirectory : ( realpath( dirname( __FILE__ ) . '/../../' ) ); | ||||||
|  |         $autoloadDirs['ezc'] = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_INTERNAL, $repositoryDir, $repositoryDir . "/autoload" ); | ||||||
|  | 
 | ||||||
|  |         foreach ( ezcBase::$repositoryDirs as $extraDirKey => $extraDirArray ) | ||||||
|  |         { | ||||||
|  |             $repositoryDirectory = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_EXTERNAL, realpath( $extraDirArray['basePath'] ), realpath( $extraDirArray['autoloadDirPath'] ) ); | ||||||
|  |             $autoloadDirs[$extraDirKey] = $repositoryDirectory; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $autoloadDirs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Adds an additional class repository. | ||||||
|  |      * | ||||||
|  |      * Used for adding class repositoryies outside the eZ components to be | ||||||
|  |      * loaded by the autoload system. | ||||||
|  |      * | ||||||
|  |      * This function takes two arguments: $basePath is the base path for the | ||||||
|  |      * whole class repository and $autoloadDirPath the path where autoload | ||||||
|  |      * files for this repository are found. The paths in the autoload files are | ||||||
|  |      * relative to the package directory as specified by the $basePath | ||||||
|  |      * argument. I.e. class definition file will be searched at location | ||||||
|  |      * $basePath + path to the class definition file as stored in the autoload | ||||||
|  |      * file. | ||||||
|  |      * | ||||||
|  |      * addClassRepository() should be called somewhere in code before external classes | ||||||
|  |      * are used. | ||||||
|  |      * | ||||||
|  |      * Example: | ||||||
|  |      * Take the following facts: | ||||||
|  |      * <ul> | ||||||
|  |      * <li>there is a class repository stored in the directory "./repos"</li> | ||||||
|  |      * <li>autoload files for that repository are stored in "./repos/autoloads"</li> | ||||||
|  |      * <li>there are two components in this repository: "Me" and "You"</li> | ||||||
|  |      * <li>the "Me" component has the classes "erMyClass1" and "erMyClass2"</li> | ||||||
|  |      * <li>the "You" component has the classes "erYourClass1" and "erYourClass2"</li> | ||||||
|  |      * </ul> | ||||||
|  |      * | ||||||
|  |      * In this case you would need to create the following files in | ||||||
|  |      * "./repos/autoloads". Please note that the part before _autoload.php in | ||||||
|  |      * the filename is the first part of the <b>classname</b>, not considering | ||||||
|  |      * the all lower-case letter prefix. | ||||||
|  |      * | ||||||
|  |      * "my_autoload.php": | ||||||
|  |      * <code> | ||||||
|  |      * <?php | ||||||
|  |      *     return array ( | ||||||
|  |      *       'erMyClass1' => 'Me/myclass1.php', | ||||||
|  |      *       'erMyClass2' => 'Me/myclass2.php', | ||||||
|  |      *     ); | ||||||
|  |      * ?>
 | ||||||
|  |      * </code> | ||||||
|  |      * | ||||||
|  |      * "your_autoload.php": | ||||||
|  |      * <code> | ||||||
|  |      * <?php | ||||||
|  |      *     return array ( | ||||||
|  |      *       'erYourClass1' => 'You/yourclass1.php', | ||||||
|  |      *       'erYourClass2' => 'You/yourclass2.php', | ||||||
|  |      *     ); | ||||||
|  |      * ?>
 | ||||||
|  |      * </code> | ||||||
|  |      * | ||||||
|  |      * The directory structure for the external repository is then: | ||||||
|  |      * <code> | ||||||
|  |      * ./repos/autoloads/my_autoload.php | ||||||
|  |      * ./repos/autoloads/you_autoload.php | ||||||
|  |      * ./repos/Me/myclass1.php | ||||||
|  |      * ./repos/Me/myclass2.php | ||||||
|  |      * ./repos/You/yourclass1.php | ||||||
|  |      * ./repos/You/yourclass2.php | ||||||
|  |      * </code> | ||||||
|  |      * | ||||||
|  |      * To use this repository with the autoload mechanism you have to use the | ||||||
|  |      * following code: | ||||||
|  |      * <code> | ||||||
|  |      * <?php | ||||||
|  |      * ezcBase::addClassRepository( './repos', './repos/autoloads' ); | ||||||
|  |      * $myVar = new erMyClass2(); | ||||||
|  |      * ?>
 | ||||||
|  |      * </code> | ||||||
|  |      * | ||||||
|  |      * @throws ezcBaseFileNotFoundException if $autoloadDirPath or $basePath do not exist. | ||||||
|  |      * @param string $basePath | ||||||
|  |      * @param string $autoloadDirPath | ||||||
|  |      * @param string $prefix | ||||||
|  |      */ | ||||||
|  |     public static function addClassRepository( $basePath, $autoloadDirPath = null, $prefix = null ) | ||||||
|  |     { | ||||||
|  |         // check if base path exists
 | ||||||
|  |         if ( !is_dir( $basePath ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $basePath, 'base directory' ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // calculate autoload path if it wasn't given
 | ||||||
|  |         if ( is_null( $autoloadDirPath ) ) | ||||||
|  |         { | ||||||
|  |             $autoloadDirPath = $basePath . '/autoload'; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // check if autoload dir exists
 | ||||||
|  |         if ( !is_dir( $autoloadDirPath ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $autoloadDirPath, 'autoload directory' ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // add info to $repositoryDirs
 | ||||||
|  |         if ( $prefix === null ) | ||||||
|  |         { | ||||||
|  |             $array = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath ); | ||||||
|  | 
 | ||||||
|  |             // add info to the list of extra dirs
 | ||||||
|  |             ezcBase::$repositoryDirs[] = $array; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             if ( array_key_exists( $prefix, ezcBase::$repositoryDirs ) ) | ||||||
|  |             { | ||||||
|  |                 throw new ezcBaseDoubleClassRepositoryPrefixException( $prefix, $basePath, $autoloadDirPath ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // add info to the list of extra dirs, and use the prefix to identify the new repository.
 | ||||||
|  |             ezcBase::$repositoryDirs[$prefix] = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the base path of the eZ Components installation | ||||||
|  |      * | ||||||
|  |      * This method returns the base path, including a trailing directory | ||||||
|  |      * separator. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function getInstallationPath() | ||||||
|  |     { | ||||||
|  |         self::setPackageDir(); | ||||||
|  | 
 | ||||||
|  |         $path = realpath( self::$packageDir ); | ||||||
|  |         if ( substr( $path, -1 ) !== DIRECTORY_SEPARATOR ) | ||||||
|  |         { | ||||||
|  |             $path .= DIRECTORY_SEPARATOR; | ||||||
|  |         } | ||||||
|  |         return $path; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets the development mode to the one specified. | ||||||
|  |      * | ||||||
|  |      * @param int $runMode | ||||||
|  |      */ | ||||||
|  |     public static function setRunMode( $runMode ) | ||||||
|  |     { | ||||||
|  |         if ( !in_array( $runMode, array( ezcBase::MODE_PRODUCTION, ezcBase::MODE_DEVELOPMENT ) ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseValueException( 'runMode', $runMode, 'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT' ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         self::$runMode = $runMode; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the current development mode. | ||||||
|  |      * | ||||||
|  |      * @return int | ||||||
|  |      */ | ||||||
|  |     public static function getRunMode() | ||||||
|  |     { | ||||||
|  |         return self::$runMode; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns true when we are in development mode. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function inDevMode() | ||||||
|  |     { | ||||||
|  |         return self::$runMode == ezcBase::MODE_DEVELOPMENT; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the installation method | ||||||
|  |      * | ||||||
|  |      * Possible return values are 'custom', 'devel', 'tarball' and 'pear'. Only | ||||||
|  |      * 'tarball' and 'pear' are returned for user-installed versions. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function getInstallMethod() | ||||||
|  |     { | ||||||
|  |         return self::$libraryMode; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										38
									
								
								src/TUnit/external/ezc/Base/exceptions/autoload.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/TUnit/external/ezc/Base/exceptions/autoload.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseAutoloadException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseAutoloadException is thrown whenever a class can not be found with | ||||||
|  |  * the autoload mechanism. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseAutoloadException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseAutoloadException for the $className that was | ||||||
|  |      * searched for in the autoload files $fileNames from the directories | ||||||
|  |      * specified in $dirs. | ||||||
|  |      * | ||||||
|  |      * @param string $className | ||||||
|  |      * @param array(string) $files | ||||||
|  |      * @param array(ezcBaseRepositoryDirectory) $dirs | ||||||
|  |      */ | ||||||
|  |     function __construct( $className, $files, $dirs ) | ||||||
|  |     { | ||||||
|  |         $paths = array(); | ||||||
|  |         foreach ( $dirs as $dir ) | ||||||
|  |         { | ||||||
|  |             $paths[] = realpath( $dir->autoloadPath ); | ||||||
|  |         } | ||||||
|  |         parent::__construct( "Could not find a class to file mapping for '{$className}'. Searched for ". implode( ', ', $files ) . " in: " . implode( ', ', $paths ) ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										34
									
								
								src/TUnit/external/ezc/Base/exceptions/double_class_repository_prefix.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/TUnit/external/ezc/Base/exceptions/double_class_repository_prefix.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseDoubleClassRepositoryPrefixException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseDoubleClassRepositoryPrefixException is thrown whenever you try to | ||||||
|  |  * register a class repository with a prefix that has already been added | ||||||
|  |  * before. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseDoubleClassRepositoryPrefixException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseDoubleClassRepositoryPrefixException for the | ||||||
|  |      * $prefix that points to $basePath with autoload directory | ||||||
|  |      * $autoloadDirPath. | ||||||
|  |      * | ||||||
|  |      * @param string $prefix | ||||||
|  |      * @param string $basePath | ||||||
|  |      * @param string $autoloadDirPath | ||||||
|  |      */ | ||||||
|  |     function __construct( $prefix, $basePath, $autoloadDirPath ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "The class repository in '{$basePath}' (with autoload dir '{$autoloadDirPath}') can not be added because another class repository already uses the prefix '{$prefix}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										43
									
								
								src/TUnit/external/ezc/Base/exceptions/exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/TUnit/external/ezc/Base/exceptions/exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseException class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseException is a container from which all other exceptions in the | ||||||
|  |  * components library descent. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | abstract class ezcBaseException extends Exception | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Original message, before escaping | ||||||
|  |      */ | ||||||
|  |     public $originalMessage; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseException with $message | ||||||
|  |      * | ||||||
|  |      * @param string $message | ||||||
|  |      */ | ||||||
|  |     public function __construct( $message ) | ||||||
|  |     { | ||||||
|  |         $this->originalMessage = $message; | ||||||
|  | 
 | ||||||
|  |         if ( php_sapi_name() == 'cli' ) | ||||||
|  |         { | ||||||
|  |             parent::__construct( $message ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             parent::__construct( htmlspecialchars( $message ) ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										38
									
								
								src/TUnit/external/ezc/Base/exceptions/extension_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/TUnit/external/ezc/Base/exceptions/extension_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseExtensionNotFoundException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * ezcBaseExtensionNotFoundException is thrown when a requested PHP extension was not found. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseExtensionNotFoundException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseExtensionNotFoundException. | ||||||
|  |      * | ||||||
|  |      * @param string $name The name of the extension | ||||||
|  |      * @param string $version The version of the extension | ||||||
|  |      * @param string $message Additional text | ||||||
|  |      */ | ||||||
|  |     function __construct( $name, $version = null, $message = null ) | ||||||
|  |     { | ||||||
|  |         if ( $version === null ) | ||||||
|  |         { | ||||||
|  |             parent::__construct( "The extension '{$name}' could not be found. {$message}" ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             parent::__construct( "The extension '{$name}' with version '{$version}' could not be found. {$message}" ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										25
									
								
								src/TUnit/external/ezc/Base/exceptions/file_exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/TUnit/external/ezc/Base/exceptions/file_exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFileException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseFileException is the exception from which all file related exceptions | ||||||
|  |  * inherit. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | abstract class ezcBaseFileException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     const READ    = 1; | ||||||
|  |     const WRITE   = 2; | ||||||
|  |     const EXECUTE = 4; | ||||||
|  |     const CHANGE  = 8; | ||||||
|  |     const REMOVE  = 16; | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										50
									
								
								src/TUnit/external/ezc/Base/exceptions/file_io.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/TUnit/external/ezc/Base/exceptions/file_io.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFileIoException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseFileIoException is thrown when a problem occurs while writing | ||||||
|  |  * and reading to/from an open file. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseFileIoException extends ezcBaseFileException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseFileIoException for the file $path. | ||||||
|  |      * | ||||||
|  |      * @param string $path The name of the file. | ||||||
|  |      * @param int    $mode The mode of the property that is allowed | ||||||
|  |      *               (ezcBaseFileException::READ, ezcBaseFileException::WRITE, | ||||||
|  |      *               ezcBaseFileException::EXECUTE or | ||||||
|  |      *               ezcBaseFileException::CHANGE). | ||||||
|  |      * @param string $message A string with extra information. | ||||||
|  |      */ | ||||||
|  |     function __construct( $path, $mode, $message = null ) | ||||||
|  |     { | ||||||
|  |         switch ( $mode ) | ||||||
|  |         { | ||||||
|  |             case ezcBaseFileException::READ: | ||||||
|  |                 $operation = "An error occurred while reading from '{$path}'"; | ||||||
|  |                 break; | ||||||
|  |             case ezcBaseFileException::WRITE: | ||||||
|  |                 $operation = "An error occurred while writing to '{$path}'"; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $messagePart = ''; | ||||||
|  |         if ( $message ) | ||||||
|  |         { | ||||||
|  |             $messagePart = " ($message)"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         parent::__construct( "$operation.$messagePart" ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										43
									
								
								src/TUnit/external/ezc/Base/exceptions/file_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/TUnit/external/ezc/Base/exceptions/file_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFileNotFoundException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseFileNotFoundException is thrown when a file or directory was tried to | ||||||
|  |  * be opened, but did not exist. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseFileNotFoundException extends ezcBaseFileException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseFileNotFoundException. | ||||||
|  |      * | ||||||
|  |      * @param string $path The name of the file. | ||||||
|  |      * @param string $type The type of the file. | ||||||
|  |      * @param string $message A string with extra information. | ||||||
|  |      */ | ||||||
|  |     function __construct( $path, $type = null, $message = null ) | ||||||
|  |     { | ||||||
|  |         $typePart = ''; | ||||||
|  |         if ( $type ) | ||||||
|  |         { | ||||||
|  |             $typePart = "$type "; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $messagePart = ''; | ||||||
|  |         if ( $message ) | ||||||
|  |         { | ||||||
|  |             $messagePart = " ($message)"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         parent::__construct( "The {$typePart}file '{$path}' could not be found.$messagePart" ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										63
									
								
								src/TUnit/external/ezc/Base/exceptions/file_permission.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/TUnit/external/ezc/Base/exceptions/file_permission.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFilePermissionException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseFilePermissionException is thrown whenever a permission problem with | ||||||
|  |  * a file, directory or stream occurred. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseFilePermissionException extends ezcBaseFileException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcPropertyPermissionException for the property $name. | ||||||
|  |      * | ||||||
|  |      * @param string $path The name of the file. | ||||||
|  |      * @param int    $mode The mode of the property that is allowed | ||||||
|  |      *               (ezcBaseFileException::READ, ezcBaseFileException::WRITE, | ||||||
|  |      *               ezcBaseFileException::EXECUTE, | ||||||
|  |      *               ezcBaseFileException::CHANGE or | ||||||
|  |      *               ezcBaseFileException::REMOVE). | ||||||
|  |      * @param string $message A string with extra information. | ||||||
|  |      */ | ||||||
|  |     function __construct( $path, $mode, $message = null ) | ||||||
|  |     { | ||||||
|  |         switch ( $mode ) | ||||||
|  |         { | ||||||
|  |             case ezcBaseFileException::READ: | ||||||
|  |                 $operation = "The file '{$path}' can not be opened for reading"; | ||||||
|  |                 break; | ||||||
|  |             case ezcBaseFileException::WRITE: | ||||||
|  |                 $operation = "The file '{$path}' can not be opened for writing"; | ||||||
|  |                 break; | ||||||
|  |             case ezcBaseFileException::EXECUTE: | ||||||
|  |                 $operation = "The file '{$path}' can not be executed"; | ||||||
|  |                 break; | ||||||
|  |             case ezcBaseFileException::CHANGE: | ||||||
|  |                 $operation = "The permissions for '{$path}' can not be changed"; | ||||||
|  |                 break; | ||||||
|  |             case ezcBaseFileException::REMOVE: | ||||||
|  |                 $operation = "The file '{$path}' can not be removed"; | ||||||
|  |                 break; | ||||||
|  |             case ( ezcBaseFileException::READ || ezcBaseFileException::WRITE ): | ||||||
|  |                 $operation = "The file '{$path}' can not be opened for reading and writing"; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $messagePart = ''; | ||||||
|  |         if ( $message ) | ||||||
|  |         { | ||||||
|  |             $messagePart = " ($message)"; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         parent::__construct( "$operation.$messagePart" ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Base/exceptions/functionality_not_supported.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Base/exceptions/functionality_not_supported.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFunctionalityNotSupportedException class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * The ezcBaseFunctionalityNotSupportedException is thrown when a requested | ||||||
|  |  * PHP function was not found. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseFunctionalityNotSupportedException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseFunctionalityNotSupportedException. | ||||||
|  |      * | ||||||
|  |      * @param string $message The message to throw | ||||||
|  |      * @param string $reason The reason for the exception | ||||||
|  |      */ | ||||||
|  |     function __construct( $message, $reason ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "{$message} is not supported. Reason: {$reason}." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Base/exceptions/init_callback_configured.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Base/exceptions/init_callback_configured.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseInitCallbackConfiguredException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseInitCallbackConfiguredException is thrown when you try to assign a | ||||||
|  |  * callback clasname to an identifier, while there is already a callback class | ||||||
|  |  * configured for this identifier. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseInitCallbackConfiguredException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseInitCallbackConfiguredException. | ||||||
|  |      * | ||||||
|  |      * @param string $identifier | ||||||
|  |      * @param string $originalCallbackClassName | ||||||
|  |      */ | ||||||
|  |     function __construct( $identifier, $originalCallbackClassName ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "The '{$identifier}' is already configured with callback class '{$originalCallbackClassName}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Base/exceptions/invalid_callback_class.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Base/exceptions/invalid_callback_class.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseInitInvalidCallbackClassException class | ||||||
|  |  * | ||||||
|  |  * @package Configuration | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Exception that is thrown if an invalid class is passed as callback class for | ||||||
|  |  * delayed object configuration. | ||||||
|  |  * | ||||||
|  |  * @package Configuration | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseInitInvalidCallbackClassException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseInitInvalidCallbackClassException for the $callbackClass. | ||||||
|  |      * | ||||||
|  |      * @param string $callbackClass | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     function __construct( $callbackClass ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Class '{$callbackClass}' does not exist, or does not implement the 'ezcBaseConfigurationInitializer' interface." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										29
									
								
								src/TUnit/external/ezc/Base/exceptions/invalid_parent_class.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/TUnit/external/ezc/Base/exceptions/invalid_parent_class.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseInvalidParentClassException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception that is thrown if an invalid class is passed as custom class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseInvalidParentClassException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs an ezcBaseInvalidParentClassException for custom class $customClass | ||||||
|  |      * | ||||||
|  |      * @param string $expectedParentClass | ||||||
|  |      * @param string $customClass | ||||||
|  |      */ | ||||||
|  |     function __construct( $expectedParentClass, $customClass ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Class '{$customClass}' does not exist, or does not inherit from the '{$expectedParentClass}' class." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										30
									
								
								src/TUnit/external/ezc/Base/exceptions/property_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/TUnit/external/ezc/Base/exceptions/property_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBasePropertyNotFoundException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBasePropertyNotFoundException is thrown whenever a non existent property | ||||||
|  |  * is accessed in the Components library. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBasePropertyNotFoundException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBasePropertyNotFoundException for the property | ||||||
|  |      * $name. | ||||||
|  |      * | ||||||
|  |      * @param string $name The name of the property | ||||||
|  |      */ | ||||||
|  |     function __construct( $name ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "No such property name '{$name}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										42
									
								
								src/TUnit/external/ezc/Base/exceptions/property_permission.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/TUnit/external/ezc/Base/exceptions/property_permission.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcPropertyReadOnlyException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBasePropertyPermissionException is thrown whenever a read-only property | ||||||
|  |  * is tried to be changed, or when a write-only property was accessed for reading. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBasePropertyPermissionException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Used when the property is read-only. | ||||||
|  |      */ | ||||||
|  |     const READ  = 1; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Used when the property is write-only. | ||||||
|  |      */ | ||||||
|  |     const WRITE = 2; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcPropertyPermissionException for the property $name. | ||||||
|  |      * | ||||||
|  |      * @param string $name The name of the property. | ||||||
|  |      * @param int    $mode The mode of the property that is allowed (::READ or ::WRITE). | ||||||
|  |      */ | ||||||
|  |     function __construct( $name, $mode ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "The property '{$name}' is " . | ||||||
|  |             ( $mode == self::READ ? "read" : "write" ) . | ||||||
|  |             "-only." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										29
									
								
								src/TUnit/external/ezc/Base/exceptions/setting_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/TUnit/external/ezc/Base/exceptions/setting_not_found.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseSettingNotFoundException class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseSettingNotFoundException is thrown whenever there is a name passed as | ||||||
|  |  * part as the options array to setOptions() for an option that doesn't exist. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseSettingNotFoundException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseSettingNotFoundException for $settingName. | ||||||
|  |      * | ||||||
|  |      * @param string $settingName The name of the setting that does not exist. | ||||||
|  |      */ | ||||||
|  |     function __construct( $settingName ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "The setting '{$settingName}' is not a valid configuration setting." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										42
									
								
								src/TUnit/external/ezc/Base/exceptions/setting_value.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/TUnit/external/ezc/Base/exceptions/setting_value.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseSettingValueException class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseSettingValueExeception is thrown whenever a value to a class' | ||||||
|  |  * configuration option is either of the wrong type, or has a wrong value. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseSettingValueException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseConfigException | ||||||
|  |      * | ||||||
|  |      * @param string  $settingName The name of the setting where something was | ||||||
|  |      *                wrong with. | ||||||
|  |      * @param mixed   $value The value that the option was tried to be set too. | ||||||
|  |      * @param string  $expectedValue A string explaining the allowed type and value range. | ||||||
|  |      */ | ||||||
|  |     function __construct( $settingName, $value, $expectedValue = null ) | ||||||
|  |     { | ||||||
|  |         $type = gettype( $value ); | ||||||
|  |         if ( in_array( $type, array( 'array', 'object', 'resource' ) ) ) | ||||||
|  |         { | ||||||
|  |             $value = serialize( $value ); | ||||||
|  |         } | ||||||
|  |         $msg = "The value '{$value}' that you were trying to assign to setting '{$settingName}' is invalid."; | ||||||
|  |         if ( $expectedValue ) | ||||||
|  |         { | ||||||
|  |             $msg .= " Allowed values are: " . $expectedValue; | ||||||
|  |         } | ||||||
|  |         parent::__construct( $msg ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										43
									
								
								src/TUnit/external/ezc/Base/exceptions/value.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/TUnit/external/ezc/Base/exceptions/value.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseValueException class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseValueException is thrown whenever the type or value of the given | ||||||
|  |  * variable is not as expected. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseValueException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseValueException on the $name variable. | ||||||
|  |      * | ||||||
|  |      * @param string  $settingName The name of the setting where something was | ||||||
|  |      *                wrong with. | ||||||
|  |      * @param mixed   $value The value that the option was tried to be set too. | ||||||
|  |      * @param string  $expectedValue A string explaining the allowed type and value range. | ||||||
|  |      * @param string  $variableType  What type of variable was tried to be set (setting, argument). | ||||||
|  |      */ | ||||||
|  |     function __construct( $settingName, $value, $expectedValue = null, $variableType = 'setting' ) | ||||||
|  |     { | ||||||
|  |         $type = gettype( $value ); | ||||||
|  |         if ( in_array( $type, array( 'array', 'object', 'resource' ) ) ) | ||||||
|  |         { | ||||||
|  |             $value = serialize( $value ); | ||||||
|  |         } | ||||||
|  |         $msg = "The value '{$value}' that you were trying to assign to $variableType '{$settingName}' is invalid."; | ||||||
|  |         if ( $expectedValue ) | ||||||
|  |         { | ||||||
|  |             $msg .= " Allowed values are: " . $expectedValue . '.'; | ||||||
|  |         } | ||||||
|  |         parent::__construct( $msg ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										40
									
								
								src/TUnit/external/ezc/Base/exceptions/whatever.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/TUnit/external/ezc/Base/exceptions/whatever.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseWhateverException class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * ezcBaseWhateverException is thrown whenever something is so seriously wrong. | ||||||
|  |  * | ||||||
|  |  * If this happens it is not possible to repair anything gracefully. An | ||||||
|  |  * example for this could be, that your eZ components installation has thrown | ||||||
|  |  * far to many exceptions. Whenever you receive an ezcBaseWhateverException, do | ||||||
|  |  * not even try to catch it, but forget your project completely and immediately | ||||||
|  |  * stop coding! ;) | ||||||
|  |  * | ||||||
|  |  * @access private | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseWhateverException extends ezcBaseException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseWhateverException. | ||||||
|  |      * | ||||||
|  |      * @param string $what  What happened? | ||||||
|  |      * @param string $where Where did it happen? | ||||||
|  |      * @param string $who   Who is responsible? | ||||||
|  |      * @param string $why   Why did is happen? | ||||||
|  |      * @access protected | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     function __construct( $what, $where, $who, $why ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Thanks for using eZ components. Hope you like it! Greetings from Amos, Derick, El Frederico, Ray and Toby." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										40
									
								
								src/TUnit/external/ezc/Base/ezc_bootstrap.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/TUnit/external/ezc/Base/ezc_bootstrap.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * Include file that can be used for a quick setup of the eZ Components. | ||||||
|  |  * | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @filesource | ||||||
|  |  * @package Base | ||||||
|  |  * @access private | ||||||
|  |  */ | ||||||
|  | $dir = dirname( __FILE__ ); | ||||||
|  | $dirParts = explode( DIRECTORY_SEPARATOR, $dir ); | ||||||
|  | 
 | ||||||
|  | if ( $dirParts[count( $dirParts ) - 1] === 'src' ) | ||||||
|  | { | ||||||
|  |     $baseDir = join( DIRECTORY_SEPARATOR, array_slice( $dirParts, 0, -2 ) ); | ||||||
|  |     require $baseDir . '/Base/src/base.php'; // svn, bundle
 | ||||||
|  | } | ||||||
|  | else if ( $dirParts[count( $dirParts ) - 2] === 'ezc' ) | ||||||
|  | { | ||||||
|  |     $baseDir = join( DIRECTORY_SEPARATOR, array_slice( $dirParts, 0, -2 ) ); | ||||||
|  |     require $baseDir . '/ezc/Base/base.php'; // pear
 | ||||||
|  | } | ||||||
|  | else | ||||||
|  | { | ||||||
|  |     die( "Your environment isn't properly set-up. Please refer to the eZ components documentation at http://components.ez.no/doc ." ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Implements the __autoload mechanism for PHP - which can only be done once | ||||||
|  |  * per request. | ||||||
|  |  * | ||||||
|  |  * @param string $className  The name of the class that should be loaded. | ||||||
|  |  */ | ||||||
|  | function __autoload( $className ) | ||||||
|  | { | ||||||
|  | 	ezcBase::autoload( $className ); | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										365
									
								
								src/TUnit/external/ezc/Base/features.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										365
									
								
								src/TUnit/external/ezc/Base/features.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,365 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFeatures class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Provides methods needed to check for features. | ||||||
|  |  * | ||||||
|  |  * Example: | ||||||
|  |  * <code> | ||||||
|  |  * <?php | ||||||
|  |  * echo "supports uid: " . ezcBaseFeatures::supportsUserId() . "\n"; | ||||||
|  |  * echo "supports symlink: " . ezcBaseFeatures::supportsSymLink() . "\n"; | ||||||
|  |  * echo "supports hardlink: " . ezcBaseFeatures::supportsLink() . "\n"; | ||||||
|  |  * echo "has imagemagick identify: " . ezcBaseFeatures::hasImageIdentify() . "\n"; | ||||||
|  |  * echo " identify path: " . ezcBaseFeatures::getImageIdentifyExecutable() . "\n"; | ||||||
|  |  * echo "has imagemagick convert: " . ezcBaseFeatures::hasImageConvert() . "\n"; | ||||||
|  |  * echo " convert path: " . ezcBaseFeatures::getImageConvertExecutable() . "\n"; | ||||||
|  |  * echo "has gzip extension: " . ezcBaseFeatures::hasExtensionSupport( 'zlib' ) . "\n"; | ||||||
|  |  * echo "has pdo_mysql 1.0.2: " . ezcBaseFeatures::hasExtensionSupport( 'pdo_mysql', '1.0.2' ) . "\n" | ||||||
|  |  * ?>
 | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseFeatures | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |       * Used to store the path of the ImageMagick convert utility. | ||||||
|  |       * | ||||||
|  |       * It is initialized in the {@link getImageConvertExecutable()} function. | ||||||
|  |       * | ||||||
|  |       * @var string | ||||||
|  |       */ | ||||||
|  |     private static $imageConvert = null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |       * Used to store the path of the ImageMagick identify utility. | ||||||
|  |       * | ||||||
|  |       * It is initialized in the {@link getImageIdentifyExecutable()} function. | ||||||
|  |       * | ||||||
|  |       * @var string | ||||||
|  |       */ | ||||||
|  |     private static $imageIdentify = null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |       * Used to store the operating system. | ||||||
|  |       * | ||||||
|  |       * It is initialized in the {@link os()} function. | ||||||
|  |       * | ||||||
|  |       * @var string | ||||||
|  |       */ | ||||||
|  |     private static $os = null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if hardlinks are supported. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function supportsLink() | ||||||
|  |     { | ||||||
|  |         return function_exists( 'link' ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if symlinks are supported. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function supportsSymLink() | ||||||
|  |     { | ||||||
|  |         return function_exists( 'symlink' ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if posix uids are supported. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function supportsUserId() | ||||||
|  |     { | ||||||
|  |         return function_exists( 'posix_getpwuid' ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if the ImageMagick convert utility is installed. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function hasImageConvert() | ||||||
|  |     { | ||||||
|  |         return !is_null( self::getImageConvertExecutable() ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the path to the ImageMagick convert utility. | ||||||
|  |      * | ||||||
|  |      * On Linux, Unix,... it will return something like: /usr/bin/convert | ||||||
|  |      * On Windows it will return something like: C:\Windows\System32\convert.exe | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function getImageConvertExecutable() | ||||||
|  |     { | ||||||
|  |         if ( !is_null( self::$imageConvert ) ) | ||||||
|  |         { | ||||||
|  |             return self::$imageConvert; | ||||||
|  |         } | ||||||
|  |         return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if the ImageMagick identify utility is installed. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function hasImageIdentify() | ||||||
|  |     { | ||||||
|  |         return !is_null( self::getImageIdentifyExecutable() ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the path to the ImageMagick identify utility. | ||||||
|  |      * | ||||||
|  |      * On Linux, Unix,... it will return something like: /usr/bin/identify | ||||||
|  |      * On Windows it will return something like: C:\Windows\System32\identify.exe | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function getImageIdentifyExecutable() | ||||||
|  |     { | ||||||
|  |         if ( !is_null( self::$imageIdentify ) ) | ||||||
|  |         { | ||||||
|  |             return self::$imageIdentify; | ||||||
|  |         } | ||||||
|  |         return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if the specified extension is loaded. | ||||||
|  |      * | ||||||
|  |      * If $version is specified, the specified extension will be tested also | ||||||
|  |      * against the version of the loaded extension. | ||||||
|  |      * | ||||||
|  |      * Examples: | ||||||
|  |      * <code> | ||||||
|  |      * hasExtensionSupport( 'gzip' ); | ||||||
|  |      * </code> | ||||||
|  |      * will return true if gzip extension is loaded. | ||||||
|  |      * | ||||||
|  |      * <code> | ||||||
|  |      * hasExtensionSupport( 'pdo_mysql', '1.0.2' ); | ||||||
|  |      * </code> | ||||||
|  |      * will return true if pdo_mysql extension is loaded and its version is at least 1.0.2. | ||||||
|  |      * | ||||||
|  |      * @param string $extension | ||||||
|  |      * @param string $version | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function hasExtensionSupport( $extension, $version = null ) | ||||||
|  |     { | ||||||
|  |         if ( is_null( $version ) ) | ||||||
|  |         { | ||||||
|  |             return extension_loaded( $extension ); | ||||||
|  |         } | ||||||
|  |         return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Determines if the specified function is available. | ||||||
|  |      * | ||||||
|  |      * Examples: | ||||||
|  |      * <code> | ||||||
|  |      * ezcBaseFeatures::hasFunction( 'imagepstext' ); | ||||||
|  |      * </code> | ||||||
|  |      * will return true if support for Type 1 fonts is available with your GD | ||||||
|  |      * extension. | ||||||
|  |      * | ||||||
|  |      * @param string $functionName | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function hasFunction( $functionName ) | ||||||
|  |     { | ||||||
|  |         return function_exists( $functionName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if a given class exists. | ||||||
|  |      * Checks for a given class name and returns if this class exists or not. | ||||||
|  |      * Catches the ezcBaseAutoloadException and returns false, if it was thrown. | ||||||
|  |      * | ||||||
|  |      * @param string $className The class to check for. | ||||||
|  |      * @param bool $autoload True to use __autoload(), otherwise false. | ||||||
|  |      * @return bool True if the class exists. Otherwise false. | ||||||
|  |      */ | ||||||
|  |     public static function classExists( $className, $autoload = true ) | ||||||
|  |     { | ||||||
|  |         try | ||||||
|  |         { | ||||||
|  |             if ( class_exists( $className, $autoload ) ) | ||||||
|  |             { | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         catch ( ezcBaseAutoloadException $e ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the operating system on which PHP is running. | ||||||
|  |      * | ||||||
|  |      * This method returns a sanitized form of the OS name, example | ||||||
|  |      * return values are "Windows", "Mac", "Linux" and "FreeBSD". In | ||||||
|  |      * all other cases it returns the value of the internal PHP constant | ||||||
|  |      * PHP_OS. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function os() | ||||||
|  |     { | ||||||
|  |         if ( is_null( self::$os ) ) | ||||||
|  |         { | ||||||
|  |             $uname = php_uname( 's' ); | ||||||
|  |             if ( substr( $uname, 0, 7 ) == 'Windows' ) | ||||||
|  |             { | ||||||
|  |                 self::$os = 'Windows'; | ||||||
|  |             } | ||||||
|  |             elseif ( substr( $uname, 0, 3 ) == 'Mac' ) | ||||||
|  |             { | ||||||
|  |                 self::$os = 'Mac'; | ||||||
|  |             } | ||||||
|  |             elseif ( strtolower( $uname ) == 'linux' ) | ||||||
|  |             { | ||||||
|  |                 self::$os = 'Linux'; | ||||||
|  |             } | ||||||
|  |             elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' ) | ||||||
|  |             { | ||||||
|  |                 self::$os = 'FreeBSD'; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 self::$os = PHP_OS; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return self::$os; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the path of the specified executable, if it can be found in the system's path. | ||||||
|  |      * | ||||||
|  |      * It scans the PATH enviroment variable based on the OS to find the | ||||||
|  |      * $fileName. For Windows, the path is with \, not /.  If $fileName is not | ||||||
|  |      * found, it returns null. | ||||||
|  |      * | ||||||
|  |      * @todo consider using getenv( 'PATH' ) instead of $_ENV['PATH'] | ||||||
|  |      *       (but that won't work under IIS) | ||||||
|  |      * | ||||||
|  |      * @param string $fileName | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function findExecutableInPath( $fileName ) | ||||||
|  |     { | ||||||
|  |         if ( array_key_exists( 'PATH', $_ENV ) ) | ||||||
|  |         { | ||||||
|  |             $envPath = trim( $_ENV['PATH'] ); | ||||||
|  |         } | ||||||
|  |         else if ( ( $envPath = getenv( 'PATH' ) ) !== false ) | ||||||
|  |         { | ||||||
|  |             $envPath = trim( $envPath ); | ||||||
|  |         } | ||||||
|  |         if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 ) | ||||||
|  |         { | ||||||
|  |             $envPath = false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         switch ( self::os() ) | ||||||
|  |         { | ||||||
|  |             case 'Unix': | ||||||
|  |             case 'FreeBSD': | ||||||
|  |             case 'Mac': | ||||||
|  |             case 'MacOS': | ||||||
|  |             case 'Darwin': | ||||||
|  |             case 'Linux': | ||||||
|  |             case 'SunOS': | ||||||
|  |                 if ( $envPath ) | ||||||
|  |                 { | ||||||
|  |                     $dirs = explode( ':', $envPath ); | ||||||
|  |                     foreach ( $dirs as $dir ) | ||||||
|  |                     { | ||||||
|  |                         // The @-operator is used here mainly to avoid
 | ||||||
|  |                         // open_basedir warnings. If open_basedir (or any other
 | ||||||
|  |                         // circumstance) prevents the desired file from being
 | ||||||
|  |                         // accessed, it is fine for file_exists() to return
 | ||||||
|  |                         // false, since it is useless for use then, anyway.
 | ||||||
|  |                         if ( file_exists( "{$dir}/{$fileName}" ) ) | ||||||
|  |                         { | ||||||
|  |                             return "{$dir}/{$fileName}"; | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 // The @-operator is used here mainly to avoid open_basedir
 | ||||||
|  |                 // warnings. If open_basedir (or any other circumstance)
 | ||||||
|  |                 // prevents the desired file from being accessed, it is fine
 | ||||||
|  |                 // for file_exists() to return false, since it is useless for
 | ||||||
|  |                 // use then, anyway.
 | ||||||
|  |                 elseif ( @file_exists( "./{$fileName}" ) ) | ||||||
|  |                 { | ||||||
|  |                     return $fileName; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'Windows': | ||||||
|  |                 if ( $envPath ) | ||||||
|  |                 { | ||||||
|  |                     $dirs = explode( ';', $envPath ); | ||||||
|  |                     foreach ( $dirs as $dir ) | ||||||
|  |                     { | ||||||
|  |                         // The @-operator is used here mainly to avoid
 | ||||||
|  |                         // open_basedir warnings. If open_basedir (or any other
 | ||||||
|  |                         // circumstance) prevents the desired file from being
 | ||||||
|  |                         // accessed, it is fine for file_exists() to return
 | ||||||
|  |                         // false, since it is useless for use then, anyway.
 | ||||||
|  |                         if ( @file_exists( "{$dir}\\{$fileName}.exe" ) ) | ||||||
|  |                         { | ||||||
|  |                             return "{$dir}\\{$fileName}.exe"; | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 // The @-operator is used here mainly to avoid open_basedir
 | ||||||
|  |                 // warnings. If open_basedir (or any other circumstance)
 | ||||||
|  |                 // prevents the desired file from being accessed, it is fine
 | ||||||
|  |                 // for file_exists() to return false, since it is useless for
 | ||||||
|  |                 // use then, anyway.
 | ||||||
|  |                 elseif ( @file_exists( "{$fileName}.exe" ) ) | ||||||
|  |                 { | ||||||
|  |                     return "{$fileName}.exe"; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Reset the cached information.  | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @access private | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public static function reset() | ||||||
|  |     { | ||||||
|  |         self::$imageIdentify = null; | ||||||
|  |         self::$imageConvert  = null; | ||||||
|  |         self::$os            = null; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										495
									
								
								src/TUnit/external/ezc/Base/file.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										495
									
								
								src/TUnit/external/ezc/Base/file.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,495 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @filesource | ||||||
|  |  * @package Base | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Provides a selection of static independent methods to provide functionality | ||||||
|  |  * for file and file system handling. | ||||||
|  |  * | ||||||
|  |  * This example shows how to use the findRecursive method: | ||||||
|  |  * <code> | ||||||
|  |  * <?php | ||||||
|  |  * // lists all the files under /etc (including subdirectories) that end in
 | ||||||
|  |  * // .conf
 | ||||||
|  |  * $confFiles = ezcBaseFile::findRecursive( "/etc", array( '@\.conf$@' ) ); | ||||||
|  |  * | ||||||
|  |  * // lists all autoload files in the components source tree and excludes the
 | ||||||
|  |  * // ones in the autoload subdirectory. Statistics are returned in the $stats
 | ||||||
|  |  * // variable which is passed by reference.
 | ||||||
|  |  * $files = ezcBaseFile::findRecursive( | ||||||
|  |  *     "/dat/dev/ezcomponents", | ||||||
|  |  *     array( '@src/.*_autoload.php$@' ), | ||||||
|  |  *     array( '@/autoload/@' ), | ||||||
|  |  *     $stats | ||||||
|  |  * ); | ||||||
|  |  * | ||||||
|  |  * // lists all binaries in /bin except the ones starting with a "g"
 | ||||||
|  |  * $data = ezcBaseFile::findRecursive( "/bin", array(), array( '@^/bin/g@' ) ); | ||||||
|  |  * ?>
 | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcBaseFile | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * This is the callback used by findRecursive to collect data. | ||||||
|  |      * | ||||||
|  |      * This callback method works together with walkRecursive() and is called | ||||||
|  |      * for every file/and or directory. The $context is a callback specific | ||||||
|  |      * container in which data can be stored and shared between the different | ||||||
|  |      * calls to the callback function. The walkRecursive() function also passes | ||||||
|  |      * in the full absolute directory in $sourceDir, the filename in $fileName | ||||||
|  |      * and file information (such as size, modes, types) as an array as | ||||||
|  |      * returned by PHP's stat() in the $fileInfo parameter. | ||||||
|  |      * | ||||||
|  |      * @param ezcBaseFileFindContext $context | ||||||
|  |      * @param string $sourceDir | ||||||
|  |      * @param string $fileName | ||||||
|  |      * @param array(stat) $fileInfo | ||||||
|  |      */ | ||||||
|  |     static protected function findRecursiveCallback( ezcBaseFileFindContext $context, $sourceDir, $fileName, $fileInfo ) | ||||||
|  |     { | ||||||
|  |         // ignore if we have a directory
 | ||||||
|  |         if ( $fileInfo['mode'] & 0x4000 ) | ||||||
|  |         { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // update the statistics
 | ||||||
|  |         $context->elements[] = $sourceDir . DIRECTORY_SEPARATOR . $fileName; | ||||||
|  |         $context->count++; | ||||||
|  |         $context->size += $fileInfo['size']; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Walks files and directories recursively on a file system | ||||||
|  |      * | ||||||
|  |      * This method walks over a directory and calls a callback from every file | ||||||
|  |      * and directory it finds. You can use $includeFilters to include only | ||||||
|  |      * specific files, and $excludeFilters to exclude certain files from being | ||||||
|  |      * returned. The function will always go into subdirectories even if the | ||||||
|  |      * entry would not have passed the filters. | ||||||
|  |      * | ||||||
|  |      * The callback is passed in the $callback parameter, and the | ||||||
|  |      * $callbackContext will be send to the callback function/method as | ||||||
|  |      * parameter so that you can store data in there that persists with all the | ||||||
|  |      * calls and recursive calls to this method. It's up to the callback method | ||||||
|  |      * to do something useful with this. The callback function's parameters are | ||||||
|  |      * in order: | ||||||
|  |      * | ||||||
|  |      * <ul> | ||||||
|  |      * <li>ezcBaseFileFindContext $context</li> | ||||||
|  |      * <li>string $sourceDir</li> | ||||||
|  |      * <li>string $fileName</li> | ||||||
|  |      * <li>array(stat) $fileInfo</li> | ||||||
|  |      * </ul> | ||||||
|  |      * | ||||||
|  |      * See {@see findRecursiveCallback()} for an example of a callback function. | ||||||
|  |      * | ||||||
|  |      * Filters are regular expressions and are therefore required to have | ||||||
|  |      * starting and ending delimiters. The Perl Compatible syntax is used as | ||||||
|  |      * regular expression language. | ||||||
|  |      * | ||||||
|  |      * @param string         $sourceDir | ||||||
|  |      * @param array(string)  $includeFilters | ||||||
|  |      * @param array(string)  $excludeFilters | ||||||
|  |      * @param callback       $callback | ||||||
|  |      * @param mixed          $callbackContext | ||||||
|  |      * | ||||||
|  |      * @throws ezcBaseFileNotFoundException if the $sourceDir directory is not | ||||||
|  |      *         a directory or does not exist. | ||||||
|  |      * @throws ezcBaseFilePermissionException if the $sourceDir directory could | ||||||
|  |      *         not be opened for reading. | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|  |     static public function walkRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), $callback, &$callbackContext ) | ||||||
|  |     { | ||||||
|  |         if ( !is_dir( $sourceDir ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $sourceDir, 'directory' ); | ||||||
|  |         } | ||||||
|  |         $elements = array(); | ||||||
|  |         $d = @dir( $sourceDir ); | ||||||
|  |         if ( !$d ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFilePermissionException( $sourceDir, ezcBaseFileException::READ ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         while ( ( $entry = $d->read() ) !== false ) | ||||||
|  |         { | ||||||
|  |             if ( $entry == '.' || $entry == '..' ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $fileInfo = @stat( $sourceDir . DIRECTORY_SEPARATOR . $entry ); | ||||||
|  |             if ( !$fileInfo ) | ||||||
|  |             { | ||||||
|  |                 $fileInfo = array( 'size' => 0, 'mode' => 0 ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $fileInfo['mode'] & 0x4000 ) | ||||||
|  |             { | ||||||
|  |                 // We need to ignore the Permission exceptions here as it can
 | ||||||
|  |                 // be normal that a directory can not be accessed. We only need
 | ||||||
|  |                 // the exception if the top directory could not be read.
 | ||||||
|  |                 try | ||||||
|  |                 { | ||||||
|  |                     call_user_func_array( $callback, array( $callbackContext, $sourceDir, $entry, $fileInfo ) ); | ||||||
|  |                     $subList = self::walkRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry, $includeFilters, $excludeFilters, $callback, $callbackContext ); | ||||||
|  |                     $elements = array_merge( $elements, $subList ); | ||||||
|  |                 } | ||||||
|  |                 catch ( ezcBaseFilePermissionException $e ) | ||||||
|  |                 { | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 // By default a file is included in the return list
 | ||||||
|  |                 $ok = true; | ||||||
|  |                 // Iterate over the $includeFilters and prohibit the file from
 | ||||||
|  |                 // being returned when atleast one of them does not match
 | ||||||
|  |                 foreach ( $includeFilters as $filter ) | ||||||
|  |                 { | ||||||
|  |                     if ( !preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) | ||||||
|  |                     { | ||||||
|  |                         $ok = false; | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 // Iterate over the $excludeFilters and prohibit the file from
 | ||||||
|  |                 // being returns when atleast one of them matches
 | ||||||
|  |                 foreach ( $excludeFilters as $filter ) | ||||||
|  |                 { | ||||||
|  |                     if ( preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) | ||||||
|  |                     { | ||||||
|  |                         $ok = false; | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 // If everything's allright, call the callback and add the
 | ||||||
|  |                 // entry to the elements array
 | ||||||
|  |                 if ( $ok ) | ||||||
|  |                 { | ||||||
|  |                     call_user_func( $callback, $callbackContext, $sourceDir, $entry, $fileInfo ); | ||||||
|  |                     $elements[] = $sourceDir . DIRECTORY_SEPARATOR . $entry; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         sort( $elements ); | ||||||
|  |         return $elements; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Finds files recursively on a file system | ||||||
|  |      * | ||||||
|  |      * With this method you can scan the file system for files. You can use | ||||||
|  |      * $includeFilters to include only specific files, and $excludeFilters to | ||||||
|  |      * exclude certain files from being returned. The function will always go | ||||||
|  |      * into subdirectories even if the entry would not have passed the filters. | ||||||
|  |      * It uses the {@see walkRecursive()} method to do the actually recursion. | ||||||
|  |      * | ||||||
|  |      * Filters are regular expressions and are therefore required to have | ||||||
|  |      * starting and ending delimiters. The Perl Compatible syntax is used as | ||||||
|  |      * regular expression language. | ||||||
|  |      * | ||||||
|  |      * If you pass an empty array to the $statistics argument, the function
 | ||||||
|  |      * will in details about the number of files found into the 'count' array | ||||||
|  |      * element, and the total filesize in the 'size' array element. Because this | ||||||
|  |      * argument is passed by reference, you *have* to pass a variable and you | ||||||
|  |      * can not pass a constant value such as "array()". | ||||||
|  |      * | ||||||
|  |      * @param string         $sourceDir | ||||||
|  |      * @param array(string)  $includeFilters | ||||||
|  |      * @param array(string)  $excludeFilters | ||||||
|  |      * @param array()        $statistics | ||||||
|  |      * | ||||||
|  |      * @throws ezcBaseFileNotFoundException if the $sourceDir directory is not | ||||||
|  |      *         a directory or does not exist. | ||||||
|  |      * @throws ezcBaseFilePermissionException if the $sourceDir directory could | ||||||
|  |      *         not be opened for reading. | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|  |     static public function findRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), &$statistics = null ) | ||||||
|  |     { | ||||||
|  |         // init statistics array
 | ||||||
|  |         if ( !is_array( $statistics ) || !array_key_exists( 'size', $statistics ) || !array_key_exists( 'count', $statistics ) ) | ||||||
|  |         { | ||||||
|  |             $statistics['size']  = 0; | ||||||
|  |             $statistics['count'] = 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // create the context, and then start walking over the array
 | ||||||
|  |         $context = new ezcBaseFileFindContext; | ||||||
|  |         self::walkRecursive( $sourceDir, $includeFilters, $excludeFilters, array( 'ezcBaseFile', 'findRecursiveCallback' ), $context ); | ||||||
|  | 
 | ||||||
|  |         // collect the statistics
 | ||||||
|  |         $statistics['size'] = $context->size; | ||||||
|  |         $statistics['count'] = $context->count; | ||||||
|  | 
 | ||||||
|  |         // return the found and pattern-matched files
 | ||||||
|  |         sort( $context->elements ); | ||||||
|  |         return $context->elements; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Removes files and directories recursively from a file system | ||||||
|  |      * | ||||||
|  |      * This method recursively removes the $directory and all its contents. | ||||||
|  |      * You should be <b>extremely</b> careful with this method as it has the | ||||||
|  |      * potential to erase everything that the current user has access to. | ||||||
|  |      * | ||||||
|  |      * @param string $directory | ||||||
|  |      */ | ||||||
|  |     static public function removeRecursive( $directory ) | ||||||
|  |     { | ||||||
|  |         $sourceDir = realpath( $directory ); | ||||||
|  |         if ( !$sourceDir ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $directory, 'directory' ); | ||||||
|  |         } | ||||||
|  |         $d = @dir( $sourceDir ); | ||||||
|  |         if ( !$d ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFilePermissionException( $directory, ezcBaseFileException::READ ); | ||||||
|  |         } | ||||||
|  |         // check if we can remove the dir
 | ||||||
|  |         $parentDir = realpath( $directory . DIRECTORY_SEPARATOR . '..' ); | ||||||
|  |         if ( !is_writable( $parentDir ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFilePermissionException( $parentDir, ezcBaseFileException::WRITE ); | ||||||
|  |         } | ||||||
|  |         // loop over contents
 | ||||||
|  |         while ( ( $entry = $d->read() ) !== false ) | ||||||
|  |         { | ||||||
|  |             if ( $entry == '.' || $entry == '..' ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( is_dir( $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) | ||||||
|  |             { | ||||||
|  |                 self::removeRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 if ( @unlink( $sourceDir . DIRECTORY_SEPARATOR . $entry ) === false ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseFilePermissionException( $directory . DIRECTORY_SEPARATOR . $entry, ezcBaseFileException::REMOVE ); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         $d->close(); | ||||||
|  |         rmdir( $sourceDir ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |     * Recursively copy a file or directory. | ||||||
|  |     * | ||||||
|  |     * Recursively copy a file or directory in $source to the given | ||||||
|  |     * destination. If a depth is given, the operation will stop, if the given | ||||||
|  |     * recursion depth is reached. A depth of -1 means no limit, while a depth | ||||||
|  |     * of 0 means, that only the current file or directory will be copied, | ||||||
|  |     * without any recursion. | ||||||
|  |     * | ||||||
|  |     * You may optionally define modes used to create files and directories. | ||||||
|  |     * | ||||||
|  |     * @throws ezcBaseFileNotFoundException | ||||||
|  |     *      If the $sourceDir directory is not a directory or does not exist. | ||||||
|  |     * @throws ezcBaseFilePermissionException | ||||||
|  |     *      If the $sourceDir directory could not be opened for reading, or the | ||||||
|  |     *      destination is not writeable. | ||||||
|  |     * | ||||||
|  |     * @param string $source | ||||||
|  |     * @param string $destination | ||||||
|  |     * @param int $depth | ||||||
|  |     * @param int $dirMode | ||||||
|  |     * @param int $fileMode | ||||||
|  |     * @return void | ||||||
|  |     */ | ||||||
|  |     static public function copyRecursive( $source, $destination, $depth = -1, $dirMode = 0775, $fileMode = 0664 ) | ||||||
|  |     { | ||||||
|  |         // Check if source file exists at all.
 | ||||||
|  |         if ( !is_file( $source ) && !is_dir( $source ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $source ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Destination file should NOT exist
 | ||||||
|  |         if ( is_file( $destination ) || is_dir( $destination ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFilePermissionException( $destination, ezcBaseFileException::WRITE ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Skip non readable files in source directory
 | ||||||
|  |         if ( !is_readable( $source ) ) | ||||||
|  |         { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Copy
 | ||||||
|  |         if ( is_dir( $source ) ) | ||||||
|  |         { | ||||||
|  |             mkdir( $destination ); | ||||||
|  |             // To ignore umask, umask() should not be changed with
 | ||||||
|  |             // multithreaded servers...
 | ||||||
|  |             chmod( $destination, $dirMode ); | ||||||
|  |         } | ||||||
|  |         elseif ( is_file( $source ) ) | ||||||
|  |         { | ||||||
|  |             copy( $source, $destination ); | ||||||
|  |             chmod( $destination, $fileMode ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( ( $depth === 0 ) || | ||||||
|  |             ( !is_dir( $source ) ) ) | ||||||
|  |         { | ||||||
|  |             // Do not recurse (any more)
 | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Recurse
 | ||||||
|  |         $dh = opendir( $source ); | ||||||
|  |         while ( ( $file = readdir( $dh ) ) !== false ) | ||||||
|  |         { | ||||||
|  |             if ( ( $file === '.' ) || | ||||||
|  |                 ( $file === '..' ) ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             self::copyRecursive( | ||||||
|  |                 $source . '/' . $file, | ||||||
|  |                 $destination . '/' . $file, | ||||||
|  |                 $depth - 1, $dirMode, $fileMode | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculates the relative path of the file/directory '$path' to a given | ||||||
|  |      * $base path. | ||||||
|  |      * | ||||||
|  |      * $path and $base should be fully absolute paths. This function returns the | ||||||
|  |      * answer of "How do I go from $base to $path". If the $path and $base are | ||||||
|  |      * the same path, the function returns '.'. This method does not touch the | ||||||
|  |      * filesystem. | ||||||
|  |      * | ||||||
|  |      * @param string $path | ||||||
|  |      * @param string $base | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     static public function calculateRelativePath( $path, $base ) | ||||||
|  |     { | ||||||
|  |         // Sanitize the paths to use the correct directory separator for the platform
 | ||||||
|  |         $path = strtr( $path, '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR ); | ||||||
|  |         $base = strtr( $base, '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR ); | ||||||
|  | 
 | ||||||
|  |         $base = explode( DIRECTORY_SEPARATOR, $base ); | ||||||
|  |         $path = explode( DIRECTORY_SEPARATOR, $path ); | ||||||
|  | 
 | ||||||
|  |         // If the paths are the same we return
 | ||||||
|  |         if ( $base === $path ) | ||||||
|  |         { | ||||||
|  |             return '.'; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $result = ''; | ||||||
|  | 
 | ||||||
|  |         $pathPart = array_shift( $path ); | ||||||
|  |         $basePart = array_shift( $base ); | ||||||
|  |         while ( $pathPart == $basePart ) | ||||||
|  |         { | ||||||
|  |             $pathPart = array_shift( $path ); | ||||||
|  |             $basePart = array_shift( $base ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $pathPart != null ) | ||||||
|  |         { | ||||||
|  |             array_unshift( $path, $pathPart ); | ||||||
|  |         } | ||||||
|  |         if ( $basePart != null ) | ||||||
|  |         { | ||||||
|  |             array_unshift( $base, $basePart ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $result = str_repeat( '..' . DIRECTORY_SEPARATOR, count( $base ) ); | ||||||
|  |         // prevent a trailing DIRECTORY_SEPARATOR in case there is only a ..
 | ||||||
|  |         if ( count( $path ) == 0 ) | ||||||
|  |         { | ||||||
|  |             $result = substr( $result, 0, -strlen( DIRECTORY_SEPARATOR ) ); | ||||||
|  |         } | ||||||
|  |         $result .= join( DIRECTORY_SEPARATOR, $path ); | ||||||
|  | 
 | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns whether the passed $path is an absolute path, giving the current $os. | ||||||
|  |      * | ||||||
|  |      * With the $os parameter you can tell this function to use the semantics | ||||||
|  |      * for a different operating system to determine whether a path is | ||||||
|  |      * absolute. The $os argument defaults to the OS that the script is running | ||||||
|  |      * on. | ||||||
|  |      * | ||||||
|  |      * @param string $path | ||||||
|  |      * @param string $os | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public static function isAbsolutePath( $path, $os = null ) | ||||||
|  |     { | ||||||
|  |         if ( $os === null ) | ||||||
|  |         { | ||||||
|  |             $os = ezcBaseFeatures::os(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Stream wrapper like phar can also be considered absolute paths
 | ||||||
|  |         if ( preg_match( '(^[a-z]{3,}://)S', $path ) ) | ||||||
|  |         { | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         switch ( $os ) | ||||||
|  |         { | ||||||
|  |             case 'Windows': | ||||||
|  |                 // Sanitize the paths to use the correct directory separator for the platform
 | ||||||
|  |                 $path = strtr( $path, '\\/', '\\\\' ); | ||||||
|  | 
 | ||||||
|  |                 // Absolute paths with drive letter: X:\
 | ||||||
|  |                 if ( preg_match( '@^[A-Z]:\\\\@i', $path ) ) | ||||||
|  |                 { | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 // Absolute paths with network paths: \\server\share\
 | ||||||
|  |                 if ( preg_match( '@^\\\\\\\\[A-Z]+\\\\[^\\\\]@i', $path ) ) | ||||||
|  |                 { | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'Mac': | ||||||
|  |             case 'Linux': | ||||||
|  |             case 'FreeBSD': | ||||||
|  |             default: | ||||||
|  |                 // Sanitize the paths to use the correct directory separator for the platform
 | ||||||
|  |                 $path = strtr( $path, '\\/', '//' ); | ||||||
|  | 
 | ||||||
|  |                 if ( $path[0] == '/' ) | ||||||
|  |                 { | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  |         } | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										125
									
								
								src/TUnit/external/ezc/Base/init.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								src/TUnit/external/ezc/Base/init.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,125 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseInit class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Provides a method to implement delayed initialization of objects. | ||||||
|  |  * | ||||||
|  |  * With the methods in this class you can implement callbacks to configure | ||||||
|  |  * singleton classes. In order to do so you will have to change the | ||||||
|  |  * getInstance() method of your singleton class to include a call to | ||||||
|  |  * ezcBaseInit::fetchConfig() as in the following example: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  * <?php | ||||||
|  |  * public static function getInstance() | ||||||
|  |  * { | ||||||
|  |  *     if ( is_null( self::$instance ) ) | ||||||
|  |  *     { | ||||||
|  |  *         self::$instance = new ezcConfigurationmanager(); | ||||||
|  |  *         ezcBaseInit::fetchConfig( 'ezcInitConfigurationManager', self::$instance ); | ||||||
|  |  *     } | ||||||
|  |  *     return self::$instance; | ||||||
|  |  * } | ||||||
|  |  * ?>
 | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * You will also need to configure which callback class to call. This you do | ||||||
|  |  * with the ezcBaseInit::setCallback() method. The following examples sets the | ||||||
|  |  * callback classname for the configuration identifier | ||||||
|  |  * 'ezcInitConfigurationManager' to 'cfgConfigurationManager': | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  * <?php | ||||||
|  |  * ezcBaseInit::setCallback( 'ezcInitConfigurationManager', 'cfgConfigurationManager' ); | ||||||
|  |  * ?>
 | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * The class 'cfgConfigurationManager' is required to implement the | ||||||
|  |  * ezcBaseConfigurationInitializer interface, which defines only one method: | ||||||
|  |  * configureObject(). An example on how to implement such a class could be: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  * <?php | ||||||
|  |  * class cfgConfigurationManager implements ezcBaseConfigurationInitializer | ||||||
|  |  * { | ||||||
|  |  *     static public function configureObject( ezcConfigurationManager $cfgManagerObject ) | ||||||
|  |  *     { | ||||||
|  |  *         $cfgManagerObject->init( 'ezcConfigurationIniReader', 'settings', array( 'useComments' => true ) ); | ||||||
|  |  *     } | ||||||
|  |  * } | ||||||
|  |  * ?>
 | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * Of course the implementation of this callback class is up to the application | ||||||
|  |  * developer that uses the component (in this example the Configuration | ||||||
|  |  * component's class ezcConfigurationManager). | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseInit | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Contains the callback where the identifier is the key of the array, and the classname to callback to the value. | ||||||
|  |      * | ||||||
|  |      * @var array(string=>string) | ||||||
|  |      */ | ||||||
|  |     static private $callbackMap = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Adds the classname $callbackClassname as callback for the identifier $identifier. | ||||||
|  |      * | ||||||
|  |      * @param string $identifier | ||||||
|  |      * @param string $callbackClassname | ||||||
|  |      */ | ||||||
|  |     public static function setCallback( $identifier, $callbackClassname ) | ||||||
|  |     { | ||||||
|  |         if ( array_key_exists( $identifier, self::$callbackMap ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseInitCallbackConfiguredException( $identifier, self::$callbackMap[$identifier] ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             // Check if the passed classname actually exists
 | ||||||
|  |             if ( !ezcBaseFeatures::classExists( $callbackClassname, true ) ) | ||||||
|  |             { | ||||||
|  |                 throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Check if the passed classname actually implements the interface.
 | ||||||
|  |             if ( !in_array( 'ezcBaseConfigurationInitializer', class_implements( $callbackClassname ) ) ) | ||||||
|  |             { | ||||||
|  |                 throw new ezcBaseInitInvalidCallbackClassException( $callbackClassname ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             self::$callbackMap[$identifier] = $callbackClassname; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Uses the configured callback belonging to $identifier to configure the $object. | ||||||
|  |      * | ||||||
|  |      * The method will return the return value of the callback method, or null | ||||||
|  |      * in case there was no callback set for the specified $identifier. | ||||||
|  |      * | ||||||
|  |      * @param string $identifier | ||||||
|  |      * @param object $object | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public static function fetchConfig( $identifier, $object ) | ||||||
|  |     { | ||||||
|  |         if ( isset( self::$callbackMap[$identifier] ) ) | ||||||
|  |         { | ||||||
|  |             $callbackClassname = self::$callbackMap[$identifier]; | ||||||
|  |             return call_user_func( array( $callbackClassname, 'configureObject' ), $object ); | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Base/interfaces/configuration_initializer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Base/interfaces/configuration_initializer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseConfigurationInitializer class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * This class provides the interface that classes need to implement to act as | ||||||
|  |  * an callback initializer class to work with the delayed initialization | ||||||
|  |  * mechanism. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | interface ezcBaseConfigurationInitializer | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Configures the given object, or returns the proper object depending on | ||||||
|  |      * the given identifier. | ||||||
|  |      * | ||||||
|  |      * In case a string identifier was given, it should return the associated | ||||||
|  |      * object, in case an object was given the method should return null. | ||||||
|  |      * | ||||||
|  |      * @param string|object $object | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     static public function configureObject( $object ); | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										40
									
								
								src/TUnit/external/ezc/Base/interfaces/persistable.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/TUnit/external/ezc/Base/interfaces/persistable.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBasePersistable interface | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * This class provides the interface that classes need to implement to be able | ||||||
|  |  * to be used by the PersistentObject and Search components. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | interface ezcBasePersistable | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * The constructor for the object needs to be able to accept no arguments. | ||||||
|  |      * | ||||||
|  |      * The data is later set through the setState() method. | ||||||
|  |      */ | ||||||
|  |     public function __construct(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns all the object's properties so that they can be stored or indexed. | ||||||
|  |      * | ||||||
|  |      * @return array(string=>mixed) | ||||||
|  |      */ | ||||||
|  |     public function getState(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Accepts an array containing data for one or more of the class' properties. | ||||||
|  |      * | ||||||
|  |      * @param array $properties | ||||||
|  |      */ | ||||||
|  |     public function setState( array $properties ); | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										120
									
								
								src/TUnit/external/ezc/Base/metadata.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								src/TUnit/external/ezc/Base/metadata.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,120 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseMetaData class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Base class implements ways of fetching information about the installed | ||||||
|  |  * eZ Components. It knows whether to use the PEAR registry or the bundled XML | ||||||
|  |  * file, depending on how eZ Components is installed. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcBaseMetaData | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Creates a ezcBaseMetaData object | ||||||
|  |      * | ||||||
|  |      * The sole parameter $installMethod should only be used if you are really | ||||||
|  |      * sure that you need to use it. It is mostly there to make testing at | ||||||
|  |      * least slightly possible. Again, do not set it unless instructed. | ||||||
|  |      * | ||||||
|  |      * @param string $installMethod | ||||||
|  |      */ | ||||||
|  |     public function __construct( $installMethod = NULL ) | ||||||
|  |     { | ||||||
|  |         $installMethod = $installMethod !== NULL ? $installMethod : ezcBase::getInstallMethod(); | ||||||
|  | 
 | ||||||
|  |         // figure out which reader to use
 | ||||||
|  |         switch ( $installMethod ) | ||||||
|  |         { | ||||||
|  |             case 'tarball': | ||||||
|  |                 $this->reader = new ezcBaseMetaDataTarballReader; | ||||||
|  |                 break; | ||||||
|  |             case 'pear': | ||||||
|  |                 $this->reader = new ezcBaseMetaDataPearReader; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 throw new ezcBaseMetaDataReaderException( "Unknown install method '$installMethod'." ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the version string for the installed eZ Components bundle. | ||||||
|  |      * | ||||||
|  |      * A version string such as "2008.2.2" is returned. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getBundleVersion() | ||||||
|  |     { | ||||||
|  |         return $this->reader->getBundleVersion(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a PHP version string that describes the required PHP version for | ||||||
|  |      * this installed eZ Components bundle. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getRequiredPhpVersion() | ||||||
|  |     { | ||||||
|  |         return $this->reader->getRequiredPhpVersion(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns whether $componentName is installed | ||||||
|  |      * | ||||||
|  |      * If installed with PEAR, it checks the PEAR registry whether the | ||||||
|  |      * component is there. In case the tarball installation method is used, it | ||||||
|  |      * will return true for every component that exists (because all of them | ||||||
|  |      * are then available). | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public function isComponentInstalled( $componentName ) | ||||||
|  |     { | ||||||
|  |         return $this->reader->isComponentInstalled( $componentName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the version string of the available $componentName or false when | ||||||
|  |      * the component is not installed. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getComponentVersion( $componentName ) | ||||||
|  |     { | ||||||
|  |         return $this->reader->getComponentVersion( $componentName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a list of components that $componentName depends on. | ||||||
|  |      * | ||||||
|  |      * If $componentName is left empty, all installed components are returned. | ||||||
|  |      * | ||||||
|  |      * The returned array has as keys the component names, and as values the | ||||||
|  |      * version of the components. | ||||||
|  |      * | ||||||
|  |      * @return array(string=>string). | ||||||
|  |      */ | ||||||
|  |     public function getComponentDependencies( $componentName = null ) | ||||||
|  |     { | ||||||
|  |         if ( $componentName === null ) | ||||||
|  |         { | ||||||
|  |             return $this->reader->getComponentDependencies(); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return $this->reader->getComponentDependencies( $componentName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										129
									
								
								src/TUnit/external/ezc/Base/metadata/pear.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								src/TUnit/external/ezc/Base/metadata/pear.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,129 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseMetaDataPearReader class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | @require 'PEAR/Registry.php'; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Base class implements ways of fetching information about the installed | ||||||
|  |  * eZ Components when installed as tarball. | ||||||
|  |  * | ||||||
|  |  * Note: there are lots of @ used here, because PEAR still lives in the stone | ||||||
|  |  * age with their PHP 3 code and general liberal use of throwing warnings and | ||||||
|  |  * notices. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcBaseMetaDataPearReader | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Stores the PEAR_Registry to query for information | ||||||
|  |      * | ||||||
|  |      * @var PEAR_Registry | ||||||
|  |      */ | ||||||
|  |     private $registry; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates the reader object and initialized the registry for querying | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         @$this->registry = new PEAR_Registry; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the version string for the installed eZ Components bundle. | ||||||
|  |      * | ||||||
|  |      * A version string such as "2008.2.2" is returned. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getBundleVersion() | ||||||
|  |     { | ||||||
|  |         @$packageInfo = $this->registry->packageInfo( 'ezcomponents', null, 'components.ez.no' ); | ||||||
|  |         return $packageInfo['version']['release']; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a PHP version string that describes the required PHP version for | ||||||
|  |      * this installed eZ Components bundle. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getRequiredPhpVersion() | ||||||
|  |     { | ||||||
|  |         @$packageInfo = $this->registry->packageInfo( 'ezcomponents', null, 'components.ez.no' ); | ||||||
|  |         if ( array_key_exists( 'required', $packageInfo['dependencies'] ) ) | ||||||
|  |         { | ||||||
|  |             return $packageInfo['dependencies']['required']['php']['min']; | ||||||
|  |         } | ||||||
|  |         return $packageInfo['dependencies']['php']['min']; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns whether $componentName is installed | ||||||
|  |      * | ||||||
|  |      * Checks the PEAR registry whether the component is there. | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public function isComponentInstalled( $componentName ) | ||||||
|  |     { | ||||||
|  |         @$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' ); | ||||||
|  |         return is_array( $packageInfo ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the version string of the available $componentName or false when | ||||||
|  |      * the component is not installed. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getComponentVersion( $componentName ) | ||||||
|  |     { | ||||||
|  |         @$packageInfo = $this->registry->packageInfo( $componentName, null, 'components.ez.no' ); | ||||||
|  |         $release = $packageInfo['version']['release']; | ||||||
|  |         return $release === null ? false : $release; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a list of components that $componentName depends on. | ||||||
|  |      * | ||||||
|  |      * If $componentName is left empty, all installed components are returned. | ||||||
|  |      * | ||||||
|  |      * The returned array has as keys the component names, and as values the | ||||||
|  |      * version of the components. | ||||||
|  |      * | ||||||
|  |      * @return array(string=>string). | ||||||
|  |      */ | ||||||
|  |     public function getComponentDependencies( $componentName = 'ezcomponents' ) | ||||||
|  |     { | ||||||
|  |         @$packageInfo = $this->registry->packageInfo( $componentName, 'dependencies', 'components.ez.no' ); | ||||||
|  |         if ( isset( $packageInfo['required']['package'] ) ) | ||||||
|  |         { | ||||||
|  |             $deps = array(); | ||||||
|  |             if ( isset( $packageInfo['required']['package']['name'] ) ) | ||||||
|  |             { | ||||||
|  |                 $deps[$packageInfo['required']['package']['name']] = $packageInfo['required']['package']['min']; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 foreach ( $packageInfo['required']['package'] as $package ) | ||||||
|  |                 { | ||||||
|  |                     $deps[$package['name']] = $package['min']; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             return $deps; | ||||||
|  |         } | ||||||
|  |         return array(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										153
									
								
								src/TUnit/external/ezc/Base/metadata/tarball.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								src/TUnit/external/ezc/Base/metadata/tarball.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,153 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseMetaDataTarballReader class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Base class implements ways of fetching information about the installed | ||||||
|  |  * eZ Components when installed as tarball. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcBaseMetaDataTarballReader | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Contains the handler to the XML file containing the release information. | ||||||
|  |      * @var SimpleXmlElement | ||||||
|  |      */ | ||||||
|  |     private $xml; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates the reader object and opens the release-info file. | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         $filename = dirname( __FILE__ ) . '/../../../release-info.xml'; | ||||||
|  |         $this->xml = simplexml_load_file( $filename ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the version string for the installed eZ Components bundle. | ||||||
|  |      * | ||||||
|  |      * A version string such as "2008.2.2" is returned. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getBundleVersion() | ||||||
|  |     { | ||||||
|  |         return (string) $this->xml->version; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a PHP version string that describes the required PHP version for | ||||||
|  |      * this installed eZ Components bundle. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getRequiredPhpVersion() | ||||||
|  |     { | ||||||
|  |         return (string) $this->xml->deps->php; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns whether $componentName is installed | ||||||
|  |      * | ||||||
|  |      * Returns true for every component that exists (because all of them are | ||||||
|  |      * then available). | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public function isComponentInstalled( $componentName ) | ||||||
|  |     { | ||||||
|  |         $root = $this->xml->deps->packages->package; | ||||||
|  | 
 | ||||||
|  |         foreach ( $root as $package ) | ||||||
|  |         { | ||||||
|  |             if ( (string) $package['name'] == $componentName ) | ||||||
|  |             { | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the version string of the available $componentName or false when | ||||||
|  |      * the component is not installed. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getComponentVersion( $componentName ) | ||||||
|  |     { | ||||||
|  |         $root = $this->xml->deps->packages->package; | ||||||
|  | 
 | ||||||
|  |         foreach ( $root as $package ) | ||||||
|  |         { | ||||||
|  |             if ( (string) $package['name'] == $componentName ) | ||||||
|  |             { | ||||||
|  |                 return (string) $package['version']; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a list of components that $componentName depends on. | ||||||
|  |      * | ||||||
|  |      * If $componentName is left empty, all installed components are returned. | ||||||
|  |      * | ||||||
|  |      * The returned array has as keys the component names, and as values the | ||||||
|  |      * version of the components. It returns null of the $componentName | ||||||
|  |      * is not found. | ||||||
|  |      * | ||||||
|  |      * @return array(string=>string). | ||||||
|  |      */ | ||||||
|  |     public function getComponentDependencies( $componentName = null ) | ||||||
|  |     { | ||||||
|  |         $baseVersion = false; | ||||||
|  |         $root = $this->xml->deps->packages; | ||||||
|  |         $found = $componentName === null ? true : false; | ||||||
|  | 
 | ||||||
|  |         // in case $componentName != null, we loop through all the components
 | ||||||
|  |         // in the file, and figure out the new root that we can list dependency
 | ||||||
|  |         // packages from.
 | ||||||
|  |         foreach ( $root->package as $package ) | ||||||
|  |         { | ||||||
|  |             if ( (string) $package['name'] == 'Base' ) | ||||||
|  |             { | ||||||
|  |                 $baseVersion = $package['version']; | ||||||
|  |             } | ||||||
|  |             if ( !$found && (string) $package['name'] == $componentName ) | ||||||
|  |             { | ||||||
|  |                 $root = $package->deps; | ||||||
|  |                 $found = true; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( !$found ) | ||||||
|  |         { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // We always add the Base dependency even though it's not in the dependency file.
 | ||||||
|  |         $deps = array(); | ||||||
|  |         $deps['Base'] = (string) $baseVersion; | ||||||
|  | 
 | ||||||
|  |         if ( !isset( $root->package ) ) | ||||||
|  |         { | ||||||
|  |             return $deps; | ||||||
|  |         } | ||||||
|  |         foreach ( $root->package as $package ) | ||||||
|  |         { | ||||||
|  |             $deps[(string) $package['name']] = (string) $package['version']; | ||||||
|  |         } | ||||||
|  |         return $deps; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										174
									
								
								src/TUnit/external/ezc/Base/options.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								src/TUnit/external/ezc/Base/options.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,174 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseOptions class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Base options class for all eZ components. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | abstract class ezcBaseOptions implements ArrayAccess | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Container to hold the properties | ||||||
|  |      * | ||||||
|  |      * @var array(string=>mixed) | ||||||
|  |      */ | ||||||
|  |     protected $properties; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Construct a new options object. | ||||||
|  |      * Options are constructed from an option array by default. The constructor | ||||||
|  |      * automatically passes the given options to the __set() method to set them | ||||||
|  |      * in the class. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If trying to access a non existent property. | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If the value for a property is out of range. | ||||||
|  |      * @param array(string=>mixed) $options The initial options to set. | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         foreach ( $options as $option => $value ) | ||||||
|  |         { | ||||||
|  |             $this->__set( $option, $value ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Merge an array into the actual options object. | ||||||
|  |      * This method merges an array of new options into the actual options object. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If trying to access a non existent property. | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If the value for a property is out of range. | ||||||
|  |      * @param array(string=>mixed) $newOptions The new options. | ||||||
|  |      */ | ||||||
|  |     public function merge( array $newOptions ) | ||||||
|  |     { | ||||||
|  |         foreach ( $newOptions as $key => $value ) | ||||||
|  |         { | ||||||
|  |             $this->__set( $key, $value ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property get access. | ||||||
|  |      * Simply returns a given option. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      * @param string $propertyName The name of the option to get. | ||||||
|  |      * @return mixed The option value. | ||||||
|  |      * @ignore | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         if the given property does not exist. | ||||||
|  |      * @throws ezcBasePropertyPermissionException | ||||||
|  |      *         if the property to be set is a write-only property. | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         if ( $this->__isset( $propertyName ) === true ) | ||||||
|  |         { | ||||||
|  |             return $this->properties[$propertyName]; | ||||||
|  |         } | ||||||
|  |         throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets an option. | ||||||
|  |      * This method is called when an option is set. | ||||||
|  |      * | ||||||
|  |      * @param string $propertyName  The name of the option to set. | ||||||
|  |      * @param mixed $propertyValue The option value. | ||||||
|  |      * @ignore | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         if the given property does not exist. | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         if the value to be assigned to a property is invalid. | ||||||
|  |      * @throws ezcBasePropertyPermissionException | ||||||
|  |      *         if the property to be set is a read-only property. | ||||||
|  |      */ | ||||||
|  |     abstract public function __set( $propertyName, $propertyValue ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if a option exists. | ||||||
|  |      * | ||||||
|  |      * @param string $propertyName Option name to check for. | ||||||
|  |      * @return bool Whether the option exists. | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __isset( $propertyName ) | ||||||
|  |     { | ||||||
|  |         return array_key_exists( $propertyName, $this->properties ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if an option exists. | ||||||
|  |      * Allows isset() using ArrayAccess. | ||||||
|  |      * | ||||||
|  |      * @param string $propertyName The name of the option to get. | ||||||
|  |      * @return bool Whether the option exists. | ||||||
|  |      */ | ||||||
|  |     public function offsetExists( $propertyName ) | ||||||
|  |     { | ||||||
|  |         return $this->__isset( $propertyName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns an option value. | ||||||
|  |      * Get an option value by ArrayAccess. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If $propertyName is not a key in the $properties array. | ||||||
|  |      * @param string $propertyName The name of the option to get. | ||||||
|  |      * @return mixed The option value. | ||||||
|  |      */ | ||||||
|  |     public function offsetGet( $propertyName ) | ||||||
|  |     { | ||||||
|  |         return $this->__get( $propertyName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set an option. | ||||||
|  |      * Sets an option using ArrayAccess. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If $propertyName is not a key in the $properties array. | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If the value for a property is out of range. | ||||||
|  |      * @param string $propertyName The name of the option to set. | ||||||
|  |      * @param mixed $propertyValue The value for the option. | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         $this->__set( $propertyName, $propertyValue ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Unset an option. | ||||||
|  |      * Unsets an option using ArrayAccess. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If $propertyName is not a key in the $properties array. | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If a the value for a property is out of range. | ||||||
|  |      * @param string $propertyName The name of the option to unset. | ||||||
|  |      */ | ||||||
|  |     public function offsetUnset( $propertyName ) | ||||||
|  |     { | ||||||
|  |         $this->__set( $propertyName, null ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										75
									
								
								src/TUnit/external/ezc/Base/options/autoload.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								src/TUnit/external/ezc/Base/options/autoload.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,75 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseAutoloadOptions class | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class containing the basic options for ezcBase' autoload. | ||||||
|  |  * | ||||||
|  |  * @property bool $preload | ||||||
|  |  *           If component preloading is enabled then as soon as one of the | ||||||
|  |  *           classes of a component is request, all other classes in the | ||||||
|  |  *           component are loaded as well (except for Exception classes). | ||||||
|  |  * @property bool $debug | ||||||
|  |  *           If debug is enabled then the autoload method will show exceptions | ||||||
|  |  *           when a class can not be found. Because exceptions are ignored by | ||||||
|  |  *           PHP in the autoload handler, you have to catch them in autoload() | ||||||
|  |  *           yourself and do something with the exception message. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseAutoloadOptions extends ezcBaseOptions | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructs an object with the specified values. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         if $options contains a property not defined | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         if $options contains a property with a value not allowed | ||||||
|  |      * @param array(string=>mixed) $options | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->preload = false; | ||||||
|  |         $this->debug = false; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets the option $name to $value. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         if the property $name is not defined | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         if $value is not correct for the property $name | ||||||
|  |      * @param string $name | ||||||
|  |      * @param mixed $value | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $name, $value ) | ||||||
|  |     { | ||||||
|  |         switch ( $name ) | ||||||
|  |         { | ||||||
|  |             case 'debug': | ||||||
|  |             case 'preload': | ||||||
|  |                 if ( !is_bool( $value ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $name, $value, 'bool' ); | ||||||
|  |                 } | ||||||
|  |                 $this->properties[$name] = $value; | ||||||
|  |                 break; | ||||||
|  | 
 | ||||||
|  |             default: | ||||||
|  |                 throw new ezcBasePropertyNotFoundException( $name ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										42
									
								
								src/TUnit/external/ezc/Base/struct.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/TUnit/external/ezc/Base/struct.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseStruct. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Base class for all struct classes. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseStruct | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Throws a BasePropertyNotFound exception. | ||||||
|  |      * | ||||||
|  |      * @param string $name | ||||||
|  |      * @param mixed $value | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     final public function __set( $name, $value ) | ||||||
|  |     { | ||||||
|  |         throw new ezcBasePropertyNotFoundException( $name ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Throws a BasePropertyNotFound exception. | ||||||
|  |      * | ||||||
|  |      * @param string $name | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     final public function __get( $name ) | ||||||
|  |     { | ||||||
|  |         throw new ezcBasePropertyNotFoundException( $name ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										72
									
								
								src/TUnit/external/ezc/Base/structs/file_find_context.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								src/TUnit/external/ezc/Base/structs/file_find_context.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseFileFindContext class. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Struct which defines the information collected by the file walker for locating files. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseFileFindContext extends ezcBaseStruct | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * The list of files | ||||||
|  |      * | ||||||
|  |      * @var array(string) | ||||||
|  |      */ | ||||||
|  |     public $elements; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The number of files | ||||||
|  |      * | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     public $count; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The total file size of all files found | ||||||
|  |      * | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     public $size; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseFileFindContext with initial values. | ||||||
|  |      * | ||||||
|  |      * @param array(string) $elements | ||||||
|  |      * @param int $count | ||||||
|  |      * @param int $size | ||||||
|  |      */ | ||||||
|  |     public function __construct( $elements = array(), $count = 0, $size = 0 ) | ||||||
|  |     { | ||||||
|  |         $this->elements = $elements; | ||||||
|  |         $this->count = $count; | ||||||
|  |         $this->size = $size; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a new instance of this class with the data specified by $array. | ||||||
|  |      * | ||||||
|  |      * $array contains all the data members of this class in the form: | ||||||
|  |      * array('member_name'=>value). | ||||||
|  |      * | ||||||
|  |      * __set_state makes this class exportable with var_export. | ||||||
|  |      * var_export() generates code, that calls this method when it | ||||||
|  |      * is parsed with PHP. | ||||||
|  |      * | ||||||
|  |      * @param array(string=>mixed) $array | ||||||
|  |      * @return ezcBaseFileFindContext | ||||||
|  |      */ | ||||||
|  |     static public function __set_state( array $array ) | ||||||
|  |     { | ||||||
|  |         return new ezcBaseFileFindContext( $array['elements'], $array['count'], $array['size'] ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										83
									
								
								src/TUnit/external/ezc/Base/structs/repository_directory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								src/TUnit/external/ezc/Base/structs/repository_directory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,83 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcBaseRepositoryDirectory. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Struct which defines a repository directory. | ||||||
|  |  * | ||||||
|  |  * @package Base | ||||||
|  |  * @version 1.7 | ||||||
|  |  */ | ||||||
|  | class ezcBaseRepositoryDirectory extends ezcBaseStruct | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Specifies that the entry is for the eZ Components repository. | ||||||
|  |      */ | ||||||
|  |     const TYPE_INTERNAL = 0; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Specifies that the entry is for an external (user defined) repository. | ||||||
|  |      */ | ||||||
|  |     const TYPE_EXTERNAL = 1; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The $type is one of the two TYPE_* constants defined in this class. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     public $type; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The path to the configured repository. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     public $basePath; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The path to the autoload files. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     public $autoloadPath; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructs a new ezcBaseRepositoryDirectory of type $type with base path | ||||||
|  |      * $basePath and autoload path $autoloadPath. | ||||||
|  |      * | ||||||
|  |      * @param string $type | ||||||
|  |      * @param string $basePath | ||||||
|  |      * @param string $autoloadPath | ||||||
|  |      */ | ||||||
|  |     public function __construct( $type, $basePath, $autoloadPath ) | ||||||
|  |     { | ||||||
|  |         $this->type = $type; | ||||||
|  |         $this->basePath = $basePath; | ||||||
|  |         $this->autoloadPath = $autoloadPath; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a new instance of this class with the data specified by $array. | ||||||
|  |      * | ||||||
|  |      * $array contains all the data members of this class in the form: | ||||||
|  |      * array('member_name'=>value). | ||||||
|  |      * | ||||||
|  |      * __set_state makes this class exportable with var_export. | ||||||
|  |      * var_export() generates code, that calls this method when it | ||||||
|  |      * is parsed with PHP. | ||||||
|  |      * | ||||||
|  |      * @param array(string=>mixed) $array | ||||||
|  |      * @return ezcBaseRepositoryDirectory | ||||||
|  |      */ | ||||||
|  |     static public function __set_state( array $array ) | ||||||
|  |     { | ||||||
|  |         return new ezcBaseRepositoryDirectory( $array['type'], $array['basePath'], $array['autoloadPath'] ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										221
									
								
								src/TUnit/external/ezc/Graph/axis/container.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										221
									
								
								src/TUnit/external/ezc/Graph/axis/container.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,221 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphAxisContainer class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * The axis container class is internally used to store and validate sets of | ||||||
|  |  * axis, and offering access using the SPL ArrayAccess interface to add or | ||||||
|  |  * modify its contents. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphAxisContainer | ||||||
|  |     implements | ||||||
|  |         Countable, | ||||||
|  |         ArrayAccess, | ||||||
|  |         Iterator | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Chart the container is used with | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphLineChart | ||||||
|  |      */ | ||||||
|  |     protected $chart; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains the data of a chart | ||||||
|  |      *  | ||||||
|  |      * @var array(ezcGraphChartElementAxis) | ||||||
|  |      */ | ||||||
|  |     protected $data = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Construct container with corresponding chart. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphLineChart $chart  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( ezcGraphLineChart $chart ) | ||||||
|  |     { | ||||||
|  |         $this->chart = $chart; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the given offset exists. | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array. | ||||||
|  |      *  | ||||||
|  |      * @param string $key Identifier of dataset. | ||||||
|  |      * @return bool True when the offset exists, otherwise false. | ||||||
|  |      */ | ||||||
|  |     public function offsetExists( $key ) | ||||||
|  |     { | ||||||
|  |         return isset( $this->data[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the element with the given offset.  | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array.  | ||||||
|  |      *  | ||||||
|  |      * @param string $key Identifier of dataset. | ||||||
|  |      * @return ezcGraphChartElementAxis | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If no dataset with identifier exists | ||||||
|  |      */ | ||||||
|  |     public function offsetGet( $key ) | ||||||
|  |     { | ||||||
|  |         if ( !isset( $this->data[$key] ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBasePropertyNotFoundException( $key ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $this->data[$key]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set the element with the given offset.  | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array.  | ||||||
|  |      *  | ||||||
|  |      * @param string $key | ||||||
|  |      * @param ezcGraphChartElementAxis $value | ||||||
|  |      * @return void | ||||||
|  |      * | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If supplied value is not an ezcGraphChartElementAxis | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         if ( !$value instanceof ezcGraphChartElementAxis ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseValueException( $key, $value, 'ezcGraphChartElementAxis' ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $key === null ) | ||||||
|  |         { | ||||||
|  |             $key = count( $this->data ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Add axis and configure it with current font and palette
 | ||||||
|  |         $this->data[$key] = $value; | ||||||
|  |         $value->font = $this->chart->options->font; | ||||||
|  |         $value->setFromPalette( $this->chart->palette ); | ||||||
|  | 
 | ||||||
|  |         return $value; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Unset the element with the given offset.  | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array.  | ||||||
|  |      *  | ||||||
|  |      * @param string $key | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function offsetUnset( $key ) | ||||||
|  |     { | ||||||
|  |         if ( !isset( $this->data[$key] ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBasePropertyNotFoundException( $key ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         unset( $this->data[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the currently selected dataset. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return ezcGraphChartElementAxis The currently selected dataset. | ||||||
|  |      */ | ||||||
|  |     public function current() | ||||||
|  |     { | ||||||
|  |         return current( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the next dataset and selects it or false on the last dataset. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return mixed ezcGraphChartElementAxis if the next dataset exists, or false. | ||||||
|  |      */ | ||||||
|  |     public function next() | ||||||
|  |     { | ||||||
|  |         return next( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the key of the currently selected dataset. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return int The key of the currently selected dataset. | ||||||
|  |      */ | ||||||
|  |     public function key() | ||||||
|  |     { | ||||||
|  |         return key( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the current dataset is valid. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return bool If the current dataset is valid | ||||||
|  |      */ | ||||||
|  |     public function valid() | ||||||
|  |     { | ||||||
|  |         return ( current( $this->data ) !== false ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Selects the very first dataset and returns it. | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return ezcGraphChartElementAxis The very first dataset. | ||||||
|  |      */ | ||||||
|  |     public function rewind() | ||||||
|  |     { | ||||||
|  |         return reset( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the number of datasets in the row. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Countable interface to allow the usage of | ||||||
|  |      * PHP's count() function to check how many datasets exist. | ||||||
|  |      * | ||||||
|  |      * @return int Number of datasets. | ||||||
|  |      */ | ||||||
|  |     public function count() | ||||||
|  |     { | ||||||
|  |         return count( $this->data ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										633
									
								
								src/TUnit/external/ezc/Graph/axis/date.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										633
									
								
								src/TUnit/external/ezc/Graph/axis/date.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,633 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphChartElementDateAxis class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent date axis. | ||||||
|  |  * | ||||||
|  |  * Axis elements represent the axis in a bar, line or radar chart. They are | ||||||
|  |  * chart elements (ezcGraphChartElement) extending from | ||||||
|  |  * ezcGraphChartElementAxis, where additional formatting options can be found. | ||||||
|  |  * You should generally use the axis, which matches your input data best, so | ||||||
|  |  * that the automatic chart layouting works best. Aavailable axis types are: | ||||||
|  |  * | ||||||
|  |  * - ezcGraphChartElementDateAxis | ||||||
|  |  * - ezcGraphChartElementLabeledAxis | ||||||
|  |  * - ezcGraphChartElementLogarithmicalAxis | ||||||
|  |  * - ezcGraphChartElementNumericAxis | ||||||
|  |  * | ||||||
|  |  * Date axis will try to find a "nice" interval based on the values on the x | ||||||
|  |  * axis. If non numeric values are given, ezcGraphChartElementDateAxis will | ||||||
|  |  * convert them to timestamps using PHPs strtotime function. | ||||||
|  |  * | ||||||
|  |  * It is always possible to set start date, end date and the interval manually | ||||||
|  |  * by yourself. | ||||||
|  |  * | ||||||
|  |  * The $dateFormat option provides an additional way of formatting the labels | ||||||
|  |  * used on the axis. The options from the parent class $formatString and | ||||||
|  |  * $labelCallback do still apply. | ||||||
|  |  * | ||||||
|  |  * You may use a date axis like in the following example: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphLineChart(); | ||||||
|  |  *  $graph->options->fillLines = 210; | ||||||
|  |  *  $graph->title = 'Concurrent requests'; | ||||||
|  |  *  $graph->legend = false; | ||||||
|  |  *   | ||||||
|  |  *  $graph->xAxis = new ezcGraphChartElementDateAxis(); | ||||||
|  |  *   | ||||||
|  |  *  // Add data
 | ||||||
|  |  *  $graph->data['Machine 1'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *      '8:00' => 3241, | ||||||
|  |  *      '8:13' => 934, | ||||||
|  |  *      '8:24' => 1201, | ||||||
|  |  *      '8:27' => 1752, | ||||||
|  |  *      '8:51' => 123, | ||||||
|  |  *  ) ); | ||||||
|  |  *  $graph->data['Machine 2'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *      '8:05' => 623, | ||||||
|  |  *      '8:12' => 2103, | ||||||
|  |  *      '8:33' => 543, | ||||||
|  |  *      '8:43' => 2034, | ||||||
|  |  *      '8:59' => 3410, | ||||||
|  |  *  ) ); | ||||||
|  |  *   | ||||||
|  |  *  $graph->data['Machine 1']->symbol = ezcGraph::BULLET; | ||||||
|  |  *  $graph->data['Machine 2']->symbol = ezcGraph::BULLET; | ||||||
|  |  *   | ||||||
|  |  *  $graph->render( 400, 150, 'tutorial_axis_datetime.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property float $startDate | ||||||
|  |  *           Starting date used to display on axis. | ||||||
|  |  * @property float $endDate | ||||||
|  |  *           End date used to display on axis. | ||||||
|  |  * @property float $interval | ||||||
|  |  *           Time interval between steps on axis. | ||||||
|  |  * @property string $dateFormat | ||||||
|  |  *           Format of date string | ||||||
|  |  *           Like http://php.net/date | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementDateAxis extends ezcGraphChartElementAxis | ||||||
|  | { | ||||||
|  |      | ||||||
|  |     const MONTH = 2629800; | ||||||
|  | 
 | ||||||
|  |     const YEAR = 31536000; | ||||||
|  | 
 | ||||||
|  |     const DECADE = 315360000; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Minimum inserted date | ||||||
|  |      *  | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     protected $minValue = false; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Maximum inserted date  | ||||||
|  |      *  | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     protected $maxValue = false; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Nice time intervals to used if there is no user defined interval | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $predefinedIntervals = array( | ||||||
|  |         // Second
 | ||||||
|  |         1           => 'H:i.s', | ||||||
|  |         // Ten seconds
 | ||||||
|  |         10          => 'H:i.s', | ||||||
|  |         // Thirty seconds
 | ||||||
|  |         30          => 'H:i.s', | ||||||
|  |         // Minute
 | ||||||
|  |         60          => 'H:i', | ||||||
|  |         // Ten minutes
 | ||||||
|  |         600         => 'H:i', | ||||||
|  |         // Half an hour
 | ||||||
|  |         1800        => 'H:i', | ||||||
|  |         // Hour
 | ||||||
|  |         3600        => 'H:i', | ||||||
|  |         // Four hours
 | ||||||
|  |         14400       => 'H:i', | ||||||
|  |         // Six hours
 | ||||||
|  |         21600       => 'H:i', | ||||||
|  |         // Half a day
 | ||||||
|  |         43200       => 'd.m a', | ||||||
|  |         // Day
 | ||||||
|  |         86400       => 'd.m', | ||||||
|  |         // Week
 | ||||||
|  |         604800      => 'W', | ||||||
|  |         // Month
 | ||||||
|  |         self::MONTH => 'M y', | ||||||
|  |         // Year
 | ||||||
|  |         self::YEAR  => 'Y', | ||||||
|  |         // Decade
 | ||||||
|  |         self::DECADE => 'Y', | ||||||
|  |     ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constant used for calculation of automatic definition of major scaling  | ||||||
|  |      * steps | ||||||
|  |      */ | ||||||
|  |     const MAJOR_COUNT = 10; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['startDate'] = false; | ||||||
|  |         $this->properties['endDate'] = false; | ||||||
|  |         $this->properties['interval'] = false; | ||||||
|  |         $this->properties['dateFormat'] = false; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'startDate': | ||||||
|  |                 $this->properties['startDate'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'endDate': | ||||||
|  |                 $this->properties['endDate'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'interval': | ||||||
|  |                 $this->properties['interval'] = (int) $propertyValue; | ||||||
|  |                 $this->properties['initialized'] = true; | ||||||
|  |                 break; | ||||||
|  |             case 'dateFormat': | ||||||
|  |                 $this->properties['dateFormat'] = (string) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Ensure proper timestamp | ||||||
|  |      * | ||||||
|  |      * Takes a mixed value from datasets, like timestamps, or strings  | ||||||
|  |      * describing some time and converts it to a timestamp. | ||||||
|  |      *  | ||||||
|  |      * @param mixed $value  | ||||||
|  |      * @return int | ||||||
|  |      */ | ||||||
|  |     protected static function ensureTimestamp( $value ) | ||||||
|  |     { | ||||||
|  |         if ( is_numeric( $value ) ) | ||||||
|  |         { | ||||||
|  |             $timestamp = (int) $value; | ||||||
|  |         } | ||||||
|  |         elseif ( ( $timestamp = strtotime( $value ) ) === false ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphErrorParsingDateException( $value ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $timestamp; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Add data for this axis | ||||||
|  |      *  | ||||||
|  |      * @param array $values Value which will be displayed on this axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function addData( array $values ) | ||||||
|  |     { | ||||||
|  |         foreach ( $values as $nr => $value ) | ||||||
|  |         { | ||||||
|  |             $value = self::ensureTimestamp( $value ); | ||||||
|  | 
 | ||||||
|  |             if ( $this->minValue === false || | ||||||
|  |                  $value < $this->minValue ) | ||||||
|  |             { | ||||||
|  |                 $this->minValue = $value; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $this->maxValue === false || | ||||||
|  |                  $value > $this->maxValue ) | ||||||
|  |             { | ||||||
|  |                 $this->maxValue = $value; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->properties['initialized'] = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate nice time interval | ||||||
|  |      * | ||||||
|  |      * Use the best fitting time interval defined in class property array | ||||||
|  |      * predefinedIntervals. | ||||||
|  |      *  | ||||||
|  |      * @param int $min Start time | ||||||
|  |      * @param int $max End time | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function calculateInterval( $min, $max ) | ||||||
|  |     { | ||||||
|  |         $diff = $max - $min; | ||||||
|  | 
 | ||||||
|  |         foreach ( $this->predefinedIntervals as $interval => $format ) | ||||||
|  |         { | ||||||
|  |             if ( ( $diff / $interval ) <= self::MAJOR_COUNT ) | ||||||
|  |             { | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( ( $this->properties['startDate'] !== false ) && | ||||||
|  |              ( $this->properties['endDate'] !== false ) ) | ||||||
|  |         { | ||||||
|  |             // Use interval between defined borders
 | ||||||
|  |             if ( ( $diff % $interval ) > 0 ) | ||||||
|  |             { | ||||||
|  |                 // Stil use predefined date format from old interval if not set
 | ||||||
|  |                 if ( $this->properties['dateFormat'] === false ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['dateFormat'] = $this->predefinedIntervals[$interval]; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $count = ceil( $diff / $interval ); | ||||||
|  |                 $interval = round( $diff / $count, 0 ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->properties['interval'] = $interval; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate lower nice date | ||||||
|  |      * | ||||||
|  |      * Calculates a date which is earlier or equal to the given date, and is | ||||||
|  |      * divisible by the given interval. | ||||||
|  |      *  | ||||||
|  |      * @param int $min Date | ||||||
|  |      * @param int $interval Interval  | ||||||
|  |      * @return int Earlier date | ||||||
|  |      */ | ||||||
|  |     protected function calculateLowerNiceDate( $min, $interval ) | ||||||
|  |     { | ||||||
|  |         switch ( $interval ) | ||||||
|  |         { | ||||||
|  |             case self::MONTH: | ||||||
|  |                 // Special handling for months - not covered by the default 
 | ||||||
|  |                 // algorithm 
 | ||||||
|  |                 return mktime( | ||||||
|  |                     1, | ||||||
|  |                     0, | ||||||
|  |                     0, | ||||||
|  |                     (int) date( 'm', $min ), | ||||||
|  |                     1, | ||||||
|  |                     (int) date( 'Y', $min ) | ||||||
|  |                 ); | ||||||
|  |             default: | ||||||
|  |                 $dateSteps = array( 60, 60, 24, 7, 52 ); | ||||||
|  | 
 | ||||||
|  |                 $date = array( | ||||||
|  |                     (int) date( 's', $min ), | ||||||
|  |                     (int) date( 'i', $min ), | ||||||
|  |                     (int) date( 'H', $min ), | ||||||
|  |                     (int) date( 'd', $min ), | ||||||
|  |                     (int) date( 'm', $min ), | ||||||
|  |                     (int) date( 'Y', $min ), | ||||||
|  |                 ); | ||||||
|  | 
 | ||||||
|  |                 $element = 0; | ||||||
|  |                 while ( ( $step = array_shift( $dateSteps ) ) && | ||||||
|  |                         ( $interval > $step ) ) | ||||||
|  |                 { | ||||||
|  |                     $interval /= $step; | ||||||
|  |                     $date[$element++] = (int) ( $element > 2 ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $date[$element] -= $date[$element] % $interval; | ||||||
|  | 
 | ||||||
|  |                 return mktime( | ||||||
|  |                     $date[2], | ||||||
|  |                     $date[1], | ||||||
|  |                     $date[0], | ||||||
|  |                     $date[4], | ||||||
|  |                     $date[3], | ||||||
|  |                     $date[5] | ||||||
|  |                 ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate start date | ||||||
|  |      * | ||||||
|  |      * Use calculateLowerNiceDate to get a date earlier or equal date then the  | ||||||
|  |      * minimum date to use it as the start date for the axis depending on the | ||||||
|  |      * selected interval. | ||||||
|  |      *  | ||||||
|  |      * @param mixed $min Minimum date | ||||||
|  |      * @param mixed $max Maximum date | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function calculateMinimum( $min, $max ) | ||||||
|  |     { | ||||||
|  |         if ( $this->properties['endDate'] === false ) | ||||||
|  |         { | ||||||
|  |             $this->properties['startDate'] = $this->calculateLowerNiceDate( $min, $this->interval ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $this->properties['startDate'] = $this->properties['endDate']; | ||||||
|  | 
 | ||||||
|  |             while ( $this->properties['startDate'] > $min ) | ||||||
|  |             { | ||||||
|  |                 switch ( $this->interval ) | ||||||
|  |                 { | ||||||
|  |                     case self::MONTH: | ||||||
|  |                         $this->properties['startDate'] = strtotime( '-1 month', $this->properties['startDate'] ); | ||||||
|  |                         break; | ||||||
|  |                     case self::YEAR: | ||||||
|  |                         $this->properties['startDate'] = strtotime( '-1 year', $this->properties['startDate'] ); | ||||||
|  |                         break; | ||||||
|  |                     case self::DECADE: | ||||||
|  |                         $this->properties['startDate'] = strtotime( '-10 years', $this->properties['startDate'] ); | ||||||
|  |                         break; | ||||||
|  |                     default: | ||||||
|  |                         $this->properties['startDate'] -= $this->interval; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate end date | ||||||
|  |      * | ||||||
|  |      * Use calculateLowerNiceDate to get a date later or equal date then the  | ||||||
|  |      * maximum date to use it as the end date for the axis depending on the | ||||||
|  |      * selected interval. | ||||||
|  |      *  | ||||||
|  |      * @param mixed $min Minimum date | ||||||
|  |      * @param mixed $max Maximum date | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function calculateMaximum( $min, $max ) | ||||||
|  |     { | ||||||
|  |         $this->properties['endDate'] = $this->properties['startDate']; | ||||||
|  | 
 | ||||||
|  |         while ( $this->properties['endDate'] < $max ) | ||||||
|  |         { | ||||||
|  |             switch ( $this->interval ) | ||||||
|  |             { | ||||||
|  |                 case self::MONTH: | ||||||
|  |                     $this->properties['endDate'] = strtotime( '+1 month', $this->properties['endDate'] ); | ||||||
|  |                     break; | ||||||
|  |                 case self::YEAR: | ||||||
|  |                     $this->properties['endDate'] = strtotime( '+1 year', $this->properties['endDate'] ); | ||||||
|  |                     break; | ||||||
|  |                 case self::DECADE: | ||||||
|  |                     $this->properties['endDate'] = strtotime( '+10 years', $this->properties['endDate'] ); | ||||||
|  |                     break; | ||||||
|  |                 default: | ||||||
|  |                     $this->properties['endDate'] += $this->interval; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate axis bounding values on base of the assigned values  | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function calculateAxisBoundings() | ||||||
|  |     { | ||||||
|  |         // Prevent division by zero, when min == max
 | ||||||
|  |         if ( $this->minValue == $this->maxValue ) | ||||||
|  |         { | ||||||
|  |             if ( $this->minValue == 0 ) | ||||||
|  |             { | ||||||
|  |                 $this->maxValue = 1; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $this->minValue -= ( $this->minValue * .1 ); | ||||||
|  |                 $this->maxValue += ( $this->maxValue * .1 ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Use custom minimum and maximum if available
 | ||||||
|  |         if ( $this->properties['startDate'] !== false ) | ||||||
|  |         { | ||||||
|  |             $this->minValue = $this->properties['startDate']; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['endDate'] !== false ) | ||||||
|  |         { | ||||||
|  |             $this->maxValue = $this->properties['endDate']; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Calculate "nice" values for scaling parameters
 | ||||||
|  |         if ( $this->properties['interval'] === false ) | ||||||
|  |         { | ||||||
|  |             $this->calculateInterval( $this->minValue, $this->maxValue ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['dateFormat'] === false && isset( $this->predefinedIntervals[$this->interval] ) ) | ||||||
|  |         { | ||||||
|  |             $this->properties['dateFormat'] = $this->predefinedIntervals[$this->interval]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['startDate'] === false ) | ||||||
|  |         { | ||||||
|  |             $this->calculateMinimum( $this->minValue, $this->maxValue ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['endDate'] === false ) | ||||||
|  |         { | ||||||
|  |             $this->calculateMaximum( $this->minValue, $this->maxValue ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get coordinate for a dedicated value on the chart | ||||||
|  |      *  | ||||||
|  |      * @param float $value Value to determine position for | ||||||
|  |      * @return float Position on chart | ||||||
|  |      */ | ||||||
|  |     public function getCoordinate( $value ) | ||||||
|  |     { | ||||||
|  |         // Force typecast, because ( false < -100 ) results in (bool) true
 | ||||||
|  |         $intValue = ( $value === false ? false : self::ensureTimestamp( $value ) ); | ||||||
|  | 
 | ||||||
|  |         if ( ( $value === false ) && | ||||||
|  |              ( ( $intValue < $this->startDate ) || ( $intValue > $this->endDate ) ) ) | ||||||
|  |         { | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return 0.; | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1.; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return ( $intValue - $this->startDate ) / ( $this->endDate - $this->startDate ); | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1 - ( $intValue - $this->startDate ) / ( $this->endDate - $this->startDate ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of minor steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of minor steps | ||||||
|  |      */ | ||||||
|  |     public function getMinorStepCount() | ||||||
|  |     { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of major steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of major steps | ||||||
|  |      */ | ||||||
|  |     public function getMajorStepCount() | ||||||
|  |     { | ||||||
|  |         return (int) ceil( ( $this->properties['endDate'] - $this->startDate ) / $this->interval ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get label for a dedicated step on the axis | ||||||
|  |      *  | ||||||
|  |      * @param integer $step Number of step | ||||||
|  |      * @return string label | ||||||
|  |      */ | ||||||
|  |     public function getLabel( $step ) | ||||||
|  |     { | ||||||
|  |         return $this->getLabelFromTimestamp( $this->startDate + ( $step * $this->interval ), $step ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get label for timestamp | ||||||
|  |      *  | ||||||
|  |      * @param int $time | ||||||
|  |      * @param int $step | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     protected function getLabelFromTimestamp( $time, $step ) | ||||||
|  |     { | ||||||
|  |         if ( $this->properties['labelCallback'] !== null ) | ||||||
|  |         { | ||||||
|  |             return call_user_func_array( | ||||||
|  |                 $this->properties['labelCallback'], | ||||||
|  |                 array( | ||||||
|  |                     date( $this->properties['dateFormat'], $time ), | ||||||
|  |                     $step, | ||||||
|  |                 ) | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return date( $this->properties['dateFormat'], $time ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return array of steps on this axis | ||||||
|  |      *  | ||||||
|  |      * @return array( ezcGraphAxisStep ) | ||||||
|  |      */ | ||||||
|  |     public function getSteps() | ||||||
|  |     { | ||||||
|  |         $steps = array(); | ||||||
|  | 
 | ||||||
|  |         $start = $this->properties['startDate']; | ||||||
|  |         $end = $this->properties['endDate']; | ||||||
|  |         $distance = $end - $start; | ||||||
|  | 
 | ||||||
|  |         $step = 0; | ||||||
|  |         for ( $time = $start; $time <= $end; ) | ||||||
|  |         { | ||||||
|  |             $steps[] = new ezcGraphAxisStep( | ||||||
|  |                 ( $time - $start ) / $distance, | ||||||
|  |                 $this->interval / $distance, | ||||||
|  |                 $this->getLabelFromTimestamp( $time, $step++ ), | ||||||
|  |                 array(), | ||||||
|  |                 $step === 1, | ||||||
|  |                 $time >= $end | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |             switch ( $this->interval ) | ||||||
|  |             { | ||||||
|  |                 case self::MONTH: | ||||||
|  |                     $time = strtotime( '+1 month', $time ); | ||||||
|  |                     break; | ||||||
|  |                 case self::YEAR: | ||||||
|  |                     $time = strtotime( '+1 year', $time ); | ||||||
|  |                     break; | ||||||
|  |                 case self::DECADE: | ||||||
|  |                     $time = strtotime( '+10 years', $time ); | ||||||
|  |                     break; | ||||||
|  |                 default: | ||||||
|  |                     $time += $this->interval; | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $steps; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Is zero step | ||||||
|  |      * | ||||||
|  |      * Returns true if the given step is the one on the initial axis position | ||||||
|  |      *  | ||||||
|  |      * @param int $step Number of step | ||||||
|  |      * @return bool Status If given step is initial axis position | ||||||
|  |      */ | ||||||
|  |     public function isZeroStep( $step ) | ||||||
|  |     { | ||||||
|  |         return ( $step == 0 ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										520
									
								
								src/TUnit/external/ezc/Graph/axis/labeled.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										520
									
								
								src/TUnit/external/ezc/Graph/axis/labeled.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,520 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphChartElementLabeledAxis class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent a labeled axis. | ||||||
|  |  * | ||||||
|  |  * Axis elements represent the axis in a bar, line or radar chart. They are | ||||||
|  |  * chart elements (ezcGraphChartElement) extending from | ||||||
|  |  * ezcGraphChartElementAxis, where additional formatting options can be found. | ||||||
|  |  * You should generally use the axis, which matches your input data best, so | ||||||
|  |  * that the automatic chart layouting works best. Aavailable axis types are: | ||||||
|  |  * | ||||||
|  |  * - ezcGraphChartElementDateAxis | ||||||
|  |  * - ezcGraphChartElementLabeledAxis | ||||||
|  |  * - ezcGraphChartElementLogarithmicalAxis | ||||||
|  |  * - ezcGraphChartElementNumericAxis | ||||||
|  |  * | ||||||
|  |  * The labeled axis will accept any values and converts them to strings. The | ||||||
|  |  * labeled axis does not know about any special meanings of values and | ||||||
|  |  * maintains the order of the given labels with equidistant spaces between all | ||||||
|  |  * values. If your data has a special meaning, like a set of numbers or dates, | ||||||
|  |  * use one of the other more appropriate axis. | ||||||
|  |  * | ||||||
|  |  * Because it is not always possible to fit all labels in a chart you may | ||||||
|  |  * define the count of labels drawn using the $labelCount option. For all other | ||||||
|  |  * labels only a small step will be rendered. | ||||||
|  |  * | ||||||
|  |  * The labeled axis may be used like: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphLineChart(); | ||||||
|  |  *  $graph->options->fillLines = 210; | ||||||
|  |  *  $graph->options->font->maxFontSize = 10; | ||||||
|  |  *  $graph->title = 'Error level colors'; | ||||||
|  |  *  $graph->legend = false; | ||||||
|  |  *   | ||||||
|  |  *  $graph->yAxis = new ezcGraphChartElementLabeledAxis(); | ||||||
|  |  *  $graph->yAxis->axisLabelRenderer->showZeroValue = true; | ||||||
|  |  *   | ||||||
|  |  *  $graph->yAxis->label = 'Color'; | ||||||
|  |  *  $graph->xAxis->label = 'Error level'; | ||||||
|  |  *   | ||||||
|  |  *  // Add data
 | ||||||
|  |  *  $graph->data['colors'] = new ezcGraphArrayDataSet( | ||||||
|  |  *      array( | ||||||
|  |  *          'info' => 'blue', | ||||||
|  |  *          'notice' => 'green', | ||||||
|  |  *          'warning' => 'orange', | ||||||
|  |  *          'error' => 'red', | ||||||
|  |  *          'fatal' => 'red', | ||||||
|  |  *      ) | ||||||
|  |  *  ); | ||||||
|  |  *   | ||||||
|  |  *  $graph->render( 400, 150, 'tutorial_axis_labeled.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property float $labelCount | ||||||
|  |  *           Define count of displayed labels on the axis | ||||||
|  |  *  | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Array with labeles for data  | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $labels = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Labels indexed by their name as key for faster lookups | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $labelsIndexed = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Reduced amount of labels which will be displayed in the chart | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $displayedLabels = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Maximum count of labels which can be displayed on one axis | ||||||
|  |      * @todo Perhaps base this on the chart size | ||||||
|  |      */ | ||||||
|  |     const MAX_LABEL_COUNT = 10; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Precalculated steps on the axis | ||||||
|  |      *  | ||||||
|  |      * @var array(ezcGraphAxisStep) | ||||||
|  |      */ | ||||||
|  |     protected $steps; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['labelCount'] = null; | ||||||
|  | 
 | ||||||
|  |         $this->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'labelCount': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['labelCount'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Increase the keys of all elements in the array up from the start key, to | ||||||
|  |      * insert an additional element at the correct position. | ||||||
|  |      *  | ||||||
|  |      * @param array $array Array | ||||||
|  |      * @param int $startKey Key to increase keys from | ||||||
|  |      * @return array Updated array | ||||||
|  |      */ | ||||||
|  |     protected function increaseKeys( array $array, $startKey ) | ||||||
|  |     { | ||||||
|  |         foreach ( $array as $key => $value ) | ||||||
|  |         { | ||||||
|  |             if ( $key === $startKey ) | ||||||
|  |             { | ||||||
|  |                 // Recursive check, if next key should be increased, too
 | ||||||
|  |                 if ( isset ( $array[$key + 1] ) ) | ||||||
|  |                 { | ||||||
|  |                     $array = $this->increaseKeys( $array, $key + 1 ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 // Increase key
 | ||||||
|  |                 $array[$key + 1] = $array[$key]; | ||||||
|  |                 unset( $array[$key] ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $array; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Provide initial set of labels | ||||||
|  |      * | ||||||
|  |      * This method may be used to provide an ordered set of labels, containing | ||||||
|  |      * labels, which are not available in the datasets or to provide a label | ||||||
|  |      * order different to the one in the given dataset. | ||||||
|  |      *  | ||||||
|  |      * @param array $labels  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function provideLabels( array $labels ) | ||||||
|  |     { | ||||||
|  |         $this->addData( $labels ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Add data for this axis | ||||||
|  |      *  | ||||||
|  |      * @param array $values Value which will be displayed on this axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function addData( array $values ) | ||||||
|  |     { | ||||||
|  |         $position = 0; | ||||||
|  |         foreach ( $values as $label ) | ||||||
|  |         { | ||||||
|  |             $label = (string) $label; | ||||||
|  | 
 | ||||||
|  |             if ( !in_array( $label, $this->labels, true ) ) | ||||||
|  |             { | ||||||
|  |                 if ( isset( $this->labels[$position] ) ) | ||||||
|  |                 { | ||||||
|  |                     $this->labels = $this->increaseKeys( $this->labels, $position ); | ||||||
|  |                     $this->labels[$position++] = $label; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $this->labels[$position++] = $label; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else  | ||||||
|  |             { | ||||||
|  |                 $position = array_search( $label, $this->labels, true ) + 1; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         ksort( $this->labels ); | ||||||
|  |         $this->labelsIndexed = array_flip( $this->labels ); | ||||||
|  | 
 | ||||||
|  |         $this->properties['initialized'] = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate axis bounding values on base of the assigned values  | ||||||
|  |      *  | ||||||
|  |      * @abstract | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function calculateAxisBoundings() | ||||||
|  |     { | ||||||
|  |         $this->steps = array(); | ||||||
|  | 
 | ||||||
|  |         // Apply label format callback function
 | ||||||
|  |         if ( $this->properties['labelCallback'] !==  null ) | ||||||
|  |         { | ||||||
|  |             foreach ( $this->labels as $nr => $label ) | ||||||
|  |             { | ||||||
|  |                 $this->labels[$nr] = call_user_func_array( | ||||||
|  |                     $this->properties['labelCallback'], | ||||||
|  |                     array( | ||||||
|  |                         $label, | ||||||
|  |                         $nr | ||||||
|  |                     ) | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $labelCount = count( $this->labels ) - 1; | ||||||
|  | 
 | ||||||
|  |         if ( $labelCount === 0 ) | ||||||
|  |         { | ||||||
|  |             // Create single only step
 | ||||||
|  |             $this->steps = array( | ||||||
|  |                 new ezcGraphAxisStep( | ||||||
|  |                     0, | ||||||
|  |                     1, | ||||||
|  |                     reset( $this->labels ), | ||||||
|  |                     array(), | ||||||
|  |                     true, | ||||||
|  |                     true | ||||||
|  |                 ), | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['labelCount'] === null ) | ||||||
|  |         { | ||||||
|  |             if ( $labelCount <= self::MAX_LABEL_COUNT ) | ||||||
|  |             { | ||||||
|  |                 $stepSize = 1 / $labelCount; | ||||||
|  | 
 | ||||||
|  |                 foreach ( $this->labels as $nr => $label ) | ||||||
|  |                 { | ||||||
|  |                     $this->steps[] = new ezcGraphAxisStep( | ||||||
|  |                         $stepSize * $nr, | ||||||
|  |                         $stepSize, | ||||||
|  |                         $label, | ||||||
|  |                         array(), | ||||||
|  |                         $nr === 0, | ||||||
|  |                         $nr === $labelCount | ||||||
|  |                     ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 // @TODO: This line is deprecated and only build for 
 | ||||||
|  |                 // deprecated getLabel()
 | ||||||
|  |                 $this->displayedLabels = $this->labels; | ||||||
|  | 
 | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             for ( $div = self::MAX_LABEL_COUNT; $div > 1; --$div ) | ||||||
|  |             { | ||||||
|  |                 if ( ( $labelCount % $div ) === 0 ) | ||||||
|  |                 { | ||||||
|  |                     // @TODO: This part is deprecated and only build for 
 | ||||||
|  |                     // deprecated getLabel()
 | ||||||
|  |                     $step = $labelCount / $div; | ||||||
|  | 
 | ||||||
|  |                     foreach ( $this->labels as $nr => $label ) | ||||||
|  |                     { | ||||||
|  |                         if ( ( $nr % $step ) === 0 ) | ||||||
|  |                         { | ||||||
|  |                             $this->displayedLabels[] = $label; | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     // End of deprecated part
 | ||||||
|  | 
 | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $div = false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Build up step array
 | ||||||
|  |         if ( $div > 2 ) | ||||||
|  |         { | ||||||
|  |             $step = $labelCount / $div; | ||||||
|  |             $stepSize = 1 / $div; | ||||||
|  |             $minorStepSize = $stepSize / $step; | ||||||
|  | 
 | ||||||
|  |             foreach ( $this->labels as $nr => $label ) | ||||||
|  |             { | ||||||
|  |                 if ( ( $nr % $step ) === 0 ) | ||||||
|  |                 { | ||||||
|  |                     $mainstep = new ezcGraphAxisStep( | ||||||
|  |                         $stepSize * ( $nr / $step ), | ||||||
|  |                         $stepSize, | ||||||
|  |                         $label, | ||||||
|  |                         array(), | ||||||
|  |                         $nr === 0, | ||||||
|  |                         $nr === $labelCount | ||||||
|  |                     ); | ||||||
|  | 
 | ||||||
|  |                     $this->steps[] = $mainstep; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $mainstep->childs[] = new ezcGraphAxisStep( | ||||||
|  |                         $mainstep->position + $minorStepSize * ( $nr % $step ), | ||||||
|  |                         $minorStepSize | ||||||
|  |                     ); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             if ( $this->properties['labelCount'] === null ) | ||||||
|  |             { | ||||||
|  |                 $floatStep = $labelCount / ( self::MAX_LABEL_COUNT - 1 ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $floatStep = $labelCount / min( $labelCount, $this->properties['labelCount'] - 1 ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $position = 0; | ||||||
|  |             $minorStepSize = 1 / $labelCount; | ||||||
|  |              | ||||||
|  |             foreach ( $this->labels as $nr => $label ) | ||||||
|  |             { | ||||||
|  |                 if ( $nr >= $position ) | ||||||
|  |                 { | ||||||
|  |                     $position += $floatStep; | ||||||
|  | 
 | ||||||
|  |                     // Add as major step
 | ||||||
|  |                     $mainstep = new ezcGraphAxisStep( | ||||||
|  |                         $minorStepSize * $nr, | ||||||
|  |                         ceil( $position - $nr ) * $minorStepSize, | ||||||
|  |                         $label, | ||||||
|  |                         array(), | ||||||
|  |                         $nr === 0, | ||||||
|  |                         $nr === $labelCount | ||||||
|  |                     ); | ||||||
|  | 
 | ||||||
|  |                     // @TODO: This line is deprecated and only build for 
 | ||||||
|  |                     // deprecated getLabel()
 | ||||||
|  |                     $this->displayedLabels[] = $label; | ||||||
|  | 
 | ||||||
|  |                     $this->steps[] = $mainstep; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $mainstep->childs[] = new ezcGraphAxisStep( | ||||||
|  |                         $minorStepSize * $nr, | ||||||
|  |                         $minorStepSize | ||||||
|  |                     ); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return array of steps on this axis | ||||||
|  |      *  | ||||||
|  |      * @return array( ezcGraphAxisStep ) | ||||||
|  |      */ | ||||||
|  |     public function getSteps() | ||||||
|  |     { | ||||||
|  |         return $this->steps; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get coordinate for a dedicated value on the chart | ||||||
|  |      *  | ||||||
|  |      * @param string $value Value to determine position for | ||||||
|  |      * @return float Position on chart | ||||||
|  |      */ | ||||||
|  |     public function getCoordinate( $value ) | ||||||
|  |     { | ||||||
|  |         if ( ( $value === false ) ||  | ||||||
|  |              ( $value === null ) || | ||||||
|  |              ( !isset( $this->labelsIndexed[$value] ) ) ) | ||||||
|  |         { | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return 0.; | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1.; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $key = $this->labelsIndexed[$value]; | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     if ( count( $this->labels ) > 1 ) | ||||||
|  |                     { | ||||||
|  |                         return (float) $key / ( count ( $this->labels ) - 1 ); | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         return 0; | ||||||
|  |                     } | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                     if ( count( $this->labels ) > 1 ) | ||||||
|  |                     { | ||||||
|  |                         return (float) 1 - $key / ( count ( $this->labels ) - 1 ); | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         return 1; | ||||||
|  |                     } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of minor steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of minor steps | ||||||
|  |      */ | ||||||
|  |     public function getMinorStepCount() | ||||||
|  |     { | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of major steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of major steps | ||||||
|  |      */ | ||||||
|  |     public function getMajorStepCount() | ||||||
|  |     { | ||||||
|  |         return max( count( $this->displayedLabels ) - 1, 1 ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get label for a dedicated step on the axis | ||||||
|  |      *  | ||||||
|  |      * @param integer $step Number of step | ||||||
|  |      * @return string label | ||||||
|  |      */ | ||||||
|  |     public function getLabel( $step ) | ||||||
|  |     { | ||||||
|  |         if ( isset( $this->displayedLabels[$step] ) ) | ||||||
|  |         { | ||||||
|  |             return $this->displayedLabels[$step]; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Is zero step | ||||||
|  |      * | ||||||
|  |      * Returns true if the given step is the one on the initial axis position | ||||||
|  |      *  | ||||||
|  |      * @param int $step Number of step | ||||||
|  |      * @return bool Status If given step is initial axis position | ||||||
|  |      */ | ||||||
|  |     public function isZeroStep( $step ) | ||||||
|  |     { | ||||||
|  |         return !$step; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										341
									
								
								src/TUnit/external/ezc/Graph/axis/logarithmic.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										341
									
								
								src/TUnit/external/ezc/Graph/axis/logarithmic.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,341 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphChartElementLogarithmicalAxis class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent a logarithmic axis. | ||||||
|  |  * | ||||||
|  |  * Axis elements represent the axis in a bar, line or radar chart. They are | ||||||
|  |  * chart elements (ezcGraphChartElement) extending from | ||||||
|  |  * ezcGraphChartElementAxis, where additional formatting options can be found. | ||||||
|  |  * You should generally use the axis, which matches your input data best, so | ||||||
|  |  * that the automatic chart layouting works best. Aavailable axis types are: | ||||||
|  |  * | ||||||
|  |  * - ezcGraphChartElementDateAxis | ||||||
|  |  * - ezcGraphChartElementLabeledAxis | ||||||
|  |  * - ezcGraphChartElementLogarithmicalAxis | ||||||
|  |  * - ezcGraphChartElementNumericAxis | ||||||
|  |  * | ||||||
|  |  * Logarithmic axis are normally used to display very large or small values. | ||||||
|  |  * Logarithmic axis can not be used for value spans including zero, so you | ||||||
|  |  * should either pass only positive or only negative values to the chart. | ||||||
|  |  * | ||||||
|  |  * By default the axis uses a base of 10 for scaling, you may assign any other | ||||||
|  |  * base to the $base property of the chart. With a base of 10 the steps on the | ||||||
|  |  * axis may, for example, be at: 1, 10, 100, 1000, 10000, ... | ||||||
|  |  * | ||||||
|  |  * The logarithmic axis may be used like: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphLineChart(); | ||||||
|  |  *  $graph->title = 'The power of x'; | ||||||
|  |  *  $graph->legend->position = ezcGraph::BOTTOM; | ||||||
|  |  *   | ||||||
|  |  *  $graph->xAxis = new ezcGraphChartElementNumericAxis(); | ||||||
|  |  *  $graph->yAxis = new ezcGraphChartElementLogarithmicalAxis(); | ||||||
|  |  *   | ||||||
|  |  *  $graph->data['x^2'] = new ezcGraphNumericDataSet(  | ||||||
|  |  *      -10, 10, | ||||||
|  |  *      create_function( '$x', 'return pow( $x, 2 ) + 1;' ) | ||||||
|  |  *  ); | ||||||
|  |  *   | ||||||
|  |  *  $graph->data['x^4'] = new ezcGraphNumericDataSet(  | ||||||
|  |  *      -10, 10, | ||||||
|  |  *      create_function( '$x', 'return pow( $x, 4 ) + 1;' ) | ||||||
|  |  *  ); | ||||||
|  |  *   | ||||||
|  |  *  $graph->data['x^6'] = new ezcGraphNumericDataSet(  | ||||||
|  |  *      -10, 10, | ||||||
|  |  *      create_function( '$x', 'return pow( $x, 6 ) + 1;' ) | ||||||
|  |  *  ); | ||||||
|  |  *   | ||||||
|  |  *  $graph->render( 400, 250, 'tutorial_axis_logarithmic.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property float $base | ||||||
|  |  *           Base for logarithmical scaling. | ||||||
|  |  * @property string $logarithmicalFormatString | ||||||
|  |  *           Sprintf formatstring for the axis labels where | ||||||
|  |  *              $1 is the base and | ||||||
|  |  *              $2 is the exponent. | ||||||
|  |  * @property-read float $minValue | ||||||
|  |  *                Minimum Value to display on this axis. | ||||||
|  |  * @property-read float $maxValue | ||||||
|  |  *                Maximum value to display on this axis. | ||||||
|  |  *            | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementLogarithmicalAxis extends ezcGraphChartElementAxis | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constant used for calculation of automatic definition of major scaling  | ||||||
|  |      * steps | ||||||
|  |      */ | ||||||
|  |     const MAX_STEPS = 9; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['min'] = null; | ||||||
|  |         $this->properties['max'] = null; | ||||||
|  |         $this->properties['base'] = 10; | ||||||
|  |         $this->properties['logarithmicalFormatString'] = '%1$d^%2$d'; | ||||||
|  |         $this->properties['minValue'] = null; | ||||||
|  |         $this->properties['maxValue'] = null; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'min': | ||||||
|  |             case 'max': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties[$propertyName] = (float) $propertyValue; | ||||||
|  |                 $this->properties['initialized'] = true; | ||||||
|  |                 break; | ||||||
|  |             case 'base': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties[$propertyName] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'logarithmicalFormatString': | ||||||
|  |                 $this->properties['logarithmicalFormatString'] = (string) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Add data for this axis | ||||||
|  |      *  | ||||||
|  |      * @param array $values Value which will be displayed on this axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function addData( array $values ) | ||||||
|  |     { | ||||||
|  |         foreach ( $values as $value ) | ||||||
|  |         { | ||||||
|  |             if ( $this->properties['minValue'] === null || | ||||||
|  |                  $value < $this->properties['minValue'] ) | ||||||
|  |             { | ||||||
|  |                 $this->properties['minValue'] = $value; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $this->properties['maxValue'] === null || | ||||||
|  |                  $value > $this->properties['maxValue'] ) | ||||||
|  |             { | ||||||
|  |                 $this->properties['maxValue'] = $value; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->properties['initialized'] = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate axis bounding values on base of the assigned values  | ||||||
|  |      *  | ||||||
|  |      * @abstract | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function calculateAxisBoundings() | ||||||
|  |     { | ||||||
|  |         // Prevent division by zero, when min == max
 | ||||||
|  |         if ( $this->properties['minValue'] == $this->properties['maxValue'] ) | ||||||
|  |         { | ||||||
|  |             if ( $this->properties['minValue'] == 0 ) | ||||||
|  |             { | ||||||
|  |                 $this->properties['maxValue'] = 1; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $this->properties['minValue'] -= ( $this->properties['minValue'] * .1 ); | ||||||
|  |                 $this->properties['maxValue'] += ( $this->properties['maxValue'] * .1 ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['minValue'] <= 0 ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphOutOfLogithmicalBoundingsException( $this->properties['minValue'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Use custom minimum and maximum if available
 | ||||||
|  |         if ( $this->properties['min'] !== null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['minValue'] = pow( $this->properties['base'], $this->properties['min'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['max'] !== null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['maxValue'] = pow( $this->properties['base'], $this->properties['max'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Calculate "nice" values for scaling parameters
 | ||||||
|  |         if ( $this->properties['min'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['min'] = floor( log( $this->properties['minValue'], $this->properties['base'] ) ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['max'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['max'] = ceil( log( $this->properties['maxValue'], $this->properties['base'] ) ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->properties['minorStep'] = 1; | ||||||
|  |         if ( ( $modifier = ( ( $this->properties['max'] - $this->properties['min'] ) / self::MAX_STEPS ) ) > 1 ) | ||||||
|  |         { | ||||||
|  |             $this->properties['majorStep'] = $modifier = ceil( $modifier ); | ||||||
|  |             $this->properties['min'] = floor( $this->properties['min'] / $modifier ) * $modifier; | ||||||
|  |             $this->properties['max'] = floor( $this->properties['max'] / $modifier ) * $modifier; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $this->properties['majorStep'] = 1; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get coordinate for a dedicated value on the chart | ||||||
|  |      *  | ||||||
|  |      * @param float $value Value to determine position for | ||||||
|  |      * @return float Position on chart | ||||||
|  |      */ | ||||||
|  |     public function getCoordinate( $value ) | ||||||
|  |     { | ||||||
|  |         // Force typecast, because ( false < -100 ) results in (bool) true
 | ||||||
|  |         $floatValue = (float) $value; | ||||||
|  | 
 | ||||||
|  |         if ( $value === false ) | ||||||
|  |         { | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return 0.; | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1.; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $position = ( log( $value, $this->properties['base'] ) - $this->properties['min'] ) / ( $this->properties['max'] - $this->properties['min'] ); | ||||||
|  | 
 | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return $position; | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1 - $position; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of minor steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of minor steps | ||||||
|  |      */ | ||||||
|  |     public function getMinorStepCount() | ||||||
|  |     { | ||||||
|  |         return (int) ( ( $this->properties['max'] - $this->properties['min'] ) / $this->properties['minorStep'] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of major steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of major steps | ||||||
|  |      */ | ||||||
|  |     public function getMajorStepCount() | ||||||
|  |     { | ||||||
|  |         return (int) ( ( $this->properties['max'] - $this->properties['min'] ) / $this->properties['majorStep'] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get label for a dedicated step on the axis | ||||||
|  |      *  | ||||||
|  |      * @param integer $step Number of step | ||||||
|  |      * @return string label | ||||||
|  |      */ | ||||||
|  |     public function getLabel( $step ) | ||||||
|  |     { | ||||||
|  |         if ( $this->properties['labelCallback'] !== null ) | ||||||
|  |         { | ||||||
|  |             return call_user_func_array( | ||||||
|  |                 $this->properties['labelCallback'], | ||||||
|  |                 array( | ||||||
|  |                     sprintf(  | ||||||
|  |                         $this->properties['logarithmicalFormatString'], | ||||||
|  |                         $this->properties['base'], | ||||||
|  |                         $this->properties['min'] + ( $step * $this->properties['majorStep'] ) | ||||||
|  |                     ), | ||||||
|  |                     $step, | ||||||
|  |                 ) | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return sprintf(  | ||||||
|  |                 $this->properties['logarithmicalFormatString'], | ||||||
|  |                 $this->properties['base'], | ||||||
|  |                 $this->properties['min'] + ( $step * $this->properties['majorStep'] ) | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Is zero step | ||||||
|  |      * | ||||||
|  |      * Returns true if the given step is the one on the initial axis position | ||||||
|  |      *  | ||||||
|  |      * @param int $step Number of step | ||||||
|  |      * @return bool Status If given step is initial axis position | ||||||
|  |      */ | ||||||
|  |     public function isZeroStep( $step ) | ||||||
|  |     { | ||||||
|  |         return ( $step == 0 ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										501
									
								
								src/TUnit/external/ezc/Graph/axis/numeric.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										501
									
								
								src/TUnit/external/ezc/Graph/axis/numeric.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,501 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphChartElementNumericAxis class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent a numeric axis. | ||||||
|  |  * | ||||||
|  |  * Axis elements represent the axis in a bar, line or radar chart. They are | ||||||
|  |  * chart elements (ezcGraphChartElement) extending from | ||||||
|  |  * ezcGraphChartElementAxis, where additional formatting options can be found. | ||||||
|  |  * You should generally use the axis, which matches your input data best, so | ||||||
|  |  * that the automatic chart layouting works best. Aavailable axis types are: | ||||||
|  |  * | ||||||
|  |  * - ezcGraphChartElementDateAxis | ||||||
|  |  * - ezcGraphChartElementLabeledAxis | ||||||
|  |  * - ezcGraphChartElementLogarithmicalAxis | ||||||
|  |  * - ezcGraphChartElementNumericAxis | ||||||
|  |  * | ||||||
|  |  * The axis tries to calculate "nice" start and end values for the axis scale. | ||||||
|  |  * The used interval is considered as nice, if it is equal to [1,2,5] * 10^x | ||||||
|  |  * with x in [.., -1, 0, 1, ..]. | ||||||
|  |  * | ||||||
|  |  * The start and end value are the next bigger / smaller multiple of the  | ||||||
|  |  * intervall compared to the maximum / minimum axis value. | ||||||
|  |  * | ||||||
|  |  * You may specify custom step sizes using the properties $majorStep and | ||||||
|  |  * $minorStep. The minimum and maximum values for the axis labels can be | ||||||
|  |  * defined using the $min and $max properties. You should be able to set any | ||||||
|  |  * subset of these values, and all values not explicitely set will be | ||||||
|  |  * calculated automatically. | ||||||
|  |  * | ||||||
|  |  * This axis should be used for all numeric values except dates. If your data | ||||||
|  |  * does span very big number intervals you might want to consider using the | ||||||
|  |  * logrithmic axis instead. | ||||||
|  |  * | ||||||
|  |  * The numeric axis may be used like: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphLineChart(); | ||||||
|  |  *  $graph->title = 'Some random data'; | ||||||
|  |  *  $graph->legend = false; | ||||||
|  |  *   | ||||||
|  |  *  $graph->xAxis = new ezcGraphChartElementNumericAxis(); | ||||||
|  |  *  // The y axis is numeric by default.
 | ||||||
|  |  *   | ||||||
|  |  *  $graph->xAxis->min = -15; | ||||||
|  |  *  $graph->xAxis->max = 15; | ||||||
|  |  *  $graph->xAxis->majorStep = 5; | ||||||
|  |  *   | ||||||
|  |  *  $data = array( | ||||||
|  |  *      array(), | ||||||
|  |  *      array() | ||||||
|  |  *  ); | ||||||
|  |  *  for ( $i = -10; $i <= 10; $i++ ) | ||||||
|  |  *  { | ||||||
|  |  *      $data[0][$i] = mt_rand( -23, 59 ); | ||||||
|  |  *      $data[1][$i] = mt_rand( -23, 59 ); | ||||||
|  |  *  } | ||||||
|  |  *   | ||||||
|  |  *  // Add data
 | ||||||
|  |  *  $graph->data['random blue'] = new ezcGraphArrayDataSet( $data[0] ); | ||||||
|  |  *  $graph->data['random green'] = new ezcGraphArrayDataSet( $data[1] ); | ||||||
|  |  *   | ||||||
|  |  *  $graph->render( 400, 150, 'tutorial_axis_numeric.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property float $min | ||||||
|  |  *           Minimum value of displayed scale on axis. | ||||||
|  |  * @property float $max | ||||||
|  |  *           Maximum value of displayed scale on axis. | ||||||
|  |  * @property mixed $majorStep | ||||||
|  |  *           Labeled major steps displayed on the axis. | ||||||
|  |  * @property mixed $minorStep | ||||||
|  |  *           Non labeled minor steps on the axis. | ||||||
|  |  * @property-read float $minValue | ||||||
|  |  *                Minimum Value to display on this axis. | ||||||
|  |  * @property-read float $maxValue | ||||||
|  |  *                Maximum value to display on this axis. | ||||||
|  |  *            | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constant used for calculation of automatic definition of major scaling  | ||||||
|  |      * steps | ||||||
|  |      */ | ||||||
|  |     const MIN_MAJOR_COUNT = 5; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constant used for automatic calculation of minor steps from given major  | ||||||
|  |      * steps  | ||||||
|  |      */ | ||||||
|  |     const MIN_MINOR_COUNT = 8; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['min'] = null; | ||||||
|  |         $this->properties['max'] = null; | ||||||
|  |         $this->properties['minValue'] = null; | ||||||
|  |         $this->properties['maxValue'] = null; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'min': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['min'] = (float) $propertyValue; | ||||||
|  |                 $this->properties['initialized'] = true; | ||||||
|  |                 break; | ||||||
|  |             case 'max': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['max'] = (float) $propertyValue; | ||||||
|  |                 $this->properties['initialized'] = true; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a "nice" number for a given floating point number. | ||||||
|  |      * | ||||||
|  |      * Nice numbers are steps on a scale which are easily recognized by humans | ||||||
|  |      * like 0.5, 25, 1000 etc. | ||||||
|  |      *  | ||||||
|  |      * @param float $float Number to be altered | ||||||
|  |      * @return float Nice number | ||||||
|  |      */ | ||||||
|  |     protected function getNiceNumber( $float ) | ||||||
|  |     { | ||||||
|  |         // Get absolute value and save sign
 | ||||||
|  |         $abs = abs( $float ); | ||||||
|  |         $sign = $float / $abs; | ||||||
|  | 
 | ||||||
|  |         // Normalize number to a range between 1 and 10
 | ||||||
|  |         $log = (int) round( log10( $abs ), 0 ); | ||||||
|  |         $abs /= pow( 10, $log ); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         // find next nice number
 | ||||||
|  |         if ( $abs > 5 ) | ||||||
|  |         { | ||||||
|  |             $abs = 10.; | ||||||
|  |         } | ||||||
|  |         elseif ( $abs > 2.5 ) | ||||||
|  |         { | ||||||
|  |             $abs = 5.; | ||||||
|  |         } | ||||||
|  |         elseif ( $abs > 1 ) | ||||||
|  |         { | ||||||
|  |             $abs = 2.5; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $abs = 1; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // unnormalize number to original values
 | ||||||
|  |         return $abs * pow( 10, $log ) * $sign; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate minimum value for displayed axe basing on real minimum and | ||||||
|  |      * major step size | ||||||
|  |      *  | ||||||
|  |      * @param float $min Real data minimum  | ||||||
|  |      * @param float $max Real data maximum | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function calculateMinimum( $min, $max ) | ||||||
|  |     { | ||||||
|  |         if ( $this->properties['max'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['min'] = floor( $min / $this->properties['majorStep'] ) * $this->properties['majorStep']; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $calculatedMin = $this->properties['max']; | ||||||
|  |              | ||||||
|  |             do { | ||||||
|  |                 $calculatedMin -= $this->properties['majorStep']; | ||||||
|  |             } while ( $calculatedMin > $min ); | ||||||
|  | 
 | ||||||
|  |             $this->properties['min'] = $calculatedMin; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate maximum value for displayed axe basing on real maximum and | ||||||
|  |      * major step size | ||||||
|  |      *  | ||||||
|  |      * @param float $min Real data minimum  | ||||||
|  |      * @param float $max Real data maximum | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function calculateMaximum( $min, $max ) | ||||||
|  |     { | ||||||
|  |         $calculatedMax = $this->properties['min']; | ||||||
|  |          | ||||||
|  |         do { | ||||||
|  |             $calculatedMax += $this->properties['majorStep']; | ||||||
|  |         } while ( $calculatedMax < $max ); | ||||||
|  | 
 | ||||||
|  |         $this->properties['max'] = $calculatedMax; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate size of minor steps based on the size of the major step size | ||||||
|  |      * | ||||||
|  |      * @param float $min Real data minimum  | ||||||
|  |      * @param float $max Real data maximum | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function calculateMinorStep( $min, $max ) | ||||||
|  |     { | ||||||
|  |         $stepSize = $this->properties['majorStep'] / self::MIN_MINOR_COUNT; | ||||||
|  |         $this->properties['minorStep'] = $this->getNiceNumber( $stepSize ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate size of major step based on the span to be displayed and the | ||||||
|  |      * defined MIN_MAJOR_COUNT constant. | ||||||
|  |      * | ||||||
|  |      * @param float $min Real data minimum  | ||||||
|  |      * @param float $max Real data maximum | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function calculateMajorStep( $min, $max ) | ||||||
|  |     { | ||||||
|  |         $span = $max - $min; | ||||||
|  |         $stepSize = $span / self::MIN_MAJOR_COUNT; | ||||||
|  |         $this->properties['majorStep'] = $this->getNiceNumber( $stepSize ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Add data for this axis | ||||||
|  |      *  | ||||||
|  |      * @param array $values Value which will be displayed on this axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function addData( array $values ) | ||||||
|  |     { | ||||||
|  |         foreach ( $values as $value ) | ||||||
|  |         { | ||||||
|  |             if ( $this->properties['minValue'] === null || | ||||||
|  |                  $value < $this->properties['minValue'] ) | ||||||
|  |             { | ||||||
|  |                 $this->properties['minValue'] = $value; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $this->properties['maxValue'] === null || | ||||||
|  |                  $value > $this->properties['maxValue'] ) | ||||||
|  |             { | ||||||
|  |                 $this->properties['maxValue'] = $value; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->properties['initialized'] = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate axis bounding values on base of the assigned values  | ||||||
|  |      *  | ||||||
|  |      * @abstract | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function calculateAxisBoundings() | ||||||
|  |     { | ||||||
|  |         // Prevent division by zero, when min == max
 | ||||||
|  |         if ( $this->properties['minValue'] == $this->properties['maxValue'] ) | ||||||
|  |         { | ||||||
|  |             if ( $this->properties['minValue'] == 0 ) | ||||||
|  |             { | ||||||
|  |                 $this->properties['maxValue'] = 1; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 if ( $this->properties['majorStep'] !== null ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['minValue'] -= $this->properties['majorStep']; | ||||||
|  |                     $this->properties['maxValue'] += $this->properties['majorStep']; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $this->properties['minValue'] -= ( $this->properties['minValue'] * .1 ); | ||||||
|  |                     $this->properties['maxValue'] += ( $this->properties['maxValue'] * .1 ); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Use custom minimum and maximum if available
 | ||||||
|  |         if ( $this->properties['min'] !== null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['minValue'] = $this->properties['min']; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['max'] !== null ) | ||||||
|  |         { | ||||||
|  |             $this->properties['maxValue'] = $this->properties['max']; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // If min and max values are forced, we may not be able to find a
 | ||||||
|  |         // "nice" number for the steps. Try to find such a nice step size, or
 | ||||||
|  |         // fall back to a step size, which is just the span divided by 5.
 | ||||||
|  |         if ( ( $this->properties['min'] !== null ) && | ||||||
|  |              ( $this->properties['max'] !== null ) && | ||||||
|  |              ( $this->properties['majorStep'] === null ) ) | ||||||
|  |         { | ||||||
|  |             $diff = $this->properties['max'] - $this->properties['min']; | ||||||
|  |             $this->calculateMajorStep( $this->properties['minValue'], $this->properties['maxValue'] ); | ||||||
|  |             $stepInvariance = $diff / $this->properties['majorStep']; | ||||||
|  |             if ( ( $stepInvariance - floor( $stepInvariance ) ) > .0000001 ) | ||||||
|  |             { | ||||||
|  |                 // For too big step invariances calculate the step size just
 | ||||||
|  |                 // from the given difference between min and max value.
 | ||||||
|  |                 $this->properties['majorStep'] = ( $this->properties['max'] - $this->properties['min'] ) / self::MIN_MAJOR_COUNT; | ||||||
|  |                 $this->properties['minorStep'] = $this->properties['majorStep'] / self::MIN_MAJOR_COUNT; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Calculate "nice" values for scaling parameters
 | ||||||
|  |         if ( $this->properties['majorStep'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->calculateMajorStep( $this->properties['minValue'], $this->properties['maxValue'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['minorStep'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->calculateMinorStep( $this->properties['minValue'], $this->properties['maxValue'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['min'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->calculateMinimum( $this->properties['minValue'], $this->properties['maxValue'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->properties['max'] === null ) | ||||||
|  |         { | ||||||
|  |             $this->calculateMaximum( $this->properties['minValue'], $this->properties['maxValue'] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Check that the major step size matches up with the min and max
 | ||||||
|  |         // values on the axis.
 | ||||||
|  |         $quotient = ( $this->properties['max'] - $this->properties['min'] ) / $this->properties['majorStep']; | ||||||
|  |         $quotient = abs( $quotient - floor( $quotient ) ); | ||||||
|  |         if ( ( $quotient >= .00001 ) && | ||||||
|  |              ( abs( $quotient - 1 ) >=  .00001 ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphInvalidStepSizeException( "The difference between minimum and maximum value is not a multiplier of the major step size." ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Check that the minor step size matches up with major step size on
 | ||||||
|  |         // the axis.
 | ||||||
|  |         $quotient = $this->properties['majorStep'] / $this->properties['minorStep']; | ||||||
|  |         $quotient = abs( $quotient - floor( $quotient ) ); | ||||||
|  |         if ( ( $quotient >= .00001 ) && | ||||||
|  |              ( abs( $quotient - 1 ) >=  .00001 ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphInvalidStepSizeException( "The major step size value is not a multiplier of the minor step size." ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get coordinate for a dedicated value on the chart | ||||||
|  |      *  | ||||||
|  |      * @param float $value Value to determine position for | ||||||
|  |      * @return float Position on chart | ||||||
|  |      */ | ||||||
|  |     public function getCoordinate( $value ) | ||||||
|  |     { | ||||||
|  |         // Force typecast, because ( false < -100 ) results in (bool) true
 | ||||||
|  |         $floatValue = (float) $value; | ||||||
|  | 
 | ||||||
|  |         if ( ( $value === false ) && | ||||||
|  |              ( ( $floatValue < $this->properties['min'] ) || ( $floatValue > $this->properties['max'] ) ) ) | ||||||
|  |         { | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return 0.; | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1.; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             switch ( $this->position ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::LEFT: | ||||||
|  |                 case ezcGraph::TOP: | ||||||
|  |                     return ( $value - $this->properties['min'] ) / ( $this->properties['max'] - $this->properties['min'] ); | ||||||
|  |                 case ezcGraph::RIGHT: | ||||||
|  |                 case ezcGraph::BOTTOM: | ||||||
|  |                     return 1 - ( $value - $this->properties['min'] ) / ( $this->properties['max'] - $this->properties['min'] ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of minor steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of minor steps | ||||||
|  |      */ | ||||||
|  |     public function getMinorStepCount() | ||||||
|  |     { | ||||||
|  |         return (int) ( ( $this->properties['max'] - $this->properties['min'] ) / $this->properties['minorStep'] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of major steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of major steps | ||||||
|  |      */ | ||||||
|  |     public function getMajorStepCount() | ||||||
|  |     { | ||||||
|  |         return (int) ( ( $this->properties['max'] - $this->properties['min'] ) / $this->properties['majorStep'] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get label for a dedicated step on the axis | ||||||
|  |      *  | ||||||
|  |      * @param integer $step Number of step | ||||||
|  |      * @return string label | ||||||
|  |      */ | ||||||
|  |     public function getLabel( $step ) | ||||||
|  |     { | ||||||
|  |         if ( $this->properties['labelCallback'] !== null ) | ||||||
|  |         { | ||||||
|  |             return call_user_func_array( | ||||||
|  |                 $this->properties['labelCallback'], | ||||||
|  |                 array( | ||||||
|  |                     $this->properties['min'] + ( $step * $this->properties['majorStep'] ), | ||||||
|  |                     $step, | ||||||
|  |                 ) | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return $this->properties['min'] + ( $step * $this->properties['majorStep'] ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Is zero step | ||||||
|  |      * | ||||||
|  |      * Returns true if the given step is the one on the initial axis position | ||||||
|  |      *  | ||||||
|  |      * @param int $step Number of step | ||||||
|  |      * @return bool Status If given step is initial axis position | ||||||
|  |      */ | ||||||
|  |     public function isZeroStep( $step ) | ||||||
|  |     { | ||||||
|  |         return ( $this->getLabel( $step ) == 0 ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										94
									
								
								src/TUnit/external/ezc/Graph/charts/bar.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								src/TUnit/external/ezc/Graph/charts/bar.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,94 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphBarChart class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for bar charts. Can make use of an unlimited amount of datasets and  | ||||||
|  |  * will display them as bars by default. | ||||||
|  |  * X axis: | ||||||
|  |  *  - Labeled axis | ||||||
|  |  *  - Boxed axis label renderer | ||||||
|  |  * Y axis: | ||||||
|  |  *  - Numeric axis | ||||||
|  |  *  - Exact axis label renderer | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  // Create a new line chart
 | ||||||
|  |  *  $chart = new ezcGraphBarChart(); | ||||||
|  |  * | ||||||
|  |  *  // Add data to line chart
 | ||||||
|  |  *  $chart->data['sample dataset'] = new ezcGraphArrayDataSet( | ||||||
|  |  *      array( | ||||||
|  |  *          '100' => 1.2, | ||||||
|  |  *          '200' => 43.2, | ||||||
|  |  *          '300' => -34.14, | ||||||
|  |  *          '350' => 65, | ||||||
|  |  *          '400' => 123, | ||||||
|  |  *      )    | ||||||
|  |  *  ); | ||||||
|  |  * | ||||||
|  |  *  // Render chart with default 2d renderer and default SVG driver
 | ||||||
|  |  *  $chart->render( 500, 200, 'bar_chart.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * Each chart consists of several chart elements which represents logical  | ||||||
|  |  * parts of the chart and can be formatted independently. The bar chart | ||||||
|  |  * consists of: | ||||||
|  |  *  - title ( {@link ezcGraphChartElementText} ) | ||||||
|  |  *  - legend ( {@link ezcGraphChartElementLegend} ) | ||||||
|  |  *  - background ( {@link ezcGraphChartElementBackground} ) | ||||||
|  |  *  - xAxis ( {@link ezcGraphChartElementLabeledAxis} ) | ||||||
|  |  *  - yAxis ( {@link ezcGraphChartElementNumericAxis} ) | ||||||
|  |  * | ||||||
|  |  * The type of the axis may be changed and all elements can be configured by | ||||||
|  |  * accessing them as properties of the chart: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->legend->position = ezcGraph::RIGHT; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * The chart itself also offers several options to configure the appearance. As | ||||||
|  |  * bar charts extend line charts the the extended configure options are | ||||||
|  |  * available in {@link ezcGraphLineChartOptions} extending the  | ||||||
|  |  * {@link ezcGraphChartOptions}. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphLineChartOptions $options | ||||||
|  |  *           Chart options class | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphBarChart extends ezcGraphLineChart | ||||||
|  | { | ||||||
|  |   | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         parent::__construct(); | ||||||
|  | 
 | ||||||
|  |         $this->elements['xAxis']->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the default display type of the current chart type. | ||||||
|  |      *  | ||||||
|  |      * @return int Display type | ||||||
|  |      */ | ||||||
|  |     public function getDefaultDisplayType() | ||||||
|  |     { | ||||||
|  |         return ezcGraph::BAR; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										715
									
								
								src/TUnit/external/ezc/Graph/charts/line.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										715
									
								
								src/TUnit/external/ezc/Graph/charts/line.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,715 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphLineChart class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for line charts. Can make use of an unlimited amount of datasets and  | ||||||
|  |  * will display them as lines by default. | ||||||
|  |  * X axis: | ||||||
|  |  *  - Labeled axis | ||||||
|  |  *  - Centered axis label renderer | ||||||
|  |  * Y axis: | ||||||
|  |  *  - Numeric axis | ||||||
|  |  *  - Exact axis label renderer | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  // Create a new line chart
 | ||||||
|  |  *  $chart = new ezcGraphLineChart(); | ||||||
|  |  * | ||||||
|  |  *  // Add data to line chart
 | ||||||
|  |  *  $chart->data['sample dataset'] = new ezcGraphArrayDataSet( | ||||||
|  |  *      array( | ||||||
|  |  *          '100' => 1.2, | ||||||
|  |  *          '200' => 43.2, | ||||||
|  |  *          '300' => -34.14, | ||||||
|  |  *          '350' => 65, | ||||||
|  |  *          '400' => 123, | ||||||
|  |  *      )    | ||||||
|  |  *  ); | ||||||
|  |  * | ||||||
|  |  *  // Render chart with default 2d renderer and default SVG driver
 | ||||||
|  |  *  $chart->render( 500, 200, 'line_chart.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * Each chart consists of several chart elements which represents logical  | ||||||
|  |  * parts of the chart and can be formatted independently. The line chart | ||||||
|  |  * consists of: | ||||||
|  |  *  - title ( {@link ezcGraphChartElementText} ) | ||||||
|  |  *  - legend ( {@link ezcGraphChartElementLegend} ) | ||||||
|  |  *  - background ( {@link ezcGraphChartElementBackground} ) | ||||||
|  |  *  - xAxis ( {@link ezcGraphChartElementLabeledAxis} ) | ||||||
|  |  *  - yAxis ( {@link ezcGraphChartElementNumericAxis} ) | ||||||
|  |  * | ||||||
|  |  * The type of the axis may be changed and all elements can be configured by | ||||||
|  |  * accessing them as properties of the chart: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->legend->position = ezcGraph::RIGHT; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * The chart itself also offers several options to configure the appearance. | ||||||
|  |  * The extended configure options are available in  | ||||||
|  |  * {@link ezcGraphLineChartOptions} extending the {@link ezcGraphChartOptions}. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphLineChartOptions $options | ||||||
|  |  *           Chart options class | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphLineChart extends ezcGraphChart | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Array with additional axis for the chart | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphAxisContainer | ||||||
|  |      */ | ||||||
|  |     protected $additionalAxis; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->additionalAxis = new ezcGraphAxisContainer( $this ); | ||||||
|  | 
 | ||||||
|  |         $this->options = new ezcGraphLineChartOptions( $options ); | ||||||
|  |         $this->options->highlightFont = $this->options->font; | ||||||
|  | 
 | ||||||
|  |         parent::__construct(); | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'xAxis', new ezcGraphChartElementLabeledAxis() ); | ||||||
|  |         $this->elements['xAxis']->position = ezcGraph::LEFT; | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'yAxis', new ezcGraphChartElementNumericAxis() ); | ||||||
|  |         $this->elements['yAxis']->position = ezcGraph::BOTTOM; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'additionalAxis': | ||||||
|  |                 return $this->additionalAxis; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return parent::__get( $propertyName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Options write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param mixed $propertyName   Option name | ||||||
|  |      * @param mixed $propertyValue  Option value; | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue )  | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) { | ||||||
|  |             case 'xAxis': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphChartElementAxis ) | ||||||
|  |                 { | ||||||
|  |                     $this->addElement( 'xAxis', $propertyValue ); | ||||||
|  |                     $this->elements['xAxis']->position = ezcGraph::LEFT; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'yAxis': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphChartElementAxis ) | ||||||
|  |                 { | ||||||
|  |                     $this->addElement( 'yAxis', $propertyValue ); | ||||||
|  |                     $this->elements['yAxis']->position = ezcGraph::BOTTOM; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set colors and border for this element | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphPalette $palette Palette | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function setFromPalette( ezcGraphPalette $palette ) | ||||||
|  |     { | ||||||
|  |         foreach ( $this->additionalAxis as $element ) | ||||||
|  |         { | ||||||
|  |             $element->setFromPalette( $palette ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         parent::setFromPalette( $palette ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the assigned data | ||||||
|  |      * | ||||||
|  |      * Will renderer all charts data in the remaining boundings after drawing  | ||||||
|  |      * all other chart elements. The data will be rendered depending on the  | ||||||
|  |      * settings in the dataset. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Remaining boundings | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderData( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphBoundings $innerBoundings ) | ||||||
|  |     { | ||||||
|  |         // Use inner boundings for drawning chart data
 | ||||||
|  |         $boundings = $innerBoundings; | ||||||
|  | 
 | ||||||
|  |         $yAxisNullPosition = $this->elements['yAxis']->getCoordinate( false ); | ||||||
|  | 
 | ||||||
|  |         // Initialize counters
 | ||||||
|  |         $nr = array(); | ||||||
|  |         $count = array(); | ||||||
|  | 
 | ||||||
|  |         foreach ( $this->data as $data ) | ||||||
|  |         { | ||||||
|  |             if ( !isset( $nr[$data->displayType->default] ) ) | ||||||
|  |             { | ||||||
|  |                 $nr[$data->displayType->default] = 0; | ||||||
|  |                 $count[$data->displayType->default] = 0; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $nr[$data->displayType->default]++; | ||||||
|  |             $count[$data->displayType->default]++; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $checkedRegularSteps = false; | ||||||
|  | 
 | ||||||
|  |         // Display data
 | ||||||
|  |         foreach ( $this->data as $datasetName => $data ) | ||||||
|  |         { | ||||||
|  |             --$nr[$data->displayType->default]; | ||||||
|  | 
 | ||||||
|  |             // Check which axis should be used
 | ||||||
|  |             $xAxis = ( $data->xAxis->default ? $data->xAxis->default: $this->elements['xAxis'] ); | ||||||
|  |             $yAxis = ( $data->yAxis->default ? $data->yAxis->default: $this->elements['yAxis'] ); | ||||||
|  | 
 | ||||||
|  |             // Determine fill color for dataset
 | ||||||
|  |             if ( $this->options->fillLines !== false ) | ||||||
|  |             { | ||||||
|  |                 $fillColor = clone $data->color->default; | ||||||
|  |                 $fillColor->alpha = (int) round( ( 255 - $fillColor->alpha ) * ( $this->options->fillLines / 255 ) ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $fillColor = null; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Ensure regular steps on axis when used with bar charts and
 | ||||||
|  |             // precalculate some values use to render bar charts
 | ||||||
|  |             //
 | ||||||
|  |             // Called only once and only when bars should be rendered
 | ||||||
|  |             if ( ( $checkedRegularSteps === false ) && | ||||||
|  |                  ( $data->displayType->default === ezcGraph::BAR ) ) | ||||||
|  |             { | ||||||
|  |                 $steps = $xAxis->getSteps(); | ||||||
|  | 
 | ||||||
|  |                 $stepWidth = null; | ||||||
|  |                 foreach ( $steps as $step ) | ||||||
|  |                 { | ||||||
|  |                     if ( $stepWidth === null ) | ||||||
|  |                     { | ||||||
|  |                         $stepWidth = $step->width; | ||||||
|  |                     }  | ||||||
|  |                     elseif ( $step->width !== $stepWidth ) | ||||||
|  |                     { | ||||||
|  |                         throw new ezcGraphUnregularStepsException(); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $step = reset( $steps ); | ||||||
|  |                 if ( count( $step->childs ) ) | ||||||
|  |                 { | ||||||
|  |                     // Keep this for BC reasons
 | ||||||
|  |                     $barCount = ( $xAxis->getMajorStepCount() + 1 ) * ( $xAxis->getMinorStepCount() - 1 ); | ||||||
|  |                     $stepWidth = 1 / $barCount; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $checkedRegularSteps = true; | ||||||
|  |                 $width = $xAxis->axisLabelRenderer->modifyChartDataPosition(  | ||||||
|  |                     $yAxis->axisLabelRenderer->modifyChartDataPosition( | ||||||
|  |                         new ezcGraphCoordinate( | ||||||
|  |                             ( $boundings->x1 - $boundings->x0 ) * $stepWidth, | ||||||
|  |                             0  | ||||||
|  |                         ) | ||||||
|  |                     ) | ||||||
|  |                 )->x; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Draw lines for dataset
 | ||||||
|  |             $lastPoint = false; | ||||||
|  |             foreach ( $data as $key => $value ) | ||||||
|  |             { | ||||||
|  |                 // Calculate point in chart
 | ||||||
|  |                 $point = $xAxis->axisLabelRenderer->modifyChartDataPosition(  | ||||||
|  |                     $yAxis->axisLabelRenderer->modifyChartDataPosition( | ||||||
|  |                         new ezcGraphCoordinate(  | ||||||
|  |                             $xAxis->getCoordinate( $key ), | ||||||
|  |                             $yAxis->getCoordinate( $value ) | ||||||
|  |                         ) | ||||||
|  |                     ) | ||||||
|  |                 ); | ||||||
|  | 
 | ||||||
|  |                 // Render depending on display type of dataset
 | ||||||
|  |                 switch ( true ) | ||||||
|  |                 { | ||||||
|  |                     case $data->displayType->default === ezcGraph::LINE: | ||||||
|  |                         $renderer->drawDataLine( | ||||||
|  |                             $boundings, | ||||||
|  |                             new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                             $data->color->default, | ||||||
|  |                             ( $lastPoint === false ? $point : $lastPoint ), | ||||||
|  |                             $point, | ||||||
|  |                             $nr[$data->displayType->default], | ||||||
|  |                             $count[$data->displayType->default], | ||||||
|  |                             $data->symbol[$key], | ||||||
|  |                             $data->color[$key], | ||||||
|  |                             $fillColor, | ||||||
|  |                             $yAxisNullPosition, | ||||||
|  |                             ( $data->lineThickness->default ? $data->lineThickness->default : $this->options->lineThickness ) | ||||||
|  |                         ); | ||||||
|  | 
 | ||||||
|  |                         // Render highlight string if requested
 | ||||||
|  |                         if ( $data->highlight[$key] ) | ||||||
|  |                         { | ||||||
|  |                             $renderer->drawDataHighlightText( | ||||||
|  |                                 $boundings, | ||||||
|  |                                 new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                                 $point, | ||||||
|  |                                 $yAxisNullPosition, | ||||||
|  |                                 $nr[$data->displayType->default], | ||||||
|  |                                 $count[$data->displayType->default], | ||||||
|  |                                 $this->options->highlightFont, | ||||||
|  |                                 ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), | ||||||
|  |                                 $this->options->highlightSize + $this->options->highlightFont->padding * 2, | ||||||
|  |                                 ( $this->options->highlightLines ? $data->color[$key] : null ), | ||||||
|  |                                 ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), | ||||||
|  |                                 ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ), | ||||||
|  |                                 0., | ||||||
|  |                                 ezcGraph::LINE | ||||||
|  |                             ); | ||||||
|  |                         } | ||||||
|  |                         break; | ||||||
|  |                     case ( $data->displayType->default === ezcGraph::BAR ) && | ||||||
|  |                          $this->options->stackBars : | ||||||
|  |                         // Check if a bar has already been stacked
 | ||||||
|  |                         if ( !isset( $stackedValue[(int) ( $point->x * 10000 )][(int) $value > 0] ) ) | ||||||
|  |                         { | ||||||
|  |                             $start = new ezcGraphCoordinate( | ||||||
|  |                                 $point->x, | ||||||
|  |                                 $yAxisNullPosition | ||||||
|  |                             ); | ||||||
|  | 
 | ||||||
|  |                             $stackedValue[(int) ( $point->x * 10000 )][(int) $value > 0] = $value; | ||||||
|  |                         } | ||||||
|  |                         else | ||||||
|  |                         { | ||||||
|  |                             $start = $xAxis->axisLabelRenderer->modifyChartDataPosition(  | ||||||
|  |                                 $yAxis->axisLabelRenderer->modifyChartDataPosition( | ||||||
|  |                                     new ezcGraphCoordinate(  | ||||||
|  |                                         $xAxis->getCoordinate( $key ), | ||||||
|  |                                         $yAxis->getCoordinate( $stackedValue[(int) ( $point->x * 10000 )][(int) $value > 0] ) | ||||||
|  |                                     ) | ||||||
|  |                                 ) | ||||||
|  |                             ); | ||||||
|  | 
 | ||||||
|  |                             $point = $xAxis->axisLabelRenderer->modifyChartDataPosition(  | ||||||
|  |                                 $yAxis->axisLabelRenderer->modifyChartDataPosition( | ||||||
|  |                                     new ezcGraphCoordinate(  | ||||||
|  |                                         $xAxis->getCoordinate( $key ), | ||||||
|  |                                         $yAxis->getCoordinate( $stackedValue[(int) ( $point->x * 10000 )][(int) $value > 0] += $value ) | ||||||
|  |                                     ) | ||||||
|  |                                 ) | ||||||
|  |                             ); | ||||||
|  |                         } | ||||||
|  | 
 | ||||||
|  |                         // Force one symbol for each stacked bar
 | ||||||
|  |                         if ( !isset( $stackedSymbol[(int) ( $point->x * 10000 )] ) ) | ||||||
|  |                         { | ||||||
|  |                             $stackedSymbol[(int) ( $point->x * 10000 )] = $data->symbol[$key]; | ||||||
|  |                         } | ||||||
|  | 
 | ||||||
|  |                         // Store stacked value for next iteration
 | ||||||
|  |                         $side = ( $point->y == 0 ? 1 : $point->y / abs( $point->y ) ); | ||||||
|  |                         $stacked[(int) ( $point->x * 10000 )][$side] = $point; | ||||||
|  | 
 | ||||||
|  |                         $renderer->drawStackedBar( | ||||||
|  |                             $boundings, | ||||||
|  |                             new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                             $data->color->default, | ||||||
|  |                             $start, | ||||||
|  |                             $point, | ||||||
|  |                             $width, | ||||||
|  |                             $stackedSymbol[(int) ( $point->x * 10000 )], | ||||||
|  |                             $yAxisNullPosition | ||||||
|  |                         ); | ||||||
|  | 
 | ||||||
|  |                         // Render highlight string if requested
 | ||||||
|  |                         if ( $data->highlight[$key] ) | ||||||
|  |                         { | ||||||
|  |                             $renderer->drawDataHighlightText( | ||||||
|  |                                 $boundings, | ||||||
|  |                                 new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                                 $point, | ||||||
|  |                                 $yAxisNullPosition, | ||||||
|  |                                 $nr[$data->displayType->default], | ||||||
|  |                                 $count[$data->displayType->default], | ||||||
|  |                                 $this->options->highlightFont, | ||||||
|  |                                 ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), | ||||||
|  |                                 $this->options->highlightSize + $this->options->highlightFont->padding * 2, | ||||||
|  |                                 ( $this->options->highlightLines ? $data->color[$key] : null ), | ||||||
|  |                                 ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), | ||||||
|  |                                 ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ), | ||||||
|  |                                 0., | ||||||
|  |                                 ezcGraph::LINE | ||||||
|  |                             ); | ||||||
|  |                         } | ||||||
|  |                         break; | ||||||
|  |                     case $data->displayType->default === ezcGraph::BAR: | ||||||
|  |                         $renderer->drawBar( | ||||||
|  |                             $boundings, | ||||||
|  |                             new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                             $data->color[$key], | ||||||
|  |                             $point, | ||||||
|  |                             $width, | ||||||
|  |                             $nr[$data->displayType->default], | ||||||
|  |                             $count[$data->displayType->default], | ||||||
|  |                             $data->symbol[$key], | ||||||
|  |                             $yAxisNullPosition | ||||||
|  |                         ); | ||||||
|  | 
 | ||||||
|  |                         // Render highlight string if requested
 | ||||||
|  |                         if ( $data->highlight[$key] ) | ||||||
|  |                         { | ||||||
|  |                             $renderer->drawDataHighlightText( | ||||||
|  |                                 $boundings, | ||||||
|  |                                 new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                                 $point, | ||||||
|  |                                 $yAxisNullPosition, | ||||||
|  |                                 $nr[$data->displayType->default], | ||||||
|  |                                 $count[$data->displayType->default], | ||||||
|  |                                 $this->options->highlightFont, | ||||||
|  |                                 ( $data->highlightValue[$key] ? $data->highlightValue[$key] : $value ), | ||||||
|  |                                 $this->options->highlightSize + $this->options->highlightFont->padding * 2, | ||||||
|  |                                 ( $this->options->highlightLines ? $data->color[$key] : null ), | ||||||
|  |                                 ( $this->options->highlightXOffset ? $this->options->highlightXOffset : 0 ), | ||||||
|  |                                 ( $this->options->highlightYOffset ? $this->options->highlightYOffset : 0 ), | ||||||
|  |                                 $width, | ||||||
|  |                                 $data->displayType->default | ||||||
|  |                             ); | ||||||
|  |                         } | ||||||
|  |                         break; | ||||||
|  |                     default: | ||||||
|  |                         throw new ezcGraphInvalidDisplayTypeException( $data->displayType->default ); | ||||||
|  |                         break; | ||||||
|  |                 } | ||||||
|  |      | ||||||
|  |                 // Store last point, used to connect lines in line chart.
 | ||||||
|  |                 $lastPoint = $point; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the default display type of the current chart type. | ||||||
|  |      *  | ||||||
|  |      * @return int Display type | ||||||
|  |      */ | ||||||
|  |     public function getDefaultDisplayType() | ||||||
|  |     { | ||||||
|  |         return ezcGraph::LINE; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Check if renderer supports features requested by some special chart | ||||||
|  |      * options. | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If some feature is not supported | ||||||
|  |      * | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function checkRenderer() | ||||||
|  |     { | ||||||
|  |         // When stacked bars are enabled, check if renderer supports them
 | ||||||
|  |         if ( $this->options->stackBars ) | ||||||
|  |         { | ||||||
|  |             if ( !$this->renderer instanceof ezcGraphStackedBarsRenderer ) | ||||||
|  |             { | ||||||
|  |                 throw new ezcBaseValueException( 'renderer', $this->renderer, 'ezcGraphStackedBarsRenderer' ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Aggregate and calculate value boundings on axis. | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function setAxisValues() | ||||||
|  |     { | ||||||
|  |         // Virtual data set build for agrregated values sums for bar charts
 | ||||||
|  |         $virtualBarSumDataSet = array( array(), array() ); | ||||||
|  | 
 | ||||||
|  |         // Calculate axis scaling and labeling
 | ||||||
|  |         foreach ( $this->data as $dataset ) | ||||||
|  |         { | ||||||
|  |             $nr = 0; | ||||||
|  |             $labels = array(); | ||||||
|  |             $values = array(); | ||||||
|  |             foreach ( $dataset as $label => $value ) | ||||||
|  |             { | ||||||
|  |                 $labels[] = $label; | ||||||
|  |                 $values[] = $value; | ||||||
|  | 
 | ||||||
|  |                 // Build sum of all bars
 | ||||||
|  |                 if ( $this->options->stackBars && | ||||||
|  |                      ( $dataset->displayType->default === ezcGraph::BAR ) ) | ||||||
|  |                 { | ||||||
|  |                     if ( !isset( $virtualBarSumDataSet[(int) $value >= 0][$nr] ) ) | ||||||
|  |                     { | ||||||
|  |                         $virtualBarSumDataSet[(int) $value >= 0][$nr++] = $value; | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         $virtualBarSumDataSet[(int) $value >= 0][$nr++] += $value; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Check if data has been associated with another custom axis, use
 | ||||||
|  |             // default axis otherwise.
 | ||||||
|  |             if ( $dataset->xAxis->default ) | ||||||
|  |             { | ||||||
|  |                 $dataset->xAxis->default->addData( $labels ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $this->elements['xAxis']->addData( $labels ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $dataset->yAxis->default ) | ||||||
|  |             { | ||||||
|  |                 $dataset->yAxis->default->addData( $values ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $this->elements['yAxis']->addData( $values ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Also use stacked bar values as base for y axis value span
 | ||||||
|  |         // calculation
 | ||||||
|  |         if ( $this->options->stackBars ) | ||||||
|  |         { | ||||||
|  |             $this->elements['yAxis']->addData( $virtualBarSumDataSet[0] ); | ||||||
|  |             $this->elements['yAxis']->addData( $virtualBarSumDataSet[1] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // There should always be something assigned to the main x and y axis.
 | ||||||
|  |         if ( !$this->elements['xAxis']->initialized || | ||||||
|  |              !$this->elements['yAxis']->initialized ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoDataException(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Calculate boundings from assigned data
 | ||||||
|  |         $this->elements['xAxis']->calculateAxisBoundings(); | ||||||
|  |         $this->elements['yAxis']->calculateAxisBoundings(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders the basic elements of this chart type | ||||||
|  |      *  | ||||||
|  |      * @param int $width  | ||||||
|  |      * @param int $height  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderElements( $width, $height ) | ||||||
|  |     { | ||||||
|  |         if ( !count( $this->data ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoDataException(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Check if renderer supports requested features
 | ||||||
|  |         $this->checkRenderer(); | ||||||
|  | 
 | ||||||
|  |         // Set values form datasets on axis to calculate correct spans
 | ||||||
|  |         $this->setAxisValues(); | ||||||
|  | 
 | ||||||
|  |         // Generate legend
 | ||||||
|  |         $this->elements['legend']->generateFromDataSets( $this->data ); | ||||||
|  | 
 | ||||||
|  |         // Get boundings from parameters
 | ||||||
|  |         $this->options->width = $width; | ||||||
|  |         $this->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         // Set image properties in driver
 | ||||||
|  |         $this->driver->options->width = $width; | ||||||
|  |         $this->driver->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         // Render subelements
 | ||||||
|  |         $boundings = new ezcGraphBoundings(); | ||||||
|  |         $boundings->x1 = $this->options->width; | ||||||
|  |         $boundings->y1 = $this->options->height; | ||||||
|  | 
 | ||||||
|  |         $boundings = $this->elements['xAxis']->axisLabelRenderer->modifyChartBoundings(  | ||||||
|  |             $this->elements['yAxis']->axisLabelRenderer->modifyChartBoundings( | ||||||
|  |                 $boundings, new ezcGraphCoordinate( 1, 0 ) | ||||||
|  |             ), new ezcGraphCoordinate( -1, 0 ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Render subelements
 | ||||||
|  |         foreach ( $this->elements as $name => $element ) | ||||||
|  |         { | ||||||
|  |             // Skip element, if it should not get rendered
 | ||||||
|  |             if ( ( $this->renderElement[$name] === false ) || | ||||||
|  |                  ( $name === 'xAxis' ) || | ||||||
|  |                  ( $name === 'yAxis' ) ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->driver->options->font = $element->font; | ||||||
|  |             $boundings = $element->render( $this->renderer, $boundings ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Set relative positions of axis in chart depending on the "null"
 | ||||||
|  |         // value on the other axis.
 | ||||||
|  |         $this->elements['xAxis']->nullPosition = $this->elements['yAxis']->getCoordinate( false ); | ||||||
|  |         $this->elements['yAxis']->nullPosition = $this->elements['xAxis']->getCoordinate( false ); | ||||||
|  | 
 | ||||||
|  |         // Calculate inner data boundings of chart
 | ||||||
|  |         $innerBoundings = new ezcGraphBoundings( | ||||||
|  |             $boundings->x0 + $boundings->width * | ||||||
|  |                 ( ( ( $this->elements['yAxis']->outerAxisSpace === null ) ||  | ||||||
|  |                     ( $this->elements['xAxis']->position === ezcGraph::LEFT ) ) ? | ||||||
|  |                     $this->elements['yAxis']->axisSpace : | ||||||
|  |                     $this->elements['yAxis']->outerAxisSpace ), | ||||||
|  |             $boundings->y0 + $boundings->height * | ||||||
|  |                 ( ( ( $this->elements['xAxis']->outerAxisSpace === null ) ||  | ||||||
|  |                     ( $this->elements['yAxis']->position === ezcGraph::TOP ) ) ? | ||||||
|  |                     $this->elements['xAxis']->axisSpace : | ||||||
|  |                     $this->elements['yAxis']->outerAxisSpace ), | ||||||
|  |             $boundings->x1 - $boundings->width * | ||||||
|  |                 ( ( ( $this->elements['yAxis']->outerAxisSpace === null ) ||  | ||||||
|  |                     ( $this->elements['xAxis']->position === ezcGraph::RIGHT ) ) ? | ||||||
|  |                     $this->elements['yAxis']->axisSpace : | ||||||
|  |                     $this->elements['yAxis']->outerAxisSpace ), | ||||||
|  |             $boundings->y1 - $boundings->height * | ||||||
|  |                 ( ( ( $this->elements['xAxis']->outerAxisSpace === null ) ||  | ||||||
|  |                     ( $this->elements['yAxis']->position === ezcGraph::BOTTOM ) ) ? | ||||||
|  |                     $this->elements['xAxis']->axisSpace : | ||||||
|  |                     $this->elements['yAxis']->outerAxisSpace ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Render axis
 | ||||||
|  |         $this->driver->options->font = $this->elements['yAxis']->font; | ||||||
|  |         $boundings = $this->elements['xAxis']->render( $this->renderer, $boundings, $innerBoundings ); | ||||||
|  |         $boundings = $this->elements['yAxis']->render( $this->renderer, $boundings, $innerBoundings ); | ||||||
|  | 
 | ||||||
|  |         // Render additional axis
 | ||||||
|  |         foreach ( $this->additionalAxis as $element ) | ||||||
|  |         { | ||||||
|  |             if ( $element->initialized ) | ||||||
|  |             { | ||||||
|  |                 // Calculate all required step sizes if values has been
 | ||||||
|  |                 // assigned to axis.
 | ||||||
|  |                 $element->calculateAxisBoundings(); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 // Do not render any axis labels, if no values were assigned
 | ||||||
|  |                 // and no step sizes were defined.
 | ||||||
|  |                 $element->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->driver->options->font = $element->font; | ||||||
|  |             $element->nullPosition = $element->chartPosition; | ||||||
|  |             $boundings = $element->render( $this->renderer, $boundings, $innerBoundings ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Render graph
 | ||||||
|  |         $this->renderData( $this->renderer, $boundings, $innerBoundings ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the line chart | ||||||
|  |      * | ||||||
|  |      * Renders the chart into a file or stream. The width and height are  | ||||||
|  |      * needed to specify the dimensions of the resulting image. For direct | ||||||
|  |      * output use 'php://stdout' as output file. | ||||||
|  |      *  | ||||||
|  |      * @param int $width Image width | ||||||
|  |      * @param int $height Image height | ||||||
|  |      * @param string $file Output file | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function render( $width, $height, $file = null ) | ||||||
|  |     { | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  | 
 | ||||||
|  |         if ( !empty( $file ) ) | ||||||
|  |         { | ||||||
|  |             $this->renderer->render( $file ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->renderedFile = $file; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders this chart to direct output | ||||||
|  |      *  | ||||||
|  |      * Does the same as ezcGraphChart::render(), but renders directly to  | ||||||
|  |      * output and not into a file. | ||||||
|  |      * | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @apichange  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function renderToOutput( $width, $height ) | ||||||
|  |     { | ||||||
|  |         // @TODO: merge this function with render an deprecate ommit of third 
 | ||||||
|  |         // argument in render() when API break is possible
 | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  |         $this->renderer->render( null ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										296
									
								
								src/TUnit/external/ezc/Graph/charts/odometer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										296
									
								
								src/TUnit/external/ezc/Graph/charts/odometer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,296 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphOdometerChart class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for odometer charts. Can only use one dataset which will be dispalyed | ||||||
|  |  * as a odometer chart. | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphOdometerChart(); | ||||||
|  |  *  $graph->title = 'Custom odometer'; | ||||||
|  |  *   | ||||||
|  |  *  $graph->data['data'] = new ezcGraphArrayDataSet( | ||||||
|  |  *      array( 87 ) | ||||||
|  |  *  ); | ||||||
|  |  *   | ||||||
|  |  *  // Set the marker color
 | ||||||
|  |  *  $graph->data['data']->color[0]  = '#A0000055'; | ||||||
|  |  *   | ||||||
|  |  *  // Set colors for the background gradient
 | ||||||
|  |  *  $graph->options->startColor     = '#2E3436'; | ||||||
|  |  *  $graph->options->endColor       = '#EEEEEC'; | ||||||
|  |  *   | ||||||
|  |  *  // Define a border for the odometer
 | ||||||
|  |  *  $graph->options->borderWidth    = 2; | ||||||
|  |  *  $graph->options->borderColor    = '#BABDB6'; | ||||||
|  |  *   | ||||||
|  |  *  // Set marker width
 | ||||||
|  |  *  $graph->options->markerWidth    = 5; | ||||||
|  |  *   | ||||||
|  |  *  // Set space, which the odometer may consume
 | ||||||
|  |  *  $graph->options->odometerHeight = .7; | ||||||
|  |  *   | ||||||
|  |  *  // Set axis span and label
 | ||||||
|  |  *  $graph->axis->min               = 0; | ||||||
|  |  *  $graph->axis->max               = 100; | ||||||
|  |  *  $graph->axis->label             = 'Coverage  '; | ||||||
|  |  *   | ||||||
|  |  *  $graph->render( 400, 150, 'custom_odometer_chart.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * Each chart consists of several chart elements which represents logical parts | ||||||
|  |  * of the chart and can be formatted independently. The odometer chart consists | ||||||
|  |  * of: | ||||||
|  |  *  - title ( {@link ezcGraphChartElementText} ) | ||||||
|  |  *  - background ( {@link ezcGraphChartElementBackground} ) | ||||||
|  |  * | ||||||
|  |  * All elements can be configured by accessing them as properties of the chart: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->title->position = ezcGraph::BOTTOM; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * The chart itself also offers several options to configure the appearance. | ||||||
|  |  * The extended configure options are available in  | ||||||
|  |  * {@link ezcGraphOdometerChartOptions} extending the {@link | ||||||
|  |  * ezcGraphChartOptions}. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphOdometerChartOptions $options | ||||||
|  |  *           Chart options class | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphOdometerChart extends ezcGraphChart | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      * | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->options = new ezcGraphOdometerChartOptions( $options ); | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  | 
 | ||||||
|  |         $this->data = new ezcGraphChartSingleDataContainer( $this ); | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'axis', new ezcGraphChartElementNumericAxis()); | ||||||
|  |         $this->elements['axis']->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); | ||||||
|  |         $this->elements['axis']->axisLabelRenderer->showZeroValue = true; | ||||||
|  |         $this->elements['axis']->position  = ezcGraph::LEFT; | ||||||
|  |         $this->elements['axis']->axisSpace = .05; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param string $propertyName Option name | ||||||
|  |      * @param mixed $propertyValue Option value; | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue )  | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) { | ||||||
|  |             case 'axis': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphChartElementAxis ) | ||||||
|  |                 { | ||||||
|  |                     $this->addElement( 'axis', $propertyValue ); | ||||||
|  |                     $this->elements['axis']->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); | ||||||
|  |                     $this->elements['axis']->axisLabelRenderer->showZeroValue = true; | ||||||
|  |                     $this->elements['axis']->position  = ezcGraph::LEFT; | ||||||
|  |                     $this->elements['axis']->axisSpace = .05; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'renderer': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphOdometerRenderer ) | ||||||
|  |                 { | ||||||
|  |                     parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 } | ||||||
|  |                 else  | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphOdometerRenderer' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the assigned data | ||||||
|  |      * | ||||||
|  |      * Will renderer all charts data in the remaining boundings after drawing | ||||||
|  |      * all other chart elements. The data will be rendered depending on the | ||||||
|  |      * settings in the dataset. | ||||||
|  |      * | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Remaining boundings | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderData( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         // Draw the odometer data
 | ||||||
|  |         $dataset = $this->data->rewind(); | ||||||
|  | 
 | ||||||
|  |         foreach ( $dataset as $key => $value ) | ||||||
|  |         { | ||||||
|  |             $renderer->drawOdometerMarker( | ||||||
|  |                 $boundings, | ||||||
|  |                 $this->elements['axis']->axisLabelRenderer->modifyChartDataPosition( | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->elements['axis']->getCoordinate( $value ), | ||||||
|  |                         0 | ||||||
|  |                     ) | ||||||
|  |                 ), | ||||||
|  |                 $dataset->symbol[$key], | ||||||
|  |                 $dataset->color[$key], | ||||||
|  |                 $this->options->markerWidth | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the default display type of the current chart type. | ||||||
|  |      * | ||||||
|  |      * @return int Display type | ||||||
|  |      */ | ||||||
|  |     public function getDefaultDisplayType() | ||||||
|  |     { | ||||||
|  |         return ezcGraph::ODOMETER; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders the basic elements of this chart type | ||||||
|  |      * | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderElements( $width, $height ) | ||||||
|  |     { | ||||||
|  |         if ( !count( $this->data ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoDataException(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Set image properties in driver
 | ||||||
|  |         $this->driver->options->width = $width; | ||||||
|  |         $this->driver->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         // no legend
 | ||||||
|  |         $this->renderElement['legend'] = false; | ||||||
|  | 
 | ||||||
|  |         // Get boundings from parameters
 | ||||||
|  |         $this->options->width = $width; | ||||||
|  |         $this->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         $boundings = new ezcGraphBoundings(); | ||||||
|  |         $boundings->x1 = $this->options->width; | ||||||
|  |         $boundings->y1 = $this->options->height; | ||||||
|  | 
 | ||||||
|  |         // Get values out the single used dataset to calculate axis boundings
 | ||||||
|  |         $values = array(); | ||||||
|  |         foreach ( $this->data->rewind() as $value ) | ||||||
|  |         { | ||||||
|  |             $values[] = $value; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Set values for Axis
 | ||||||
|  |         $this->elements['axis']->addData( $values ); | ||||||
|  |         $this->elements['axis']->nullPosition = 0.5 + $this->options->odometerHeight / 2; | ||||||
|  |         $this->elements['axis']->calculateAxisBoundings(); | ||||||
|  | 
 | ||||||
|  |         // Render subelements exept axis, which will be drawn together with the
 | ||||||
|  |         // odometer bar
 | ||||||
|  |         foreach ( $this->elements as $name => $element ) | ||||||
|  |         { | ||||||
|  |             // Skip element, if it should not get rendered
 | ||||||
|  |             if ( $this->renderElement[$name] === false || | ||||||
|  |                  $name === 'axis' ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->driver->options->font = $element->font; | ||||||
|  |             $boundings = $element->render( $this->renderer, $boundings ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Draw basic odometer
 | ||||||
|  |         $this->driver->options->font = $this->elements['axis']->font; | ||||||
|  |         $boundings = $this->renderer->drawOdometer(  | ||||||
|  |             $boundings, | ||||||
|  |             $this->elements['axis'], | ||||||
|  |             $this->options | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Render graph
 | ||||||
|  |         $this->renderData( $this->renderer, $boundings ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the pie chart | ||||||
|  |      * | ||||||
|  |      * Renders the chart into a file or stream. The width and height are | ||||||
|  |      * needed to specify the dimensions of the resulting image. For direct | ||||||
|  |      * output use 'php://stdout' as output file. | ||||||
|  |      * | ||||||
|  |      * @param int $width Image width | ||||||
|  |      * @param int $height Image height | ||||||
|  |      * @param string $file Output file | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function render( $width, $height, $file = null ) | ||||||
|  |     { | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  | 
 | ||||||
|  |         if ( !empty( $file ) ) | ||||||
|  |         { | ||||||
|  |             $this->renderer->render( $file ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->renderedFile = $file; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders this chart to direct output | ||||||
|  |      * | ||||||
|  |      * Does the same as ezcGraphChart::render(), but renders directly to | ||||||
|  |      * output and not into a file. | ||||||
|  |      * | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function renderToOutput( $width, $height ) | ||||||
|  |     { | ||||||
|  |         // @TODO: merge this function with render an deprecate ommit of third
 | ||||||
|  |         // argument in render() when API break is possible
 | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  |         $this->renderer->render( null ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										308
									
								
								src/TUnit/external/ezc/Graph/charts/pie.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										308
									
								
								src/TUnit/external/ezc/Graph/charts/pie.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,308 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphPieChart class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for pie charts. Can only use one dataset which will be dispalyed as a  | ||||||
|  |  * pie chart. | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  // Create a new pie chart
 | ||||||
|  |  *  $chart = new ezcGraphPieChart(); | ||||||
|  |  * | ||||||
|  |  *  // Add data to line chart
 | ||||||
|  |  *  $chart->data['sample dataset'] = new ezcGraphArrayDataSet( | ||||||
|  |  *      array( | ||||||
|  |  *          'one' => 1.2, | ||||||
|  |  *          'two' => 43.2, | ||||||
|  |  *          'three' => -34.14, | ||||||
|  |  *          'four' => 65, | ||||||
|  |  *          'five' => 123, | ||||||
|  |  *      )    | ||||||
|  |  *  ); | ||||||
|  |  * | ||||||
|  |  *  // Render chart with default 2d renderer and default SVG driver
 | ||||||
|  |  *  $chart->render( 500, 200, 'pie_chart.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * Each chart consists of several chart elements which represents logical  | ||||||
|  |  * parts of the chart and can be formatted independently. The pie chart | ||||||
|  |  * consists of: | ||||||
|  |  *  - title ( {@link ezcGraphChartElementText} ) | ||||||
|  |  *  - legend ( {@link ezcGraphChartElementLegend} ) | ||||||
|  |  *  - background ( {@link ezcGraphChartElementBackground} ) | ||||||
|  |  * | ||||||
|  |  * All elements can be configured by accessing them as properties of the chart: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->legend->position = ezcGraph::RIGHT; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * The chart itself also offers several options to configure the appearance. | ||||||
|  |  * The extended configure options are available in  | ||||||
|  |  * {@link ezcGraphPieChartOptions} extending the {@link ezcGraphChartOptions}. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphPieChartOptions $options | ||||||
|  |  *           Chart options class | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphPieChart extends ezcGraphChart | ||||||
|  | { | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->options = new ezcGraphPieChartOptions( $options ); | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  | 
 | ||||||
|  |         $this->data = new ezcGraphChartSingleDataContainer( $this ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the assigned data | ||||||
|  |      * | ||||||
|  |      * Will renderer all charts data in the remaining boundings after drawing  | ||||||
|  |      * all other chart elements. The data will be rendered depending on the  | ||||||
|  |      * settings in the dataset. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Remaining boundings | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderData( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         // Only draw the first (and only) dataset
 | ||||||
|  |         $dataset = $this->data->rewind(); | ||||||
|  |         $datasetName = $this->data->key(); | ||||||
|  | 
 | ||||||
|  |         $this->driver->options->font = $this->options->font; | ||||||
|  | 
 | ||||||
|  |         // Calculate sum of all values to be able to calculate percentage
 | ||||||
|  |         $sum = 0; | ||||||
|  |         foreach ( $dataset as $name => $value ) | ||||||
|  |         { | ||||||
|  |             if ( $value < 0 ) | ||||||
|  |             { | ||||||
|  |                 throw new ezcGraphInvalidDataException( "Values >= 0 required, '$name' => '$value'." ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $sum += $value; | ||||||
|  |         } | ||||||
|  |         if ( $this->options->sum !== false ) | ||||||
|  |         { | ||||||
|  |             $sum = max( $sum, $this->options->sum ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $sum <= 0 ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphInvalidDataException( "Pie charts require a value sum > 0, your value: '$sum'." ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $angle = 0; | ||||||
|  |         foreach ( $dataset as $label => $value ) | ||||||
|  |         { | ||||||
|  |             // Skip rendering values which equals 0
 | ||||||
|  |             if ( $value <= 0 ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             switch ( $dataset->displayType->default ) | ||||||
|  |             { | ||||||
|  |                 case ezcGraph::PIE: | ||||||
|  |                     $displayLabel = ( $this->options->labelCallback !== null | ||||||
|  |                         ? call_user_func( $this->options->labelCallback, $label, $value, $value / $sum ) | ||||||
|  |                         : sprintf( $this->options->label, $label, $value, $value / $sum * 100 ) ); | ||||||
|  | 
 | ||||||
|  |                     $renderer->drawPieSegment( | ||||||
|  |                         $boundings, | ||||||
|  |                         new ezcGraphContext( $datasetName, $label, $dataset->url[$label] ), | ||||||
|  |                         $dataset->color[$label], | ||||||
|  |                         $angle, | ||||||
|  |                         $angle += $value / $sum * 360, | ||||||
|  |                         $displayLabel, | ||||||
|  |                         $dataset->highlight[$label] | ||||||
|  |                     ); | ||||||
|  |                     break; | ||||||
|  |                 default: | ||||||
|  |                     throw new ezcGraphInvalidDisplayTypeException( $dataset->displayType->default ); | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the default display type of the current chart type. | ||||||
|  |      *  | ||||||
|  |      * @return int Display type | ||||||
|  |      */ | ||||||
|  |     public function getDefaultDisplayType() | ||||||
|  |     { | ||||||
|  |         return ezcGraph::PIE; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Apply tresh hold | ||||||
|  |      * | ||||||
|  |      * Iterates over the dataset and applies the configured tresh hold to | ||||||
|  |      * the datasets data. | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function applyThreshold() | ||||||
|  |     { | ||||||
|  |         if ( $this->options->percentThreshold || $this->options->absoluteThreshold ) | ||||||
|  |         { | ||||||
|  |             $dataset = $this->data->rewind(); | ||||||
|  | 
 | ||||||
|  |             $sum = 0; | ||||||
|  |             foreach ( $dataset as $value ) | ||||||
|  |             { | ||||||
|  |                 $sum += $value; | ||||||
|  |             } | ||||||
|  |             if ( $this->options->sum !== false ) | ||||||
|  |             { | ||||||
|  |                 $sum = max( $sum, $this->options->sum ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $unset = array(); | ||||||
|  |             foreach ( $dataset as $label => $value ) | ||||||
|  |             { | ||||||
|  |                 if ( $label === $this->options->summarizeCaption ) | ||||||
|  |                 { | ||||||
|  |                     continue; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 if ( ( $value <= $this->options->absoluteThreshold ) || | ||||||
|  |                      ( ( $value / $sum ) <= $this->options->percentThreshold ) ) | ||||||
|  |                 { | ||||||
|  |                     if ( !isset( $dataset[$this->options->summarizeCaption] ) ) | ||||||
|  |                     { | ||||||
|  |                         $dataset[$this->options->summarizeCaption] = $value; | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         $dataset[$this->options->summarizeCaption] += $value; | ||||||
|  |                     } | ||||||
|  |                      | ||||||
|  |                     $unset[] = $label; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             foreach ( $unset as $label ) | ||||||
|  |             { | ||||||
|  |                 unset( $dataset[$label] ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders the basic elements of this chart type | ||||||
|  |      *  | ||||||
|  |      * @param int $width  | ||||||
|  |      * @param int $height  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderElements( $width, $height ) | ||||||
|  |     { | ||||||
|  |         if ( !count( $this->data ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoDataException(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Set image properties in driver
 | ||||||
|  |         $this->driver->options->width = $width; | ||||||
|  |         $this->driver->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         // Apply tresh hold
 | ||||||
|  |         $this->applyThreshold(); | ||||||
|  | 
 | ||||||
|  |         // Generate legend
 | ||||||
|  |         $this->elements['legend']->generateFromDataSet( $this->data->rewind() ); | ||||||
|  | 
 | ||||||
|  |         // Get boundings from parameters
 | ||||||
|  |         $this->options->width = $width; | ||||||
|  |         $this->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         $boundings = new ezcGraphBoundings(); | ||||||
|  |         $boundings->x1 = $this->options->width; | ||||||
|  |         $boundings->y1 = $this->options->height; | ||||||
|  | 
 | ||||||
|  |         // Render subelements
 | ||||||
|  |         foreach ( $this->elements as $name => $element ) | ||||||
|  |         { | ||||||
|  |             // Skip element, if it should not get rendered
 | ||||||
|  |             if ( $this->renderElement[$name] === false ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->driver->options->font = $element->font; | ||||||
|  |             $boundings = $element->render( $this->renderer, $boundings ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Render graph
 | ||||||
|  |         $this->renderData( $this->renderer, $boundings ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the pie chart | ||||||
|  |      * | ||||||
|  |      * Renders the chart into a file or stream. The width and height are  | ||||||
|  |      * needed to specify the dimensions of the resulting image. For direct | ||||||
|  |      * output use 'php://stdout' as output file. | ||||||
|  |      *  | ||||||
|  |      * @param int $width Image width | ||||||
|  |      * @param int $height Image height | ||||||
|  |      * @param string $file Output file | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function render( $width, $height, $file = null ) | ||||||
|  |     { | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  | 
 | ||||||
|  |         if ( !empty( $file ) ) | ||||||
|  |         { | ||||||
|  |             $this->renderer->render( $file ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->renderedFile = $file; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders this chart to direct output | ||||||
|  |      *  | ||||||
|  |      * Does the same as ezcGraphChart::render(), but renders directly to  | ||||||
|  |      * output and not into a file. | ||||||
|  |      * | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function renderToOutput( $width, $height ) | ||||||
|  |     { | ||||||
|  |         // @TODO: merge this function with render an deprecate ommit of third 
 | ||||||
|  |         // argument in render() when API break is possible
 | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  |         $this->renderer->render( null ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										457
									
								
								src/TUnit/external/ezc/Graph/charts/radar.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										457
									
								
								src/TUnit/external/ezc/Graph/charts/radar.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,457 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphRadarChart class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for radar charts. | ||||||
|  |  * Can make use of an unlimited amount of datasets and will display them as | ||||||
|  |  * lines by default. | ||||||
|  |  * Rotation axis: | ||||||
|  |  *  - Labeled axis | ||||||
|  |  *  - Centered axis label renderer | ||||||
|  |  * Axis: | ||||||
|  |  *  - Numeric axis | ||||||
|  |  *  - radar axis label renderer | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  // Create a new radar chart
 | ||||||
|  |  *  $chart = new ezcGraphRadarChart(); | ||||||
|  |  * | ||||||
|  |  *  // Add data to line chart
 | ||||||
|  |  *  $chart->data['sample dataset'] = new ezcGraphArrayDataSet( | ||||||
|  |  *      array( | ||||||
|  |  *          '100' => 1.2, | ||||||
|  |  *          '200' => 43.2, | ||||||
|  |  *          '300' => -34.14, | ||||||
|  |  *          '350' => 65, | ||||||
|  |  *          '400' => 123, | ||||||
|  |  *      )    | ||||||
|  |  *  ); | ||||||
|  |  * | ||||||
|  |  *  // Render chart with default 2d renderer and default SVG driver
 | ||||||
|  |  *  $chart->render( 500, 200, 'radar_chart.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * Each chart consists of several chart elements which represents logical  | ||||||
|  |  * parts of the chart and can be formatted independently. The line chart | ||||||
|  |  * consists of: | ||||||
|  |  *  - title ( {@link ezcGraphChartElementText} ) | ||||||
|  |  *  - legend ( {@link ezcGraphChartElementLegend} ) | ||||||
|  |  *  - background ( {@link ezcGraphChartElementBackground} ) | ||||||
|  |  *  - axis ( {@link ezcGraphChartElementNumericAxis} ) | ||||||
|  |  *  - ratation axis ( {@link ezcGraphChartElementLabeledAxis} ) | ||||||
|  |  * | ||||||
|  |  * The type of the axis may be changed and all elements can be configured by | ||||||
|  |  * accessing them as properties of the chart: | ||||||
|  |  * | ||||||
|  |  * The chart itself also offers several options to configure the appearance. | ||||||
|  |  * The extended configure options are available in  | ||||||
|  |  * {@link ezcGraphRadarChartOptions} extending the  | ||||||
|  |  * {@link ezcGraphChartOptions}. | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->legend->position = ezcGraph::RIGHT; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphRadarChartOptions $options | ||||||
|  |  *           Chart options class | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphRadarChart extends ezcGraphChart | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Store major grid color for child axis. | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphColor | ||||||
|  |      */ | ||||||
|  |     protected $childAxisColor; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->options = new ezcGraphRadarChartOptions( $options ); | ||||||
|  |         $this->options->highlightFont = $this->options->font; | ||||||
|  | 
 | ||||||
|  |         parent::__construct(); | ||||||
|  | 
 | ||||||
|  |         $this->elements['rotationAxis'] = new ezcGraphChartElementLabeledAxis(); | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'axis', new ezcGraphChartElementNumericAxis() ); | ||||||
|  |         $this->elements['axis']->position = ezcGraph::BOTTOM; | ||||||
|  |         $this->elements['axis']->axisLabelRenderer = new ezcGraphAxisRadarLabelRenderer(); | ||||||
|  |         $this->elements['axis']->axisLabelRenderer->outerStep = true; | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'rotationAxis', new ezcGraphChartElementLabeledAxis() ); | ||||||
|  | 
 | ||||||
|  |         // Do not render axis with default method, because we need an axis for
 | ||||||
|  |         // each label in dataset
 | ||||||
|  |         $this->renderElement['axis'] = false; | ||||||
|  |         $this->renderElement['rotationAxis'] = false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set colors and border fro this element | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphPalette $palette Palette | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function setFromPalette( ezcGraphPalette $palette ) | ||||||
|  |     { | ||||||
|  |         $this->childAxisColor = $palette->majorGridColor; | ||||||
|  | 
 | ||||||
|  |         parent::setFromPalette( $palette ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param string $propertyName Option name | ||||||
|  |      * @param mixed $propertyValue Option value; | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue )  | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) { | ||||||
|  |             case 'axis': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphChartElementAxis ) | ||||||
|  |                 { | ||||||
|  |                     $this->addElement( 'axis', $propertyValue ); | ||||||
|  |                     $this->elements['axis']->position = ezcGraph::BOTTOM; | ||||||
|  |                     $this->elements['axis']->axisLabelRenderer = new ezcGraphAxisRadarLabelRenderer(); | ||||||
|  |                     $this->renderElement['axis'] = false; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'rotationAxis': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphChartElementAxis ) | ||||||
|  |                 { | ||||||
|  |                     $this->addElement( 'rotationAxis', $propertyValue ); | ||||||
|  |                     $this->renderElement['rotationAxis'] = false; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'renderer': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphRadarRenderer ) | ||||||
|  |                 { | ||||||
|  |                     parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 } | ||||||
|  |                 else  | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphRadarRenderer' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a single rotated axis | ||||||
|  |      * | ||||||
|  |      * Sets the axis label position depending on the axis rotation. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphChartElementAxis $axis  | ||||||
|  |      * @param ezcGraphBoundings $boundings  | ||||||
|  |      * @param ezcGraphCoordinate $center  | ||||||
|  |      * @param float $position  | ||||||
|  |      * @param float $lastPosition  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function drawRotatedAxis( ezcGraphChartElementAxis $axis, ezcGraphBoundings $boundings, ezcGraphCoordinate $center, $position, $lastPosition = null ) | ||||||
|  |     { | ||||||
|  |         // Set axis position depending on angle for better axis label 
 | ||||||
|  |         // positioning
 | ||||||
|  |         $angle = $position * 2 * M_PI; | ||||||
|  |         switch ( (int) ( ( $position + .125 ) * 4 ) ) | ||||||
|  |         { | ||||||
|  |             case 0: | ||||||
|  |             case 4: | ||||||
|  |                 $axis->position = ezcGraph::BOTTOM; | ||||||
|  |                 break; | ||||||
|  |             case 1: | ||||||
|  |                 $axis->position = ezcGraph::LEFT; | ||||||
|  |                 break; | ||||||
|  |             case 2: | ||||||
|  |                 $axis->position = ezcGraph::TOP; | ||||||
|  |                 break; | ||||||
|  |             case 3: | ||||||
|  |                 $axis->position = ezcGraph::RIGHT; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Set last step to correctly draw grid
 | ||||||
|  |         if ( $axis->axisLabelRenderer instanceof ezcGraphAxisRadarLabelRenderer ) | ||||||
|  |         { | ||||||
|  |             $axis->axisLabelRenderer->lastStep = $lastPosition; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Do not draw axis label for last step
 | ||||||
|  |         if ( abs( $position - 1 ) <= .001 )  | ||||||
|  |         { | ||||||
|  |             $axis->label = null; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->renderer->drawAxis( | ||||||
|  |             $boundings, | ||||||
|  |             clone $center, | ||||||
|  |             $dest = new ezcGraphCoordinate( | ||||||
|  |                 $center->x + sin( $angle ) * ( $boundings->width / 2 ), | ||||||
|  |                 $center->y - cos( $angle ) * ( $boundings->height / 2 ) | ||||||
|  |             ), | ||||||
|  |             clone $axis, | ||||||
|  |             clone $axis->axisLabelRenderer | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the assigned data | ||||||
|  |      * | ||||||
|  |      * Will renderer all charts data in the remaining boundings after drawing  | ||||||
|  |      * all other chart elements. The data will be rendered depending on the  | ||||||
|  |      * settings in the dataset. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Remaining boundings | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderData( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         // Apply axis space
 | ||||||
|  |         $xAxisSpace = ( $boundings->x1 - $boundings->x0 ) * $this->axis->axisSpace; | ||||||
|  |         $yAxisSpace = ( $boundings->y1 - $boundings->y0 ) * $this->axis->axisSpace; | ||||||
|  | 
 | ||||||
|  |         $center = new ezcGraphCoordinate( | ||||||
|  |             ( $boundings->width / 2 ), | ||||||
|  |             ( $boundings->height / 2 ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // We do not differentiate between display types in radar charts.
 | ||||||
|  |         $nr = $count = count( $this->data ); | ||||||
|  | 
 | ||||||
|  |         // Draw axis at major steps of virtual axis
 | ||||||
|  |         $steps = $this->elements['rotationAxis']->getSteps(); | ||||||
|  |         $lastStepPosition = null; | ||||||
|  |         $axisColor = $this->elements['axis']->border; | ||||||
|  |         foreach ( $steps as $step ) | ||||||
|  |         { | ||||||
|  |             $this->elements['axis']->label = $step->label; | ||||||
|  |             $this->drawRotatedAxis( $this->elements['axis'], $boundings, $center, $step->position, $lastStepPosition ); | ||||||
|  |             $lastStepPosition = $step->position; | ||||||
|  | 
 | ||||||
|  |             if ( count( $step->childs ) ) | ||||||
|  |             { | ||||||
|  |                 foreach ( $step->childs as $childStep ) | ||||||
|  |                 { | ||||||
|  |                     $this->elements['axis']->label = null; | ||||||
|  |                     $this->elements['axis']->border = $this->childAxisColor; | ||||||
|  | 
 | ||||||
|  |                     $this->drawRotatedAxis( $this->elements['axis'], $boundings, $center, $childStep->position, $lastStepPosition ); | ||||||
|  |                     $lastStepPosition = $childStep->position; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->elements['axis']->border = $axisColor; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Display data
 | ||||||
|  |         $this->elements['axis']->position = ezcGraph::TOP; | ||||||
|  |         foreach ( $this->data as $datasetName => $data ) | ||||||
|  |         { | ||||||
|  |             --$nr; | ||||||
|  |             // Determine fill color for dataset
 | ||||||
|  |             if ( $this->options->fillLines !== false ) | ||||||
|  |             { | ||||||
|  |                 $fillColor = clone $data->color->default; | ||||||
|  |                 $fillColor->alpha = (int) round( ( 255 - $fillColor->alpha ) * ( $this->options->fillLines / 255 ) ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $fillColor = null; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Draw lines for dataset
 | ||||||
|  |             $lastPoint = false; | ||||||
|  |             foreach ( $data as $key => $value ) | ||||||
|  |             { | ||||||
|  |                 $point = new ezcGraphCoordinate(  | ||||||
|  |                     $this->elements['rotationAxis']->getCoordinate( $key ), | ||||||
|  |                     $this->elements['axis']->getCoordinate( $value ) | ||||||
|  |                 );  | ||||||
|  | 
 | ||||||
|  |                 /* Transformation required for 3d like renderers ...  | ||||||
|  |                  * which axis should transform here? | ||||||
|  |                 $point = $this->elements['xAxis']->axisLabelRenderer->modifyChartDataPosition(  | ||||||
|  |                     $this->elements['yAxis']->axisLabelRenderer->modifyChartDataPosition( | ||||||
|  |                         new ezcGraphCoordinate(  | ||||||
|  |                             $this->elements['xAxis']->getCoordinate( $key ), | ||||||
|  |                             $this->elements['yAxis']->getCoordinate( $value ) | ||||||
|  |                         ) | ||||||
|  |                     ) | ||||||
|  |                 );  | ||||||
|  |                 // */
 | ||||||
|  | 
 | ||||||
|  |                 $renderer->drawRadarDataLine( | ||||||
|  |                     $boundings, | ||||||
|  |                     new ezcGraphContext( $datasetName, $key, $data->url[$key] ), | ||||||
|  |                     $data->color->default, | ||||||
|  |                     clone $center, | ||||||
|  |                     ( $lastPoint === false ? $point : $lastPoint ), | ||||||
|  |                     $point, | ||||||
|  |                     $nr, | ||||||
|  |                     $count, | ||||||
|  |                     $data->symbol[$key], | ||||||
|  |                     $data->color[$key], | ||||||
|  |                     $fillColor, | ||||||
|  |                     $this->options->lineThickness | ||||||
|  |                 ); | ||||||
|  | 
 | ||||||
|  |                 $lastPoint = $point; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the default display type of the current chart type. | ||||||
|  |      *  | ||||||
|  |      * @return int Display type | ||||||
|  |      */ | ||||||
|  |     public function getDefaultDisplayType() | ||||||
|  |     { | ||||||
|  |         return ezcGraph::LINE; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders the basic elements of this chart type | ||||||
|  |      *  | ||||||
|  |      * @param int $width  | ||||||
|  |      * @param int $height  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderElements( $width, $height ) | ||||||
|  |     { | ||||||
|  |         if ( !count( $this->data ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoDataException(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Set image properties in driver
 | ||||||
|  |         $this->driver->options->width = $width; | ||||||
|  |         $this->driver->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         // Calculate axis scaling and labeling
 | ||||||
|  |         foreach ( $this->data as $dataset ) | ||||||
|  |         { | ||||||
|  |             $labels = array(); | ||||||
|  |             $values = array(); | ||||||
|  |             foreach ( $dataset as $label => $value ) | ||||||
|  |             { | ||||||
|  |                 $labels[] = $label; | ||||||
|  |                 $values[] = $value; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->elements['axis']->addData( $values ); | ||||||
|  |             $this->elements['rotationAxis']->addData( $labels ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->elements['axis']->calculateAxisBoundings(); | ||||||
|  |         $this->elements['rotationAxis']->calculateAxisBoundings(); | ||||||
|  | 
 | ||||||
|  |         // Generate legend
 | ||||||
|  |         $this->elements['legend']->generateFromDataSets( $this->data ); | ||||||
|  | 
 | ||||||
|  |         // Get boundings from parameters
 | ||||||
|  |         $this->options->width = $width; | ||||||
|  |         $this->options->height = $height; | ||||||
|  | 
 | ||||||
|  |         // Render subelements
 | ||||||
|  |         $boundings = new ezcGraphBoundings(); | ||||||
|  |         $boundings->x1 = $this->options->width; | ||||||
|  |         $boundings->y1 = $this->options->height; | ||||||
|  | 
 | ||||||
|  |         // Render subelements
 | ||||||
|  |         foreach ( $this->elements as $name => $element ) | ||||||
|  |         { | ||||||
|  |             // Skip element, if it should not get rendered
 | ||||||
|  |             if ( $this->renderElement[$name] === false ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $this->driver->options->font = $element->font; | ||||||
|  |             $boundings = $element->render( $this->renderer, $boundings ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Render graph
 | ||||||
|  |         $this->renderData( $this->renderer, $boundings ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the line chart | ||||||
|  |      * | ||||||
|  |      * Renders the chart into a file or stream. The width and height are  | ||||||
|  |      * needed to specify the dimensions of the resulting image. For direct | ||||||
|  |      * output use 'php://stdout' as output file. | ||||||
|  |      *  | ||||||
|  |      * @param int $width Image width | ||||||
|  |      * @param int $height Image height | ||||||
|  |      * @param string $file Output file | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function render( $width, $height, $file = null ) | ||||||
|  |     { | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  | 
 | ||||||
|  |         if ( !empty( $file ) ) | ||||||
|  |         { | ||||||
|  |             $this->renderer->render( $file ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->renderedFile = $file; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders this chart to direct output | ||||||
|  |      *  | ||||||
|  |      * Does the same as ezcGraphChart::render(), but renders directly to  | ||||||
|  |      * output and not into a file. | ||||||
|  |      * | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @apichange | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function renderToOutput( $width, $height ) | ||||||
|  |     { | ||||||
|  |         // @TODO: merge this function with render an deprecate ommit of third 
 | ||||||
|  |         // argument in render() when API break is possible
 | ||||||
|  |         $this->renderElements( $width, $height ); | ||||||
|  |         $this->renderer->render( null ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										290
									
								
								src/TUnit/external/ezc/Graph/colors/color.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										290
									
								
								src/TUnit/external/ezc/Graph/colors/color.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,290 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphColor class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * ezcGraphColor  | ||||||
|  |  * | ||||||
|  |  * Struct for representing colors in ezcGraph. A color is defined using the | ||||||
|  |  * common RGBA model with integer values between 0 and 255. An alpha value  | ||||||
|  |  * of zero means full opacity, while 255 means full transparency. | ||||||
|  |  * | ||||||
|  |  * @property integer $red | ||||||
|  |  *           Red RGBA value of color. | ||||||
|  |  * @property integer $green | ||||||
|  |  *           Green RGBA value of color. | ||||||
|  |  * @property integer $blue | ||||||
|  |  *           Blue RGBA value of color. | ||||||
|  |  * @property integer $alpha | ||||||
|  |  *           Alpha RGBA value of color. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphColor extends ezcBaseOptions | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['red']   = 0; | ||||||
|  |         $this->properties['green'] = 0; | ||||||
|  |         $this->properties['blue']  = 0; | ||||||
|  |         $this->properties['alpha'] = 0; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'red': | ||||||
|  |             case 'green': | ||||||
|  |             case 'blue': | ||||||
|  |             case 'alpha': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) ||  | ||||||
|  |                      ( $propertyValue < 0 ) ||  | ||||||
|  |                      ( $propertyValue > 255 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 255' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties[$propertyName] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates an ezcGraphColor object from a hexadecimal color representation | ||||||
|  |      *  | ||||||
|  |      * @param mixed $string Hexadecimal color representation | ||||||
|  |      * @return ezcGraphColor | ||||||
|  |      */ | ||||||
|  |     static public function fromHex( $string )  | ||||||
|  |     { | ||||||
|  |         // Remove trailing #
 | ||||||
|  |         if ( $string[0] === '#' ) | ||||||
|  |         { | ||||||
|  |             $string = substr( $string, 1 ); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         // Iterate over chunks and convert to integer
 | ||||||
|  |         $color = new ezcGraphColor(); | ||||||
|  |         $keys = array( 'red', 'green', 'blue', 'alpha' ); | ||||||
|  |         foreach ( str_split( $string, 2) as $nr => $hexValue ) | ||||||
|  |         { | ||||||
|  |             if ( isset( $keys[$nr] ) )  | ||||||
|  |             { | ||||||
|  |                 $key = $keys[$nr]; | ||||||
|  |                 $color->$key = hexdec( $hexValue ) % 256; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         // Set missing values to zero
 | ||||||
|  |         for ( ++$nr; $nr < count( $keys ); ++$nr ) | ||||||
|  |         { | ||||||
|  |             $key = $keys[$nr]; | ||||||
|  |             $color->$key = 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $color; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates an ezcGraphColor object from an array of integers | ||||||
|  |      *  | ||||||
|  |      * @param array $array Array of integer color values | ||||||
|  |      * @return ezcGraphColor | ||||||
|  |      */ | ||||||
|  |     static public function fromIntegerArray( array $array ) | ||||||
|  |     { | ||||||
|  |         // Iterate over array elements
 | ||||||
|  |         $color = new ezcGraphColor(); | ||||||
|  |         $keys = array( 'red', 'green', 'blue', 'alpha' ); | ||||||
|  |         $nr = 0; | ||||||
|  |         foreach ( $array as $colorValue ) | ||||||
|  |         { | ||||||
|  |             if ( isset( $keys[$nr] ) )  | ||||||
|  |             { | ||||||
|  |                 $key = $keys[$nr++]; | ||||||
|  |                 $color->$key = ( (int) $colorValue ) % 256; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         // Set missing values to zero
 | ||||||
|  |         for ( $nr; $nr < count( $keys ); ++$nr ) | ||||||
|  |         { | ||||||
|  |             $key = $keys[$nr]; | ||||||
|  |             $color->$key = 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $color; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Creates an ezcGraphColor object from an array of floats | ||||||
|  |      *  | ||||||
|  |      * @param array $array Array of float color values | ||||||
|  |      * @return ezcGraphColor | ||||||
|  |      */ | ||||||
|  |     static public function fromFloatArray( array $array ) | ||||||
|  |     { | ||||||
|  |         // Iterate over array elements
 | ||||||
|  |         $color = new ezcGraphColor(); | ||||||
|  |         $keys = array( 'red', 'green', 'blue', 'alpha' ); | ||||||
|  |         $nr = 0; | ||||||
|  |         foreach ( $array as $colorValue ) | ||||||
|  |         { | ||||||
|  |             if ( isset( $keys[$nr] ) )  | ||||||
|  |             { | ||||||
|  |                 $key = $keys[$nr++]; | ||||||
|  |                 $color->$key = ( (float) $colorValue * 255 ) % 256; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         // Set missing values to zero
 | ||||||
|  |         for ( $nr; $nr < count( $keys ); ++$nr ) | ||||||
|  |         { | ||||||
|  |             $key = $keys[$nr]; | ||||||
|  |             $color->$key = 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $color; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Tries to parse provided color value | ||||||
|  |      * | ||||||
|  |      * This method can be used to create a color struct from arbritrary color | ||||||
|  |      * representations. The following values are accepted | ||||||
|  |      * | ||||||
|  |      * - Hexadecimal color definitions, like known from HTML, CSS and SVG | ||||||
|  |      * | ||||||
|  |      *   Color definitions like #FF0000, with and and without number sign,
 | ||||||
|  |      *   where each pair of bytes is interpreted as a color value for the | ||||||
|  |      *   channels RGB(A). These color values may contain up to 4 values, where | ||||||
|  |      *   the last value is considered as the alpha channel. | ||||||
|  |      * | ||||||
|  |      * - Array of integers | ||||||
|  |      * | ||||||
|  |      *   If an array of integers is provided as input teh value in each channel | ||||||
|  |      *   may be in the span [0 - 255] and is assigned to the color channels | ||||||
|  |      *   RGB(A). Up to four values are used from the array. | ||||||
|  |      *  | ||||||
|  |      * - Array of floats | ||||||
|  |      * | ||||||
|  |      *   If an array of floats is provided as input teh value in each channel | ||||||
|  |      *   may be in the span [0 - 1] and is assigned to the color channels | ||||||
|  |      *   RGB(A). Up to four values are used from the array. | ||||||
|  |      *  | ||||||
|  |      * @param mixed $color Some kind of color definition | ||||||
|  |      * @return ezcGraphColor | ||||||
|  |      */ | ||||||
|  |     static public function create( $color ) | ||||||
|  |     { | ||||||
|  |         if ( $color instanceof ezcGraphColor ) | ||||||
|  |         { | ||||||
|  |             return $color; | ||||||
|  |         } | ||||||
|  |         elseif ( is_string( $color ) ) | ||||||
|  |         { | ||||||
|  |             return ezcGraphColor::fromHex( $color ); | ||||||
|  |         } | ||||||
|  |         elseif ( is_array( $color ) ) | ||||||
|  |         { | ||||||
|  |             $testElement = reset( $color ); | ||||||
|  |             if ( is_int( $testElement ) ) | ||||||
|  |             { | ||||||
|  |                 return ezcGraphColor::fromIntegerArray( $color ); | ||||||
|  |             }  | ||||||
|  |             else  | ||||||
|  |             { | ||||||
|  |                 return ezcGraphColor::fromFloatArray( $color ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphUnknownColorDefinitionException( $color ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a copy of the current color made more transparent by the given | ||||||
|  |      * factor | ||||||
|  |      *  | ||||||
|  |      * @param mixed $value  Percent to make color mor transparent | ||||||
|  |      * @return ezcGraphColor New color | ||||||
|  |      */ | ||||||
|  |     public function transparent( $value ) | ||||||
|  |     { | ||||||
|  |         $color = clone $this; | ||||||
|  | 
 | ||||||
|  |         $color->alpha = 255 - (int) round( ( 255 - $this->alpha ) * ( 1 - $value ) ); | ||||||
|  | 
 | ||||||
|  |         return $color; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Inverts and returns a copy of the current color | ||||||
|  |      *  | ||||||
|  |      * @return ezcGraphColor New Color | ||||||
|  |      */ | ||||||
|  |     public function invert() | ||||||
|  |     { | ||||||
|  |         $color = new ezcGraphColor(); | ||||||
|  |                 | ||||||
|  |         $color->red   = 255 - $this->red; | ||||||
|  |         $color->green = 255 - $this->green; | ||||||
|  |         $color->blue  = 255 - $this->blue; | ||||||
|  |         $color->alpha = $this->alpha; | ||||||
|  | 
 | ||||||
|  |         return $color; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a copy of the current color darkened by the given factor | ||||||
|  |      *  | ||||||
|  |      * @param float $value Percent to darken the color | ||||||
|  |      * @return ezcGraphColor New color | ||||||
|  |      */ | ||||||
|  |     public function darken( $value ) | ||||||
|  |     { | ||||||
|  |         $color = clone $this; | ||||||
|  | 
 | ||||||
|  |         $value        = 1 - $value; | ||||||
|  |         $color->red   = min( 255, max( 0, (int) round( $this->red * $value ) ) ); | ||||||
|  |         $color->green = min( 255, max( 0, (int) round( $this->green * $value ) ) ); | ||||||
|  |         $color->blue  = min( 255, max( 0, (int) round( $this->blue * $value ) ) ); | ||||||
|  | 
 | ||||||
|  |         return $color; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										147
									
								
								src/TUnit/external/ezc/Graph/colors/linear_gradient.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								src/TUnit/external/ezc/Graph/colors/linear_gradient.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,147 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphLinearGradient class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class representing linear gradient fills. For drivers which cannot draw | ||||||
|  |  * gradients it falls back to a native {@link ezcGraphColor}. In this case the | ||||||
|  |  * start color of the gradient will be used. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphCoordinate $startPoint | ||||||
|  |  *           Starting point of the gradient. | ||||||
|  |  * @property ezcGraphCoordinate $endPoint | ||||||
|  |  *           Ending point of the gradient. | ||||||
|  |  * @property ezcGraphColor $startColor | ||||||
|  |  *           Starting color of the gradient. | ||||||
|  |  * @property ezcGraphColor $endColor | ||||||
|  |  *           Ending color of the gradient. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphLinearGradient extends ezcGraphColor | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $startPoint  | ||||||
|  |      * @param ezcGraphCoordinate $endPoint  | ||||||
|  |      * @param ezcGraphColor $startColor  | ||||||
|  |      * @param ezcGraphColor $endColor  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __construct( ezcGraphCoordinate $startPoint, ezcGraphCoordinate $endPoint, ezcGraphColor $startColor, ezcGraphColor $endColor ) | ||||||
|  |     { | ||||||
|  |         $this->properties['startColor'] = $startColor; | ||||||
|  |         $this->properties['endColor'] = $endColor; | ||||||
|  |         $this->properties['startPoint'] = $startPoint; | ||||||
|  |         $this->properties['endPoint'] = $endPoint; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'startPoint': | ||||||
|  |                 if ( !$propertyValue instanceof ezcGraphCoordinate ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphCoordinate' ); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $this->properties['startPoint'] = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'endPoint': | ||||||
|  |                 if ( !$propertyValue instanceof ezcGraphCoordinate ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphCoordinate' ); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $this->properties['endPoint'] = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'startColor': | ||||||
|  |                 $this->properties['startColor'] = ezcGraphColor::create( $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |             case 'endColor': | ||||||
|  |                 $this->properties['endColor'] = ezcGraphColor::create( $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'red': | ||||||
|  |             case 'green': | ||||||
|  |             case 'blue': | ||||||
|  |             case 'alpha': | ||||||
|  |                 // Fallback to native color
 | ||||||
|  |                 return $this->properties['startColor']->$propertyName; | ||||||
|  |             default: | ||||||
|  |                 if ( isset( $this->properties[$propertyName] ) ) | ||||||
|  |                 { | ||||||
|  |                     return $this->properties[$propertyName]; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |                 } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a unique string representation for the gradient. | ||||||
|  |      *  | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __toString() | ||||||
|  |     { | ||||||
|  |         return sprintf( 'LinearGradient_%d_%d_%d_%d_%02x%02x%02x%02x_%02x%02x%02x%02x', | ||||||
|  |             $this->properties['startPoint']->x, | ||||||
|  |             $this->properties['startPoint']->y, | ||||||
|  |             $this->properties['endPoint']->x, | ||||||
|  |             $this->properties['endPoint']->y, | ||||||
|  |             $this->properties['startColor']->red, | ||||||
|  |             $this->properties['startColor']->green, | ||||||
|  |             $this->properties['startColor']->blue, | ||||||
|  |             $this->properties['startColor']->alpha, | ||||||
|  |             $this->properties['endColor']->red, | ||||||
|  |             $this->properties['endColor']->green, | ||||||
|  |             $this->properties['endColor']->blue, | ||||||
|  |             $this->properties['endColor']->alpha | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										173
									
								
								src/TUnit/external/ezc/Graph/colors/radial_gradient.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								src/TUnit/external/ezc/Graph/colors/radial_gradient.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,173 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphRadialGradient class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class representing radial gradient fills. For drivers which cannot draw  | ||||||
|  |  * gradients it falls back to a native ezcGraphColor. In this case the start | ||||||
|  |  * color of the gradient will be used. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphCoordinate $center | ||||||
|  |  *           Center point of the gradient. | ||||||
|  |  * @property int $width | ||||||
|  |  *           Width of ellipse | ||||||
|  |  * @property int $height | ||||||
|  |  *           Width of ellipse | ||||||
|  |  * @property int $offset | ||||||
|  |  *           Offset for starting color | ||||||
|  |  * @property ezcGraphColor $startColor | ||||||
|  |  *           Starting color of the gradient. | ||||||
|  |  * @property ezcGraphColor $endColor | ||||||
|  |  *           Ending color of the gradient. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphRadialGradient extends ezcGraphColor | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center  | ||||||
|  |      * @param mixed $width  | ||||||
|  |      * @param mixed $height  | ||||||
|  |      * @param ezcGraphColor $startColor  | ||||||
|  |      * @param ezcGraphColor $endColor  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __construct( ezcGraphCoordinate $center, $width, $height, ezcGraphColor $startColor, ezcGraphColor $endColor ) | ||||||
|  |     { | ||||||
|  |         $this->properties['center'] = $center; | ||||||
|  |         $this->properties['width'] = (float) $width; | ||||||
|  |         $this->properties['height'] = (float) $height; | ||||||
|  |         $this->properties['offset'] = 0; | ||||||
|  |         $this->properties['startColor'] = $startColor; | ||||||
|  |         $this->properties['endColor'] = $endColor; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'center': | ||||||
|  |                 if ( !$propertyValue instanceof ezcGraphCoordinate ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphCoordinate' ); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     $this->properties['center'] = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'width': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['width'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'height': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['height'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'offset': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ||  | ||||||
|  |                      ( $propertyValue > 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['offset'] = $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'startColor': | ||||||
|  |                 $this->properties['startColor'] = ezcGraphColor::create( $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |             case 'endColor': | ||||||
|  |                 $this->properties['endColor'] = ezcGraphColor::create( $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'red': | ||||||
|  |             case 'green': | ||||||
|  |             case 'blue': | ||||||
|  |             case 'alpha': | ||||||
|  |                 // Fallback to native color
 | ||||||
|  |                 return $this->properties['startColor']->$propertyName; | ||||||
|  |             default: | ||||||
|  |                 if ( isset( $this->properties[$propertyName] ) ) | ||||||
|  |                 { | ||||||
|  |                     return $this->properties[$propertyName]; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |                 } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a unique string representation for the gradient. | ||||||
|  |      *  | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __toString() | ||||||
|  |     { | ||||||
|  |         return sprintf( 'RadialGradient_%d_%d_%d_%d_%.2f_%02x%02x%02x%02x_%02x%02x%02x%02x', | ||||||
|  |             $this->properties['center']->x, | ||||||
|  |             $this->properties['center']->y, | ||||||
|  |             $this->properties['width'], | ||||||
|  |             $this->properties['height'], | ||||||
|  |             $this->properties['offset'], | ||||||
|  |             $this->properties['startColor']->red, | ||||||
|  |             $this->properties['startColor']->green, | ||||||
|  |             $this->properties['startColor']->blue, | ||||||
|  |             $this->properties['startColor']->alpha, | ||||||
|  |             $this->properties['endColor']->red, | ||||||
|  |             $this->properties['endColor']->green, | ||||||
|  |             $this->properties['endColor']->blue, | ||||||
|  |             $this->properties['endColor']->alpha | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										225
									
								
								src/TUnit/external/ezc/Graph/data_container/base.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										225
									
								
								src/TUnit/external/ezc/Graph/data_container/base.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,225 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphChartDataContainer class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Container class for datasets used by the chart classes. Implements usefull | ||||||
|  |  * interfaces for convenient access to the datasets. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | class ezcGraphChartDataContainer implements ArrayAccess, Iterator, Countable | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Contains the data of a chart | ||||||
|  |      *  | ||||||
|  |      * @var array(ezcGraphDataSet) | ||||||
|  |      */ | ||||||
|  |     protected $data = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Chart using this data set storage | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphChart | ||||||
|  |      */ | ||||||
|  |     protected $chart; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphChart $chart  | ||||||
|  |      * @ignore | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __construct( ezcGraphChart $chart ) | ||||||
|  |     { | ||||||
|  |         $this->chart = $chart; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Adds a dataset to the charts data | ||||||
|  |      *  | ||||||
|  |      * @param string $name Name of dataset | ||||||
|  |      * @param ezcGraphDataSet $dataSet | ||||||
|  |      * @param mixed $values Values to create dataset with | ||||||
|  |      * @throws ezcGraphTooManyDataSetExceptions | ||||||
|  |      *          If too many datasets are created | ||||||
|  |      * @return ezcGraphDataSet | ||||||
|  |      */ | ||||||
|  |     protected function addDataSet( $name, ezcGraphDataSet $dataSet ) | ||||||
|  |     { | ||||||
|  |         $this->data[$name] = $dataSet; | ||||||
|  |          | ||||||
|  |         $this->data[$name]->label = $name; | ||||||
|  |         $this->data[$name]->palette = $this->chart->palette; | ||||||
|  |         $this->data[$name]->displayType = $this->chart->getDefaultDisplayType(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the given offset exists. | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array. | ||||||
|  |      *  | ||||||
|  |      * @param string $key Identifier of dataset. | ||||||
|  |      * @return bool True when the offset exists, otherwise false. | ||||||
|  |      */ | ||||||
|  |     public function offsetExists( $key ) | ||||||
|  |     { | ||||||
|  |         return isset( $this->data[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the element with the given offset.  | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array.  | ||||||
|  |      *  | ||||||
|  |      * @param string $key Identifier of dataset. | ||||||
|  |      * @return ezcGraphDataSet | ||||||
|  |      * | ||||||
|  |      * @throws ezcGraphNoSuchDataSetException | ||||||
|  |      *         If no dataset with identifier exists | ||||||
|  |      */ | ||||||
|  |     public function offsetGet( $key ) | ||||||
|  |     { | ||||||
|  |         if ( !isset( $this->data[$key] ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoSuchDataSetException( $key ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $this->data[$key]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set the element with the given offset.  | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array.  | ||||||
|  |      *  | ||||||
|  |      * @param string $key | ||||||
|  |      * @param ezcGraphDataSet $value | ||||||
|  |      * @return void | ||||||
|  |      * | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If supplied value is not an ezcGraphDataSet | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         if ( !$value instanceof ezcGraphDataSet ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseValueException( $key, $value, 'ezcGraphDataSet' ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $this->addDataSet( $key, $value ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Unset the element with the given offset.  | ||||||
|  |      * | ||||||
|  |      * This method is part of the ArrayAccess interface to allow access to the | ||||||
|  |      * data of this object as if it was an array.  | ||||||
|  |      *  | ||||||
|  |      * @param string $key | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function offsetUnset( $key ) | ||||||
|  |     { | ||||||
|  |         if ( !isset( $this->data[$key] ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoSuchDataSetException( $key ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         unset( $this->data[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the currently selected dataset. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return ezcGraphDataSet The currently selected dataset. | ||||||
|  |      */ | ||||||
|  |     public function current() | ||||||
|  |     { | ||||||
|  |         return current( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the next dataset and selects it or false on the last dataset. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return mixed ezcGraphDataSet if the next dataset exists, or false. | ||||||
|  |      */ | ||||||
|  |     public function next() | ||||||
|  |     { | ||||||
|  |         return next( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the key of the currently selected dataset. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return int The key of the currently selected dataset. | ||||||
|  |      */ | ||||||
|  |     public function key() | ||||||
|  |     { | ||||||
|  |         return key( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the current dataset is valid. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return bool If the current dataset is valid | ||||||
|  |      */ | ||||||
|  |     public function valid() | ||||||
|  |     { | ||||||
|  |         return ( current( $this->data ) !== false ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Selects the very first dataset and returns it. | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datasets of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return ezcGraphDataSet The very first dataset. | ||||||
|  |      */ | ||||||
|  |     public function rewind() | ||||||
|  |     { | ||||||
|  |         return reset( $this->data ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the number of datasets in the row. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Countable interface to allow the usage of | ||||||
|  |      * PHP's count() function to check how many datasets exist. | ||||||
|  |      * | ||||||
|  |      * @return int Number of datasets. | ||||||
|  |      */ | ||||||
|  |     public function count() | ||||||
|  |     { | ||||||
|  |         return count( $this->data ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										51
									
								
								src/TUnit/external/ezc/Graph/data_container/single.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/TUnit/external/ezc/Graph/data_container/single.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,51 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphChartSingleDataContainer class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Container class for datasets, which ensures, that only one dataset is used. | ||||||
|  |  * Needed for pie charts which can only display one dataset. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | class ezcGraphChartSingleDataContainer extends ezcGraphChartDataContainer  | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Adds a dataset to the charts data | ||||||
|  |      *  | ||||||
|  |      * @param string $name | ||||||
|  |      * @param ezcGraphDataSet $dataSet | ||||||
|  |      * @throws ezcGraphTooManyDataSetExceptions | ||||||
|  |      *          If too many datasets are created | ||||||
|  |      * @return ezcGraphDataSet | ||||||
|  |      */ | ||||||
|  |     protected function addDataSet( $name, ezcGraphDataSet $dataSet ) | ||||||
|  |     { | ||||||
|  |         if ( count( $this->data ) >= 1 && | ||||||
|  |              !isset( $this->data[$name] ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphTooManyDataSetsExceptions( $name ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             parent::addDataSet( $name, $dataSet ); | ||||||
|  | 
 | ||||||
|  |             // Resette palette color counter
 | ||||||
|  |             $this->chart->palette->resetColorCounter(); | ||||||
|  | 
 | ||||||
|  |             // Colorize each data element
 | ||||||
|  |             foreach ( $this->data[$name] as $label => $value ) | ||||||
|  |             { | ||||||
|  |                 $this->data[$name]->color[$label] = $this->chart->palette->dataSetColor; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										71
									
								
								src/TUnit/external/ezc/Graph/datasets/array.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								src/TUnit/external/ezc/Graph/datasets/array.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphArrayDataSet class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Dataset class which receives arrays and use them as a base for datasets. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphArrayDataSet extends ezcGraphDataSet | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array|Iterator $data Array or Iterator containing the data | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __construct( $data ) | ||||||
|  |     { | ||||||
|  |         $this->createFromArray( $data ); | ||||||
|  |         parent::__construct(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * setData | ||||||
|  |      * | ||||||
|  |      * Can handle data provided through an array or iterator. | ||||||
|  |      *  | ||||||
|  |      * @param array|Iterator $data  | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function createFromArray( $data = array() )  | ||||||
|  |     { | ||||||
|  |         if ( !is_array( $data ) &&  | ||||||
|  |              !( $data instanceof Traversable ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphInvalidArrayDataSourceException( $data ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->data = array(); | ||||||
|  |         foreach ( $data as $key => $value ) | ||||||
|  |         { | ||||||
|  |             $this->data[$key] = $value; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( !count( $this->data ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphInvalidDataException( 'Data sets should contain some values.' ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the number of elements in this dataset | ||||||
|  |      *  | ||||||
|  |      * @return int | ||||||
|  |      */ | ||||||
|  |     public function count() | ||||||
|  |     { | ||||||
|  |         return count( $this->data ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										359
									
								
								src/TUnit/external/ezc/Graph/datasets/average.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										359
									
								
								src/TUnit/external/ezc/Graph/datasets/average.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,359 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphDataSetAverage class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Extension of basic dataset to represent averation. | ||||||
|  |  * Algorithm: http://en.wikipedia.org/wiki/Least_squares | ||||||
|  |  * | ||||||
|  |  * @property int $polynomOrder | ||||||
|  |  *           Maximum order of polygon to interpolate from points | ||||||
|  |  * @property int $resolution | ||||||
|  |  *           Resolution used to draw line in graph | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphDataSetAveragePolynom extends ezcGraphDataSet  | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Source dataset to base averation on. | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphDataSet | ||||||
|  |      */ | ||||||
|  |     protected $source; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculated averation polynom | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphPolynom | ||||||
|  |      */ | ||||||
|  |     protected $polynom = false; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Minimum key | ||||||
|  |      *  | ||||||
|  |      * @var float | ||||||
|  |      */ | ||||||
|  |     protected $min = false; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Maximum key | ||||||
|  |      *  | ||||||
|  |      * @var float | ||||||
|  |      */ | ||||||
|  |     protected $max = false; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Position of the data iterator. Depends on the configured resolution. | ||||||
|  |      *  | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     protected $position = 0; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Container to hold the properties | ||||||
|  |      * | ||||||
|  |      * @var array(string=>mixed) | ||||||
|  |      */ | ||||||
|  |     protected $properties; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphDataSet $dataset Dataset to interpolate | ||||||
|  |      * @param int $order Maximum order of interpolating polynom | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( ezcGraphDataSet $dataset, $order = 3 ) | ||||||
|  |     { | ||||||
|  |         parent::__construct(); | ||||||
|  | 
 | ||||||
|  |         $this->properties['resolution'] = 100; | ||||||
|  |         $this->properties['polynomOrder'] = (int) $order; | ||||||
|  | 
 | ||||||
|  |         $this->source = $dataset; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Options write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param mixed $propertyName   Option name | ||||||
|  |      * @param mixed $propertyValue  Option value; | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue )  | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) { | ||||||
|  |             case 'polynomOrder': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['polynomOrder'] = (int) $propertyValue; | ||||||
|  |                 $this->polynom = false; | ||||||
|  |                 break; | ||||||
|  |             case 'resolution': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['resolution'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property get access. | ||||||
|  |      * Simply returns a given option. | ||||||
|  |      *  | ||||||
|  |      * @param string $propertyName The name of the option to get. | ||||||
|  |      * @return mixed The option value. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         if ( array_key_exists( $propertyName, $this->properties ) ) | ||||||
|  |         { | ||||||
|  |             return $this->properties[$propertyName]; | ||||||
|  |         } | ||||||
|  |         return parent::__get( $propertyName ); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Build the polynom based on the given points. | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function buildPolynom() | ||||||
|  |     { | ||||||
|  |         $points = array(); | ||||||
|  | 
 | ||||||
|  |         foreach ( $this->source as $key => $value ) | ||||||
|  |         { | ||||||
|  |             if ( !is_numeric( $key ) ) | ||||||
|  |             { | ||||||
|  |                 throw new ezcGraphDatasetAverageInvalidKeysException(); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( ( $this->min === false ) || ( $this->min > $key ) ) | ||||||
|  |             { | ||||||
|  |                 $this->min = (float) $key; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( ( $this->max === false ) || ( $this->max < $key ) ) | ||||||
|  |             { | ||||||
|  |                 $this->max = (float) $key; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $points[] = new ezcGraphCoordinate( (float) $key, (float) $value ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Build transposed and normal Matrix out of coordiantes
 | ||||||
|  |         $a = new ezcGraphMatrix( count( $points ), $this->polynomOrder + 1 ); | ||||||
|  |         $b = new ezcGraphMatrix( count( $points ), 1 ); | ||||||
|  | 
 | ||||||
|  |         for ( $i = 0; $i <= $this->properties['polynomOrder']; ++$i ) | ||||||
|  |         { | ||||||
|  |             foreach ( $points as $nr => $point ) | ||||||
|  |             { | ||||||
|  |                 $a->set( $nr, $i, pow( $point->x, $i ) ); | ||||||
|  |                 $b->set( $nr, 0, $point->y ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $at = clone $a; | ||||||
|  |         $at->transpose(); | ||||||
|  |          | ||||||
|  |         $left = $at->multiply( $a ); | ||||||
|  |         $right = $at->multiply( $b ); | ||||||
|  | 
 | ||||||
|  |         $this->polynom = $left->solveNonlinearEquatation( $right ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns a polynom of the defined order witch matches the datapoints | ||||||
|  |      * using the least squares algorithm. | ||||||
|  |      *  | ||||||
|  |      * @return ezcGraphPolynom Polynom | ||||||
|  |      */ | ||||||
|  |     public function getPolynom() | ||||||
|  |     { | ||||||
|  |         if ( $this->polynom === false ) | ||||||
|  |         { | ||||||
|  |             $this->buildPolynom(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $this->polynom; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get the x coordinate for the current position | ||||||
|  |      *  | ||||||
|  |      * @param int $position Position | ||||||
|  |      * @return float x coordinate | ||||||
|  |      */ | ||||||
|  |     protected function getKey() | ||||||
|  |     { | ||||||
|  |         $polynom = $this->getPolynom(); | ||||||
|  |         return $this->min + | ||||||
|  |             ( $this->max - $this->min ) / $this->resolution * $this->position; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Returns true if the given datapoint exists | ||||||
|  |      * Allows isset() using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The key of the datapoint to get. | ||||||
|  |      * @return bool Wether the key exists. | ||||||
|  |      */ | ||||||
|  |     public function offsetExists( $key ) | ||||||
|  |     { | ||||||
|  |         $polynom = $this->getPolynom(); | ||||||
|  |         return ( ( $key >= $this->min ) && ( $key <= $this->max ) ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the value for the given datapoint | ||||||
|  |      * Get an datapoint value by ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The key of the datapoint to get. | ||||||
|  |      * @return float The datapoint value. | ||||||
|  |      */ | ||||||
|  |     public function offsetGet( $key ) | ||||||
|  |     { | ||||||
|  |         $polynom = $this->getPolynom(); | ||||||
|  |         return $polynom->evaluate( $key ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Throws a ezcBasePropertyPermissionException because single datapoints | ||||||
|  |      * cannot be set in average datasets. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The kex of a datapoint to set. | ||||||
|  |      * @param float $value The value for the datapoint. | ||||||
|  |      * @throws ezcBasePropertyPermissionException | ||||||
|  |      *         Always, because access is readonly. | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         throw new ezcBasePropertyPermissionException( $key, ezcBasePropertyPermissionException::READ ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the currently selected datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return string The currently selected datapoint. | ||||||
|  |      */ | ||||||
|  |     final public function current() | ||||||
|  |     { | ||||||
|  |         $polynom = $this->getPolynom(); | ||||||
|  |         return $polynom->evaluate( $this->getKey() ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the next datapoint and selects it or false on the last datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return float datapoint if it exists, or false. | ||||||
|  |      */ | ||||||
|  |     final public function next() | ||||||
|  |     { | ||||||
|  |         if ( ++$this->position >= $this->resolution ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             return $this->current(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the key of the currently selected datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return string The key of the currently selected datapoint. | ||||||
|  |      */ | ||||||
|  |     final public function key() | ||||||
|  |     { | ||||||
|  |         return (string) $this->getKey(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the current datapoint is valid. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return bool If the current datapoint is valid | ||||||
|  |      */ | ||||||
|  |     final public function valid() | ||||||
|  |     { | ||||||
|  |         $polynom = $this->getPolynom(); | ||||||
|  | 
 | ||||||
|  |         if ( $this->min >= $this->max ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return ( ( $this->getKey() >= $this->min ) && ( $this->getKey() <= $this->max ) ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Selects the very first datapoint and returns it. | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return float The very first datapoint. | ||||||
|  |      */ | ||||||
|  |     final public function rewind() | ||||||
|  |     { | ||||||
|  |         $this->position = 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the number of elements in this dataset | ||||||
|  |      *  | ||||||
|  |      * @return int | ||||||
|  |      */ | ||||||
|  |     public function count() | ||||||
|  |     { | ||||||
|  |         return $this->resolution; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										302
									
								
								src/TUnit/external/ezc/Graph/datasets/base.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										302
									
								
								src/TUnit/external/ezc/Graph/datasets/base.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,302 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSet class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  * @access private | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Basic class to contain the charts data | ||||||
|  |  * | ||||||
|  |  * @property string $label | ||||||
|  |  *           Labels for datapoint and datapoint elements | ||||||
|  |  * @property ezcGraphColor $color | ||||||
|  |  *           Colors for datapoint elements | ||||||
|  |  * @property int $symbol | ||||||
|  |  *           Symbols for datapoint elements | ||||||
|  |  * @property string $highlightValue | ||||||
|  |  *           Displayed string if a data point is highlighted | ||||||
|  |  * @property bool $highlight | ||||||
|  |  *           Status if datapoint element is hilighted | ||||||
|  |  * @property int $displayType | ||||||
|  |  *           Display type of chart data | ||||||
|  |  * @property string $url | ||||||
|  |  *           URL associated with datapoint | ||||||
|  |  * @property ezcGraphChartElementAxis $xAxis | ||||||
|  |  *           Associate dataset with a different X axis then the default one | ||||||
|  |  * @property ezcGraphChartElementAxis $yAxis | ||||||
|  |  *           Associate dataset with a different Y axis then the default one | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property array | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $properties; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Array which contains the data of the datapoint | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $data; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Current datapoint element | ||||||
|  |      * needed for iteration over datapoint with ArrayAccess | ||||||
|  |      *  | ||||||
|  |      * @var mixed | ||||||
|  |      */ | ||||||
|  |     protected $current; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Color palette used for datapoint colorization | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphPalette | ||||||
|  |      */ | ||||||
|  |     protected $pallet; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Array keys | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $keys; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         $this->properties['label'] = new ezcGraphDataSetStringProperty( $this ); | ||||||
|  |         $this->properties['color'] = new ezcGraphDataSetColorProperty( $this ); | ||||||
|  |         $this->properties['symbol'] = new ezcGraphDataSetIntProperty( $this ); | ||||||
|  |         $this->properties['lineThickness'] = new ezcGraphDataSetIntProperty( $this ); | ||||||
|  |         $this->properties['highlight'] = new ezcGraphDataSetBooleanProperty( $this ); | ||||||
|  |         $this->properties['highlightValue'] = new ezcGraphDataSetStringProperty( $this ); | ||||||
|  |         $this->properties['displayType'] = new ezcGraphDataSetIntProperty( $this ); | ||||||
|  |         $this->properties['url'] = new ezcGraphDataSetStringProperty( $this ); | ||||||
|  | 
 | ||||||
|  |         $this->properties['xAxis'] = new ezcGraphDataSetAxisProperty( $this ); | ||||||
|  |         $this->properties['yAxis'] = new ezcGraphDataSetAxisProperty( $this ); | ||||||
|  | 
 | ||||||
|  |         $this->properties['highlight']->default = false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Options write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param mixed $propertyName   Option name | ||||||
|  |      * @param mixed $propertyValue  Option value; | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'hilight': | ||||||
|  |                 $propertyName = 'highlight'; | ||||||
|  |             case 'label': | ||||||
|  |             case 'url': | ||||||
|  |             case 'color': | ||||||
|  |             case 'symbol': | ||||||
|  |             case 'lineThickness': | ||||||
|  |             case 'highlight': | ||||||
|  |             case 'highlightValue': | ||||||
|  |             case 'displayType': | ||||||
|  |             case 'xAxis': | ||||||
|  |             case 'yAxis': | ||||||
|  |                 $this->properties[$propertyName]->default = $propertyValue; | ||||||
|  |                 break; | ||||||
|  | 
 | ||||||
|  |             case 'palette': | ||||||
|  |                 $this->palette = $propertyValue; | ||||||
|  |                 $this->color->default = $this->palette->dataSetColor; | ||||||
|  |                 $this->symbol->default = $this->palette->dataSetSymbol; | ||||||
|  |                 break; | ||||||
|  | 
 | ||||||
|  |             default: | ||||||
|  |                 throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property get access. | ||||||
|  |      * Simply returns a given option. | ||||||
|  |      *  | ||||||
|  |      * @param string $propertyName The name of the option to get. | ||||||
|  |      * @return mixed The option value. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         if ( array_key_exists( $propertyName, $this->properties ) ) | ||||||
|  |         { | ||||||
|  |             return $this->properties[$propertyName]; | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Returns true if the given datapoint exists | ||||||
|  |      * Allows isset() using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The key of the datapoint to get. | ||||||
|  |      * @return bool Wether the key exists. | ||||||
|  |      */ | ||||||
|  |     public function offsetExists( $key ) | ||||||
|  |     { | ||||||
|  |         return isset( $this->data[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the value for the given datapoint | ||||||
|  |      * Get an datapoint value by ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The key of the datapoint to get. | ||||||
|  |      * @return float The datapoint value. | ||||||
|  |      */ | ||||||
|  |     public function offsetGet( $key ) | ||||||
|  |     { | ||||||
|  |         return $this->data[$key]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Sets the value for a datapoint. | ||||||
|  |      * Sets an datapoint using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The kex of a datapoint to set. | ||||||
|  |      * @param float $value The value for the datapoint. | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         $this->data[$key] = (float) $value; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Unset an option. | ||||||
|  |      * Unsets an option using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The options to unset. | ||||||
|  |      * @return void | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If a the value for a property is out of range. | ||||||
|  |      */ | ||||||
|  |     public function offsetUnset( $key ) | ||||||
|  |     { | ||||||
|  |         unset( $this->data[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the currently selected datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return string The currently selected datapoint. | ||||||
|  |      */ | ||||||
|  |     public function current() | ||||||
|  |     { | ||||||
|  |         if ( !isset( $this->current ) ) | ||||||
|  |         { | ||||||
|  |             $this->keys    = array_keys( $this->data ); | ||||||
|  |             $this->current = 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $this->data[$this->keys[$this->current]]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the next datapoint and selects it or false on the last datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return float datapoint if it exists, or false. | ||||||
|  |      */ | ||||||
|  |     public function next() | ||||||
|  |     { | ||||||
|  |         if ( ++$this->current >= count( $this->keys ) ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             return $this->data[$this->keys[$this->current]]; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the key of the currently selected datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return string The key of the currently selected datapoint. | ||||||
|  |      */ | ||||||
|  |     public function key() | ||||||
|  |     { | ||||||
|  |         return $this->keys[$this->current]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the current datapoint is valid. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return bool If the current datapoint is valid | ||||||
|  |      */ | ||||||
|  |     public function valid() | ||||||
|  |     { | ||||||
|  |         return isset( $this->keys[$this->current] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Selects the very first datapoint and returns it. | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return float The very first datapoint. | ||||||
|  |      */ | ||||||
|  |     public function rewind() | ||||||
|  |     { | ||||||
|  |         $this->keys    = array_keys( $this->data ); | ||||||
|  |         $this->current = 0; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										287
									
								
								src/TUnit/external/ezc/Graph/datasets/numeric.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										287
									
								
								src/TUnit/external/ezc/Graph/datasets/numeric.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,287 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphNumericDataSet class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Dataset for numeric data. | ||||||
|  |  * | ||||||
|  |  * Uses user defined functions for numeric data creation | ||||||
|  |  * | ||||||
|  |  * @property float $start | ||||||
|  |  *           Start value for x axis values of function
 | ||||||
|  |  * @property float $end | ||||||
|  |  *           End value for x axis values of function
 | ||||||
|  |  * @property callback $callback | ||||||
|  |  *           Callback function which represents the mathmatical function to  | ||||||
|  |  *           show | ||||||
|  |  * @property int $resolution | ||||||
|  |  *           Steps used to draw line in graph | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphNumericDataSet extends ezcGraphDataSet  | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Position of the data iterator. Depends on the configured resolution. | ||||||
|  |      *  | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     protected $position = 0; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Container to hold the properties | ||||||
|  |      * | ||||||
|  |      * @var array(string=>mixed) | ||||||
|  |      */ | ||||||
|  |     protected $properties; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param float $start Start value for x axis values of function
 | ||||||
|  |      * @param float $end End value for x axis values of function
 | ||||||
|  |      * @param callback $callback Callback function
 | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $start = null, $end = null, $callback = null ) | ||||||
|  |     { | ||||||
|  |         parent::__construct(); | ||||||
|  | 
 | ||||||
|  |         $this->properties['start'] = null; | ||||||
|  |         $this->properties['end'] = null; | ||||||
|  |         $this->properties['callback'] = null; | ||||||
|  | 
 | ||||||
|  |         if ( $start !== null ) | ||||||
|  |         { | ||||||
|  |             $this->start = $start; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $end !== null ) | ||||||
|  |         { | ||||||
|  |             $this->end = $end; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $callback !== null ) | ||||||
|  |         { | ||||||
|  |             $this->callback = $callback; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->properties['resolution'] = 100; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Options write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param mixed $propertyName   Option name | ||||||
|  |      * @param mixed $propertyValue  Option value; | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue )  | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) { | ||||||
|  |             case 'resolution': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['resolution'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'start': | ||||||
|  |             case 'end': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties[$propertyName] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'callback': | ||||||
|  |                 if ( !is_callable( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'callback' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties[$propertyName] = $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Property get access. | ||||||
|  |      * Simply returns a given option. | ||||||
|  |      *  | ||||||
|  |      * @param string $propertyName The name of the option to get. | ||||||
|  |      * @return mixed The option value. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         if ( array_key_exists( $propertyName, $this->properties ) ) | ||||||
|  |         { | ||||||
|  |             return $this->properties[$propertyName]; | ||||||
|  |         } | ||||||
|  |         return parent::__get( $propertyName ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get the x coordinate for the current position | ||||||
|  |      *  | ||||||
|  |      * @param int $position Position | ||||||
|  |      * @return float x coordinate | ||||||
|  |      */ | ||||||
|  |     protected function getKey() | ||||||
|  |     { | ||||||
|  |         return $this->start + | ||||||
|  |             ( $this->end - $this->start ) / $this->resolution * $this->position; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Returns true if the given datapoint exists | ||||||
|  |      * Allows isset() using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The key of the datapoint to get. | ||||||
|  |      * @return bool Wether the key exists. | ||||||
|  |      */ | ||||||
|  |     public function offsetExists( $key ) | ||||||
|  |     { | ||||||
|  |         return ( ( $key >= $this->start ) && ( $key <= $this->end ) ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the value for the given datapoint | ||||||
|  |      * Get an datapoint value by ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The key of the datapoint to get. | ||||||
|  |      * @return float The datapoint value. | ||||||
|  |      */ | ||||||
|  |     public function offsetGet( $key ) | ||||||
|  |     { | ||||||
|  |         return call_user_func( $this->callback, $key ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Throws a ezcBasePropertyPermissionException because single datapoints | ||||||
|  |      * cannot be set in average datasets. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The kex of a datapoint to set. | ||||||
|  |      * @param float $value The value for the datapoint. | ||||||
|  |      * @throws ezcBasePropertyPermissionException | ||||||
|  |      *         Always, because access is readonly. | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         throw new ezcBasePropertyPermissionException( $key, ezcBasePropertyPermissionException::READ ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the currently selected datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return string The currently selected datapoint. | ||||||
|  |      */ | ||||||
|  |     final public function current() | ||||||
|  |     { | ||||||
|  |         return call_user_func( $this->callback, $this->getKey() ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the next datapoint and selects it or false on the last datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return float datapoint if it exists, or false. | ||||||
|  |      */ | ||||||
|  |     final public function next() | ||||||
|  |     { | ||||||
|  |         if ( $this->start === $this->end ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphDatasetAverageInvalidKeysException(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( ++$this->position >= $this->resolution ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             return $this->current(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the key of the currently selected datapoint. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      *  | ||||||
|  |      * @return string The key of the currently selected datapoint. | ||||||
|  |      */ | ||||||
|  |     final public function key() | ||||||
|  |     { | ||||||
|  |         return (string) $this->getKey(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if the current datapoint is valid. | ||||||
|  |      * | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return bool If the current datapoint is valid | ||||||
|  |      */ | ||||||
|  |     final public function valid() | ||||||
|  |     { | ||||||
|  |         return ( ( $this->getKey() >= $this->start ) && ( $this->getKey() <= $this->end ) ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Selects the very first datapoint and returns it. | ||||||
|  |      * This method is part of the Iterator interface to allow access to the  | ||||||
|  |      * datapoints of this row by iterating over it like an array (e.g. using | ||||||
|  |      * foreach). | ||||||
|  |      * | ||||||
|  |      * @return float The very first datapoint. | ||||||
|  |      */ | ||||||
|  |     final public function rewind() | ||||||
|  |     { | ||||||
|  |         $this->position = 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the number of elements in this dataset | ||||||
|  |      *  | ||||||
|  |      * @return int | ||||||
|  |      */ | ||||||
|  |     public function count() | ||||||
|  |     { | ||||||
|  |         return $this->resolution + 1; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										62
									
								
								src/TUnit/external/ezc/Graph/datasets/property/axis.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								src/TUnit/external/ezc/Graph/datasets/property/axis.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,62 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSetIntProperty class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for axis properties of datasets | ||||||
|  |  * | ||||||
|  |  * This class is used to store properties for datasets, which should be | ||||||
|  |  * validated as objects extending the ezcGraphChartElementAxis class. | ||||||
|  |  * | ||||||
|  |  * For a basic usage example of those dataset properties take a look at the API | ||||||
|  |  * documentation of the ezcGraphDataSetProperty class. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphDataSetAxisProperty extends ezcGraphDataSetProperty | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Chacks if value is really an axis | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphChartElementAxis $value  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function checkValue( &$value ) | ||||||
|  |     { | ||||||
|  |        if ( ! $value instanceof ezcGraphChartElementAxis ) | ||||||
|  |        { | ||||||
|  |            throw new ezcBaseValueException( 'default', $value, 'ezcGraphChartElementAxis' ); | ||||||
|  |        } | ||||||
|  | 
 | ||||||
|  |        return true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set an option. | ||||||
|  |      * | ||||||
|  |      * Sets an option using ArrayAccess. | ||||||
|  |      * | ||||||
|  |      * This is deaktivated, because you need not set a different axis for some | ||||||
|  |      * data point. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The option to set. | ||||||
|  |      * @param mixed $value The value for the option. | ||||||
|  |      * @return void | ||||||
|  |      * | ||||||
|  |      * @throws ezcGraphInvalidAssignementException | ||||||
|  |      *         Always | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         throw new ezcGraphInvalidAssignementException(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/boolean.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/boolean.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSetBooleanProperty class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for boolean properties of datasets | ||||||
|  |  * | ||||||
|  |  * This class is used to store properties for datasets, which should be | ||||||
|  |  * validated as boolean values. | ||||||
|  |  * | ||||||
|  |  * For a basic usage example of those dataset properties take a look at the API | ||||||
|  |  * documentation of the ezcGraphDataSetProperty class. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphDataSetBooleanProperty extends ezcGraphDataSetProperty | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Converts value to an {@link ezcGraphColor} object | ||||||
|  |      *  | ||||||
|  |      * @param & $value  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function checkValue( &$value ) | ||||||
|  |     { | ||||||
|  |         $value = (bool) $value; | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/color.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/color.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSetColorProperty class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for color properties of datasets | ||||||
|  |  * | ||||||
|  |  * This class is used to store properties for datasets, which should be | ||||||
|  |  * validated as objects extending the ezcGraphColor class. | ||||||
|  |  * | ||||||
|  |  * For a basic usage example of those dataset properties take a look at the API | ||||||
|  |  * documentation of the ezcGraphDataSetProperty class. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphDataSetColorProperty extends ezcGraphDataSetProperty | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Converts value to an {@link ezcGraphColor} object | ||||||
|  |      *  | ||||||
|  |      * @param & $value  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function checkValue( &$value ) | ||||||
|  |     { | ||||||
|  |         $value = ezcGraphColor::create( $value ); | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/integer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/integer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSetIntProperty class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for integer properties of datasets | ||||||
|  |  * | ||||||
|  |  * This class is used to store properties for datasets, which should be | ||||||
|  |  * validated as integer values. | ||||||
|  |  * | ||||||
|  |  * For a basic usage example of those dataset properties take a look at the API | ||||||
|  |  * documentation of the ezcGraphDataSetProperty class. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphDataSetIntProperty extends ezcGraphDataSetProperty | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Converts value to an {@link ezcGraphColor} object | ||||||
|  |      *  | ||||||
|  |      * @param & $value  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function checkValue( &$value ) | ||||||
|  |     { | ||||||
|  |         $value = (int) $value; | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/string.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/TUnit/external/ezc/Graph/datasets/property/string.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSetStringProperty class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class for string properties of datasets | ||||||
|  |  * | ||||||
|  |  * This class is used to store properties for datasets, which should be | ||||||
|  |  * validated as string values. | ||||||
|  |  * | ||||||
|  |  * For a basic usage example of those dataset properties take a look at the API | ||||||
|  |  * documentation of the ezcGraphDataSetProperty class. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraphDataSetStringProperty extends ezcGraphDataSetProperty | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Converts value to an {@link ezcGraphColor} object | ||||||
|  |      *  | ||||||
|  |      * @param & $value  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function checkValue( &$value ) | ||||||
|  |     { | ||||||
|  |         $value = (string) $value; | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										1010
									
								
								src/TUnit/external/ezc/Graph/driver/cairo.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1010
									
								
								src/TUnit/external/ezc/Graph/driver/cairo.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										972
									
								
								src/TUnit/external/ezc/Graph/driver/flash.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										972
									
								
								src/TUnit/external/ezc/Graph/driver/flash.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,972 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphFlashDriver class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Driver to create Flash4 (SWF) files as graph output. The options of this | ||||||
|  |  * class are defined in The options of this class are defined in the option | ||||||
|  |  * class {@link ezcGraphFlashDriverOptions} extending the basic | ||||||
|  |  * {@link ezcGraphDriverOptions}. | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *   $graph = new ezcGraphPieChart(); | ||||||
|  |  *   $graph->title = 'Access statistics'; | ||||||
|  |  *   $graph->legend = false; | ||||||
|  |  *    | ||||||
|  |  *   $graph->driver = new ezcGraphFlashDriver(); | ||||||
|  |  *   $graph->options->font = 'tutorial_font.fdb'; | ||||||
|  |  *    | ||||||
|  |  *   $graph->driver->options->compression = 7; | ||||||
|  |  *    | ||||||
|  |  *   $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *       'Mozilla' => 19113, | ||||||
|  |  *       'Explorer' => 10917, | ||||||
|  |  *       'Opera' => 1464, | ||||||
|  |  *       'Safari' => 652, | ||||||
|  |  *       'Konqueror' => 474, | ||||||
|  |  *   ) ); | ||||||
|  |  *    | ||||||
|  |  *   $graph->render( 400, 200, 'tutorial_driver_flash.swf' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphFlashDriver extends ezcGraphDriver | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Flash movie | ||||||
|  |      *  | ||||||
|  |      * @var SWFMovie | ||||||
|  |      */ | ||||||
|  |     protected $movie; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Unique element id | ||||||
|  |      *  | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     protected $id = 1; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Array with strings to draw later | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $strings = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         ezcBase::checkDependency( 'Graph', ezcBase::DEP_PHP_EXTENSION, 'ming' ); | ||||||
|  |         $this->options = new ezcGraphFlashDriverOptions( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns unique movie object as a parent canvas for all swf objects. | ||||||
|  |      *  | ||||||
|  |      * @return SWFMovie | ||||||
|  |      */ | ||||||
|  |     public function getDocument() | ||||||
|  |     { | ||||||
|  |         if ( $this->movie === null ) | ||||||
|  |         { | ||||||
|  |             ming_setscale( 1.0 ); | ||||||
|  |             $this->movie = new SWFMovie(); | ||||||
|  |             $this->movie->setDimension( $this->modifyCoordinate( $this->options->width ), $this->modifyCoordinate( $this->options->height ) ); | ||||||
|  |             $this->movie->setRate( 1 ); | ||||||
|  |             $this->movie->setBackground( 255, 255, 255 ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $this->movie; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set the fill and line properties for a SWWFShape according to the  | ||||||
|  |      * given parameters. | ||||||
|  |      *  | ||||||
|  |      * @param SWFShape $shape | ||||||
|  |      * @param ezcGraphColor $color  | ||||||
|  |      * @param mixed $thickness  | ||||||
|  |      * @param mixed $filled  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function setShapeColor( SWFShape $shape, ezcGraphColor $color, $thickness, $filled ) | ||||||
|  |     { | ||||||
|  |         if ( $filled ) | ||||||
|  |         { | ||||||
|  |             switch ( true ) | ||||||
|  |             { | ||||||
|  |                 case ( $color instanceof ezcGraphLinearGradient ): | ||||||
|  |                     $gradient = new SWFGradient(); | ||||||
|  |                     $gradient->addEntry(  | ||||||
|  |                         0,  | ||||||
|  |                         $color->startColor->red,  | ||||||
|  |                         $color->startColor->green,  | ||||||
|  |                         $color->startColor->blue,  | ||||||
|  |                         255 - $color->startColor->alpha  | ||||||
|  |                     ); | ||||||
|  |                     $gradient->addEntry(  | ||||||
|  |                         1,  | ||||||
|  |                         $color->endColor->red,  | ||||||
|  |                         $color->endColor->green,  | ||||||
|  |                         $color->endColor->blue,  | ||||||
|  |                         255 - $color->endColor->alpha  | ||||||
|  |                     ); | ||||||
|  | 
 | ||||||
|  |                     $fill = $shape->addFill( $gradient, SWFFILL_LINEAR_GRADIENT ); | ||||||
|  | 
 | ||||||
|  |                     // Calculate desired length of gradient
 | ||||||
|  |                     $length = sqrt(  | ||||||
|  |                         pow( $color->endPoint->x - $color->startPoint->x, 2 ) +  | ||||||
|  |                         pow( $color->endPoint->y - $color->startPoint->y, 2 )  | ||||||
|  |                     );  | ||||||
|  | 
 | ||||||
|  |                     $fill->scaleTo( $this->modifyCoordinate( $length ) / 32768 , $this->modifyCoordinate( $length ) / 32768 ); | ||||||
|  |                     $fill->rotateTo(  | ||||||
|  |                         rad2deg( asin(  | ||||||
|  |                             ( $color->endPoint->x - $color->startPoint->x ) / $length | ||||||
|  |                         ) + 180 ) | ||||||
|  |                     ); | ||||||
|  |                     $fill->moveTo(  | ||||||
|  |                         $this->modifyCoordinate(  | ||||||
|  |                             ( $color->startPoint->x + $color->endPoint->x ) / 2  | ||||||
|  |                         ),  | ||||||
|  |                         $this->modifyCoordinate(  | ||||||
|  |                             ( $color->startPoint->y + $color->endPoint->y ) / 2  | ||||||
|  |                         ) | ||||||
|  |                     ); | ||||||
|  | 
 | ||||||
|  |                     $shape->setLeftFill( $fill ); | ||||||
|  |                     break; | ||||||
|  |                 case ( $color instanceof ezcGraphRadialGradient ): | ||||||
|  |                     $gradient = new SWFGradient(); | ||||||
|  |                     $gradient->addEntry(  | ||||||
|  |                         0,  | ||||||
|  |                         $color->startColor->red,  | ||||||
|  |                         $color->startColor->green,  | ||||||
|  |                         $color->startColor->blue,  | ||||||
|  |                         255 - $color->startColor->alpha  | ||||||
|  |                     ); | ||||||
|  |                     $gradient->addEntry(  | ||||||
|  |                         1,  | ||||||
|  |                         $color->endColor->red,  | ||||||
|  |                         $color->endColor->green,  | ||||||
|  |                         $color->endColor->blue,  | ||||||
|  |                         255 - $color->endColor->alpha  | ||||||
|  |                     ); | ||||||
|  | 
 | ||||||
|  |                     $fill = $shape->addFill( $gradient, SWFFILL_RADIAL_GRADIENT ); | ||||||
|  | 
 | ||||||
|  |                     $fill->scaleTo( $this->modifyCoordinate( $color->width ) / 32768, $this->modifyCoordinate( $color->height ) / 32768 ); | ||||||
|  |                     $fill->moveTo( $this->modifyCoordinate( $color->center->x ), $this->modifyCoordinate( $color->center->y ) ); | ||||||
|  | 
 | ||||||
|  |                     $shape->setLeftFill( $fill ); | ||||||
|  |                     break; | ||||||
|  |                 default: | ||||||
|  |                     $fill = $shape->addFill( $color->red, $color->green, $color->blue, 255 - $color->alpha ); | ||||||
|  |                     $shape->setLeftFill( $fill ); | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $shape->setLine( $this->modifyCoordinate( $thickness ), $color->red, $color->green, $color->blue, 255 - $color->alpha ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Modifies a coordinate value, as flash usally uses twips instead of  | ||||||
|  |      * pixels for a higher solution, as it only accepts integer values. | ||||||
|  |      *  | ||||||
|  |      * @param float $pointValue  | ||||||
|  |      * @return float | ||||||
|  |      */ | ||||||
|  |     protected function modifyCoordinate( $pointValue ) | ||||||
|  |     { | ||||||
|  |         return $pointValue * 10; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Demodifies a coordinate value, as flash usally uses twips instead of  | ||||||
|  |      * pixels for a higher solution, as it only accepts integer values. | ||||||
|  |      *  | ||||||
|  |      * @param float $pointValue  | ||||||
|  |      * @return float | ||||||
|  |      */ | ||||||
|  |     protected function deModifyCoordinate( $pointValue ) | ||||||
|  |     { | ||||||
|  |         return $pointValue / 10; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a single polygon.  | ||||||
|  |      *  | ||||||
|  |      * @param array $points Point array | ||||||
|  |      * @param ezcGraphColor $color Polygon color | ||||||
|  |      * @param mixed $filled Filled | ||||||
|  |      * @param float $thickness Line thickness | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1. ) | ||||||
|  |     { | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  | 
 | ||||||
|  |         if ( !$filled ) | ||||||
|  |         { | ||||||
|  |             // The middle of the border is on the outline of a polygon in ming, 
 | ||||||
|  |             // fix that:
 | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 $points = $this->reducePolygonSize( $points, $thickness / 2 ); | ||||||
|  |             } | ||||||
|  |             catch ( ezcGraphReducementFailedException $e ) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $shape = new SWFShape(); | ||||||
|  | 
 | ||||||
|  |         $this->setShapeColor( $shape, $color, $thickness, $filled ); | ||||||
|  | 
 | ||||||
|  |         $lastPoint = end( $points ); | ||||||
|  |         $shape->movePenTo( $this->modifyCoordinate( $lastPoint->x ), $this->modifyCoordinate( $lastPoint->y ) ); | ||||||
|  | 
 | ||||||
|  |         foreach ( $points as $point ) | ||||||
|  |         { | ||||||
|  |             $shape->drawLineTo( $this->modifyCoordinate( $point->x ), $this->modifyCoordinate( $point->y ) ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $object = $movie->add( $shape ); | ||||||
|  |         $object->setName( $id = 'ezcGraphPolygon_' . $this->id++ ); | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Draws a line  | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $start Start point | ||||||
|  |      * @param ezcGraphCoordinate $end End point | ||||||
|  |      * @param ezcGraphColor $color Line color | ||||||
|  |      * @param float $thickness Line thickness | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color, $thickness = 1. ) | ||||||
|  |     { | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  | 
 | ||||||
|  |         $shape = new SWFShape(); | ||||||
|  | 
 | ||||||
|  |         $this->setShapeColor( $shape, $color, $thickness, false ); | ||||||
|  | 
 | ||||||
|  |         $shape->movePenTo( $this->modifyCoordinate( $start->x ), $this->modifyCoordinate( $start->y ) ); | ||||||
|  |         $shape->drawLineTo( $this->modifyCoordinate( $end->x ), $this->modifyCoordinate( $end->y ) ); | ||||||
|  | 
 | ||||||
|  |         $object = $movie->add( $shape ); | ||||||
|  |         $object->setName( $id = 'ezcGraphLine_' . $this->id++ ); | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns boundings of text depending on the available font extension | ||||||
|  |      *  | ||||||
|  |      * @param float $size Textsize | ||||||
|  |      * @param ezcGraphFontOptions $font Font | ||||||
|  |      * @param string $text Text | ||||||
|  |      * @return ezcGraphBoundings Boundings of text | ||||||
|  |      */ | ||||||
|  |     protected function getTextBoundings( $size, ezcGraphFontOptions $font, $text ) | ||||||
|  |     { | ||||||
|  |         $t = new SWFText(); | ||||||
|  |         $t->setFont( new SWFFont( $font->path ) ); | ||||||
|  |         $t->setHeight( $size ); | ||||||
|  | 
 | ||||||
|  |         $boundings = new ezcGraphBoundings( 0, 0, $t->getWidth( $text ), $size ); | ||||||
|  |          | ||||||
|  |         return $boundings; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Writes text in a box of desired size | ||||||
|  |      *  | ||||||
|  |      * @param string $string Text | ||||||
|  |      * @param ezcGraphCoordinate $position Top left position | ||||||
|  |      * @param float $width Width of text box | ||||||
|  |      * @param float $height Height of text box | ||||||
|  |      * @param int $align Alignement of text | ||||||
|  |      * @param ezcGraphRotation $rotation | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null ) | ||||||
|  |     { | ||||||
|  |         $padding = $this->options->font->padding + ( $this->options->font->border !== false ? $this->options->font->borderWidth : 0 ); | ||||||
|  | 
 | ||||||
|  |         $width = $this->modifyCoordinate( $width - $padding * 2 ); | ||||||
|  |         $height = $this->modifyCoordinate( $height - $padding * 2 ); | ||||||
|  |         $position = new ezcGraphCoordinate( | ||||||
|  |             $this->modifyCoordinate( $position->x + $padding ), | ||||||
|  |             $this->modifyCoordinate( $position->y + $padding ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Try to get a font size for the text to fit into the box
 | ||||||
|  |         $maxSize = $this->modifyCoordinate( min( $height, $this->options->font->maxFontSize ) ); | ||||||
|  |         $minSize = $this->modifyCoordinate( $this->options->font->minFontSize ); | ||||||
|  |         $result = false; | ||||||
|  |         for ( $size = $maxSize; $size >= $minSize; ) | ||||||
|  |         { | ||||||
|  |             $result = $this->testFitStringInTextBox( $string, $position, $width, $height, $size ); | ||||||
|  |             if ( is_array( $result ) ) | ||||||
|  |             { | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |             $size = $this->deModifyCoordinate( $size ); | ||||||
|  |             $size = $this->modifyCoordinate( floor( ( $newsize = $size * ( $result ) ) >= $size ? $size - 1 : $newsize ) ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( !is_array( $result ) ) | ||||||
|  |         { | ||||||
|  |             if ( ( $height >= $this->options->font->minFontSize ) && | ||||||
|  |                  ( $this->options->autoShortenString ) ) | ||||||
|  |             { | ||||||
|  |                 $result = $this->tryFitShortenedString( $string, $position, $width, $height, $size = $this->modifyCoordinate( $this->options->font->minFontSize ) ); | ||||||
|  |             }  | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 throw new ezcGraphFontRenderingException( $string, $this->options->font->minFontSize, $width, $height ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         $this->options->font->minimalUsedFont = $this->deModifyCoordinate( $size ); | ||||||
|  | 
 | ||||||
|  |         $this->strings[] = array( | ||||||
|  |             'text' => $result, | ||||||
|  |             'id' => $id = 'ezcGraphTextBox_' . $this->id++, | ||||||
|  |             'position' => $position, | ||||||
|  |             'width' => $width, | ||||||
|  |             'height' => $height, | ||||||
|  |             'align' => $align, | ||||||
|  |             'font' => $this->options->font, | ||||||
|  |             'rotation' => $rotation, | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Render text depending of font type and available font extensions | ||||||
|  |      *  | ||||||
|  |      * @param string $id  | ||||||
|  |      * @param string $text  | ||||||
|  |      * @param string $chars  | ||||||
|  |      * @param int $type  | ||||||
|  |      * @param string $path  | ||||||
|  |      * @param ezcGraphColor $color  | ||||||
|  |      * @param ezcGraphCoordinate $position  | ||||||
|  |      * @param float $size  | ||||||
|  |      * @param float $rotation  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function renderText( $id, $text, $chars, $type, $path, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null ) | ||||||
|  |     { | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  | 
 | ||||||
|  |         $tb = new SWFTextField( SWFTEXTFIELD_NOEDIT ); | ||||||
|  |         $tb->setFont( new SWFFont( $path ) ); | ||||||
|  |         $tb->setHeight( $size ); | ||||||
|  |         $tb->setColor( $color->red, $color->green, $color->blue, 255 - $color->alpha ); | ||||||
|  |         $tb->addString( $text ); | ||||||
|  |         $tb->addChars( $chars ); | ||||||
|  | 
 | ||||||
|  |         $object = $movie->add( $tb ); | ||||||
|  |         $object->rotate( | ||||||
|  |             ( $rotation !== null ? -$rotation->getRotation() : 0 ) | ||||||
|  |         ); | ||||||
|  |         $object->moveTo(  | ||||||
|  |             $position->x + | ||||||
|  |                 ( $rotation === null ? 0 : $this->modifyCoordinate( $rotation->get( 0, 2 ) ) ), | ||||||
|  |             $position->y - | ||||||
|  |                 $size * ( 1 + $this->options->lineSpacing ) + | ||||||
|  |                 ( $rotation === null ? 0 : $this->modifyCoordinate( $rotation->get( 1, 2 ) ) ) | ||||||
|  |         ); | ||||||
|  |         $object->setName( $id ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draw all collected texts | ||||||
|  |      * | ||||||
|  |      * The texts are collected and their maximum possible font size is  | ||||||
|  |      * calculated. This function finally draws the texts on the image, this | ||||||
|  |      * delayed drawing has two reasons: | ||||||
|  |      * | ||||||
|  |      * 1) This way the text strings are always on top of the image, what  | ||||||
|  |      *    results in better readable texts | ||||||
|  |      * 2) The maximum possible font size can be calculated for a set of texts | ||||||
|  |      *    with the same font configuration. Strings belonging to one chart  | ||||||
|  |      *    element normally have the same font configuration, so that all texts | ||||||
|  |      *    belonging to one element will have the same font size. | ||||||
|  |      *  | ||||||
|  |      * @access protected | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function drawAllTexts() | ||||||
|  |     { | ||||||
|  |         // Iterate over all strings to collect used chars per font
 | ||||||
|  |         $chars = array(); | ||||||
|  |         foreach ( $this->strings as $text ) | ||||||
|  |         { | ||||||
|  |             $completeString = ''; | ||||||
|  |             foreach ( $text['text'] as $line ) | ||||||
|  |             { | ||||||
|  |                 $completeString .= implode( ' ', $line ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Collect chars for each font
 | ||||||
|  |             if ( !isset( $chars[$text['font']->path] ) ) | ||||||
|  |             { | ||||||
|  |                 $chars[$text['font']->path] = $completeString; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $chars[$text['font']->path] .= $completeString; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         foreach ( $this->strings as $text ) | ||||||
|  |         { | ||||||
|  |             $size = $this->modifyCoordinate( $text['font']->minimalUsedFont ); | ||||||
|  | 
 | ||||||
|  |             $completeHeight = count( $text['text'] ) * $size + ( count( $text['text'] ) - 1 ) * $this->options->lineSpacing; | ||||||
|  | 
 | ||||||
|  |             // Calculate y offset for vertical alignement
 | ||||||
|  |             switch ( true ) | ||||||
|  |             { | ||||||
|  |                 case ( $text['align'] & ezcGraph::BOTTOM ): | ||||||
|  |                     $yOffset = $text['height'] - $completeHeight; | ||||||
|  |                     break; | ||||||
|  |                 case ( $text['align'] & ezcGraph::MIDDLE ): | ||||||
|  |                     $yOffset = ( $text['height'] - $completeHeight ) / 2; | ||||||
|  |                     break; | ||||||
|  |                 case ( $text['align'] & ezcGraph::TOP ): | ||||||
|  |                 default: | ||||||
|  |                     $yOffset = 0; | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $padding = $text['font']->padding + $text['font']->borderWidth / 2; | ||||||
|  |             if ( $this->options->font->minimizeBorder === true ) | ||||||
|  |             { | ||||||
|  |                 // Calculate maximum width of text rows
 | ||||||
|  |                 $width = false; | ||||||
|  |                 foreach ( $text['text'] as $line ) | ||||||
|  |                 { | ||||||
|  |                     $string = implode( ' ', $line ); | ||||||
|  |                     $boundings = $this->getTextBoundings( $size, $text['font'], $string ); | ||||||
|  |                     if ( ( $width === false) || ( $boundings->width > $width ) ) | ||||||
|  |                     { | ||||||
|  |                         $width = $boundings->width; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 switch ( true ) | ||||||
|  |                 { | ||||||
|  |                     case ( $text['align'] & ezcGraph::LEFT ): | ||||||
|  |                         $xOffset = 0; | ||||||
|  |                         break; | ||||||
|  |                     case ( $text['align'] & ezcGraph::CENTER ): | ||||||
|  |                         $xOffset = ( $text['width'] - $width ) / 2; | ||||||
|  |                         break; | ||||||
|  |                     case ( $text['align'] & ezcGraph::RIGHT ): | ||||||
|  |                         $xOffset = $text['width'] - $width; | ||||||
|  |                         break; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $borderPolygonArray = array( | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x - $padding + $xOffset ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y - $padding + $yOffset ) | ||||||
|  |                     ), | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $xOffset + $width ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y - $padding + $yOffset ) | ||||||
|  |                     ), | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $xOffset + $width ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $yOffset + $completeHeight ) | ||||||
|  |                     ), | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x - $padding + $xOffset ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $yOffset + $completeHeight ) | ||||||
|  |                     ), | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 $borderPolygonArray = array( | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x - $padding ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y - $padding ) | ||||||
|  |                     ), | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $text['width'] ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y - $padding ) | ||||||
|  |                     ), | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x + $padding * 2 + $text['width'] ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $text['height'] ) | ||||||
|  |                     ), | ||||||
|  |                     new ezcGraphCoordinate( | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->x - $padding ), | ||||||
|  |                         $this->deModifyCoordinate( $text['position']->y + $padding * 2 + $text['height'] ) | ||||||
|  |                     ), | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $text['rotation'] !==  null ) | ||||||
|  |             { | ||||||
|  |                 foreach ( $borderPolygonArray as $nr => $point ) | ||||||
|  |                 { | ||||||
|  |                     $borderPolygonArray[$nr] = $text['rotation']->transformCoordinate( $point ); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $text['font']->background !== false ) | ||||||
|  |             { | ||||||
|  |                 $this->drawPolygon(  | ||||||
|  |                     $borderPolygonArray,  | ||||||
|  |                     $text['font']->background, | ||||||
|  |                     true | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ( $text['font']->border !== false ) | ||||||
|  |             { | ||||||
|  |                 $this->drawPolygon(  | ||||||
|  |                     $borderPolygonArray,  | ||||||
|  |                     $text['font']->border, | ||||||
|  |                     false, | ||||||
|  |                     $text['font']->borderWidth | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Render text with evaluated font size
 | ||||||
|  |             $completeString = ''; | ||||||
|  |             foreach ( $text['text'] as $line ) | ||||||
|  |             { | ||||||
|  |                 $string = implode( ' ', $line ); | ||||||
|  |                 $completeString .= $string; | ||||||
|  |                 $boundings = $this->getTextBoundings( $size, $text['font'], $string ); | ||||||
|  |                 $text['position']->y += $size; | ||||||
|  | 
 | ||||||
|  |                 switch ( true ) | ||||||
|  |                 { | ||||||
|  |                     case ( $text['align'] & ezcGraph::LEFT ): | ||||||
|  |                         $position = new ezcGraphCoordinate(  | ||||||
|  |                             $text['position']->x,  | ||||||
|  |                             $text['position']->y + $yOffset | ||||||
|  |                         ); | ||||||
|  |                         break; | ||||||
|  |                     case ( $text['align'] & ezcGraph::RIGHT ): | ||||||
|  |                         $position = new ezcGraphCoordinate(  | ||||||
|  |                             $text['position']->x + ( $text['width'] - $boundings->width ),  | ||||||
|  |                             $text['position']->y + $yOffset | ||||||
|  |                         ); | ||||||
|  |                         break; | ||||||
|  |                     case ( $text['align'] & ezcGraph::CENTER ): | ||||||
|  |                         $position = new ezcGraphCoordinate(  | ||||||
|  |                             $text['position']->x + ( ( $text['width'] - $boundings->width ) / 2 ),  | ||||||
|  |                             $text['position']->y + $yOffset | ||||||
|  |                         ); | ||||||
|  |                         break; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 // Optionally draw text shadow
 | ||||||
|  |                 if ( $text['font']->textShadow === true ) | ||||||
|  |                 { | ||||||
|  |                     $this->renderText(  | ||||||
|  |                         $text['id'], | ||||||
|  |                         $string, | ||||||
|  |                         $chars[$text['font']->path], | ||||||
|  |                         $text['font']->type,  | ||||||
|  |                         $text['font']->path,  | ||||||
|  |                         $text['font']->textShadowColor, | ||||||
|  |                         new ezcGraphCoordinate( | ||||||
|  |                             $position->x + $this->modifyCoordinate( $text['font']->textShadowOffset ), | ||||||
|  |                             $position->y + $this->modifyCoordinate( $text['font']->textShadowOffset ) | ||||||
|  |                         ), | ||||||
|  |                         $size, | ||||||
|  |                         $text['rotation'] | ||||||
|  |                     ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 // Finally draw text
 | ||||||
|  |                 $this->renderText(  | ||||||
|  |                     $text['id'], | ||||||
|  |                     $string, | ||||||
|  |                     $chars[$text['font']->path], | ||||||
|  |                     $text['font']->type,  | ||||||
|  |                     $text['font']->path,  | ||||||
|  |                     $text['font']->color,  | ||||||
|  |                     $position, | ||||||
|  |                     $size, | ||||||
|  |                     $text['rotation'] | ||||||
|  |                 ); | ||||||
|  | 
 | ||||||
|  |                 $text['position']->y += $size * $this->options->lineSpacing; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a sector of cirlce | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center Center of circle | ||||||
|  |      * @param mixed $width Width | ||||||
|  |      * @param mixed $height Height | ||||||
|  |      * @param mixed $startAngle Start angle of circle sector | ||||||
|  |      * @param mixed $endAngle End angle of circle sector | ||||||
|  |      * @param ezcGraphColor $color Color | ||||||
|  |      * @param mixed $filled Filled | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) | ||||||
|  |     { | ||||||
|  |         if ( $startAngle > $endAngle ) | ||||||
|  |         { | ||||||
|  |             $tmp = $startAngle; | ||||||
|  |             $startAngle = $endAngle; | ||||||
|  |             $endAngle = $tmp; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  | 
 | ||||||
|  |         $shape = new SWFShape(); | ||||||
|  |         $this->setShapeColor( $shape, $color, 1, $filled ); | ||||||
|  | 
 | ||||||
|  |         if ( !$filled ) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 $reduced = $this->reduceEllipseSize( $center, $width, $height, $startAngle, $endAngle, .5 ); | ||||||
|  |             } | ||||||
|  |             catch ( ezcGraphReducementFailedException $e ) | ||||||
|  |             { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $startAngle = $reduced['startAngle']; | ||||||
|  |             $endAngle = $reduced['endAngle']; | ||||||
|  | 
 | ||||||
|  |             $width -= 1; | ||||||
|  |             $height -= 1; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $shape->movePenTo( $this->modifyCoordinate( $center->x ), $this->modifyCoordinate( $center->y ) ); | ||||||
|  | 
 | ||||||
|  |         // @TODO: User SWFShape::curveTo
 | ||||||
|  |         for( | ||||||
|  |             $angle = $startAngle; | ||||||
|  |             $angle <= $endAngle; | ||||||
|  |             $angle = min( $angle + $this->options->circleResolution, $endAngle ) ) | ||||||
|  |         { | ||||||
|  |             $shape->drawLineTo(  | ||||||
|  |                 $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ),  | ||||||
|  |                 $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |             if ( $angle === $endAngle ) | ||||||
|  |             { | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $shape->drawLineTo(  | ||||||
|  |             $this->modifyCoordinate( $center->x ),  | ||||||
|  |             $this->modifyCoordinate( $center->y )  | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         $object = $movie->add( $shape ); | ||||||
|  |         $object->setName( $id = 'ezcGraphCircleSector_' . $this->id++ ); | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a circular arc consisting of several minor steps on the bounding  | ||||||
|  |      * lines. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center  | ||||||
|  |      * @param mixed $width  | ||||||
|  |      * @param mixed $height  | ||||||
|  |      * @param mixed $size  | ||||||
|  |      * @param mixed $startAngle  | ||||||
|  |      * @param mixed $endAngle  | ||||||
|  |      * @param ezcGraphColor $color  | ||||||
|  |      * @param bool $filled  | ||||||
|  |      * @return string Element id | ||||||
|  |      */ | ||||||
|  |     protected function simulateCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled ) | ||||||
|  |     { | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  |         $id = 'ezcGraphCircularArc_' . $this->id++; | ||||||
|  | 
 | ||||||
|  |         for (  | ||||||
|  |             $tmpAngle = min( ceil ( $startAngle / 180 ) * 180, $endAngle );  | ||||||
|  |             $tmpAngle <= $endAngle;  | ||||||
|  |             $tmpAngle = min( ceil ( $startAngle / 180 + 1 ) * 180, $endAngle ) ) | ||||||
|  |         { | ||||||
|  |             $shape = new SWFShape(); | ||||||
|  |             $this->setShapeColor( $shape, $color, 1, $filled ); | ||||||
|  | 
 | ||||||
|  |             $shape->movePenTo(  | ||||||
|  |                 $this->modifyCoordinate( $center->x + cos( deg2rad( $startAngle ) ) * $width / 2 ),  | ||||||
|  |                 $this->modifyCoordinate( $center->y + sin( deg2rad( $startAngle ) ) * $height / 2 ) | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |             // @TODO: Use SWFShape::curveTo
 | ||||||
|  |             for( | ||||||
|  |                 $angle = $startAngle; | ||||||
|  |                 $angle <= $tmpAngle; | ||||||
|  |                 $angle = min( $angle + $this->options->circleResolution, $tmpAngle ) ) | ||||||
|  |             { | ||||||
|  |                 $shape->drawLineTo(  | ||||||
|  |                     $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ),  | ||||||
|  |                     $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 + $size ) | ||||||
|  |                 ); | ||||||
|  | 
 | ||||||
|  |                 if ( $angle === $tmpAngle ) | ||||||
|  |                 { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             for( | ||||||
|  |                 $angle = $tmpAngle; | ||||||
|  |                 $angle >= $startAngle; | ||||||
|  |                 $angle = max( $angle - $this->options->circleResolution, $startAngle ) ) | ||||||
|  |             { | ||||||
|  |                 $shape->drawLineTo(  | ||||||
|  |                     $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ),  | ||||||
|  |                     $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) | ||||||
|  |                 ); | ||||||
|  | 
 | ||||||
|  |                 if ( $angle === $startAngle ) | ||||||
|  |                 { | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $object = $movie->add( $shape ); | ||||||
|  |             $object->setName( $id ); | ||||||
|  | 
 | ||||||
|  |             $startAngle = $tmpAngle; | ||||||
|  |             if ( $tmpAngle === $endAngle )  | ||||||
|  |             { | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a circular arc | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center Center of ellipse | ||||||
|  |      * @param integer $width Width of ellipse | ||||||
|  |      * @param integer $height Height of ellipse | ||||||
|  |      * @param integer $size Height of border | ||||||
|  |      * @param float $startAngle Starting angle of circle sector | ||||||
|  |      * @param float $endAngle Ending angle of circle sector | ||||||
|  |      * @param ezcGraphColor $color Color of Border | ||||||
|  |      * @param bool $filled | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) | ||||||
|  |     { | ||||||
|  |         if ( $startAngle > $endAngle ) | ||||||
|  |         { | ||||||
|  |             $tmp = $startAngle; | ||||||
|  |             $startAngle = $endAngle; | ||||||
|  |             $endAngle = $tmp; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $id = $this->simulateCircularArc( $center, $width, $height, $size, $startAngle, $endAngle, $color, $filled ); | ||||||
|  | 
 | ||||||
|  |         if ( ( $this->options->shadeCircularArc !== false ) && | ||||||
|  |              $filled ) | ||||||
|  |         { | ||||||
|  |             $gradient = new ezcGraphLinearGradient( | ||||||
|  |                 new ezcGraphCoordinate( | ||||||
|  |                     $center->x - $width, | ||||||
|  |                     $center->y | ||||||
|  |                 ), | ||||||
|  |                 new ezcGraphCoordinate( | ||||||
|  |                     $center->x + $width, | ||||||
|  |                     $center->y | ||||||
|  |                 ), | ||||||
|  |                 ezcGraphColor::fromHex( '#FFFFFF' )->transparent( $this->options->shadeCircularArc * 1.5 ), | ||||||
|  |                 ezcGraphColor::fromHex( '#000000' )->transparent( $this->options->shadeCircularArc * 1.5 ) | ||||||
|  |             ); | ||||||
|  |          | ||||||
|  |             $this->simulateCircularArc( $center, $width, $height, $size, $startAngle, $endAngle, $gradient, $filled ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draw circle  | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center Center of ellipse | ||||||
|  |      * @param mixed $width Width of ellipse | ||||||
|  |      * @param mixed $height height of ellipse | ||||||
|  |      * @param ezcGraphColor $color Color | ||||||
|  |      * @param mixed $filled Filled | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawCircle( ezcGraphCoordinate $center, $width, $height, ezcGraphColor $color, $filled = true ) | ||||||
|  |     { | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  | 
 | ||||||
|  |         $shape = new SWFShape(); | ||||||
|  |         $this->setShapeColor( $shape, $color, 1, $filled ); | ||||||
|  | 
 | ||||||
|  |         // Reduce size
 | ||||||
|  |         if ( !$filled ) | ||||||
|  |         { | ||||||
|  |             $width -= 1; | ||||||
|  |             $height -= 1; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $shape->movePenTo(  | ||||||
|  |             $this->modifyCoordinate( $center->x + $width / 2 ),  | ||||||
|  |             $this->modifyCoordinate( $center->y ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // @TODO: User SWFShape::curveTo
 | ||||||
|  |         for ( $angle = $this->options->circleResolution; $angle < 360; $angle += $this->options->circleResolution ) | ||||||
|  |         { | ||||||
|  |             $shape->drawLineTo(  | ||||||
|  |                 $this->modifyCoordinate( $center->x + cos( deg2rad( $angle ) ) * $width / 2 ),  | ||||||
|  |                 $this->modifyCoordinate( $center->y + sin( deg2rad( $angle ) ) * $height / 2 ) | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $shape->drawLineTo(  | ||||||
|  |             $this->modifyCoordinate( $center->x + $width / 2 ),  | ||||||
|  |             $this->modifyCoordinate( $center->y ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         $object = $movie->add( $shape ); | ||||||
|  |         $object->setName( $id = 'ezcGraphCircle_' . $this->id++ ); | ||||||
|  | 
 | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draw an image  | ||||||
|  |      * | ||||||
|  |      * The image will be inlined in the SVG document using data URL scheme. For | ||||||
|  |      * this the mime type and base64 encoded file content will be merged to  | ||||||
|  |      * URL. | ||||||
|  |      *  | ||||||
|  |      * @param mixed $file Image file | ||||||
|  |      * @param ezcGraphCoordinate $position Top left position | ||||||
|  |      * @param float $width Width of image in destination image | ||||||
|  |      * @param float $height Height of image in destination image | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawImage( $file, ezcGraphCoordinate $position, $width, $height ) | ||||||
|  |     { | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  | 
 | ||||||
|  |         $imageData = getimagesize( $file ); | ||||||
|  |         if ( ( $imageData[2] !== IMAGETYPE_JPEG ) && ( $imageData[2] !== IMAGETYPE_PNG ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphFlashBitmapTypeException( $imageData[2] ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Try to create a new SWFBitmap object from provided file
 | ||||||
|  |         $bitmap = new SWFBitmap( fopen( $file, 'rb' ) ); | ||||||
|  | 
 | ||||||
|  |         // Add the image to the movie
 | ||||||
|  |         $object = $this->movie->add( $bitmap ); | ||||||
|  | 
 | ||||||
|  |         // Image size is calculated on the base of a tick size of 20, so
 | ||||||
|  |         // that we need to transform this, to our tick size.
 | ||||||
|  |         $factor = $this->modifyCoordinate( 1 ) / 20; | ||||||
|  |         $object->scale( $factor, $factor ); | ||||||
|  | 
 | ||||||
|  |         // Scale by ratio of requested and original image size
 | ||||||
|  |         $object->scale( | ||||||
|  |             $width / $imageData[0], | ||||||
|  |             $height / $imageData[1] | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Move object to the right position
 | ||||||
|  |         $object->moveTo(  | ||||||
|  |             $this->modifyCoordinate( $position->x ), | ||||||
|  |             $this->modifyCoordinate( $position->y ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Create, set and return unique ID
 | ||||||
|  |         $object->setName( $id = 'ezcGraphImage_'. $this->id++ ); | ||||||
|  |         return $id; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return mime type for current image format | ||||||
|  |      *  | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getMimeType() | ||||||
|  |     { | ||||||
|  |         return 'application/x-shockwave-flash'; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Finally save image | ||||||
|  |      *  | ||||||
|  |      * @param string $file Destination filename | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function render( $file ) | ||||||
|  |     { | ||||||
|  |         $this->drawAllTexts(); | ||||||
|  |         $movie = $this->getDocument(); | ||||||
|  |         $movie->save( $file, $this->options->compression ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get resource of rendered result | ||||||
|  |      * | ||||||
|  |      * Return the resource of the rendered result. You should not use this | ||||||
|  |      * method before you called either renderToOutput() or render(), as the | ||||||
|  |      * image may not be completely rendered until then. | ||||||
|  |      *  | ||||||
|  |      * @return SWFMovie | ||||||
|  |      */ | ||||||
|  |     public function getResource() | ||||||
|  |     { | ||||||
|  |         return $this->movie; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										1236
									
								
								src/TUnit/external/ezc/Graph/driver/gd.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1236
									
								
								src/TUnit/external/ezc/Graph/driver/gd.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1230
									
								
								src/TUnit/external/ezc/Graph/driver/svg.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1230
									
								
								src/TUnit/external/ezc/Graph/driver/svg.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										298
									
								
								src/TUnit/external/ezc/Graph/driver/svg_font.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										298
									
								
								src/TUnit/external/ezc/Graph/driver/svg_font.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,298 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphSVGDriver class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @author Freddie Witherden | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Helper class, offering requrired calculation basics and font metrics to use | ||||||
|  |  * SVG fonts with the SVG driver. | ||||||
|  |  * | ||||||
|  |  * You may convert any ttf font into a SVG font using the `ttf2svg` bianry from | ||||||
|  |  * the batik package. Depending on the distribution it may only be available as | ||||||
|  |  * `batik-ttf2svg-<version>`. | ||||||
|  |  * | ||||||
|  |  * Usage: | ||||||
|  |  * <code> | ||||||
|  |  *  $font = new ezcGraphSvgFont(); | ||||||
|  |  *  var_dump( | ||||||
|  |  *      $font->calculateStringWidth( '../tests/data/font.svg', 'Just a test string.' ), | ||||||
|  |  *      $font->calculateStringWidth( '../tests/data/font2.svg', 'Just a test string.' ) | ||||||
|  |  *  ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphSvgFont | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Units per EM | ||||||
|  |      * | ||||||
|  |      * @var float | ||||||
|  |      */ | ||||||
|  |     protected $unitsPerEm; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Used glyphs | ||||||
|  |      * | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $usedGlyphs = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Cache for glyph size to save XPath lookups. | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $glyphCache = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Used kernings | ||||||
|  |      * | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $usedKerns = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Path to font | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $fonts = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Initialize SVG font | ||||||
|  |      * | ||||||
|  |      * Loads the SVG font $filename. This should be the path to the file | ||||||
|  |      * generated by ttf2svg. | ||||||
|  |      * | ||||||
|  |      * Returns the (normlized) name of the initilized font. | ||||||
|  |      * | ||||||
|  |      * @param string $fontPath | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     protected function initializeFont( $fontPath ) | ||||||
|  |     { | ||||||
|  |         if ( isset( $this->fonts[$fontPath] ) ) | ||||||
|  |         { | ||||||
|  |             return $fontPath; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Check for existance of font file
 | ||||||
|  |         if ( !is_file( $fontPath ) || !is_readable( $fontPath ) ) | ||||||
|  |         { | ||||||
|  |             throw new ezcBaseFileNotFoundException( $fontPath ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $this->fonts[$fontPath] = simplexml_load_file( $fontPath )->defs->font; | ||||||
|  | 
 | ||||||
|  |         // SimpleXML requires us to register a namespace for XPath to work
 | ||||||
|  |         $this->fonts[$fontPath]->registerXPathNamespace( 'svg', 'http://www.w3.org/2000/svg' ); | ||||||
|  | 
 | ||||||
|  |         // Extract the number of units per Em
 | ||||||
|  |         $this->unitsPerEm[$fontPath] = (int) $this->fonts[$fontPath]->{'font-face'}['units-per-em']; | ||||||
|  | 
 | ||||||
|  |         return $fontPath; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get name of font | ||||||
|  |      * | ||||||
|  |      * Get the name of the given font, by extracting its font family from the | ||||||
|  |      * SVG font file. | ||||||
|  |      *  | ||||||
|  |      * @param string $fontPath  | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public static function getFontName( $fontPath ) | ||||||
|  |     { | ||||||
|  |         $font = simplexml_load_file( $fontPath )->defs->font; | ||||||
|  | 
 | ||||||
|  |         // SimpleXML requires us to register a namespace for XPath to work
 | ||||||
|  |         $font->registerXPathNamespace( 'svg', 'http://www.w3.org/2000/svg' ); | ||||||
|  | 
 | ||||||
|  |         // Extract the font family name
 | ||||||
|  |         return (string) $font->{'font-face'}['font-family']; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * XPath has no standard means of escaping ' and ", with the only solution
 | ||||||
|  |      * being to delimit your string with the opposite type of quote. ( And if | ||||||
|  |      * your string contains both concat(  ) it ). | ||||||
|  |      * | ||||||
|  |      * This method will correctly delimit $char with the appropriate quote type | ||||||
|  |      * so that it can be used in an XPath expression. | ||||||
|  |      * | ||||||
|  |      * @param string $char | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     protected static function xpathEscape( $char ) | ||||||
|  |     { | ||||||
|  |         return "'" . str_replace(  | ||||||
|  |             array( '\'', '\\' ), | ||||||
|  |             array( '\\\'', '\\\\' ), | ||||||
|  |             $char ) . "'"; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the <glyph> associated with $char. | ||||||
|  |      * | ||||||
|  |      * @param string $fontPath | ||||||
|  |      * @param string $char | ||||||
|  |      * @return float | ||||||
|  |      */ | ||||||
|  |     protected function getGlyph( $fontPath, $char ) | ||||||
|  |     { | ||||||
|  |         // Check if glyphwidth has already been calculated.
 | ||||||
|  |         if ( isset( $this->glyphCache[$fontPath][$char] ) ) | ||||||
|  |         { | ||||||
|  |             return $this->glyphCache[$fontPath][$char]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $matches = $this->fonts[$fontPath]->xpath( | ||||||
|  |             $query = "glyph[@unicode=" . self::xpathEscape( $char ) . "]" | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         if ( count( $matches ) === 0 ) | ||||||
|  |         { | ||||||
|  |              // Just ignore missing glyphs. The client will still render them
 | ||||||
|  |              // using a default font. We try to estimate some width by using a
 | ||||||
|  |              // common other character.
 | ||||||
|  |             return $this->glyphCache[$fontPath][$char] =  | ||||||
|  |                 ( $char === 'o' ? false : $this->getGlyph( $fontPath, 'o' ) ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $glyph = $matches[0]; | ||||||
|  |         if ( !in_array( $glyph, $this->usedGlyphs ) ) | ||||||
|  |         { | ||||||
|  |             $this->usedGlyphs[$fontPath][] = $glyph; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // There should only ever be one match
 | ||||||
|  |         return $this->glyphCache[$fontPath][$char] = $glyph; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the amount of kerning to apply for glyphs $g1 and $g2. If no | ||||||
|  |      * valid kerning pair can be found 0 is returned. | ||||||
|  |      * | ||||||
|  |      * @param string $fontPath | ||||||
|  |      * @param SimpleXMLElement $g1 | ||||||
|  |      * @param SimpleXMLElement $g2 | ||||||
|  |      * @return int | ||||||
|  |      */ | ||||||
|  |     public function getKerning( $fontPath, SimpleXMLElement $glyph1, SimpleXMLElement $glyph2 ) | ||||||
|  |     { | ||||||
|  |         // Get the glyph names
 | ||||||
|  |         $g1Name = self::xpathEscape( ( string ) $glyph1['glyph-name'] ); | ||||||
|  |         $g2Name = self::xpathEscape( ( string ) $glyph2['glyph-name'] ); | ||||||
|  | 
 | ||||||
|  |         // Get the unicode character names
 | ||||||
|  |         $g1Uni = self::xpathEscape( ( string ) $glyph1['unicode'] ); | ||||||
|  |         $g2Uni = self::xpathEscape( ( string ) $glyph2['unicode'] ); | ||||||
|  | 
 | ||||||
|  |         // Search for kerning pairs
 | ||||||
|  |         $pair = $this->fonts[$fontPath]->xpath(  | ||||||
|  |             "svg:hkern[( @g1=$g1Name and @g2=$g2Name )
 | ||||||
|  |                 or | ||||||
|  |              ( @u1=$g1Uni and @g2=$g2Uni )]" | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // If we found anything return it
 | ||||||
|  |         if ( count( $pair ) ) | ||||||
|  |         { | ||||||
|  |             if ( !in_array( $pair[0], $this->usedKerns ) ) | ||||||
|  |             { | ||||||
|  |                 $this->usedKerns[$fontPath][] = $pair[0]; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             return ( int ) $pair[0]['k']; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return 0; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculates the width of $string in the current font in Em's. | ||||||
|  |      * | ||||||
|  |      * @param string $fontPath | ||||||
|  |      * @param string $string | ||||||
|  |      * @return float | ||||||
|  |      */ | ||||||
|  |     public function calculateStringWidth( $fontPath, $string ) | ||||||
|  |     { | ||||||
|  |         // Ensure font is properly initilized
 | ||||||
|  |         $fontPath = $this->initializeFont( $fontPath ); | ||||||
|  | 
 | ||||||
|  |         $strlen = strlen( $string ); | ||||||
|  |         $prevCharInfo = null; | ||||||
|  |         $length = 0; | ||||||
|  |         // @TODO: Add UTF-8 support here - iterating over the bytes does not
 | ||||||
|  |         // really help.
 | ||||||
|  |         for ( $i = 0; $i < $strlen; ++$i ) | ||||||
|  |         { | ||||||
|  |             // Find the font information for the character
 | ||||||
|  |             $charInfo = $this->getGlyph( $fontPath, $string[$i] ); | ||||||
|  | 
 | ||||||
|  |             // Handle missing glyphs
 | ||||||
|  |             if ( $charInfo === false ) | ||||||
|  |             { | ||||||
|  |                 $prevCharInfo = null; | ||||||
|  |                 $length += .5 * $this->unitsPerEm[$fontPath]; | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Add the horizontal advance for the character to the length
 | ||||||
|  |             $length += (float) $charInfo['horiz-adv-x']; | ||||||
|  | 
 | ||||||
|  |             // If we are not the first character, look for kerning pairs
 | ||||||
|  |             if ( $prevCharInfo !== null ) | ||||||
|  |             { | ||||||
|  |                 // Apply kerning (if any)
 | ||||||
|  |                 $length -= $this->getKerning( $fontPath, $prevCharInfo, $charInfo ); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $prevCharInfo = clone $charInfo; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Divide by _unitsPerEm to get the length in Em
 | ||||||
|  |         return (float) $length / $this->unitsPerEm[$fontPath]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Add font definitions to SVG document | ||||||
|  |      * | ||||||
|  |      * Add the SVG font definition paths for all used glyphs and kernings to | ||||||
|  |      * the given SVG document. | ||||||
|  |      *  | ||||||
|  |      * @param DOMDocument $document  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function addFontToDocument( DOMDocument $document ) | ||||||
|  |     { | ||||||
|  |         $defs = $document->getElementsByTagName( 'defs' )->item( 0 ); | ||||||
|  | 
 | ||||||
|  |         $fontNr = 0; | ||||||
|  |         foreach ( $this->fonts as $path => $definition ) | ||||||
|  |         { | ||||||
|  |             // Just import complete font for now.
 | ||||||
|  |             // @TODO: Only import used characters.
 | ||||||
|  |             $font = dom_import_simplexml( $definition ); | ||||||
|  |             $font = $document->importNode( $font, true ); | ||||||
|  |             $font->setAttribute( 'id', 'Font' . ++$fontNr ); | ||||||
|  | 
 | ||||||
|  |             $defs->appendChild( $font ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										242
									
								
								src/TUnit/external/ezc/Graph/driver/verbose.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										242
									
								
								src/TUnit/external/ezc/Graph/driver/verbose.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,242 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphSVGDriver class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  * @access private | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Simple output driver for debuggin purposes. Just outputs shapes as text on | ||||||
|  |  * CLI. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @access private | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | class ezcGraphVerboseDriver extends ezcGraphDriver | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Number of call on driver | ||||||
|  |      *  | ||||||
|  |      * @var int | ||||||
|  |      */ | ||||||
|  |     protected $call = 0; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->options = new ezcGraphSvgDriverOptions( $options ); | ||||||
|  |         echo "\n"; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a single polygon  | ||||||
|  |      *  | ||||||
|  |      * @param array $points  | ||||||
|  |      * @param ezcGraphColor $color  | ||||||
|  |      * @param bool $filled  | ||||||
|  |      * @param float $thickness | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1. ) | ||||||
|  |     { | ||||||
|  |         $pointString = ''; | ||||||
|  |         foreach ( $points as $point ) | ||||||
|  |         { | ||||||
|  |             $pointString .= sprintf( "\t( %.2f, %.2f )\n", $point->x, $point->y ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         printf( "% 4d: Draw %spolygon:\n%s",  | ||||||
|  |             $this->call++, | ||||||
|  |             ( $filled ? 'filled ' : '' ), | ||||||
|  |             $pointString | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Draws a single line | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $start  | ||||||
|  |      * @param ezcGraphCoordinate $end  | ||||||
|  |      * @param ezcGraphColor $color  | ||||||
|  |      * @param float $thickness | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color, $thickness = 1. ) | ||||||
|  |     { | ||||||
|  |         printf( "% 4d: Draw line from ( %.2f, %.2f ) to ( %.2f, %.2f ) with thickness %d.\n", | ||||||
|  |             $this->call++, | ||||||
|  |             $start->x, | ||||||
|  |             $start->y, | ||||||
|  |             $end->x, | ||||||
|  |             $end->y, | ||||||
|  |             $thickness | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns boundings of text depending on the available font extension | ||||||
|  |      *  | ||||||
|  |      * @param float $size Textsize | ||||||
|  |      * @param ezcGraphFontOptions $font Font | ||||||
|  |      * @param string $text Text | ||||||
|  |      * @return ezcGraphBoundings Boundings of text | ||||||
|  |      */ | ||||||
|  |     protected function getTextBoundings( $size, ezcGraphFontOptions $font, $text ) | ||||||
|  |     { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Wrties text in a box of desired size | ||||||
|  |      *  | ||||||
|  |      * @param mixed $string  | ||||||
|  |      * @param ezcGraphCoordinate $position  | ||||||
|  |      * @param mixed $width  | ||||||
|  |      * @param mixed $height  | ||||||
|  |      * @param int $align  | ||||||
|  |      * @param ezcGraphRotation $rotation | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawTextBox( $string, ezcGraphCoordinate $position, $width, $height, $align, ezcGraphRotation $rotation = null ) | ||||||
|  |     { | ||||||
|  |         printf( "% 4d: Draw text '%s' at ( %.2f, %.2f ) with dimensions ( %d, %d ) and alignement %d.\n", | ||||||
|  |             $this->call++, | ||||||
|  |             $string, | ||||||
|  |             $position->x, | ||||||
|  |             $position->y, | ||||||
|  |             $width, | ||||||
|  |             $height, | ||||||
|  |             $align | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  |     /** | ||||||
|  |      * Draws a sector of cirlce | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center  | ||||||
|  |      * @param mixed $width | ||||||
|  |      * @param mixed $height | ||||||
|  |      * @param mixed $startAngle  | ||||||
|  |      * @param mixed $endAngle  | ||||||
|  |      * @param ezcGraphColor $color  | ||||||
|  |      * @param bool $filled | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) | ||||||
|  |     { | ||||||
|  |         printf( "% 4d: Draw %scicle sector at ( %.2f, %.2f ) with dimensions ( %d, %d ) from %.2f to %.2f.\n", | ||||||
|  |             $this->call++, | ||||||
|  |             ( $filled ? 'filled ' : '' ), | ||||||
|  |             $center->x, | ||||||
|  |             $center->y, | ||||||
|  |             $width, | ||||||
|  |             $height, | ||||||
|  |             $startAngle, | ||||||
|  |             $endAngle | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a circular arc | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center Center of ellipse | ||||||
|  |      * @param integer $width Width of ellipse | ||||||
|  |      * @param integer $height Height of ellipse | ||||||
|  |      * @param integer $size Height of border | ||||||
|  |      * @param float $startAngle Starting angle of circle sector | ||||||
|  |      * @param float $endAngle Ending angle of circle sector | ||||||
|  |      * @param ezcGraphColor $color Color of Border | ||||||
|  |      * @param bool $filled | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawCircularArc( ezcGraphCoordinate $center, $width, $height, $size, $startAngle, $endAngle, ezcGraphColor $color, $filled = true ) | ||||||
|  |     { | ||||||
|  |         printf( "% 4d: Draw circular arc at ( %.2f, %.2f ) with dimensions ( %d, %d ) and size %.2f from %.2f to %.2f.\n", | ||||||
|  |             $this->call++, | ||||||
|  |             $center->x, | ||||||
|  |             $center->y, | ||||||
|  |             $width, | ||||||
|  |             $height, | ||||||
|  |             $size, | ||||||
|  |             $startAngle, | ||||||
|  |             $endAngle | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a circle | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $center  | ||||||
|  |      * @param mixed $width | ||||||
|  |      * @param mixed $height | ||||||
|  |      * @param ezcGraphColor $color | ||||||
|  |      * @param bool $filled | ||||||
|  |      * | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawCircle( ezcGraphCoordinate $center, $width, $height, ezcGraphColor $color, $filled = true ) | ||||||
|  |     { | ||||||
|  |         printf( "% 4d: Draw %scircle at ( %.2f, %.2f ) with dimensions ( %d, %d ).\n", | ||||||
|  |             $this->call++, | ||||||
|  |             ( $filled ? 'filled ' : '' ), | ||||||
|  |             $center->x, | ||||||
|  |             $center->y, | ||||||
|  |             $width, | ||||||
|  |             $height | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draws a imagemap of desired size | ||||||
|  |      *  | ||||||
|  |      * @param mixed $file  | ||||||
|  |      * @param ezcGraphCoordinate $position  | ||||||
|  |      * @param mixed $width  | ||||||
|  |      * @param mixed $height  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawImage( $file, ezcGraphCoordinate $position, $width, $height ) | ||||||
|  |     { | ||||||
|  |         printf( "% 4d: Draw image '%s' at ( %.2f, %.2f ) with dimensions ( %d, %d ).\n", | ||||||
|  |             $this->call++, | ||||||
|  |             $file, | ||||||
|  |             $position->x, | ||||||
|  |             $position->y, | ||||||
|  |             $width, | ||||||
|  |             $height | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return mime type for current image format | ||||||
|  |      *  | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getMimeType() | ||||||
|  |     { | ||||||
|  |         return 'text/plain'; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Finally save image | ||||||
|  |      *  | ||||||
|  |      * @param mixed $file  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function render ( $file ) | ||||||
|  |     { | ||||||
|  |         printf( "Render image.\n" ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										535
									
								
								src/TUnit/external/ezc/Graph/element/axis.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										535
									
								
								src/TUnit/external/ezc/Graph/element/axis.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,535 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphChartElementAxis class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent an axis as a chart element | ||||||
|  |  * | ||||||
|  |  * Chart elements can be understood as widgets or layout container inside the | ||||||
|  |  * chart. The actual transformation to images happens inside the renderers. | ||||||
|  |  * They represent all elements inside the chart and contain mostly general | ||||||
|  |  * formatting options, while the renderer itself might define additional | ||||||
|  |  * formatting options for some chart elments. You can find more about the | ||||||
|  |  * general formatting options for chart elements in the base class | ||||||
|  |  * ezcGraphChartElement. | ||||||
|  |  * | ||||||
|  |  * The axis elements are special elements, as the border and background | ||||||
|  |  * settings do not apply directly as axis axis are not put inside any boxes. | ||||||
|  |  * The border value is reused for the color of the axis itself. | ||||||
|  |  * | ||||||
|  |  * Generally you should select the axis which matches your data best. By | ||||||
|  |  * default a labeled x axis and a numeric y axis are used. If you are using | ||||||
|  |  * date or time values on either axis, you should for example use a | ||||||
|  |  * ezcGraphChartElementDateAxis. The currently available axis types are: | ||||||
|  |  * | ||||||
|  |  * - ezcGraphChartElementDateAxis | ||||||
|  |  * - ezcGraphChartElementLabeledAxis | ||||||
|  |  * - ezcGraphChartElementLogarithmicalAxis | ||||||
|  |  * - ezcGraphChartElementNumericAxis | ||||||
|  |  * | ||||||
|  |  * Beside this there are several option to define the general layout of the | ||||||
|  |  * axis labels. The $formatString option may be used to add additional text to | ||||||
|  |  * each label on the axis, like a percent sign on the y axis: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->xAxis->formatString = '%s %%'; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * For more complex formatting operations for the label you may assign a custom | ||||||
|  |  * formatter function to the property $labelCallback. | ||||||
|  |  * | ||||||
|  |  * The orientation of labels and their position relatively to the axis ticks is | ||||||
|  |  * calcualted and rendered by the ezcGraphAxisLabelRenderer classes. You can | ||||||
|  |  * choose between different axis label renderer, or create you own, and assign | ||||||
|  |  * an instance of one to the property $axisLabelRenderer. Currently the | ||||||
|  |  * available axis label renderers are: | ||||||
|  |  *  | ||||||
|  |  * - ezcGraphAxisBoxedLabelRenderer | ||||||
|  |  * | ||||||
|  |  *   Renders grid and labels like commonly used in bar charts, with the label | ||||||
|  |  *   between two grid lines. | ||||||
|  |  *   | ||||||
|  |  * - ezcGraphAxisCenteredLabelRenderer | ||||||
|  |  * | ||||||
|  |  *   Centers the label right next to a tick. Commonly used for labeled axis. | ||||||
|  |  * | ||||||
|  |  * - ezcGraphAxisExactLabelRenderer | ||||||
|  |  * | ||||||
|  |  *   Put the label next to each tick. Commonly used for numeric axis. | ||||||
|  |  * | ||||||
|  |  * - ezcGraphAxisNoLabelRenderer | ||||||
|  |  * | ||||||
|  |  *   Renders no labels. | ||||||
|  |  * | ||||||
|  |  * - ezcGraphAxisRadarLabelRenderer | ||||||
|  |  * | ||||||
|  |  *   Special label renderer for radar charts. | ||||||
|  |  * | ||||||
|  |  * - ezcGraphAxisRotatedLabelRenderer | ||||||
|  |  * | ||||||
|  |  *   Accepts a rotation angle for the texts put at some axis, which might be | ||||||
|  |  *   useful for longer textual labels on the axis. | ||||||
|  |  * | ||||||
|  |  * The label renderer used by default is different depending on the axis type. | ||||||
|  |  * | ||||||
|  |  * @property float $nullPosition | ||||||
|  |  *           The position of the null value. | ||||||
|  |  * @property float $axisSpace | ||||||
|  |  *           Percent of the chart space used to display axis labels and  | ||||||
|  |  *           arrowheads instead of data values. | ||||||
|  |  * @property float $outerAxisSpace | ||||||
|  |  *           Percent of the chart space used to display axis arrow at the outer | ||||||
|  |  *           side of the axis. If set to null, the axisSpace will be used here. | ||||||
|  |  * @property ezcGraphColor $majorGrid | ||||||
|  |  *           Color of major majorGrid. | ||||||
|  |  * @property ezcGraphColor $minorGrid | ||||||
|  |  *           Color of minor majorGrid. | ||||||
|  |  * @property mixed $majorStep | ||||||
|  |  *           Labeled major steps displayed on the axis. @TODO: Should be moved | ||||||
|  |  *           to numeric axis. | ||||||
|  |  * @property mixed $minorStep | ||||||
|  |  *           Non labeled minor steps on the axis. @TODO: Should be moved to | ||||||
|  |  *           numeric axis. | ||||||
|  |  * @property string $formatString | ||||||
|  |  *           Formatstring to use for labeling of the axis. | ||||||
|  |  * @property string $label | ||||||
|  |  *           Axis label | ||||||
|  |  * @property int $labelSize | ||||||
|  |  *           Size of axis label | ||||||
|  |  * @property int $labelMargin | ||||||
|  |  *           Distance between label an axis | ||||||
|  |  * @property int $minArrowHeadSize | ||||||
|  |  *           Minimum Size used to draw arrow heads. | ||||||
|  |  * @property int $maxArrowHeadSize | ||||||
|  |  *           Maximum Size used to draw arrow heads. | ||||||
|  |  * @property ezcGraphAxisLabelRenderer $axisLabelRenderer | ||||||
|  |  *           AxisLabelRenderer used to render labels and grid on this axis. | ||||||
|  |  * @property callback $labelCallback | ||||||
|  |  *           Callback function to format chart labels. | ||||||
|  |  *           Function will receive two parameters and should return a  | ||||||
|  |  *           reformatted label. | ||||||
|  |  *              string function( label, step ) | ||||||
|  |  * @property float $chartPosition | ||||||
|  |  *           Position of the axis in the chart. Only useful for additional | ||||||
|  |  *           axis. The basic chart axis will be automatically positioned. | ||||||
|  |  * @property-read bool $initialized | ||||||
|  |  *           Property indicating if some values were associated with axis, or a | ||||||
|  |  *           scaling has been set manually. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | abstract class ezcGraphChartElementAxis extends ezcGraphChartElement | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Axis label renderer class | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphAxisLabelRenderer | ||||||
|  |      */ | ||||||
|  |     protected $axisLabelRenderer; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Optionally set inner boundings. May be null depending on the used chart | ||||||
|  |      * implementation. | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphBoundings | ||||||
|  |      */ | ||||||
|  |     protected $innerBoundings; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['nullPosition'] = false; | ||||||
|  |         $this->properties['axisSpace'] = .1; | ||||||
|  |         $this->properties['outerAxisSpace'] = null; | ||||||
|  |         $this->properties['majorGrid'] = false; | ||||||
|  |         $this->properties['minorGrid'] = false; | ||||||
|  |         $this->properties['majorStep'] = null; | ||||||
|  |         $this->properties['minorStep'] = null; | ||||||
|  |         $this->properties['formatString'] = '%s'; | ||||||
|  |         $this->properties['label'] = false; | ||||||
|  |         $this->properties['labelSize'] = 14; | ||||||
|  |         $this->properties['labelMargin'] = 2; | ||||||
|  |         $this->properties['minArrowHeadSize'] = 4; | ||||||
|  |         $this->properties['maxArrowHeadSize'] = 8; | ||||||
|  |         $this->properties['labelCallback'] = null; | ||||||
|  |         $this->properties['chartPosition'] = null; | ||||||
|  |         $this->properties['initialized'] = false; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  | 
 | ||||||
|  |         if ( !isset( $this->axisLabelRenderer ) ) | ||||||
|  |         { | ||||||
|  |             $this->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set colors and border fro this element | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphPalette $palette Palette | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function setFromPalette( ezcGraphPalette $palette ) | ||||||
|  |     { | ||||||
|  |         $this->border = $palette->axisColor; | ||||||
|  |         $this->padding = $palette->padding; | ||||||
|  |         $this->margin = $palette->margin; | ||||||
|  |         $this->majorGrid = $palette->majorGridColor; | ||||||
|  |         $this->minorGrid = $palette->minorGridColor; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'nullPosition': | ||||||
|  |                 $this->properties['nullPosition'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'axisSpace': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) || | ||||||
|  |                      ( $propertyValue >= 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float < 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['axisSpace'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             /* Do not yet allow to modify this value, this need further testing. | ||||||
|  |             case 'outerAxisSpace': | ||||||
|  |                 if ( !is_null( $propertyValue ) && | ||||||
|  |                      ( !is_numeric( $propertyValue ) || | ||||||
|  |                        ( $propertyValue < 0 ) || | ||||||
|  |                        ( $propertyValue >= 1 ) ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'null, or 0 <= float < 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['outerAxisSpace'] = $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             */ | ||||||
|  |             case 'majorGrid': | ||||||
|  |                 $this->properties['majorGrid'] = ezcGraphColor::create( $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |             case 'minorGrid': | ||||||
|  |                 $this->properties['minorGrid'] = ezcGraphColor::create( $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |             case 'majorStep': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 $this->properties['majorStep'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'minorStep': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 $this->properties['minorStep'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'formatString': | ||||||
|  |                 $this->properties['formatString'] = (string) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'label': | ||||||
|  |                 $this->properties['label'] = (string) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'labelSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 6 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 6' ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 $this->properties['labelSize'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'labelMargin': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 $this->properties['labelMargin'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'maxArrowHeadSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 $this->properties['maxArrowHeadSize'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'minArrowHeadSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue <= 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  |                  | ||||||
|  |                 $this->properties['minArrowHeadSize'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'axisLabelRenderer': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphAxisLabelRenderer ) | ||||||
|  |                 { | ||||||
|  |                     $this->axisLabelRenderer = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphAxisLabelRenderer' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'labelCallback': | ||||||
|  |                 if ( is_callable( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['labelCallback'] = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'callback function' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'chartPosition': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) || | ||||||
|  |                      ( $propertyValue > 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['chartPosition'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'axisLabelRenderer': | ||||||
|  |                 return $this->axisLabelRenderer; | ||||||
|  |             default: | ||||||
|  |                 return parent::__get( $propertyName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get coordinate for a dedicated value on the chart | ||||||
|  |      *  | ||||||
|  |      * @param float $value Value to determine position for | ||||||
|  |      * @return float Position on chart | ||||||
|  |      */ | ||||||
|  |     abstract public function getCoordinate( $value ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of minor steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of minor steps | ||||||
|  |      */ | ||||||
|  |     abstract public function getMinorStepCount(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return count of major steps | ||||||
|  |      *  | ||||||
|  |      * @return integer Count of major steps | ||||||
|  |      */ | ||||||
|  |     abstract public function getMajorStepCount(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get label for a dedicated step on the axis | ||||||
|  |      *  | ||||||
|  |      * @param integer $step Number of step | ||||||
|  |      * @return string label | ||||||
|  |      */ | ||||||
|  |     abstract public function getLabel( $step ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return array of steps on this axis | ||||||
|  |      *  | ||||||
|  |      * @return array( ezcGraphAxisStep ) | ||||||
|  |      */ | ||||||
|  |     public function getSteps() | ||||||
|  |     { | ||||||
|  |         $majorSteps = $this->getMajorStepCount(); | ||||||
|  |         $minorStepsPerMajorStepCount = ( $this->getMinorStepCount() / $majorSteps ); | ||||||
|  | 
 | ||||||
|  |         $majorStepSize = 1 / $majorSteps; | ||||||
|  |         $minorStepSize = ( $minorStepsPerMajorStepCount > 0 ? $majorStepSize / $minorStepsPerMajorStepCount : 0 ); | ||||||
|  | 
 | ||||||
|  |         $steps = array(); | ||||||
|  |         for ( $major = 0; $major <= $majorSteps; ++$major ) | ||||||
|  |         { | ||||||
|  |             $majorStep = new ezcGraphAxisStep( | ||||||
|  |                 $majorStepSize * $major, | ||||||
|  |                 $majorStepSize, | ||||||
|  |                 $this->getLabel( $major ), | ||||||
|  |                 array(), | ||||||
|  |                 $this->isZeroStep( $major ), | ||||||
|  |                 ( $major === $majorSteps ) | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |             if ( ( $minorStepsPerMajorStepCount > 0 ) && | ||||||
|  |                  ( $major < $majorSteps ) ) | ||||||
|  |             { | ||||||
|  |                 // Do not add minor steps at major steps positions
 | ||||||
|  |                 for( $minor = 1; $minor < $minorStepsPerMajorStepCount; ++$minor ) | ||||||
|  |                 { | ||||||
|  |                     $majorStep->childs[] = new ezcGraphAxisStep( | ||||||
|  |                         ( $majorStepSize * $major ) + ( $minorStepSize * $minor ), | ||||||
|  |                         $minorStepSize | ||||||
|  |                     ); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $steps[] = $majorStep; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $steps; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Is zero step | ||||||
|  |      * | ||||||
|  |      * Returns true if the given step is the one on the initial axis position | ||||||
|  |      *  | ||||||
|  |      * @param int $step Number of step | ||||||
|  |      * @return bool Status If given step is initial axis position | ||||||
|  |      */ | ||||||
|  |     abstract public function isZeroStep( $step ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Add data for this axis | ||||||
|  |      *  | ||||||
|  |      * @param array $values | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     abstract public function addData( array $values ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Calculate axis bounding values on base of the assigned values  | ||||||
|  |      *  | ||||||
|  |      * @abstract | ||||||
|  |      * @access public | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     abstract public function calculateAxisBoundings(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the axis  | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings for the axis | ||||||
|  |      * @return ezcGraphBoundings Remaining boundings | ||||||
|  |      */ | ||||||
|  |     public function render( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphBoundings $innerBoundings = null ) | ||||||
|  |     { | ||||||
|  |         $this->innerBoundings = $innerBoundings; | ||||||
|  |         $startSpace = $this->axisSpace; | ||||||
|  |         $endSpace   = $this->outerAxisSpace === null ? $this->axisSpace : $this->outerAxisSpace; | ||||||
|  | 
 | ||||||
|  |         switch ( $this->position ) | ||||||
|  |         { | ||||||
|  |             case ezcGraph::TOP: | ||||||
|  |                 $start = new ezcGraphCoordinate( | ||||||
|  |                     ( $boundings->x1 - $boundings->x0 ) * $startSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $startSpace ), | ||||||
|  |                     0 | ||||||
|  |                 ); | ||||||
|  |                 $end = new ezcGraphCoordinate( | ||||||
|  |                     ( $boundings->x1 - $boundings->x0 ) * $endSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $endSpace ), | ||||||
|  |                     $boundings->y1 - $boundings->y0 | ||||||
|  |                 ); | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::BOTTOM: | ||||||
|  |                 $start = new ezcGraphCoordinate( | ||||||
|  |                     ( $boundings->x1 - $boundings->x0 ) * $startSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $startSpace ), | ||||||
|  |                     $boundings->y1 - $boundings->y0 | ||||||
|  |                 ); | ||||||
|  |                 $end = new ezcGraphCoordinate( | ||||||
|  |                     ( $boundings->x1 - $boundings->x0 ) * $endSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->x1 - $boundings->x0 ) * ( 1 - 2 * $endSpace ), | ||||||
|  |                     0 | ||||||
|  |                 ); | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::LEFT: | ||||||
|  |                 $start = new ezcGraphCoordinate( | ||||||
|  |                     0, | ||||||
|  |                     ( $boundings->y1 - $boundings->y0 ) * $startSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $startSpace ) | ||||||
|  |                 ); | ||||||
|  |                 $end = new ezcGraphCoordinate( | ||||||
|  |                     $boundings->x1 - $boundings->x0, | ||||||
|  |                     ( $boundings->y1 - $boundings->y0 ) * $endSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $endSpace ) | ||||||
|  |                 ); | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::RIGHT: | ||||||
|  |                 $start = new ezcGraphCoordinate( | ||||||
|  |                     $boundings->x1 - $boundings->x0, | ||||||
|  |                     ( $boundings->y1 - $boundings->y0 ) * $startSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $startSpace ) | ||||||
|  |                 ); | ||||||
|  |                 $end = new ezcGraphCoordinate( | ||||||
|  |                     0, | ||||||
|  |                     ( $boundings->y1 - $boundings->y0 ) * $endSpace + | ||||||
|  |                         $this->nullPosition * ( $boundings->y1 - $boundings->y0 ) * ( 1 - 2 * $endSpace ) | ||||||
|  |                 ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $renderer->drawAxis( | ||||||
|  |             $boundings, | ||||||
|  |             $start, | ||||||
|  |             $end, | ||||||
|  |             $this, | ||||||
|  |             $this->axisLabelRenderer, | ||||||
|  |             $innerBoundings | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         return $boundings;    | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										221
									
								
								src/TUnit/external/ezc/Graph/element/background.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										221
									
								
								src/TUnit/external/ezc/Graph/element/background.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,221 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphChartElementBackground class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Chart element representing the background. | ||||||
|  |  * | ||||||
|  |  * Chart elements can be understood as widgets or layout container inside the | ||||||
|  |  * chart. The actual transformation to images happens inside the renderers. | ||||||
|  |  * They represent all elements inside the chart and contain mostly general | ||||||
|  |  * formatting options, while the renderer itself might define additional | ||||||
|  |  * formatting options for some chart elments. You can find more about the | ||||||
|  |  * general formatting options for chart elements in the base class | ||||||
|  |  * ezcGraphChartElement. | ||||||
|  |  * | ||||||
|  |  * Additionally to common background and border for chart elements it can draw | ||||||
|  |  * an image on the chart background, and optionally repeat it. The position | ||||||
|  |  * will be used to define the start of the repetition. | ||||||
|  |  * | ||||||
|  |  * The repetition effects are modelled similar to the background settings in | ||||||
|  |  * CSS. The example shows some common settings: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart = new ezcGraphPieChart(); | ||||||
|  |  *  $chart->data['example'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *      'Foo' => 23, | ||||||
|  |  *      'Bar' => 42, | ||||||
|  |  *  ) ); | ||||||
|  |  * | ||||||
|  |  *  $chart->background->image = 'background.png'; | ||||||
|  |  * | ||||||
|  |  *  // Image would be repeated horizontal at the top of the background
 | ||||||
|  |  *  $chart->background->repeat = ezcGraph::HORIZONTAL; | ||||||
|  |  *  $chart->background->postion = ezcGraph::TOP; | ||||||
|  |  * | ||||||
|  |  *  // Image would be placed once in the center
 | ||||||
|  |  *  $chart->background->repeat = ezcGraph::NO_REPEAT; // default;
 | ||||||
|  |  *  $chart->background->position = ezcGraph::CENTER | ezcGraph::MIDDLE; | ||||||
|  |  * | ||||||
|  |  *  // Image would be repeated all over the chart, the position is irrelevant
 | ||||||
|  |  *  $chart->background->repeat = ezcGraph::HORIZONTAL | ezcGraph::VERTICAL; | ||||||
|  |  * | ||||||
|  |  *  $graph->render( 400, 250, 'legend.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property string $image | ||||||
|  |  *           Filename of the file to use for background | ||||||
|  |  * @property int $repeat | ||||||
|  |  *           Defines how the background image gets repeated | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementBackground extends ezcGraphChartElement | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['image'] = false; | ||||||
|  |         $this->properties['repeat'] = ezcGraph::NO_REPEAT; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'image': | ||||||
|  |                 // 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->properties['image'] = $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'repeat': | ||||||
|  |                 if ( ( $propertyValue >= 0 ) && ( $propertyValue <= 3 ) ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['repeat'] = (int) $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 3' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'position': | ||||||
|  |                 // Overwrite parent position setter, to be able to use 
 | ||||||
|  |                 // combination of positions like 
 | ||||||
|  |                 //      ezcGraph::TOP | ezcGraph::CENTER
 | ||||||
|  |                 if ( is_int( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['position'] = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 else  | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'integer' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'color': | ||||||
|  |                 // Use color as an alias to set background color for background
 | ||||||
|  |                 $this->__set( 'background', $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 return parent::__set( $propertyName, $propertyValue ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'color': | ||||||
|  |                 // Use color as an alias to set background color for background
 | ||||||
|  |                 return $this->properties['background']; | ||||||
|  |             default: | ||||||
|  |                 return parent::__get( $propertyName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set colors and border for this element | ||||||
|  |      * | ||||||
|  |      * Method is overwritten because we do not ant to apply the global padding  | ||||||
|  |      * and margin here. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphPalette $palette Palette | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function setFromPalette( ezcGraphPalette $palette ) | ||||||
|  |     { | ||||||
|  |         $this->border = $palette->chartBorderColor; | ||||||
|  |         $this->borderWidth = $palette->chartBorderWidth; | ||||||
|  |         $this->background = $palette->chartBackground; | ||||||
|  |         $this->padding = 0; | ||||||
|  |         $this->margin = 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the background | ||||||
|  |      * | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings | ||||||
|  |      * @return ezcGraphBoundings Remaining boundings | ||||||
|  |      */ | ||||||
|  |     public function render( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         $boundings = $renderer->drawBox( | ||||||
|  |             $boundings, | ||||||
|  |             $this->background, | ||||||
|  |             $this->border, | ||||||
|  |             $this->borderWidth, | ||||||
|  |             $this->margin, | ||||||
|  |             $this->padding | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         if ( $this->image === false ) | ||||||
|  |         { | ||||||
|  |             return $boundings; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $renderer->drawBackgroundImage( | ||||||
|  |             $boundings, | ||||||
|  |             $this->image, | ||||||
|  |             $this->position, | ||||||
|  |             $this->repeat | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         return $boundings; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										339
									
								
								src/TUnit/external/ezc/Graph/element/legend.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										339
									
								
								src/TUnit/external/ezc/Graph/element/legend.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,339 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphChartElementLegend class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent a legend as a chart element | ||||||
|  |  * | ||||||
|  |  * Chart elements can be understood as widgets or layout container inside the | ||||||
|  |  * chart. The actual transformation to images happens inside the renderers. | ||||||
|  |  * They represent all elements inside the chart and contain mostly general | ||||||
|  |  * formatting options, while the renderer itself might define additional | ||||||
|  |  * formatting options for some chart elments. You can find more about the | ||||||
|  |  * general formatting options for chart elements in the base class | ||||||
|  |  * ezcGraphChartElement. | ||||||
|  |  * | ||||||
|  |  * The legend chart element is used to display the legend of a chart. It can be | ||||||
|  |  * deactivated by setting the legend to false, like: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart->legend = false; | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * The position of the legend in the chart can be influenced by the postion | ||||||
|  |  * property, set to one of the position constants from the ezcGraph base class, | ||||||
|  |  * like ezcGraph::BOTTOM, ezcGraph::LEFT, ezcGraph::RIGHT, ezcGraph::TOP. | ||||||
|  |  * | ||||||
|  |  * Depending on the position of the legend, either the $portraitSize (RIGHT, | ||||||
|  |  * LEFT) or the $landscapeSize (TOP, BOTTOM) defines how much space will be | ||||||
|  |  * aqquired for the legend. | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphPieChart(); | ||||||
|  |  *  $graph->data['example'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *      'Foo' => 23, | ||||||
|  |  *      'Bar' => 42, | ||||||
|  |  *  ) ); | ||||||
|  |  *   | ||||||
|  |  *  // Format the legend element
 | ||||||
|  |  *  $graph->legend->background    = '#FFFFFF80'; | ||||||
|  |  * | ||||||
|  |  *  // Place at the bottom of the chart, with a height of 5% of the remaining
 | ||||||
|  |  *  // chart space.
 | ||||||
|  |  *  $graph->legend->position      = ezcGraph::BOTTOM; | ||||||
|  |  *  $graph->legend->landscapeSize = .05; | ||||||
|  |  *   | ||||||
|  |  *  $graph->render( 400, 250, 'legend.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property float $portraitSize | ||||||
|  |  *           Size of a portrait style legend in percent of the size of the  | ||||||
|  |  *           complete chart. | ||||||
|  |  * @property float $landscapeSize | ||||||
|  |  *           Size of a landscape style legend in percent of the size of the  | ||||||
|  |  *           complete chart. | ||||||
|  |  * @property int $symbolSize | ||||||
|  |  *           Standard size of symbols and text in legends. | ||||||
|  |  * @property float $minimumSymbolSize | ||||||
|  |  *           Scale symbol size up to to percent of complete legends size for  | ||||||
|  |  *           very big legends. | ||||||
|  |  * @property int $spacing | ||||||
|  |  *           Space between labels elements in pixel. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementLegend extends ezcGraphChartElement | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains data which should be shown in the legend | ||||||
|  |      *  array( | ||||||
|  |      *      array( | ||||||
|  |      *          'label' => (string) 'Label of data element', | ||||||
|  |      *          'color' => (ezcGraphColor) $color, | ||||||
|  |      *          'symbol' => (integer) ezcGraph::DIAMOND, | ||||||
|  |      *      ), | ||||||
|  |      *      ... | ||||||
|  |      *  ) | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $labels; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['portraitSize'] = .2; | ||||||
|  |         $this->properties['landscapeSize'] = .1; | ||||||
|  |         $this->properties['symbolSize'] = 14; | ||||||
|  |         $this->properties['padding'] = 1; | ||||||
|  |         $this->properties['minimumSymbolSize'] = .05; | ||||||
|  |         $this->properties['spacing'] = 2; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'padding': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['padding'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'symbolSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['symbolSize'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'landscapeSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) || | ||||||
|  |                      ( $propertyValue > 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['landscapeSize'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'portraitSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) || | ||||||
|  |                      ( $propertyValue > 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['portraitSize'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'minimumSymbolSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) || | ||||||
|  |                      ( $propertyValue > 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['minimumSymbolSize'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'spacing': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['spacing'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'labels': | ||||||
|  |                 return $this->labels; | ||||||
|  |             default: | ||||||
|  |                 return parent::__get( $propertyName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Generate legend from several datasets with on entry per dataset | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphChartDataContainer $datasets  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function generateFromDataSets( ezcGraphChartDataContainer $datasets ) | ||||||
|  |     { | ||||||
|  |         $this->labels = array(); | ||||||
|  |         foreach ( $datasets as $dataset ) | ||||||
|  |         { | ||||||
|  |             $this->labels[] = array( | ||||||
|  |                 'label' => $dataset->label->default, | ||||||
|  |                 'url' => $dataset->url->default, | ||||||
|  |                 'color' => $dataset->color->default, | ||||||
|  |                 'symbol' => ( $dataset->symbol->default === null ? | ||||||
|  |                               ezcGraph::NO_SYMBOL : | ||||||
|  |                               $dataset->symbol->default ), | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Generate legend from single dataset with on entry per data element  | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphDataSet $dataset  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function generateFromDataSet( ezcGraphDataSet $dataset ) | ||||||
|  |     { | ||||||
|  |         $this->labels = array(); | ||||||
|  |         foreach ( $dataset as $label => $data ) | ||||||
|  |         { | ||||||
|  |             $this->labels[] = array( | ||||||
|  |                 'label' => $label, | ||||||
|  |                 'url' => $dataset->url[$label], | ||||||
|  |                 'color' => $dataset->color[$label], | ||||||
|  |                 'symbol' => ( $dataset->symbol[$label] === null ? | ||||||
|  |                               ezcGraph::NO_SYMBOL : | ||||||
|  |                               $dataset->symbol[$label] ), | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Calculated boundings needed for the legend. | ||||||
|  |      * | ||||||
|  |      * Uses the position and the configured horizontal or vertical size of a  | ||||||
|  |      * legend to calculate the boundings for the legend. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphBoundings $boundings Avalable boundings | ||||||
|  |      * @return ezcGraphBoundings Remaining boundings | ||||||
|  |      */ | ||||||
|  |     protected function calculateBoundings( ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         $this->properties['boundings'] = clone $boundings; | ||||||
|  | 
 | ||||||
|  |         switch ( $this->position ) | ||||||
|  |         { | ||||||
|  |             case ezcGraph::LEFT: | ||||||
|  |                 $size = ( $boundings->width ) * $this->portraitSize; | ||||||
|  | 
 | ||||||
|  |                 $boundings->x0 += $size; | ||||||
|  |                 $this->boundings->x1 = $boundings->x0; | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::RIGHT: | ||||||
|  |                 $size = ( $boundings->width ) * $this->portraitSize; | ||||||
|  | 
 | ||||||
|  |                 $boundings->x1 -= $size; | ||||||
|  |                 $this->boundings->x0 = $boundings->x1; | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::TOP: | ||||||
|  |                 $size = ( $boundings->height ) * $this->landscapeSize; | ||||||
|  | 
 | ||||||
|  |                 $boundings->y0 += $size; | ||||||
|  |                 $this->boundings->y1 = $boundings->y0; | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::BOTTOM: | ||||||
|  |                 $size = ( $boundings->height ) * $this->landscapeSize; | ||||||
|  | 
 | ||||||
|  |                 $boundings->y1 -= $size; | ||||||
|  |                 $this->boundings->y0 = $boundings->y1; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return $boundings; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render a legend | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings for the axis | ||||||
|  |      * @return ezcGraphBoundings Remaining boundings | ||||||
|  |      */ | ||||||
|  |     public function render( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         $boundings = $this->calculateBoundings( $boundings ); | ||||||
|  |          | ||||||
|  |         if ( $this->position === ezcGraph::LEFT || $this->position === ezcGraph::RIGHT ) | ||||||
|  |         { | ||||||
|  |             $type = ezcGraph::VERTICAL; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $type = ezcGraph::HORIZONTAL; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Render standard elements
 | ||||||
|  |         $this->properties['boundings'] = $renderer->drawBox( | ||||||
|  |             $this->properties['boundings'], | ||||||
|  |             $this->properties['background'], | ||||||
|  |             $this->properties['border'], | ||||||
|  |             $this->properties['borderWidth'], | ||||||
|  |             $this->properties['margin'], | ||||||
|  |             $this->properties['padding'], | ||||||
|  |             $this->properties['title'], | ||||||
|  |             $this->getTitleSize( $this->properties['boundings'], $type ) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Render legend
 | ||||||
|  |         $renderer->drawLegend( | ||||||
|  |             $this->boundings, | ||||||
|  |             $this, | ||||||
|  |             $type | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         return $boundings;   | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										150
									
								
								src/TUnit/external/ezc/Graph/element/text.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								src/TUnit/external/ezc/Graph/element/text.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,150 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphChartElementText class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Chart element to display texts in a chart | ||||||
|  |  * | ||||||
|  |  * Chart elements can be understood as widgets or layout container inside the | ||||||
|  |  * chart. The actual transformation to images happens inside the renderers. | ||||||
|  |  * They represent all elements inside the chart and contain mostly general | ||||||
|  |  * formatting options, while the renderer itself might define additional | ||||||
|  |  * formatting options for some chart elments. You can find more about the | ||||||
|  |  * general formatting options for chart elements in the base class | ||||||
|  |  * ezcGraphChartElement. | ||||||
|  |  * | ||||||
|  |  * The text element can only be placed at the top or the bottom of the chart. | ||||||
|  |  * Beside the common options it has only one additional option defining the | ||||||
|  |  * maximum height used for the text box. The actaully required height is | ||||||
|  |  * calculated based on the assigned text size. | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $chart = new ezcGraphPieChart(); | ||||||
|  |  *  $chart->data['example'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *      'Foo' => 23, | ||||||
|  |  *      'Bar' => 42, | ||||||
|  |  *  ) ); | ||||||
|  |  * | ||||||
|  |  *  $chart->title = 'Some pie chart'; | ||||||
|  |  * | ||||||
|  |  *  // Use at maximum 5% of the chart height for the title.
 | ||||||
|  |  *  $chart->title->maxHeight = .05; | ||||||
|  |  * | ||||||
|  |  *  $graph->render( 400, 250, 'title.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @property float $maxHeight | ||||||
|  |  *           Maximum percent of bounding used to display the text. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  * @mainclass | ||||||
|  |  */ | ||||||
|  | class ezcGraphChartElementText extends ezcGraphChartElement | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['maxHeight'] = .1; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'maxHeight': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) || | ||||||
|  |                      ( $propertyValue > 1 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['maxHeight'] = (float) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 parent::__set( $propertyName, $propertyValue ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render the text | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings for the axis | ||||||
|  |      * @return ezcGraphBoundings Remaining boundings | ||||||
|  |      */ | ||||||
|  |     public function render( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings ) | ||||||
|  |     { | ||||||
|  |         $height = (int) min(  | ||||||
|  |             round( $this->properties['maxHeight'] * ( $boundings->y1 - $boundings->y0 ) ), | ||||||
|  |             $this->properties['font']->maxFontSize + $this->padding * 2 + $this->margin * 2 | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         switch ( $this->properties['position'] ) | ||||||
|  |         { | ||||||
|  |             case ezcGraph::TOP: | ||||||
|  |                 $textBoundings = new ezcGraphBoundings( | ||||||
|  |                     $boundings->x0, | ||||||
|  |                     $boundings->y0, | ||||||
|  |                     $boundings->x1, | ||||||
|  |                     $boundings->y0 + $height | ||||||
|  |                 ); | ||||||
|  |                 $boundings->y0 += $height + $this->properties['margin']; | ||||||
|  |                 break; | ||||||
|  |             case ezcGraph::BOTTOM: | ||||||
|  |                 $textBoundings = new ezcGraphBoundings( | ||||||
|  |                     $boundings->x0, | ||||||
|  |                     $boundings->y1 - $height, | ||||||
|  |                     $boundings->x1, | ||||||
|  |                     $boundings->y1 | ||||||
|  |                 ); | ||||||
|  |                 $boundings->y1 -= $height + $this->properties['margin']; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $textBoundings = $renderer->drawBox( | ||||||
|  |             $textBoundings, | ||||||
|  |             $this->properties['background'], | ||||||
|  |             $this->properties['border'], | ||||||
|  |             $this->properties['borderWidth'], | ||||||
|  |             $this->properties['margin'], | ||||||
|  |             $this->properties['padding'] | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         $renderer->drawText( | ||||||
|  |             $textBoundings, | ||||||
|  |             $this->properties['title'], | ||||||
|  |             ezcGraph::CENTER | ezcGraph::MIDDLE | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         return $boundings; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										33
									
								
								src/TUnit/external/ezc/Graph/exceptions/date_parsing.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/TUnit/external/ezc/Graph/exceptions/date_parsing.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphErrorParsingDateException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a date assigned to the  | ||||||
|  |  * {@link ezcGraphChartElementDateAxis} could not be parsed. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphErrorParsingDateException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param mixed $value | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $value ) | ||||||
|  |     { | ||||||
|  |         $type = gettype( $value ); | ||||||
|  |         parent::__construct( "Could not parse date '{$value}' of type '{$type}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										20
									
								
								src/TUnit/external/ezc/Graph/exceptions/exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/TUnit/external/ezc/Graph/exceptions/exception.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * Base exception for the Graph package. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * General exception container for the Graph component. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | abstract class ezcGraphException extends ezcBaseException | ||||||
|  | { | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/flash_bitmap_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/flash_bitmap_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphFlashBitmapTypeException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Flash can only embed JPEGs and PNGs. This exception is thrown for * all | ||||||
|  |  * other image types. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphFlashBitmapTypeException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Flash can only read JPEGs and PNGs." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										40
									
								
								src/TUnit/external/ezc/Graph/exceptions/font_rendering.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/TUnit/external/ezc/Graph/exceptions/font_rendering.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphFontRenderingException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when it is not possible to render a string beacause of  | ||||||
|  |  * minimum font size in the desinated bounding box. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphFontRenderingException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $string | ||||||
|  |      * @param float $size | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $string, $size, $width, $height ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Could not fit string '{$string}' with font size '{$size}' in box '{$width} * {$height}'.
 | ||||||
|  | Possible solutions to solve this problem: | ||||||
|  |     - Decrease the amount of steps on the axis. | ||||||
|  |     - Increase the size of the chart. | ||||||
|  |     - Decrease the minimum font size. | ||||||
|  |     - Use a font which consumes less space for each character." );
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/font_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/font_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphUnknownFontTypeException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown if font type is unknown or not supported. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphUnknownFontTypeException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $file | ||||||
|  |      * @param string $extension | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $file, $extension ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Unknown font type '{$extension}' of file '{$file}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										34
									
								
								src/TUnit/external/ezc/Graph/exceptions/incompatible_driver.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/TUnit/external/ezc/Graph/exceptions/incompatible_driver.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphToolsIncompatibleDriverException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when trying to modify rendered images with incompatible | ||||||
|  |  * graph tools. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphToolsIncompatibleDriverException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param mixed $driver | ||||||
|  |      * @param string $accepted | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $driver, $accepted ) | ||||||
|  |     { | ||||||
|  |         $driverClass = get_class( $driver ); | ||||||
|  |         parent::__construct( "Incompatible driver used. Driver '{$driverClass}' is not an instance of '{$accepted}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_assignement.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_assignement.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphInvalidAssignementException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown, when trying a property cannot be set for a data point, but | ||||||
|  |  * only for data sets. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphInvalidAssignementException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "This cannot be set on data points, but only for data sets." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_data.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_data.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphInvalidDataException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when invalid data is provided, which cannot be rendered  | ||||||
|  |  * for some reason. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphInvalidDataException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $message | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $message ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "You provided unusable data: '$message'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										33
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_data_source.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_data_source.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphInvalidArrayDataSourceException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when an invalid data source is provided for an array  | ||||||
|  |  * data set. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphInvalidArrayDataSourceException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param mixed $value | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $value ) | ||||||
|  |     { | ||||||
|  |         $type = gettype( $value ); | ||||||
|  |         parent::__construct( "The array dataset can only use arrays and iterators, but you supplied '{$type}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										35
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_dimensions.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_dimensions.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphMatrixInvalidDimensionsException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when an operation is not possible because of incompatible | ||||||
|  |  * matrix dimensions. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphMatrixInvalidDimensionsException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param int $rows | ||||||
|  |      * @param int $columns | ||||||
|  |      * @param int $dRows | ||||||
|  |      * @param int $dColumns | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $rows, $columns, $dRows, $dColumns ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Matrix '{$dRows}, {$dColumns}' is incompatible with matrix '{$rows}, {$columns}' for requested operation." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										46
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_display_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_display_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphInvalidDisplayTypeException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when an unsupported data type is set for the current chart. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphInvalidDisplayTypeException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param int $type | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $type ) | ||||||
|  |     { | ||||||
|  |         $chartTypeNames = array( | ||||||
|  |             ezcGraph::PIE => 'Pie', | ||||||
|  |             ezcGraph::LINE => 'Line', | ||||||
|  |             ezcGraph::BAR => 'Bar', | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         if ( isset( $chartTypeNames[$type] ) ) | ||||||
|  |         { | ||||||
|  |             $chartTypeName = $chartTypeNames[$type]; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $chartTypeName = 'Unknown'; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         parent::__construct( "Invalid data set display type '$type' ('$chartTypeName') for current chart." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_id.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_id.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphSvgDriverInvalidIdException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a id could not be found in a SVG document to insert  | ||||||
|  |  * elements in. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphSvgDriverInvalidIdException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      * | ||||||
|  |      * @param string $id | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $id ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Could not find element with id '{$id}' in SVG document." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_image_file.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_image_file.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphInvalidImageFileException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a file can not be used as a image file. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphInvalidImageFileException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $image | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $image ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "File '{$image}' is not a valid image." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_keys.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_keys.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphDatasetAverageInvalidKeysException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a dataset with non numeric keys is used with average  | ||||||
|  |  * datasets. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphDatasetAverageInvalidKeysException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "You can not use non numeric keys with Average datasets." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_step_size.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/invalid_step_size.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphInvalidStepSizeException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when the major or minor step size does not divide cleanly | ||||||
|  |  * the value span it should be used for. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphInvalidStepSizeException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $message | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $message ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Invalid step size on numeric axis: {$message}." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										30
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_data.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_data.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphNoDataException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception shown, when trying to render a chart without assigning any data. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphNoDataException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "No data sets assigned to chart." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_such_data.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_such_data.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphNoSuchDataException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception shown, when trying to access not existing data in datasets. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphNoSuchDataException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $name | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $name ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "No data with name '{$name}' found." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_such_dataset.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_such_dataset.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphNoSuchDataSetException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when trying to access a non exising dataset. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphNoSuchDataSetException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $name | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $name ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "No dataset with identifier '{$name}' could be found." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_such_element.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/no_such_element.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphNoSuchElementException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when trying to access a non existing chart element. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphNoSuchElementException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param string $name | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $name ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "No chart element with name '{$name}' found." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/not_rendered.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/not_rendered.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphToolsNotRenderedException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a chart was not rendered yet, but the graph tool  | ||||||
|  |  * requires information only available in rendered charts. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphToolsNotRenderedException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphChart $chart | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $chart ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Chart is not yet rendered." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										35
									
								
								src/TUnit/external/ezc/Graph/exceptions/out_of_boundings.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/TUnit/external/ezc/Graph/exceptions/out_of_boundings.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphMatrixOutOfBoundingsException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a requested matrix value is out of the boundings of  | ||||||
|  |  * the matrix. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphMatrixOutOfBoundingsException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param int $rows | ||||||
|  |      * @param int $columns | ||||||
|  |      * @param int $rPos | ||||||
|  |      * @param int $cPos | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $rows, $columns, $rPos, $cPos ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Position '{$rPos}, {$cPos}' is out of the matrix boundings '{$rows}, {$columns}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/out_of_logarithmical_boundings.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/out_of_logarithmical_boundings.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphOutOfLogithmicalBoundingsException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when data exceeds the values which are displayable on an | ||||||
|  |  * logarithmical scaled axis. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphOutOfLogithmicalBoundingsException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param int $minimum | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $minimum ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Value '$minimum' exceeds displayable values on a logarithmical scaled axis." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/reducement_failed.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/reducement_failed.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphReducementFailedException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a requested reducement of an ellipse or polygone  | ||||||
|  |  * failed because the shape was already too small. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphReducementFailedException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Reducement of shape failed, because it was already too small." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/too_many_datasets.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/too_many_datasets.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphTooManyDataSetsExceptions class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when trying to insert too many data sets in a data set  | ||||||
|  |  * container. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphTooManyDataSetsExceptions extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "You tried to insert to many datasets." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/unknown_color_definition.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/TUnit/external/ezc/Graph/exceptions/unknown_color_definition.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphUnknownColorDefinitionException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown, when a given value could not be interpreted as a color by | ||||||
|  |  * {@link ezcGraphColor}. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphUnknownColorDefinitionException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param mixed $definition | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $definition ) | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Unknown color definition '{$definition}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/unregular_steps.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/TUnit/external/ezc/Graph/exceptions/unregular_steps.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphUnregularStepsException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown when a bar chart shouls be rendered on an axis using  | ||||||
|  |  * unregular step sizes. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphUnregularStepsException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct( "Bar charts do not support axis with unregular steps sizes." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										61
									
								
								src/TUnit/external/ezc/Graph/exceptions/unsupported_image_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/TUnit/external/ezc/Graph/exceptions/unsupported_image_type.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,61 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the ezcGraphGdDriverUnsupportedImageTypeException class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Exception thrown if the image type is not supported and therefore could not | ||||||
|  |  * be used in the gd driver. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | class ezcGraphGdDriverUnsupportedImageTypeException extends ezcGraphException | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param int $type | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( $type ) | ||||||
|  |     { | ||||||
|  |         $typeName = array( | ||||||
|  |             1 => 'GIF', | ||||||
|  |             2 => 'Jpeg', | ||||||
|  |             3 => 'PNG', | ||||||
|  |             4 => 'SWF', | ||||||
|  |             5 => 'PSD', | ||||||
|  |             6 => 'BMP', | ||||||
|  |             7 => 'TIFF (intel)', | ||||||
|  |             8 => 'TIFF (motorola)', | ||||||
|  |             9 => 'JPC', | ||||||
|  |             10 => 'JP2', | ||||||
|  |             11 => 'JPX', | ||||||
|  |             12 => 'JB2', | ||||||
|  |             13 => 'SWC', | ||||||
|  |             14 => 'IFF', | ||||||
|  |             15 => 'WBMP', | ||||||
|  |             16 => 'XBM', | ||||||
|  | 
 | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         if ( isset( $typeName[$type] ) ) | ||||||
|  |         { | ||||||
|  |             $type = $typeName[$type]; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $type = 'Unknown'; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         parent::__construct( "Unsupported image format '{$type}'." ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										147
									
								
								src/TUnit/external/ezc/Graph/graph.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								src/TUnit/external/ezc/Graph/graph.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,147 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraph class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Base options class for all eZ components. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | class ezcGraph | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * No symbol, will fallback to a rect in the legend | ||||||
|  |      */ | ||||||
|  |     const NO_SYMBOL = 0; | ||||||
|  |     /** | ||||||
|  |      * Rhomb like looking symbol | ||||||
|  |      */ | ||||||
|  |     const DIAMOND = 1; | ||||||
|  |     /** | ||||||
|  |      * Filled circle | ||||||
|  |      */ | ||||||
|  |     const BULLET = 2; | ||||||
|  |     /** | ||||||
|  |      * Non filled circle | ||||||
|  |      */ | ||||||
|  |     const CIRCLE = 3; | ||||||
|  |     /** | ||||||
|  |      * Arrow head symbol, used for axis end markers, not available as a dataset | ||||||
|  |      * symbol. | ||||||
|  |      */ | ||||||
|  |     const ARROW = 4; | ||||||
|  |     /** | ||||||
|  |      * A square, filled box, symbol | ||||||
|  |      */ | ||||||
|  |     const SQUARE = 5; | ||||||
|  |     /** | ||||||
|  |      * A non-filled box symbol | ||||||
|  |      */ | ||||||
|  |     const BOX = 6; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constant used for background repetition. No repeat. | ||||||
|  |      */ | ||||||
|  |     const NO_REPEAT = 0; | ||||||
|  |     /** | ||||||
|  |      * Constant used for background repetition. Repeat along the x axis. May be | ||||||
|  |      * used as a bitmask together with ezcGraph::VERTICAL. | ||||||
|  |      */ | ||||||
|  |     const HORIZONTAL = 1; | ||||||
|  |     /** | ||||||
|  |      * Constant used for background repetition. Repeat along the y axis. May be | ||||||
|  |      * used as a bitmask together with ezcGraph::HORIZONTAL. | ||||||
|  |      */ | ||||||
|  |     const VERTICAL = 2; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constant used for positioning of elements. May be used as a bitmask  | ||||||
|  |      * together with other postioning constants. | ||||||
|  |      * Element will be placed at the top of the current boundings. | ||||||
|  |      */ | ||||||
|  |     const TOP = 1; | ||||||
|  |     /** | ||||||
|  |      * Constant used for positioning of elements. May be used as a bitmask  | ||||||
|  |      * together with other postioning constants. | ||||||
|  |      * Element will be placed at the bottom of the current boundings. | ||||||
|  |      */ | ||||||
|  |     const BOTTOM = 2; | ||||||
|  |     /** | ||||||
|  |      * Constant used for positioning of elements. May be used as a bitmask  | ||||||
|  |      * together with other postioning constants. | ||||||
|  |      * Element will be placed at the left of the current boundings. | ||||||
|  |      */ | ||||||
|  |     const LEFT = 4; | ||||||
|  |     /** | ||||||
|  |      * Constant used for positioning of elements. May be used as a bitmask  | ||||||
|  |      * together with other postioning constants. | ||||||
|  |      * Element will be placed at the right of the current boundings. | ||||||
|  |      */ | ||||||
|  |     const RIGHT = 8; | ||||||
|  |     /** | ||||||
|  |      * Constant used for positioning of elements. May be used as a bitmask  | ||||||
|  |      * together with other postioning constants. | ||||||
|  |      * Element will be placed at the horizontalcenter of the current boundings. | ||||||
|  |      */ | ||||||
|  |     const CENTER = 16; | ||||||
|  |     /** | ||||||
|  |      * Constant used for positioning of elements. May be used as a bitmask  | ||||||
|  |      * together with other postioning constants. | ||||||
|  |      * Element will be placed at the vertical middle of the current boundings. | ||||||
|  |      */ | ||||||
|  |     const MIDDLE = 32; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Display type for datasets. Pie may only be used with pie charts.  | ||||||
|  |      */ | ||||||
|  |     const PIE = 1; | ||||||
|  |     /** | ||||||
|  |      * Display type for datasets. Bar and line charts may contain datasets of | ||||||
|  |      * type ezcGraph::LINE. | ||||||
|  |      */ | ||||||
|  |     const LINE = 2; | ||||||
|  |     /** | ||||||
|  |      * Display type for datasets. Bar and line charts may contain datasets of | ||||||
|  |      * type ezcGraph::BAR. | ||||||
|  |      */ | ||||||
|  |     const BAR = 3; | ||||||
|  |     /** | ||||||
|  |      * @TODO: | ||||||
|  |      */ | ||||||
|  |     const ODOMETER = 4; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Font type definition. Used for True Type fonts. | ||||||
|  |      */ | ||||||
|  |     const TTF_FONT = 1; | ||||||
|  |     /** | ||||||
|  |      * Font type definition. Used for Postscript Type 1 fonts. | ||||||
|  |      */ | ||||||
|  |     const PS_FONT = 2; | ||||||
|  |     /** | ||||||
|  |      * Font type definition. Used for Palm Format Fonts for Ming driver. | ||||||
|  |      */ | ||||||
|  |     const PALM_FONT = 3; | ||||||
|  |     /** | ||||||
|  |      * Font type definition. Used for SVG fonts vonverted by ttf2svg used in | ||||||
|  |      * the SVG driver. | ||||||
|  |      */ | ||||||
|  |     const SVG_FONT = 4; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Identifier for keys in complex dataset arrays | ||||||
|  |      */ | ||||||
|  |     const KEY = 0; | ||||||
|  |     /** | ||||||
|  |      * Identifier for values in complex dataset arrays | ||||||
|  |      */ | ||||||
|  |     const VALUE = 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										557
									
								
								src/TUnit/external/ezc/Graph/interfaces/axis_label_renderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										557
									
								
								src/TUnit/external/ezc/Graph/interfaces/axis_label_renderer.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,557 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphAxisLabelRenderer class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Abstract class to render labels and grids on axis. Will be extended to | ||||||
|  |  * make it possible using different algorithms for rendering axis labels. | ||||||
|  |  * | ||||||
|  |  * Implements basic methods to render the grid and steps on a axis. | ||||||
|  |  * | ||||||
|  |  * @property bool $majorStepCount | ||||||
|  |  *           Count of major steps. | ||||||
|  |  * @property bool $minorStepCount | ||||||
|  |  *           Count of minor steps. | ||||||
|  |  * @property int $majorStepSize | ||||||
|  |  *           Size of major steps. | ||||||
|  |  * @property int $minorStepSize | ||||||
|  |  *           Size of minor steps. | ||||||
|  |  * @property bool $innerStep | ||||||
|  |  *           Indicates if steps are shown on the inner side of axis. | ||||||
|  |  * @property bool $outerStep | ||||||
|  |  *           Indicates if steps are shown on the outer side of axis. | ||||||
|  |  * @property bool $outerGrid | ||||||
|  |  *           Indicates if the grid is shown on the outer side of axis. | ||||||
|  |  * @property bool $showLables | ||||||
|  |  *           Indicates if the labels should be shown | ||||||
|  |  * @property int $labelPadding | ||||||
|  |  *           Padding of labels. | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | abstract class ezcGraphAxisLabelRenderer extends ezcBaseOptions | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Driver to render axis labels | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphDriver | ||||||
|  |      */ | ||||||
|  |     protected $driver; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->properties['majorStepCount'] = false; | ||||||
|  |         $this->properties['minorStepCount'] = false; | ||||||
|  |         $this->properties['majorStepSize'] = 3; | ||||||
|  |         $this->properties['minorStepSize'] = 1; | ||||||
|  |         $this->properties['innerStep'] = true; | ||||||
|  |         $this->properties['outerStep'] = false; | ||||||
|  |         $this->properties['outerGrid'] = false; | ||||||
|  |         $this->properties['showLabels'] = true; | ||||||
|  |         $this->properties['labelPadding'] = 2; | ||||||
|  | 
 | ||||||
|  |         parent::__construct( $options ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __set  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @param mixed $propertyValue  | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If a submitted parameter was out of range or type. | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue ) | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) | ||||||
|  |         { | ||||||
|  |             case 'driver': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphDriver ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['driver'] = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcGraphInvalidDriverException( $propertyValue ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'majorStepCount': | ||||||
|  |                 if ( ( $propertyValue !== false ) && | ||||||
|  |                      !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['majorStepCount'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'minorStepCount': | ||||||
|  |                 if ( ( $propertyValue !== false ) && | ||||||
|  |                      !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['minorStepCount'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'majorStepSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['majorStepSize'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'minorStepSize': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['minorStepSize'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'innerStep': | ||||||
|  |                 if ( !is_bool( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['innerStep'] = (bool) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'outerStep': | ||||||
|  |                 if ( !is_bool( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['outerStep'] = (bool) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'outerGrid': | ||||||
|  |                 if ( !is_bool( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['outerGrid'] = (bool) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'showLabels': | ||||||
|  |                 if ( !is_bool( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['showLabels'] = (bool) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'labelPadding': | ||||||
|  |                 if ( !is_numeric( $propertyValue ) || | ||||||
|  |                      ( $propertyValue < 0 ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->properties['labelPadding'] = (int) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Checks for the cutting point of two lines. | ||||||
|  |      * | ||||||
|  |      * The lines are given by a start position and the direction of the line,  | ||||||
|  |      * both as instances of {@link ezcGraphCoordinate}. If no cutting point | ||||||
|  |      * could be calculated, because the lines are parallel the function will | ||||||
|  |      * return false. Otherwise the factor returned can be used to calculate the | ||||||
|  |      * cutting point using the following equatation: | ||||||
|  |      *  point = $aStart + $factor * $aDir; | ||||||
|  |      * | ||||||
|  |      * We return the factor instead of the resulting point because it can be  | ||||||
|  |      * easily determined from the factor if the cutting point is in "behind" | ||||||
|  |      * the line starting point, or if the distance to the cutting point is | ||||||
|  |      * bigger then the direction vector is long ( $factor > 1 ). | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $aStart  | ||||||
|  |      * @param ezcGraphCoordinate $aDir  | ||||||
|  |      * @param ezcGraphCoordinate $bStart  | ||||||
|  |      * @param ezcGraphCoordinate $bDir  | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function determineLineCuttingPoint( ezcGraphCoordinate $aStart, ezcGraphCoordinate $aDir, ezcGraphCoordinate $bStart, ezcGraphCoordinate $bDir ) | ||||||
|  |     { | ||||||
|  |         // Check if lines are parallel
 | ||||||
|  |         if ( ( ( abs( $aDir->x ) < .000001 ) && ( abs( $bDir->x ) < .000001 ) ) || | ||||||
|  |              ( ( abs( $aDir->y ) < .000001 ) && ( abs( $bDir->y ) < .000001 ) ) ||  | ||||||
|  |              ( ( abs( $aDir->x * $bDir->x * $aDir->y * $bDir->y ) > .000001 ) &&  | ||||||
|  |                ( abs( ( $aDir->x / $aDir->y ) - ( $bDir->x / $bDir->y ) ) < .000001 ) | ||||||
|  |              ) | ||||||
|  |            ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Use ? : to prevent division by zero
 | ||||||
|  |         $denominator =  | ||||||
|  |             ( abs( $aDir->y ) > .000001 ? $bDir->y / $aDir->y : .0 ) -  | ||||||
|  |             ( abs( $aDir->x ) > .000001 ? $bDir->x / $aDir->x : .0 ); | ||||||
|  | 
 | ||||||
|  |         // Solve equatation
 | ||||||
|  |         if ( abs( $denominator ) < .000001 ) | ||||||
|  |         { | ||||||
|  |             return - (  | ||||||
|  |                 ( abs( $aDir->y ) > .000001 ? $bStart->y / $aDir->y : .0 ) - | ||||||
|  |                 ( abs( $aDir->y ) > .000001 ? $aStart->y / $aDir->y : .0 ) - | ||||||
|  |                 ( abs( $aDir->x ) > .000001 ? $bStart->x / $aDir->x : .0 ) + | ||||||
|  |                 ( abs( $aDir->x ) > .000001 ? $aStart->x / $aDir->x : .0 ) | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             return - (  | ||||||
|  |                 ( abs( $aDir->y ) > .000001 ? $bStart->y / $aDir->y : .0 ) - | ||||||
|  |                 ( abs( $aDir->y ) > .000001 ? $aStart->y / $aDir->y : .0 ) - | ||||||
|  |                 ( abs( $aDir->x ) > .000001 ? $bStart->x / $aDir->x : .0 ) + | ||||||
|  |                 ( abs( $aDir->x ) > .000001 ? $aStart->x / $aDir->x : .0 ) | ||||||
|  |             ) / $denominator; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draw single step on a axis | ||||||
|  |      * | ||||||
|  |      * Draws a step on a axis at the current position | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer to draw the step with | ||||||
|  |      * @param ezcGraphCoordinate $position Position of step | ||||||
|  |      * @param ezcGraphCoordinate $direction Direction of axis | ||||||
|  |      * @param int $axisPosition Position of axis | ||||||
|  |      * @param int $size Step size | ||||||
|  |      * @param ezcGraphColor $color Color of axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function drawStep( ezcGraphRenderer $renderer, ezcGraphCoordinate $position, ezcGraphCoordinate $direction, $axisPosition, $size, ezcGraphColor $color ) | ||||||
|  |     { | ||||||
|  |         if ( ! ( $this->innerStep || $this->outerStep ) ) | ||||||
|  |         { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $drawStep = false; | ||||||
|  |         if ( ( ( $axisPosition === ezcGraph::CENTER ) && $this->innerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::BOTTOM ) && $this->outerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::TOP ) && $this->innerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::RIGHT ) && $this->outerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::LEFT ) && $this->innerStep ) ) | ||||||
|  |         { | ||||||
|  |             // Turn direction vector to left by 90 degrees and multiply 
 | ||||||
|  |             // with major step size
 | ||||||
|  |             $stepStart = new ezcGraphCoordinate( | ||||||
|  |                 $position->x + $direction->y * $size, | ||||||
|  |                 $position->y - $direction->x * $size | ||||||
|  |             ); | ||||||
|  |             $drawStep = true; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $stepStart = $position; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( ( ( $axisPosition === ezcGraph::CENTER ) && $this->innerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::BOTTOM ) && $this->innerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::TOP ) && $this->outerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::RIGHT ) && $this->innerStep ) || | ||||||
|  |              ( ( $axisPosition === ezcGraph::LEFT ) && $this->outerStep ) ) | ||||||
|  |         { | ||||||
|  |             // Turn direction vector to right by 90 degrees and multiply 
 | ||||||
|  |             // with major step size
 | ||||||
|  |             $stepEnd = new ezcGraphCoordinate( | ||||||
|  |                 $position->x - $direction->y * $size, | ||||||
|  |                 $position->y + $direction->x * $size | ||||||
|  |             ); | ||||||
|  |             $drawStep = true; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $stepEnd = $position; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $drawStep ) | ||||||
|  |         { | ||||||
|  |             $renderer->drawStepLine( | ||||||
|  |                 $stepStart, | ||||||
|  |                 $stepEnd, | ||||||
|  |                 $color | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Draw non-rectangular grid lines grid | ||||||
|  |      * | ||||||
|  |      * Draws a grid line at the current position, for non-rectangular axis. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer to draw the grid with | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings of axis | ||||||
|  |      * @param ezcGraphCoordinate $position Position of step | ||||||
|  |      * @param ezcGraphCoordinate $direction Direction of axis | ||||||
|  |      * @param ezcGraphColor $color Color of axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function drawNonRectangularGrid( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $position, ezcGraphCoordinate $direction, ezcGraphColor $color ) | ||||||
|  |     { | ||||||
|  |         // Direction of grid line is direction of axis turned right by 90 
 | ||||||
|  |         // degrees
 | ||||||
|  |         $gridDirection = new ezcGraphCoordinate( | ||||||
|  |             $direction->y, | ||||||
|  |             - $direction->x | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         $cuttingPoints = array(); | ||||||
|  |         foreach ( array( // Bounding lines
 | ||||||
|  |                 array( | ||||||
|  |                     'start' => new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ), | ||||||
|  |                     'dir' => new ezcGraphCoordinate( 0, $boundings->y1 - $boundings->y0 ) | ||||||
|  |                 ), | ||||||
|  |                 array( | ||||||
|  |                     'start' => new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ), | ||||||
|  |                     'dir' => new ezcGraphCoordinate( $boundings->x1 - $boundings->x0, 0 ) | ||||||
|  |                 ), | ||||||
|  |                 array( | ||||||
|  |                     'start' => new ezcGraphCoordinate( $boundings->x1, $boundings->y1 ), | ||||||
|  |                     'dir' => new ezcGraphCoordinate( 0, $boundings->y0 - $boundings->y1 ) | ||||||
|  |                 ), | ||||||
|  |                 array( | ||||||
|  |                     'start' => new ezcGraphCoordinate( $boundings->x1, $boundings->y1 ), | ||||||
|  |                     'dir' => new ezcGraphCoordinate( $boundings->x0 - $boundings->x1, 0 ) | ||||||
|  |                 ), | ||||||
|  |             ) as $boundingLine ) | ||||||
|  |         { | ||||||
|  |             // Test for cutting points with bounding lines, where cutting
 | ||||||
|  |             // position is between 0 and 1, which means, that the line is hit
 | ||||||
|  |             // on the bounding box rectangle. Use these points as a start and
 | ||||||
|  |             // ending point for the grid lines. There should *always* be
 | ||||||
|  |             // exactly two points returned.
 | ||||||
|  |             $cuttingPosition = $this->determineLineCuttingPoint( | ||||||
|  |                 $boundingLine['start'], | ||||||
|  |                 $boundingLine['dir'], | ||||||
|  |                 $position, | ||||||
|  |                 $gridDirection | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |             if ( $cuttingPosition === false ) | ||||||
|  |             { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             $cuttingPosition = abs( $cuttingPosition ); | ||||||
|  | 
 | ||||||
|  |             if ( ( $cuttingPosition >= 0 ) &&  | ||||||
|  |                  ( $cuttingPosition <= 1 ) ) | ||||||
|  |             { | ||||||
|  |                 $cuttingPoints[] = new ezcGraphCoordinate( | ||||||
|  |                     $boundingLine['start']->x + $cuttingPosition * $boundingLine['dir']->x, | ||||||
|  |                     $boundingLine['start']->y + $cuttingPosition * $boundingLine['dir']->y | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( count( $cuttingPoints ) < 2 ) | ||||||
|  |         { | ||||||
|  |             // This should not happpen
 | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Finally draw grid line
 | ||||||
|  |         $renderer->drawGridLine( | ||||||
|  |             $cuttingPoints[0], | ||||||
|  |             $cuttingPoints[1], | ||||||
|  |             $color | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draw rectangular grid | ||||||
|  |      * | ||||||
|  |      * Draws a grid line at the current position for rectangular directed axis. | ||||||
|  |      * | ||||||
|  |      * Method special for rectangularly directed axis to minimize the floating | ||||||
|  |      * point calculation inaccuracies. Those are not necessary for rectangles, | ||||||
|  |      * while for non-rectangular directed axis. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer to draw the grid with | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings of axis | ||||||
|  |      * @param ezcGraphCoordinate $position Position of step | ||||||
|  |      * @param ezcGraphCoordinate $direction Direction of axis | ||||||
|  |      * @param ezcGraphColor $color Color of axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function drawRectangularGrid( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $position, ezcGraphCoordinate $direction, ezcGraphColor $color ) | ||||||
|  |     { | ||||||
|  |         if ( abs( $direction->x ) < .00001 ) | ||||||
|  |         { | ||||||
|  |             $renderer->drawGridLine( | ||||||
|  |                 new ezcGraphCoordinate( | ||||||
|  |                     $boundings->x0, | ||||||
|  |                     $position->y | ||||||
|  |                 ), | ||||||
|  |                 new ezcGraphCoordinate( | ||||||
|  |                     $boundings->x1, | ||||||
|  |                     $position->y | ||||||
|  |                 ), | ||||||
|  |                 $color | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $renderer->drawGridLine( | ||||||
|  |                 new ezcGraphCoordinate( | ||||||
|  |                     $position->x, | ||||||
|  |                     $boundings->y0 | ||||||
|  |                 ), | ||||||
|  |                 new ezcGraphCoordinate( | ||||||
|  |                     $position->x, | ||||||
|  |                     $boundings->y1 | ||||||
|  |                 ), | ||||||
|  |                 $color | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Draw grid | ||||||
|  |      * | ||||||
|  |      * Draws a grid line at the current position | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer to draw the grid with | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings of axis | ||||||
|  |      * @param ezcGraphCoordinate $position Position of step | ||||||
|  |      * @param ezcGraphCoordinate $direction Direction of axis | ||||||
|  |      * @param ezcGraphColor $color Color of axis | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function drawGrid( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphCoordinate $position, ezcGraphCoordinate $direction, ezcGraphColor $color ) | ||||||
|  |     { | ||||||
|  |         // Check if the axis direction is rectangular
 | ||||||
|  |         if ( ( abs( $direction->x ) < .00001 ) || | ||||||
|  |              ( abs( $direction->y ) < .00001 ) ) | ||||||
|  |         { | ||||||
|  |             return $this->drawRectangularGrid( $renderer, $boundings, $position, $direction, $color ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             return $this->drawNonRectangularGrid( $renderer, $boundings, $position, $direction, $color ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Modify chart boundings | ||||||
|  |      * | ||||||
|  |      * Optionally modify boundings of chart data | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphBoundings $boundings Current boundings of chart | ||||||
|  |      * @param ezcGraphCoordinate $direction Direction of the current axis | ||||||
|  |      * @return ezcGraphBoundings Modified boundings | ||||||
|  |      */ | ||||||
|  |     public function modifyChartBoundings( ezcGraphBoundings $boundings, ezcGraphCoordinate $direction ) | ||||||
|  |     { | ||||||
|  |         return $boundings; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Modify chart data position | ||||||
|  |      * | ||||||
|  |      * Optionally additionally modify the coodinate of a data point | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphCoordinate $coordinate Data point coordinate | ||||||
|  |      * @return ezcGraphCoordinate Modified coordinate | ||||||
|  |      */ | ||||||
|  |     public function modifyChartDataPosition( ezcGraphCoordinate $coordinate ) | ||||||
|  |     { | ||||||
|  |         return $coordinate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get axis space values | ||||||
|  |      * | ||||||
|  |      * Get axis space values, depending on passed parameters. If | ||||||
|  |      * $innerBoundings is given it will be used to caclulat the axis spaces | ||||||
|  |      * available for label rendering. If not given the legacy method will be | ||||||
|  |      * used, which uses the xAxisSpace and yAxisSpace values calcualted by the | ||||||
|  |      * renderer. | ||||||
|  |      * | ||||||
|  |      * Returns an array( $xSpace, $ySpace ), containing the irespective size in | ||||||
|  |      * pixels. Additionally calculates the grid boundings passed by reference. | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphRenderer $renderer  | ||||||
|  |      * @param ezcGraphBoundings $boundings  | ||||||
|  |      * @param mixed $innerBoundings  | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|  |     protected function getAxisSpace( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphChartElementAxis $axis, $innerBoundings, &$gridBoundings ) | ||||||
|  |     { | ||||||
|  |         if ( $innerBoundings !== null ) | ||||||
|  |         { | ||||||
|  |             $gridBoundings = clone $innerBoundings; | ||||||
|  |             $xSpace = abs( $axis->position === ezcGraph::LEFT ? $innerBoundings->x0 - $boundings->x0 : $boundings->x1 - $innerBoundings->x1 ); | ||||||
|  |             $ySpace = abs( $axis->position === ezcGraph::TOP  ? $innerBoundings->y0 - $boundings->y0 : $boundings->y1 - $innerBoundings->y1 ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             $gridBoundings = new ezcGraphBoundings( | ||||||
|  |                 $boundings->x0 + ( $xSpace = abs( $renderer->xAxisSpace ) ), | ||||||
|  |                 $boundings->y0 + ( $ySpace = abs( $renderer->yAxisSpace ) ), | ||||||
|  |                 $boundings->x1 - $xSpace, | ||||||
|  |                 $boundings->y1 - $ySpace | ||||||
|  |             ); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( $this->outerGrid ) | ||||||
|  |         { | ||||||
|  |             $gridBoundings = $boundings; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return array( $xSpace, $ySpace ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Render Axis labels | ||||||
|  |      * | ||||||
|  |      * Render labels for an axis. | ||||||
|  |      * | ||||||
|  |      * @param ezcGraphRenderer $renderer Renderer used to draw the chart | ||||||
|  |      * @param ezcGraphBoundings $boundings Boundings of the axis | ||||||
|  |      * @param ezcGraphCoordinate $start Axis starting point | ||||||
|  |      * @param ezcGraphCoordinate $end Axis ending point | ||||||
|  |      * @param ezcGraphChartElementAxis $axis Axis instance | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     abstract public function renderLabels( | ||||||
|  |         ezcGraphRenderer $renderer, | ||||||
|  |         ezcGraphBoundings $boundings, | ||||||
|  |         ezcGraphCoordinate $start, | ||||||
|  |         ezcGraphCoordinate $end, | ||||||
|  |         ezcGraphChartElementAxis $axis | ||||||
|  |     ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										296
									
								
								src/TUnit/external/ezc/Graph/interfaces/chart.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										296
									
								
								src/TUnit/external/ezc/Graph/interfaces/chart.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,296 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphChart class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Class to represent a complete chart. | ||||||
|  |  * | ||||||
|  |  * @property ezcGraphRenderer $renderer | ||||||
|  |  *           Renderer used to render chart | ||||||
|  |  * @property ezcGraphDriver $driver | ||||||
|  |  *           Output driver used for chart | ||||||
|  |  * @property ezcGraphPalette $palette | ||||||
|  |  *           Palette used for colorization of chart | ||||||
|  |  * @property-read mixed $renderedFile | ||||||
|  |  *           Contains the filename of the rendered file, if rendered. | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  */ | ||||||
|  | abstract class ezcGraphChart | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains all general chart options | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphChartConfig | ||||||
|  |      */ | ||||||
|  |     protected $options; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains subelelemnts of the chart like legend and axes | ||||||
|  |      *  | ||||||
|  |      * @var array(ezcGraphChartElement) | ||||||
|  |      */ | ||||||
|  |     protected $elements = array(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains the data of the chart | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphChartDataContainer | ||||||
|  |      */ | ||||||
|  |     protected $data; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Array containing chart properties | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $properties; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains the status wheather an element should be rendered | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $renderElement; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param array $options Default option array | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __construct( array $options = array() ) | ||||||
|  |     { | ||||||
|  |         $this->palette = new ezcGraphPaletteTango(); | ||||||
|  |         $this->data = new ezcGraphChartDataContainer( $this ); | ||||||
|  | 
 | ||||||
|  |         // Add standard elements
 | ||||||
|  |         $this->addElement( 'background', new ezcGraphChartElementBackground() ); | ||||||
|  |         $this->elements['background']->position = ezcGraph::CENTER | ezcGraph::MIDDLE; | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'title', new ezcGraphChartElementText() ); | ||||||
|  |         $this->elements['title']->position = ezcGraph::TOP; | ||||||
|  |         $this->renderElement['title'] = false; | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'subtitle', new ezcGraphChartElementText() ); | ||||||
|  |         $this->elements['subtitle']->position = ezcGraph::TOP; | ||||||
|  |         $this->renderElement['subtitle'] = false; | ||||||
|  | 
 | ||||||
|  |         $this->addElement( 'legend', new ezcGraphChartElementLegend() ); | ||||||
|  |         $this->elements['legend']->position = ezcGraph::LEFT; | ||||||
|  | 
 | ||||||
|  |         // Define standard renderer and driver
 | ||||||
|  |         $this->properties['driver'] = new ezcGraphSvgDriver(); | ||||||
|  |         $this->properties['renderer'] = new ezcGraphRenderer2d(); | ||||||
|  |         $this->properties['renderer']->setDriver( $this->driver ); | ||||||
|  | 
 | ||||||
|  |         // Initialize other properties
 | ||||||
|  |         $this->properties['renderedFile'] = null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Add element to chart | ||||||
|  |      * | ||||||
|  |      * Add a chart element to the chart and perform the required configuration | ||||||
|  |      * tasks for the chart element. | ||||||
|  |      *  | ||||||
|  |      * @param string $name Element name | ||||||
|  |      * @param ezcGraphChartElement $element Chart element | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     protected function addElement( $name, ezcGraphChartElement $element ) | ||||||
|  |     { | ||||||
|  |         $this->elements[$name] = $element; | ||||||
|  |         $this->elements[$name]->font = $this->options->font; | ||||||
|  |         $this->elements[$name]->setFromPalette( $this->palette ); | ||||||
|  | 
 | ||||||
|  |         // Render element by default
 | ||||||
|  |         $this->renderElement[$name] = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Options write access | ||||||
|  |      *  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If Option could not be found | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *          If value is out of range | ||||||
|  |      * @param mixed $propertyName   Option name | ||||||
|  |      * @param mixed $propertyValue  Option value; | ||||||
|  |      * @return void | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __set( $propertyName, $propertyValue )  | ||||||
|  |     { | ||||||
|  |         switch ( $propertyName ) { | ||||||
|  |             case 'title': | ||||||
|  |             case 'subtitle': | ||||||
|  |                 $this->elements[$propertyName]->title = $propertyValue; | ||||||
|  |                 $this->renderElement[$propertyName] = true; | ||||||
|  |                 break; | ||||||
|  |             case 'background': | ||||||
|  |                 $this->elements[$propertyName]->color = $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'legend': | ||||||
|  |                 if ( !is_bool( $propertyValue ) ) | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'boolean' ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 $this->renderElement['legend'] = (bool) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'renderer': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphRenderer ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['renderer'] = $propertyValue; | ||||||
|  |                     $this->properties['renderer']->setDriver( $this->driver ); | ||||||
|  |                     return $this->properties['renderer']; | ||||||
|  |                 } | ||||||
|  |                 else  | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphRenderer' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'driver': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphDriver ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['driver'] = $propertyValue; | ||||||
|  |                     $this->properties['renderer']->setDriver( $this->driver ); | ||||||
|  |                     return $this->properties['driver']; | ||||||
|  |                 } | ||||||
|  |                 else  | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphDriver' ); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case 'palette': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphPalette ) | ||||||
|  |                 { | ||||||
|  |                     $this->properties['palette'] = $propertyValue; | ||||||
|  |                     $this->setFromPalette( $this->palette ); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( "palette", $propertyValue, "instanceof ezcGraphPalette" ); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 break; | ||||||
|  |             case 'renderedFile': | ||||||
|  |                 $this->properties['renderedFile'] = (string) $propertyValue; | ||||||
|  |                 break; | ||||||
|  |             case 'options': | ||||||
|  |                 if ( $propertyValue instanceof ezcGraphChartOptions ) | ||||||
|  |                 { | ||||||
|  |                     $this->options = $propertyValue; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     throw new ezcBaseValueException( "options", $propertyValue, "instanceof ezcGraphOptions" ); | ||||||
|  |                 } | ||||||
|  |             default: | ||||||
|  |                 throw new ezcBasePropertyNotFoundException( $propertyName ); | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set colors and border fro this element | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphPalette $palette Palette | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function setFromPalette( ezcGraphPalette $palette ) | ||||||
|  |     { | ||||||
|  |         $this->options->font->name = $palette->fontName; | ||||||
|  |         $this->options->font->color = $palette->fontColor; | ||||||
|  | 
 | ||||||
|  |         foreach ( $this->elements as $element ) | ||||||
|  |         { | ||||||
|  |             $element->setFromPalette( $palette ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * __get  | ||||||
|  |      *  | ||||||
|  |      * @param mixed $propertyName  | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *          If a the value for the property options is not an instance of | ||||||
|  |      * @return mixed | ||||||
|  |      * @ignore | ||||||
|  |      */ | ||||||
|  |     public function __get( $propertyName ) | ||||||
|  |     { | ||||||
|  |         if ( array_key_exists( $propertyName, $this->properties ) ) | ||||||
|  |         { | ||||||
|  |             return $this->properties[$propertyName]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( isset( $this->elements[$propertyName] ) ) | ||||||
|  |         { | ||||||
|  |             return $this->elements[$propertyName]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ( ( $propertyName === 'options' ) || | ||||||
|  |              ( $propertyName === 'data' ) ) | ||||||
|  |         { | ||||||
|  |             return $this->$propertyName; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoSuchElementException( $propertyName ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the default display type of the current chart type. | ||||||
|  |      *  | ||||||
|  |      * @return int Display type | ||||||
|  |      */ | ||||||
|  |     abstract public function getDefaultDisplayType(); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Return filename of rendered file, and false if no file was yet rendered. | ||||||
|  |      *  | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function getRenderedFile() | ||||||
|  |     { | ||||||
|  |         return ( $this->renderedFile !== null ? $this->renderedFile : false ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders this chart | ||||||
|  |      *  | ||||||
|  |      * Creates basic visual chart elements from the chart to be processed by  | ||||||
|  |      * the renderer. | ||||||
|  |      *  | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @param string $file | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     abstract public function render( $width, $height, $file = null ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Renders this chart to direct output | ||||||
|  |      *  | ||||||
|  |      * Does the same as ezcGraphChart::render(), but renders directly to  | ||||||
|  |      * output and not into a file. | ||||||
|  |      *  | ||||||
|  |      * @param int $width | ||||||
|  |      * @param int $height | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     abstract public function renderToOutput( $width, $height ); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
							
								
								
									
										209
									
								
								src/TUnit/external/ezc/Graph/interfaces/dataset_property.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										209
									
								
								src/TUnit/external/ezc/Graph/interfaces/dataset_property.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,209 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * File containing the abstract ezcGraphDataSetProperty class | ||||||
|  |  * | ||||||
|  |  * @package Graph | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. | ||||||
|  |  * @license http://ez.no/licenses/new_bsd New BSD License | ||||||
|  |  */ | ||||||
|  | /** | ||||||
|  |  * Abstract class for properties of datasets | ||||||
|  |  * | ||||||
|  |  * This class is used to extends datasets with additional properties, and | ||||||
|  |  * stores only non default values for each data point in a data set. | ||||||
|  |  *  | ||||||
|  |  * The class is extended by property implementations including simple value | ||||||
|  |  * validators, like: | ||||||
|  |  * | ||||||
|  |  * - ezcGraphDataSetAxisProperty | ||||||
|  |  * - ezcGraphDataSetBooleanProperty | ||||||
|  |  * - ezcGraphDataSetColorProperty | ||||||
|  |  * - ezcGraphDataSetIntProperty | ||||||
|  |  * - ezcGraphDataSetStringProperty | ||||||
|  |  * | ||||||
|  |  * The color property can for example be accessed in a chart like: | ||||||
|  |  * | ||||||
|  |  * <code> | ||||||
|  |  *  $graph = new ezcGraphLineChart(); | ||||||
|  |  *  $graph->data['example'] = new ezcGraphArrayDataSet( array( | ||||||
|  |  *      'Foo' => 23, | ||||||
|  |  *      'Bar' => 42, | ||||||
|  |  *  ) ); | ||||||
|  |  * | ||||||
|  |  *  // Set color for all data points in this data set
 | ||||||
|  |  *  $graph->data['example']->color = '#a40000'; | ||||||
|  |  * | ||||||
|  |  *  // Set different color for one special datapoint
 | ||||||
|  |  *  $graph->data['example']->color['Foo'] = '#2e3436'; | ||||||
|  |  * | ||||||
|  |  *  $graph->render( 400, 200, 'test.svg' ); | ||||||
|  |  * </code> | ||||||
|  |  * | ||||||
|  |  * @version 1.4.3 | ||||||
|  |  * @package Graph | ||||||
|  |  */ | ||||||
|  | abstract class ezcGraphDataSetProperty implements ArrayAccess | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Default value for this property | ||||||
|  |      *  | ||||||
|  |      * @var mixed | ||||||
|  |      */ | ||||||
|  |     protected $defaultValue; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains specified values for single dataset elements | ||||||
|  |      *  | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $dataValue; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Contains a reference to the dataset to check for availability of data | ||||||
|  |      * keys | ||||||
|  |      *  | ||||||
|  |      * @var ezcGraphDataSet | ||||||
|  |      */ | ||||||
|  |     protected $dataset; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Abstract method to contain the check for validity of the value | ||||||
|  |      *  | ||||||
|  |      * @param mixed $value  | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     abstract protected function checkValue( &$value ); | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Constructor | ||||||
|  |      *  | ||||||
|  |      * @param ezcGraphDataSet $dataset  | ||||||
|  |      * @ignore | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __construct( ezcGraphDataSet $dataset ) | ||||||
|  |     { | ||||||
|  |         $this->dataset = $dataset; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set the default value for this property | ||||||
|  |      *  | ||||||
|  |      * @param string $name Property name | ||||||
|  |      * @param mixed $value Property value | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __set( $name, $value ) | ||||||
|  |     { | ||||||
|  |         if ( $name === 'default' && | ||||||
|  |              $this->checkValue( $value ) ) | ||||||
|  |         { | ||||||
|  |             $this->defaultValue = $value; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get the default value for this property | ||||||
|  |      *  | ||||||
|  |      * @param string $name Property name | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function __get( $name ) | ||||||
|  |     { | ||||||
|  |         if ( $name === 'default' ) | ||||||
|  |         { | ||||||
|  |             return $this->defaultValue; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns if an option exists. | ||||||
|  |      * Allows isset() using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The name of the option to get. | ||||||
|  |      * @return bool Wether the option exists. | ||||||
|  |      */ | ||||||
|  |     final public function offsetExists( $key ) | ||||||
|  |     { | ||||||
|  |         return isset( $this->dataset[$key] ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns an option value. | ||||||
|  |      * Get an option value by ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The name of the option to get. | ||||||
|  |      * @return mixed The option value. | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      */ | ||||||
|  |     final public function offsetGet( $key ) | ||||||
|  |     { | ||||||
|  |         if ( isset( $this->dataValue[$key] ) ) | ||||||
|  |         { | ||||||
|  |             return $this->dataValue[$key]; | ||||||
|  |         } | ||||||
|  |         elseif ( isset( $this->dataset[$key] ) ) | ||||||
|  |         { | ||||||
|  |             return $this->defaultValue; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoSuchDataException( $key ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Set an option. | ||||||
|  |      * Sets an option using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The option to set. | ||||||
|  |      * @param mixed $value The value for the option. | ||||||
|  |      * @return void | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If a the value for a property is out of range. | ||||||
|  |      */ | ||||||
|  |     public function offsetSet( $key, $value ) | ||||||
|  |     { | ||||||
|  |         if ( isset( $this->dataset[$key] ) && | ||||||
|  |              $this->checkValue( $value ) ) | ||||||
|  |         { | ||||||
|  |             $this->dataValue[$key] = $value; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoSuchDataException( $key ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Unset an option. | ||||||
|  |      * Unsets an option using ArrayAccess. | ||||||
|  |      *  | ||||||
|  |      * @param string $key The options to unset. | ||||||
|  |      * @return void | ||||||
|  |      * | ||||||
|  |      * @throws ezcBasePropertyNotFoundException | ||||||
|  |      *         If a the value for the property options is not an instance of | ||||||
|  |      * @throws ezcBaseValueException | ||||||
|  |      *         If a the value for a property is out of range. | ||||||
|  |      */ | ||||||
|  |     final public function offsetUnset( $key ) | ||||||
|  |     { | ||||||
|  |         if ( isset( $this->dataset[$key] ) ) | ||||||
|  |         { | ||||||
|  |             unset( $this->dataValue[$key] ); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             throw new ezcGraphNoSuchDataException( $key ); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ?>
 | ||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user