2 require_once 'Properties.php';
5 * User: Wiktor Trzonkowski
10 class PHPExcel_Chart_GridLines
extends
14 * Properties of Class:
15 * Object State (State for Minor Tick Mark) @var bool
16 * Line Properties @var array of mixed
17 * Shadow Properties @var array of mixed
18 * Glow Properties @var array of mixed
19 * Soft Properties @var array of mixed
24 $_object_state = FALSE,
25 $_line_properties = array(
27 'type' => self
::EXCEL_COLOR_TYPE_STANDARD
,
33 'compound' => self
::LINE_STYLE_COMPOUND_SIMPLE
,
34 'dash' => self
::LINE_STYLE_DASH_SOLID
,
35 'cap' => self
::LINE_STYLE_CAP_FLAT
,
36 'join' => self
::LINE_STYLE_JOIN_BEVEL
,
39 'type' => self
::LINE_STYLE_ARROW_TYPE_NOARROW
,
40 'size' => self
::LINE_STYLE_ARROW_SIZE_5
43 'type' => self
::LINE_STYLE_ARROW_TYPE_NOARROW
,
44 'size' => self
::LINE_STYLE_ARROW_SIZE_8
49 $_shadow_properties = array(
50 'presets' => self
::SHADOW_PRESETS_NOSHADOW
,
53 'type' => self
::EXCEL_COLOR_TYPE_STANDARD
,
66 'rotWithShape' => NULL
68 $_glow_properties = array(
71 'type' => self
::EXCEL_COLOR_TYPE_STANDARD
,
86 public function getObjectState() {
87 return $this->_object_state
;
91 * Change Object State to True
93 * @return PHPExcel_Chart_GridLines
96 private function _activateObject() {
97 $this->_object_state
= TRUE;
103 * Set Line Color Properties
105 * @param string $value
107 * @param string $type
110 public function setLineColorProperties($value, $alpha = 0, $type = self
::EXCEL_COLOR_TYPE_STANDARD
) {
113 ->_line_properties
['color'] = $this->setColorProperties(
120 * Set Line Color Properties
122 * @param float $line_width
123 * @param string $compound_type
124 * @param string $dash_type
125 * @param string $cap_type
126 * @param string $join_type
127 * @param string $head_arrow_type
128 * @param string $head_arrow_size
129 * @param string $end_arrow_type
130 * @param string $end_arrow_size
133 public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
134 $this->_activateObject();
135 (!is_null($line_width))
136 ?
$this->_line_properties
['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
138 (!is_null($compound_type))
139 ?
$this->_line_properties
['style']['compound'] = (string) $compound_type
141 (!is_null($dash_type))
142 ?
$this->_line_properties
['style']['dash'] = (string) $dash_type
144 (!is_null($cap_type))
145 ?
$this->_line_properties
['style']['cap'] = (string) $cap_type
147 (!is_null($join_type))
148 ?
$this->_line_properties
['style']['join'] = (string) $join_type
150 (!is_null($head_arrow_type))
151 ?
$this->_line_properties
['style']['arrow']['head']['type'] = (string) $head_arrow_type
153 (!is_null($head_arrow_size))
154 ?
$this->_line_properties
['style']['arrow']['head']['size'] = (string) $head_arrow_size
156 (!is_null($end_arrow_type))
157 ?
$this->_line_properties
['style']['arrow']['end']['type'] = (string) $end_arrow_type
159 (!is_null($end_arrow_size))
160 ?
$this->_line_properties
['style']['arrow']['end']['size'] = (string) $end_arrow_size
165 * Get Line Color Property
167 * @param string $parameter
172 public function getLineColorProperty($parameter) {
173 return $this->_line_properties
['color'][$parameter];
177 * Get Line Style Property
179 * @param array|string $elements
184 public function getLineStyleProperty($elements) {
185 return $this->getArrayElementsValue($this->_line_properties
['style'], $elements);
189 * Set Glow Properties
192 * @param string $color_value
193 * @param int $color_alpha
194 * @param string $color_type
198 public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
201 ->_setGlowSize($size)
202 ->_setGlowColor($color_value, $color_alpha, $color_type);
206 * Get Glow Color Property
208 * @param string $property
213 public function getGlowColor($property) {
214 return $this->_glow_properties
['color'][$property];
223 public function getGlowSize() {
224 return $this->_glow_properties
['size'];
232 * @return PHPExcel_Chart_GridLines
235 private function _setGlowSize($size) {
236 $this->_glow_properties
['size'] = $this->getExcelPointsWidth((float) $size);
244 * @param string $color
246 * @param string $type
248 * @return PHPExcel_Chart_GridLines
251 private function _setGlowColor($color, $alpha, $type) {
252 if (!is_null($color)) {
253 $this->_glow_properties
['color']['value'] = (string) $color;
255 if (!is_null($alpha)) {
256 $this->_glow_properties
['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
258 if (!is_null($type)) {
259 $this->_glow_properties
['color']['type'] = (string) $type;
266 * Get Line Style Arrow Parameters
268 * @param string $arrow_selector
269 * @param string $property_selector
274 public function getLineStyleArrowParameters($arrow_selector, $property_selector) {
275 return $this->getLineStyleArrowSize($this->_line_properties
['style']['arrow'][$arrow_selector]['size'], $property_selector);
279 * Set Shadow Properties
281 * @param int $sh_presets
282 * @param string $sh_color_value
283 * @param string $sh_color_type
284 * @param int $sh_color_alpha
285 * @param string $sh_blur
286 * @param int $sh_angle
287 * @param float $sh_distance
291 public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
294 ->_setShadowPresetsProperties((int) $sh_presets)
296 is_null($sh_color_value) ?
$this->_shadow_properties
['color']['value'] : $sh_color_value
297 , is_null($sh_color_alpha) ?
(int) $this->_shadow_properties
['color']['alpha']
298 : $this->getTrueAlpha($sh_color_alpha)
299 , is_null($sh_color_type) ?
$this->_shadow_properties
['color']['type'] : $sh_color_type)
300 ->_setShadowBlur($sh_blur)
301 ->_setShadowAngle($sh_angle)
302 ->_setShadowDistance($sh_distance);
306 * Set Shadow Presets Properties
308 * @param int $shadow_presets
310 * @return PHPExcel_Chart_GridLines
313 private function _setShadowPresetsProperties($shadow_presets) {
314 $this->_shadow_properties
['presets'] = $shadow_presets;
315 $this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
321 * Set Shadow Properties Values
323 * @param array $properties_map
324 * @param * $reference
326 * @return PHPExcel_Chart_GridLines
329 private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
330 $base_reference = $reference;
331 foreach ($properties_map as $property_key => $property_val) {
332 if (is_array($property_val)) {
333 if ($reference === NULL) {
334 $reference = & $this->_shadow_properties
[$property_key];
336 $reference = & $reference[$property_key];
338 $this->_setShadowProperiesMapValues($property_val, $reference);
340 if ($base_reference === NULL) {
341 $this->_shadow_properties
[$property_key] = $property_val;
343 $reference[$property_key] = $property_val;
354 * @param string $color
356 * @param string $type
358 * @return PHPExcel_Chart_GridLines
361 private function _setShadowColor($color, $alpha, $type) {
362 if (!is_null($color)) {
363 $this->_shadow_properties
['color']['value'] = (string) $color;
365 if (!is_null($alpha)) {
366 $this->_shadow_properties
['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
368 if (!is_null($type)) {
369 $this->_shadow_properties
['color']['type'] = (string) $type;
380 * @return PHPExcel_Chart_GridLines
383 private function _setShadowBlur($blur) {
384 if ($blur !== NULL) {
385 $this->_shadow_properties
['blur'] = (string) $this->getExcelPointsWidth($blur);
396 * @return PHPExcel_Chart_GridLines
399 private function _setShadowAngle($angle) {
400 if ($angle !== NULL) {
401 $this->_shadow_properties
['direction'] = (string) $this->getExcelPointsAngle($angle);
408 * Set Shadow Distance
410 * @param float $distance
412 * @return PHPExcel_Chart_GridLines
415 private function _setShadowDistance($distance) {
416 if ($distance !== NULL) {
417 $this->_shadow_properties
['distance'] = (string) $this->getExcelPointsWidth($distance);
424 * Get Shadow Property
426 * @param string $elements
427 * @param array $elements
432 public function getShadowProperty($elements) {
433 return $this->getArrayElementsValue($this->_shadow_properties
, $elements);
437 * Set Soft Edges Size
442 public function setSoftEdgesSize($size) {
443 if (!is_null($size)) {
444 $this->_activateObject();
445 $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
450 * Get Soft Edges Size
455 public function getSoftEdgesSize() {
456 return $this->_soft_edges
['size'];