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