| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * File containing the ezcGraphSvgDriverOption class 4 * 5 * @package Graph 6 * @version 1.5 7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. 8 * @license http://ez.no/licenses/new_bsd New BSD License 9 */ 10 /** 11 * Class containing the extended options for the SVG driver. 12 * 13 * <code> 14 * $graph = new ezcGraphPieChart(); 15 * $graph->background->color = '#FFFFFFFF'; 16 * $graph->title = 'Access statistics'; 17 * $graph->legend = false; 18 * 19 * $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array( 20 * 'Mozilla' => 19113, 21 * 'Explorer' => 10917, 22 * 'Opera' => 1464, 23 * 'Safari' => 652, 24 * 'Konqueror' => 474, 25 * ) ); 26 * 27 * $graph->driver->options->templateDocument = dirname( __FILE__ ) . '/template.svg'; 28 * $graph->driver->options->graphOffset = new ezcGraphCoordinate( 25, 40 ); 29 * $graph->driver->options->insertIntoGroup = 'ezcGraph'; 30 * 31 * $graph->render( 400, 200, 'tutorial_driver_svg.svg' ); 32 * </code> 33 * 34 * @property string $encoding 35 * Encoding of the SVG XML document 36 * @property float $assumedNumericCharacterWidth 37 * Assumed percentual average width of chars in numeric strings with 38 * the used font. 39 * @property float $assumedTextCharacterWidth 40 * Assumed percentual average width of chars in non numeric strings 41 * with the used font. 42 * @property string $strokeLineCap 43 * This specifies the shape to be used at the end of open subpaths 44 * when they are stroked. 45 * @property string $strokeLineJoin 46 * This specifies the shape to be used at the edges of paths. 47 * @property string $shapeRendering 48 * "The creator of SVG content might want to provide a hint to the 49 * implementation about what tradeoffs to make as it renders vector 50 * graphics elements such as 'path' elements and basic shapes such as 51 * circles and rectangles." 52 * @property string $colorRendering 53 * "The creator of SVG content might want to provide a hint to the 54 * implementation about how to make speed vs. quality tradeoffs as it 55 * performs color interpolation and compositing. The 56 * 'color-rendering' property provides a hint to the SVG user agent 57 * about how to optimize its color interpolation and compositing 58 * operations." 59 * @property string $textRendering 60 * "The creator of SVG content might want to provide a hint to the 61 * implementation about what tradeoffs to make as it renders text." 62 * @property mixed $templateDocument 63 * Use existing SVG document as template to insert graph into. If 64 * insertIntoGroup is not set, a new group will be inserted in the 65 * svg root node. 66 * @property mixed $insertIntoGroup 67 * ID of a SVG group node to insert the graph. Only works with a 68 * custom template document. 69 * @property ezcGraphCoordinate $graphOffset 70 * Offset of the graph in the svg. 71 * @property string $idPrefix 72 * Prefix used for the ids in SVG documents. 73 * @property string $linkCursor 74 * CSS value for cursor property used for linked SVG elements 75 * 76 * @version 1.5 77 * @package Graph 78 */ 79 class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions 80 { 81 /** 82 * Constructor 83 * 84 * @param array $options Default option array 85 * @return void 86 * @ignore 87 */ 88 public function __construct( array $options = array() ) 89 { 90 $this->properties['encoding'] = null; 91 $this->properties['assumedNumericCharacterWidth'] = .62; 92 $this->properties['assumedTextCharacterWidth'] = .53; 93 $this->properties['strokeLineJoin'] = 'round'; 94 $this->properties['strokeLineCap'] = 'round'; 95 $this->properties['shapeRendering'] = 'geometricPrecision'; 96 $this->properties['colorRendering'] = 'optimizeQuality'; 97 $this->properties['textRendering'] = 'optimizeLegibility'; 98 $this->properties['templateDocument'] = false; 99 $this->properties['insertIntoGroup'] = false; 100 $this->properties['graphOffset'] = new ezcGraphCoordinate( 0, 0 ); 101 $this->properties['idPrefix'] = 'ezcGraph'; 102 $this->properties['linkCursor'] = 'pointer'; 103 104 parent::__construct( $options ); 105 } 106 107 /** 108 * Set an option value 109 * 110 * @param string $propertyName 111 * @param mixed $propertyValue 112 * @throws ezcBasePropertyNotFoundException 113 * If a property is not defined in this class 114 * @return void 115 * @ignore 116 */ 117 public function __set( $propertyName, $propertyValue ) 118 { 119 switch ( $propertyName ) 120 { 121 case 'assumedNumericCharacterWidth': 122 if ( !is_numeric( $propertyValue ) || 123 ( $propertyValue < 0 ) ) 124 { 125 throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); 126 } 127 128 $this->properties['assumedNumericCharacterWidth'] = (float) $propertyValue; 129 break; 130 case 'assumedTextCharacterWidth': 131 if ( !is_numeric( $propertyValue ) || 132 ( $propertyValue < 0 ) ) 133 { 134 throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' ); 135 } 136 137 $this->properties['assumedTextCharacterWidth'] = (float) $propertyValue; 138 break; 139 case 'strokeLineJoin': 140 $values = array( 141 'round', 142 'miter', 143 'bevel', 144 'inherit', 145 ); 146 147 if ( in_array( $propertyValue, $values, true ) ) 148 { 149 $this->properties['strokeLineJoin'] = $propertyValue; 150 } 151 else 152 { 153 throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); 154 } 155 break; 156 case 'strokeLineCap': 157 $values = array( 158 'round', 159 'butt', 160 'square', 161 'inherit', 162 ); 163 164 if ( in_array( $propertyValue, $values, true ) ) 165 { 166 $this->properties['strokeLineCap'] = $propertyValue; 167 } 168 else 169 { 170 throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); 171 } 172 break; 173 case 'shapeRendering': 174 $values = array( 175 'auto', 176 'optimizeSpeed', 177 'crispEdges', 178 'geometricPrecision', 179 'inherit', 180 ); 181 182 if ( in_array( $propertyValue, $values, true ) ) 183 { 184 $this->properties['shapeRendering'] = $propertyValue; 185 } 186 else 187 { 188 throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); 189 } 190 break; 191 case 'colorRendering': 192 $values = array( 193 'auto', 194 'optimizeSpeed', 195 'optimizeQuality', 196 'inherit', 197 ); 198 199 if ( in_array( $propertyValue, $values, true ) ) 200 { 201 $this->properties['colorRendering'] = $propertyValue; 202 } 203 else 204 { 205 throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); 206 } 207 break; 208 case 'textRendering': 209 $values = array( 210 'auto', 211 'optimizeSpeed', 212 'optimizeLegibility', 213 'geometricPrecision', 214 'inherit', 215 ); 216 217 if ( in_array( $propertyValue, $values, true ) ) 218 { 219 $this->properties['textRendering'] = $propertyValue; 220 } 221 else 222 { 223 throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); 224 } 225 break; 226 case 'templateDocument': 227 if ( !is_file( $propertyValue ) || !is_readable( $propertyValue ) ) 228 { 229 throw new ezcBaseFileNotFoundException( $propertyValue ); 230 } 231 else 232 { 233 $this->properties['templateDocument'] = realpath( $propertyValue ); 234 } 235 break; 236 case 'insertIntoGroup': 237 if ( !is_string( $propertyValue ) ) 238 { 239 throw new ezcBaseValueException( $propertyName, $propertyValue, 'string' ); 240 } 241 else 242 { 243 $this->properties['insertIntoGroup'] = $propertyValue; 244 } 245 break; 246 case 'graphOffset': 247 if ( $propertyValue instanceof ezcGraphCoordinate ) 248 { 249 $this->properties['graphOffset'] = $propertyValue; 250 } 251 else 252 { 253 throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphCoordinate' ); 254 } 255 break; 256 case 'idPrefix': 257 $this->properties['idPrefix'] = (string) $propertyValue; 258 break; 259 case 'encoding': 260 $this->properties['encoding'] = (string) $propertyValue; 261 break; 262 case 'linkCursor': 263 $this->properties['linkCursor'] = (string) $propertyValue; 264 break; 265 default: 266 parent::__set( $propertyName, $propertyValue ); 267 break; 268 } 269 } 270 } 271 272 ?>
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 |