| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * File containing the ezcGraphAxisContainer class 4 * 5 * @package Graph 6 * @version 1.5 7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. 8 * @license http://ez.no/licenses/new_bsd New BSD License 9 */ 10 /** 11 * The axis container class is internally used to store and validate sets of 12 * axis, and offering access using the SPL ArrayAccess interface to add or 13 * modify its contents. 14 * 15 * @version 1.5 16 * @package Graph 17 */ 18 class ezcGraphAxisContainer 19 implements 20 Countable, 21 ArrayAccess, 22 Iterator 23 { 24 /** 25 * Chart the container is used with 26 * 27 * @var ezcGraphLineChart 28 */ 29 protected $chart; 30 31 /** 32 * Contains the data of a chart 33 * 34 * @var array(ezcGraphChartElementAxis) 35 */ 36 protected $data = array(); 37 38 /** 39 * Construct container with corresponding chart. 40 * 41 * @param ezcGraphLineChart $chart 42 * @return void 43 * @ignore 44 */ 45 public function __construct( ezcGraphLineChart $chart ) 46 { 47 $this->chart = $chart; 48 } 49 50 /** 51 * Returns if the given offset exists. 52 * 53 * This method is part of the ArrayAccess interface to allow access to the 54 * data of this object as if it was an array. 55 * 56 * @param string $key Identifier of dataset. 57 * @return bool True when the offset exists, otherwise false. 58 */ 59 public function offsetExists( $key ) 60 { 61 return isset( $this->data[$key] ); 62 } 63 64 /** 65 * Returns the element with the given offset. 66 * 67 * This method is part of the ArrayAccess interface to allow access to the 68 * data of this object as if it was an array. 69 * 70 * @param string $key Identifier of dataset. 71 * @return ezcGraphChartElementAxis 72 * 73 * @throws ezcBasePropertyNotFoundException 74 * If no dataset with identifier exists 75 */ 76 public function offsetGet( $key ) 77 { 78 if ( !isset( $this->data[$key] ) ) 79 { 80 throw new ezcBasePropertyNotFoundException( $key ); 81 } 82 83 return $this->data[$key]; 84 } 85 86 /** 87 * Set the element with the given offset. 88 * 89 * This method is part of the ArrayAccess interface to allow access to the 90 * data of this object as if it was an array. 91 * 92 * @param string $key 93 * @param ezcGraphChartElementAxis $value 94 * @return void 95 * 96 * @throws ezcBaseValueException 97 * If supplied value is not an ezcGraphChartElementAxis 98 */ 99 public function offsetSet( $key, $value ) 100 { 101 if ( !$value instanceof ezcGraphChartElementAxis ) 102 { 103 throw new ezcBaseValueException( $key, $value, 'ezcGraphChartElementAxis' ); 104 } 105 106 if ( $key === null ) 107 { 108 $key = count( $this->data ); 109 } 110 111 // Add axis and configure it with current font and palette 112 $this->data[$key] = $value; 113 $value->font = $this->chart->options->font; 114 $value->setFromPalette( $this->chart->palette ); 115 116 return $value; 117 } 118 119 /** 120 * Unset the element with the given offset. 121 * 122 * This method is part of the ArrayAccess interface to allow access to the 123 * data of this object as if it was an array. 124 * 125 * @param string $key 126 * @return void 127 */ 128 public function offsetUnset( $key ) 129 { 130 if ( !isset( $this->data[$key] ) ) 131 { 132 throw new ezcBasePropertyNotFoundException( $key ); 133 } 134 135 unset( $this->data[$key] ); 136 } 137 138 /** 139 * Returns the currently selected dataset. 140 * 141 * This method is part of the Iterator interface to allow access to the 142 * datasets of this row by iterating over it like an array (e.g. using 143 * foreach). 144 * 145 * @return ezcGraphChartElementAxis The currently selected dataset. 146 */ 147 public function current() 148 { 149 return current( $this->data ); 150 } 151 152 /** 153 * Returns the next dataset and selects it or false on the last dataset. 154 * 155 * This method is part of the Iterator interface to allow access to the 156 * datasets of this row by iterating over it like an array (e.g. using 157 * foreach). 158 * 159 * @return mixed ezcGraphChartElementAxis if the next dataset exists, or false. 160 */ 161 public function next() 162 { 163 return next( $this->data ); 164 } 165 166 /** 167 * Returns the key of the currently selected dataset. 168 * 169 * This method is part of the Iterator interface to allow access to the 170 * datasets of this row by iterating over it like an array (e.g. using 171 * foreach). 172 * 173 * @return int The key of the currently selected dataset. 174 */ 175 public function key() 176 { 177 return key( $this->data ); 178 } 179 180 /** 181 * Returns if the current dataset is valid. 182 * 183 * This method is part of the Iterator interface to allow access to the 184 * datasets of this row by iterating over it like an array (e.g. using 185 * foreach). 186 * 187 * @return bool If the current dataset is valid 188 */ 189 public function valid() 190 { 191 return ( current( $this->data ) !== false ); 192 } 193 194 /** 195 * Selects the very first dataset and returns it. 196 * This method is part of the Iterator interface to allow access to the 197 * datasets of this row by iterating over it like an array (e.g. using 198 * foreach). 199 * 200 * @return ezcGraphChartElementAxis The very first dataset. 201 */ 202 public function rewind() 203 { 204 return reset( $this->data ); 205 } 206 207 /** 208 * Returns the number of datasets in the row. 209 * 210 * This method is part of the Countable interface to allow the usage of 211 * PHP's count() function to check how many datasets exist. 212 * 213 * @return int Number of datasets. 214 */ 215 public function count() 216 { 217 return count( $this->data ); 218 } 219 } 220 221 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |