ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
GridLines.php
Go to the documentation of this file.
1 <?php
2 
4 
11 class GridLines extends Properties
12 {
21  private $objectState = false;
22 
23  private $lineProperties = [
24  'color' => [
25  'type' => self::EXCEL_COLOR_TYPE_STANDARD,
26  'value' => null,
27  'alpha' => 0,
28  ],
29  'style' => [
30  'width' => '9525',
31  'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
32  'dash' => self::LINE_STYLE_DASH_SOLID,
33  'cap' => self::LINE_STYLE_CAP_FLAT,
34  'join' => self::LINE_STYLE_JOIN_BEVEL,
35  'arrow' => [
36  'head' => [
37  'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
38  'size' => self::LINE_STYLE_ARROW_SIZE_5,
39  ],
40  'end' => [
41  'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
42  'size' => self::LINE_STYLE_ARROW_SIZE_8,
43  ],
44  ],
45  ],
46  ];
47 
48  private $shadowProperties = [
49  'presets' => self::SHADOW_PRESETS_NOSHADOW,
50  'effect' => null,
51  'color' => [
52  'type' => self::EXCEL_COLOR_TYPE_STANDARD,
53  'value' => 'black',
54  'alpha' => 85,
55  ],
56  'size' => [
57  'sx' => null,
58  'sy' => null,
59  'kx' => null,
60  ],
61  'blur' => null,
62  'direction' => null,
63  'distance' => null,
64  'algn' => null,
65  'rotWithShape' => null,
66  ];
67 
68  private $glowProperties = [
69  'size' => null,
70  'color' => [
71  'type' => self::EXCEL_COLOR_TYPE_STANDARD,
72  'value' => 'black',
73  'alpha' => 40,
74  ],
75  ];
76 
77  private $softEdges = [
78  'size' => null,
79  ];
80 
86  public function getObjectState()
87  {
88  return $this->objectState;
89  }
90 
96  private function activateObject()
97  {
98  $this->objectState = true;
99 
100  return $this;
101  }
102 
110  public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD): void
111  {
112  $this->activateObject()
113  ->lineProperties['color'] = $this->setColorProperties(
114  $value,
115  $alpha,
116  $type
117  );
118  }
119 
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): void
134  {
135  $this->activateObject();
136  ($line_width !== null)
137  ? $this->lineProperties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
138  : null;
139  ($compound_type !== null)
140  ? $this->lineProperties['style']['compound'] = (string) $compound_type
141  : null;
142  ($dash_type !== null)
143  ? $this->lineProperties['style']['dash'] = (string) $dash_type
144  : null;
145  ($cap_type !== null)
146  ? $this->lineProperties['style']['cap'] = (string) $cap_type
147  : null;
148  ($join_type !== null)
149  ? $this->lineProperties['style']['join'] = (string) $join_type
150  : null;
151  ($head_arrow_type !== null)
152  ? $this->lineProperties['style']['arrow']['head']['type'] = (string) $head_arrow_type
153  : null;
154  ($head_arrow_size !== null)
155  ? $this->lineProperties['style']['arrow']['head']['size'] = (string) $head_arrow_size
156  : null;
157  ($end_arrow_type !== null)
158  ? $this->lineProperties['style']['arrow']['end']['type'] = (string) $end_arrow_type
159  : null;
160  ($end_arrow_size !== null)
161  ? $this->lineProperties['style']['arrow']['end']['size'] = (string) $end_arrow_size
162  : null;
163  }
164 
172  public function getLineColorProperty($parameter)
173  {
174  return $this->lineProperties['color'][$parameter];
175  }
176 
184  public function getLineStyleProperty($elements)
185  {
186  return $this->getArrayElementsValue($this->lineProperties['style'], $elements);
187  }
188 
197  public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null): void
198  {
199  $this
200  ->activateObject()
201  ->setGlowSize($size)
202  ->setGlowColor($color_value, $color_alpha, $color_type);
203  }
204 
212  public function getGlowColor($property)
213  {
214  return $this->glowProperties['color'][$property];
215  }
216 
222  public function getGlowSize()
223  {
224  return $this->glowProperties['size'];
225  }
226 
234  private function setGlowSize($size)
235  {
236  $this->glowProperties['size'] = $this->getExcelPointsWidth((float) $size);
237 
238  return $this;
239  }
240 
250  private function setGlowColor($color, $alpha, $type)
251  {
252  if ($color !== null) {
253  $this->glowProperties['color']['value'] = (string) $color;
254  }
255  if ($alpha !== null) {
256  $this->glowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
257  }
258  if ($type !== null) {
259  $this->glowProperties['color']['type'] = (string) $type;
260  }
261 
262  return $this;
263  }
264 
273  public function getLineStyleArrowParameters($arrow_selector, $property_selector)
274  {
275  return $this->getLineStyleArrowSize($this->lineProperties['style']['arrow'][$arrow_selector]['size'], $property_selector);
276  }
277 
289  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): void
290  {
291  $this->activateObject()
292  ->setShadowPresetsProperties((int) $sh_presets)
293  ->setShadowColor(
294  $sh_color_value ?? $this->shadowProperties['color']['value'],
295  $sh_color_alpha === null ? (int) $this->shadowProperties['color']['alpha'] : $this->getTrueAlpha($sh_color_alpha),
296  $sh_color_type ?? $this->shadowProperties['color']['type']
297  )
298  ->setShadowBlur($sh_blur)
299  ->setShadowAngle($sh_angle)
300  ->setShadowDistance($sh_distance);
301  }
302 
310  private function setShadowPresetsProperties($shadow_presets)
311  {
312  $this->shadowProperties['presets'] = $shadow_presets;
313  $this->setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
314 
315  return $this;
316  }
317 
325  private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
326  {
327  $base_reference = $reference;
328  foreach ($properties_map as $property_key => $property_val) {
329  if (is_array($property_val)) {
330  if ($reference === null) {
331  $reference = &$this->shadowProperties[$property_key];
332  } else {
333  $reference = &$reference[$property_key];
334  }
335  $this->setShadowProperiesMapValues($property_val, $reference);
336  } else {
337  if ($base_reference === null) {
338  $this->shadowProperties[$property_key] = $property_val;
339  } else {
340  $reference[$property_key] = $property_val;
341  }
342  }
343  }
344 
345  return $this;
346  }
347 
357  private function setShadowColor($color, $alpha, $type)
358  {
359  if ($color !== null) {
360  $this->shadowProperties['color']['value'] = (string) $color;
361  }
362  if ($alpha !== null) {
363  $this->shadowProperties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
364  }
365  if ($type !== null) {
366  $this->shadowProperties['color']['type'] = (string) $type;
367  }
368 
369  return $this;
370  }
371 
379  private function setShadowBlur($blur)
380  {
381  if ($blur !== null) {
382  $this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
383  }
384 
385  return $this;
386  }
387 
395  private function setShadowAngle($angle)
396  {
397  if ($angle !== null) {
398  $this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
399  }
400 
401  return $this;
402  }
403 
411  private function setShadowDistance($distance)
412  {
413  if ($distance !== null) {
414  $this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
415  }
416 
417  return $this;
418  }
419 
427  public function getShadowProperty($elements)
428  {
429  return $this->getArrayElementsValue($this->shadowProperties, $elements);
430  }
431 
437  public function setSoftEdgesSize($size): void
438  {
439  if ($size !== null) {
440  $this->activateObject();
441  $this->softEdges['size'] = (string) $this->getExcelPointsWidth($size);
442  }
443  }
444 
450  public function getSoftEdgesSize()
451  {
452  return $this->softEdges['size'];
453  }
454 }
getShadowPresetsMap($shadow_presets_option)
Definition: Properties.php:164
getLineStyleArrowSize($array_selector, $array_kay_selector)
Definition: Properties.php:147
getShadowProperty($elements)
Get Shadow Property.
Definition: GridLines.php:427
setShadowProperties($sh_presets, $sh_color_value=null, $sh_color_type=null, $sh_color_alpha=null, $sh_blur=null, $sh_angle=null, $sh_distance=null)
Set Shadow Properties.
Definition: GridLines.php:289
$size
Definition: RandomTest.php:84
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)
Set Line Color Properties.
Definition: GridLines.php:133
$type
setShadowDistance($distance)
Set Shadow Distance.
Definition: GridLines.php:411
setShadowProperiesMapValues(array $properties_map, &$reference=null)
Set Shadow Properties Values.
Definition: GridLines.php:325
$angle
getLineStyleProperty($elements)
Get Line Style Property.
Definition: GridLines.php:184
getLineColorProperty($parameter)
Get Line Color Property.
Definition: GridLines.php:172
getSoftEdgesSize()
Get Soft Edges Size.
Definition: GridLines.php:450
setLineColorProperties($value, $alpha=0, $type=self::EXCEL_COLOR_TYPE_STANDARD)
Set Line Color Properties.
Definition: GridLines.php:110
getLineStyleArrowParameters($arrow_selector, $property_selector)
Get Line Style Arrow Parameters.
Definition: GridLines.php:273
setShadowAngle($angle)
Set Shadow Angle.
Definition: GridLines.php:395
setShadowColor($color, $alpha, $type)
Set Shadow Color.
Definition: GridLines.php:357
setShadowPresetsProperties($shadow_presets)
Set Shadow Presets Properties.
Definition: GridLines.php:310
setGlowProperties($size, $color_value=null, $color_alpha=null, $color_type=null)
Set Glow Properties.
Definition: GridLines.php:197
activateObject()
Change Object State to True.
Definition: GridLines.php:96
setGlowColor($color, $alpha, $type)
Set Glow Color.
Definition: GridLines.php:250
getGlowColor($property)
Get Glow Color Property.
Definition: GridLines.php:212
setSoftEdgesSize($size)
Set Soft Edges Size.
Definition: GridLines.php:437
setShadowBlur($blur)
Set Shadow Blur.
Definition: GridLines.php:379
getArrayElementsValue($properties, $elements)
Definition: Properties.php:356
setColorProperties($color, $alpha, $type)
Definition: Properties.php:138